How to use @ephox/snooker - 10 common examples

To help you get started, we’ve selected a few @ephox/snooker 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 / plugins / table / main / ts / actions / Clipboard.ts View on Github external
const extractSelected = function (cells) {
  // Assume for now that we only have one table (also handles the case where we multi select outside a table)
  return TableLookup.table(cells[0]).map(Replication.deep).map(function (replica) {
    return [ CopySelected.extract(replica, Ephemera.attributeSelector()) ];
  });
};
github tinymce / tinymce / modules / tinymce / src / plugins / table / main / ts / selection / SelectionTargets.ts View on Github external
return TableSelection.getSelectionStartCellOrCaption(editor).bind((cellOrCaption) => {
      const table = TableLookup.table(cellOrCaption);
      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 / actions / Clipboard.ts View on Github external
cellOpt.each(function (domCell) {
        const cell = Element.fromDom(domCell);
        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 / queries / TabContext.ts View on Github external
}, function (current) {
    return TableLookup.table(current, isRoot).bind(function (table) {
      const targets = TableTargets.noMenu(current);
      editor.undoManager.transact(function () {
        actions.insertRowsAfter(table, targets);
      });
      return getNewRowCursorPosition(editor, table);
    });
  });
};
github tinymce / tinymce / modules / tinymce / src / plugins / table / main / ts / queries / TabContext.ts View on Github external
const forward = function (editor: Editor, isRoot, cell, lazyWire) {
  return go(editor, isRoot, CellNavigation.next(cell), lazyWire);
};
github tinymce / tinymce / modules / tinymce / src / plugins / table / main / ts / queries / TabContext.ts View on Github external
const backward = function (editor: Editor, isRoot, cell, lazyWire) {
  return go(editor, isRoot, CellNavigation.prev(cell), lazyWire);
};
github tinymce / tinymce / modules / tinymce / src / plugins / table / main / ts / actions / Clipboard.ts View on Github external
return TableLookup.table(cells[0]).map(Replication.deep).map(function (replica) {
    return [ CopySelected.extract(replica, Ephemera.attributeSelector()) ];
  });
};
github tinymce / tinymce / modules / tinymce / src / plugins / table / main / ts / actions / ResizeHandler.ts View on Github external
const lazyWire = function () {
    return wire.getOr(ResizeWire.only(SugarElement.fromDom(editor.getBody())));
  };
github tinymce / tinymce / modules / tinymce / src / plugins / table / main / ts / actions / ResizeHandler.ts View on Github external
editor.on('init', function () {
    const direction = TableDirection(Direction.directionAt);
    const rawWire = TableWire.get(editor);
    wire = Option.some(rawWire);
    if (hasObjectResizing(editor) && hasTableResizeBars(editor)) {
      const sz = TableResize.create(rawWire, direction);
      sz.on();
      sz.events.startDrag.bind(function (event) {
        selectionRng = Option.some(editor.selection.getRng());
      });

      sz.events.beforeResize.bind(function (event) {
        const rawTable = event.table().dom();
        Events.fireObjectResizeStart(editor, rawTable, Util.getPixelWidth(rawTable), Util.getPixelHeight(rawTable));
      });

      sz.events.afterResize.bind(function (event) {
        const table = event.table();
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);
            });
          }
        });
      });