Beispiel #1
0
        public FakeArticle(ArticleTitle title)
        {
            _source = new FakePath(title.PlainText);

            Parts = new List <ArticlePart>()
            {
                ArticlePart.CreateHeader(title.TextWithLineBreak)
            };
        }
Beispiel #2
0
 public void Setup()
 {
     _article = new FakeArticle(new List <ArticlePart>()
     {
         ArticlePart.CreateHeader("Some new article\n"),
         ArticlePart.CreateText("Blah blah text with "),
         ArticlePart.CreateLink("link to another", "Another Article"),
         ArticlePart.CreateText(" article.\n"),
         ArticlePart.CreateText("Next P.")
     });
 }
Beispiel #3
0
        public void InsertPart(int offset, string textToInsert)
        {
            var partToInsert = GetRange(offset, 0);

            if (partToInsert.Parts.Any())
            {
                var part = partToInsert.Parts.First();

                if (part.MarkerStyle == MarkerStyle.Header && textToInsert.Contains('\n'))
                {
                    var newText = part.Text.Insert(partToInsert.StartingOffset, textToInsert);

                    var parts = newText.Split('\n');

                    if (parts.Length == 1)
                    {
                        part.Text = parts[0] + '\n';
                    }
                    else
                    {
                        part.Text = parts[0] + '\n';

                        Parts.Insert(1, ArticlePart.CreateText(parts[1] + '\n'));

                        _view?.Render();
                    }
                }
                else
                {
                    part.Text = part.Text.Insert(partToInsert.StartingOffset, textToInsert);
                }
            }
            else if (Parts.Any())
            {
                Parts.Last().Text += textToInsert;
            }
            else
            {
                Parts.Add(ArticlePart.CreateHeader(textToInsert));
            }
        }