How to use the @ephox/sugar.Insert.append function in @ephox/sugar

To help you get started, we’ve selected a few @ephox/sugar examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github tinymce / tinymce / modules / tinymce / src / themes / silver / main / ts / autocomplete / AutocompleteTag.ts View on Github external
return detect(Element.fromDom(editor.selection.getNode())).getOrThunk(() => {
    // Create a wrapper
    const wrapper = Element.fromHtml('<span data-mce-bogus="1" data-mce-autocompleter="1"></span>', editor.getDoc());

    // Wrap the content
    Insert.append(wrapper, Element.fromDom(range.extractContents()));
    range.insertNode(wrapper.dom());
    Traverse.parent(wrapper).each((elm) =&gt; elm.dom().normalize());

    // Update the cursor position
    CursorPosition.last(wrapper).map((last) =&gt; {
      editor.selection.setCursorLocation(last.dom(), Awareness.getEnd(last));
    });

    return wrapper;
  });
};
github tinymce / tinymce / src / core / main / ts / keyboard / TableNavigation.ts View on Github external
editor.undoManager.transact(() => {
      const element = SugarElement.fromTag(forcedRootBlock);
      Attr.setAll(element, Settings.getForcedRootBlockAttrs(editor));
      Insert.append(element, SugarElement.fromTag('br'));

      if (down) {
        Insert.after(SugarElement.fromDom(table), element);
      } else {
        Insert.before(SugarElement.fromDom(table), element);
      }

      const rng = editor.dom.createRng();
      rng.setStart(element.dom(), 0);
      rng.setEnd(element.dom(), 0);
      moveToRange(editor, rng);
    });
  } else {
github tinymce / tinymce / modules / tinymce / src / plugins / lists / main / ts / listModel / ComposeList.ts View on Github external
const appendItem = (segment: Segment, item: Element): void => {
  Insert.append(segment.list, item);
  segment.item = item;
};
github tinymce / tinymce / src / core / main / ts / keyboard / ContentEndpointNavigation.ts View on Github external
const insertElement = (root: Element, elm: Element, forward: boolean) => {
  if (forward) {
    Insert.append(root, elm);
  } else {
    Insert.prepend(root, elm);
  }
};
github tinymce / tinymce / modules / tinymce / src / plugins / lists / main / ts / listModel / ComposeList.ts View on Github external
const joinSegment = (parent: Segment, child: Segment): void => {
  Insert.append(parent.item, child.list);
};
github tinymce / tinymce / modules / tinymce / src / plugins / lists / main / ts / listModel / ComposeList.ts View on Github external
const createSegment = (scope: Document, listType: ListType): Segment => {
  const segment: Segment = {
    list: Element.fromTag(listType, scope),
    item: Element.fromTag('li', scope)
  };
  Insert.append(segment.list, segment.item);
  return segment;
};
github tinymce / tinymce / src / core / main / ts / keyboard / ContentEndpointNavigation.ts View on Github external
const insertBlock = (root: Element, forward: boolean, blockName: string, attrs: Record) =&gt; {
  const block = Element.fromTag(blockName);
  const br = Element.fromTag('br');

  Attr.setAll(block, attrs);
  Insert.append(block, br);
  insertElement(root, block, forward);

  return rangeBefore(br);
};