How to use the @ephox/sugar.SelectorFilter.descendants 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 / core / main / ts / mode / Readonly.ts View on Github external
const switchOffContentEditableTrue = (elm: Element) => {
  Arr.each(SelectorFilter.descendants(elm, '*[contenteditable="true"]'), (elm) => {
    Attr.set(elm, internalContentEditableAttr, 'true');
    setContentEditable(elm, false);
  });
};
github tinymce / tinymce / modules / tinymce / src / core / main / ts / caret / TableCells.ts View on Github external
const getClosestCell = (getYAxisValue: GetAxisValue, isTargetCorner: IsTargetCorner, table: HTMLElement, x: number, y: number): Option => {
  type TableThing = HTMLTableDataCellElement | HTMLTableHeaderCellElement | HTMLTableCaptionElement;
  const cells = SelectorFilter.descendants(Element.fromDom(table), 'td,th,caption').map((e) => e.dom() as TableThing);
  const corners = Arr.filter(getCorners(getYAxisValue, cells), (corner) => isTargetCorner(corner, y));

  return findClosestCorner(corners, x, y).map((corner) => {
    return corner.cell;
  });
};
github tinymce / tinymce / modules / tinymce / src / plugins / table / main / ts / actions / InsertTable.ts View on Github external
const fireEvents = (editor: Editor, table) => {
  Arr.each(SelectorFilter.descendants(table, 'tr'), (row) => {
    fireNewRow(editor, row.dom());

    Arr.each(SelectorFilter.descendants(row, 'th,td'), (cell) => {
      fireNewCell(editor, cell.dom());
    });
  });
};
github tinymce / tinymce / src / core / main / ts / mode / Readonly.ts View on Github external
const switchOnContentEditableTrue = (elm: Element) => {
  Arr.each(SelectorFilter.descendants(elm, `*[${internalContentEditableAttr}="true"]`), (elm) => {
    Attr.remove(elm, internalContentEditableAttr);
    setContentEditable(elm, true);
  });
};
github tinymce / tinymce / modules / tinymce / src / core / main / ts / mode / Readonly.ts View on Github external
const switchOnContentEditableTrue = (elm: Element) => {
  Arr.each(SelectorFilter.descendants(elm, `*[${internalContentEditableAttr}="true"]`), (elm) => {
    Attr.remove(elm, internalContentEditableAttr);
    setContentEditable(elm, true);
  });
};
github tinymce / tinymce / modules / tinymce / src / plugins / table / main / ts / actions / EnforceUnit.ts View on Github external
Traverse.parent(table).map((parent) => calculatePercentageWidth(table, parent)).each((tablePercentage) => {
    Css.set(table, 'width', tablePercentage);

    Arr.each(SelectorFilter.descendants(table, 'tr'), (tr) => {
      Arr.each(Traverse.children(tr), (td) => {
        Css.set(td, 'width', calculatePercentageWidth(td, tr));
      });
    });
  });
};
github tinymce / tinymce / src / core / main / ts / mode / Readonly.ts View on Github external
const switchOffContentEditableTrue = (elm: Element) => {
  Arr.each(SelectorFilter.descendants(elm, '*[contenteditable="true"]'), (elm) => {
    Attr.set(elm, internalContentEditableAttr, 'true');
    setContentEditable(elm, false);
  });
};
github tinymce / tinymce / modules / tinymce / src / plugins / table / main / ts / actions / InsertTable.ts View on Github external
Arr.each(SelectorFilter.descendants(table, 'tr'), (row) => {
    fireNewRow(editor, row.dom());

    Arr.each(SelectorFilter.descendants(row, 'th,td'), (cell) => {
      fireNewCell(editor, cell.dom());
    });
  });
};