How to use the @ephox/sugar.Node.name 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 / mobile / main / ts / Theme.ts View on Github external
onTapContent (evt) {
            const target = evt.target();
            // If the user has tapped (touchstart, touchend without movement) on an image, select it.
            if (Node.name(target) === 'img') {
              editor.selection.select(target.dom());
              // Prevent the default behaviour from firing so that the image stays selected
              evt.kill();
            } else if (Node.name(target) === 'a') {
              const component = realm.system().getByDom(Element.fromDom(editor.editorContainer));
              component.each(function (container) {
                /// view mode
                if (Swapping.isAlpha(container)) {
                  TinyCodeDupe.openLink(target.dom());
                }
              });
            }
          }
        },
github tinymce / tinymce / modules / tinymce / src / core / main / ts / annotate / AnnotationContext.ts View on Github external
(parent) => {
      // We used to skip these, but given that they might be representing empty paragraphs, it probably
      // makes sense to treat them just like text nodes
      if (nodeName === 'br' || isZeroWidth(elem)) {
        return ChildContext.Valid;
      } else if (isAnnotation(elem)) {
        return ChildContext.Existing;
      } else if (isCaretNode(elem)) {
        return ChildContext.Caret;
      } else if (!FormatUtils.isValid(editor, wrapName, nodeName) || !FormatUtils.isValid(editor, Node.name(parent), wrapName)) {
        return ChildContext.InvalidChild;
      } else {
        return ChildContext.Valid;
      }
    }
  );
github tinymce / tinymce / modules / tinymce / src / plugins / table / main / ts / selection / SelectionTargets.ts View on Github external
return table.map((table) => {
        if (Node.name(cellOrCaption) === 'caption') {
          return TableTargets.notCell(cellOrCaption);
        } else {
          return TableTargets.forMenu(selections, table, cellOrCaption);
        }
      });
    });
github tinymce / tinymce / modules / tinymce / src / plugins / table / main / ts / selection / SelectionTargets.ts View on Github external
  const onSetupCellOrRow = (api) => onSetup(api, (targets) => Node.name(targets.element()) === 'caption');
  const onSetupMergeable = (api) => onSetup(api, (targets) => targets.mergable().isNone());
github tinymce / tinymce / src / core / main / ts / keyboard / ContentEndpointNavigation.ts View on Github external
const isTarget = (node: Element) => Arr.contains(['figcaption'], Node.name(node));
github tinymce / tinymce / modules / tinymce / src / core / main / ts / selection / SelectionUtils.ts View on Github external
function (child) {
      if (Node.name(child) === 'br') {
        return Traverse.prevSibling(child).map(function (sibling) {
          return [node].concat(getLastChildren(sibling));
        }).getOr([]);
      } else {
        return [node].concat(getLastChildren(child));
      }
    }
  );
github tinymce / tinymce / modules / tinymce / src / core / main / ts / annotate / Wrapping.ts View on Github external
const processElement = (elem) => {
    const ctx = context(editor, elem, 'span', Node.name(elem));

    switch (ctx) {
      case ChildContext.InvalidChild: {
        finishWrapper();
        const children = Traverse.children(elem);
        processElements(children);
        finishWrapper();
        break;
      }

      case ChildContext.Valid: {
        const w = getOrOpenWrapper();
        Insert.wrap(elem, w);
        break;
      }
github tinymce / tinymce / modules / tinymce / src / plugins / table / main / ts / actions / Clipboard.ts View on Github external
TableLookup.table(cell).each((table) => {

          const elements = Arr.filter(Elements.fromHtml(e.content), function (content) {
            return Node.name(content) !== 'meta';
          });

          if (elements.length === 1 && Node.name(elements[0]) === 'table') {
            e.preventDefault();

            const doc = Element.fromDom(editor.getDoc());
            const generators = TableFill.paste(doc);
            const targets = TableTargets.paste(cell, elements[0], generators);
            actions.pasteCells(table, targets).each(function (rng) {
              editor.selection.setRng(rng);
              editor.focus();
              cellSelection.clear(table);
            });
          }
        });
      });
github tinymce / tinymce / modules / tinymce / src / plugins / table / main / ts / actions / Clipboard.ts View on Github external
const elements = Arr.filter(Elements.fromHtml(e.content), function (content) {
            return Node.name(content) !== 'meta';
          });
github tinymce / tinymce / modules / tinymce / src / plugins / lists / main / ts / listModel / Entry.ts View on Github external
return Traverse.parent(li).filter(Node.isElement).map((list) => {
    return {
      depth,
      isSelected,
      content: cloneItemContent(li),
      itemAttributes: Attr.clone(li),
      listAttributes: Attr.clone(list),
      listType: Node.name(list) as ListType
    };
  });
};