Exemplo n.º 1
0
        private IParent Add(ListItem item)
        {
            if (item.Enumerator == null)
            {
                if (!(Elements.LastOrDefault() is BulletList list) || list.Start != item.Start)
                {
                    list = new BulletList(item);
                    Add(list);
                    return(item);
                }

                return(list.Add(item));
            }
            else
            {
                if (!(Elements.LastOrDefault() is EnumeratedList list))
                {
                    list = new EnumeratedList(item);
                    Add(list);
                    return(item);
                }

                return(list.Add(item));
            }
        }
Exemplo n.º 2
0
        public IParent Add(IElement current, int level = 0)
        {
            if (current is ListItem item)
            {
                if (item.Index == Items.Last().Index + 1)
                {
                    Items.Add(item);
                    item.Parent = this;
                    return(item);
                }

                if (item.CreateNewList)
                {
                    var list = new EnumeratedList(item);
                    Parent.Add(list);
                    return(item);
                }

                // downgrade to paragraph.
                current = new Paragraph(item.TextAreas);
            }

            return(Parent.Add(current));
        }