const getTopNotification = function () { return Option.from(notifications[0]); };
const extractBlob = function (simulatedEvent) { const event = simulatedEvent.event(); const files = event.raw().target.files || event.raw().dataTransfer.files; return Option.from(files[0]); };
const toResult = (info, param) => Option.from(info[param]).fold(() => Result.error('Missing ' + param), Result.value);
function (paddPos) { if (moveCaret) { setSelection(editor, forward, Option.some(paddPos)); } }
(cellRng: any) => isWithinSameTable(isRoot, cellRng) ? Option.none() : getCellRangeFromStartTable(cellRng, isRoot)
function (element) { // After CaretContainerRemove.remove(caret.get()); const text = CaretContainerInline.insertInlineAfter(element); caret.set(text); return Option.some(new CaretPosition(text, 1)); }
const sketch = function (settings) { const dataset = convert(settings.formats, function () { return memMenu; }); // Turn settings into a tiered menu data. const memMenu = Memento.record(TieredMenu.sketch({ dom: { tag: 'div', classes: [ Styles.resolve('styles-menu') ] }, components: [ ], // Focus causes issues when the things being focused are offscreen. fakeFocus: true, // For animations, need things to stay around in the DOM (at least until animation is done) stayInDom: true, onExecute (tmenu, item) { const v = Representing.getValue(item); settings.handle(item, v.value); return Option.none(); }, onEscape () { return Option.none(); }, onOpenMenu (container, menu) { const w = Width.get(container.element()); Width.set(menu.element(), w); Transitioning.jumpTo(menu, 'current'); }, onOpenSubmenu (container, item, submenu) { const w = Width.get(container.element()); const menu = SelectorFind.ancestor(item.element(), '[role="menu"]').getOrDie('hacky'); const menuComp = container.getSystem().getByDom(menu).getOrDie(); Width.set(submenu.element(), w); Transitioning.progressTo(menuComp, 'before'); Transitioning.jumpTo(submenu, 'after'); Transitioning.progressTo(submenu, 'current'); }, onCollapseMenu (container, item, menu) { const submenu = SelectorFind.ancestor(item.element(), '[role="menu"]').getOrDie('hacky'); const submenuComp = container.getSystem().getByDom(submenu).getOrDie(); Transitioning.progressTo(submenuComp, 'after'); Transitioning.progressTo(menu, 'current'); }, navigateOnHover: false, highlightImmediately: true, data: dataset.tmenu, markers: { backgroundMenu: Styles.resolve('styles-background-menu'), menu: Styles.resolve('styles-menu'), selectedMenu: Styles.resolve('styles-selected-menu'), item: Styles.resolve('styles-item'), selectedItem: Styles.resolve('styles-selected-item') } })); return memMenu.asSpec(); };
return table.bind(function (table) { const doc = Element.fromDom(editor.getDoc()); const targets = TableTargets.forMenu(selections, table, cell); const generators = TableFill.cellOperations(Fun.noop, doc, Option.none()); return CopyRows.copyRows(table, targets, generators); });
const setup = function (realm, editor) { const commandSketch = function (name) { return function () { return Buttons.forToolbarCommand(editor, name); }; }; const stateCommandSketch = function (name) { return function () { return Buttons.forToolbarStateCommand(editor, name); }; }; const actionSketch = function (name, query, action) { return function () { return Buttons.forToolbarStateAction(editor, name, query, action); }; }; const undo = commandSketch('undo'); const redo = commandSketch('redo'); const bold = stateCommandSketch('bold'); const italic = stateCommandSketch('italic'); const underline = stateCommandSketch('underline'); const removeformat = commandSketch('removeformat'); const link = function () { return LinkButton.sketch(realm, editor); }; const unlink = actionSketch('unlink', 'link', function () { editor.execCommand('unlink', null, false); }); const image = function () { return ImagePicker.sketch(editor); }; const bullist = actionSketch('unordered-list', 'ul', function () { editor.execCommand('InsertUnorderedList', null, false); }); const numlist = actionSketch('ordered-list', 'ol', function () { editor.execCommand('InsertOrderedList', null, false); }); const fontsizeselect = function () { return FontSizeSlider.sketch(realm, editor); }; const forecolor = function () { return ColorSlider.sketch(realm, editor); }; const styleFormats = StyleFormats.register(editor, editor.settings); const styleFormatsMenu = function () { return StyleFormats.ui(editor, styleFormats, function () { editor.fire('scrollIntoView'); }); }; const styleselect = function () { return Buttons.forToolbar('style-formats', function (button) { editor.fire('toReading'); realm.dropup().appear(styleFormatsMenu, Toggling.on, button); }, Behaviour.derive([ Toggling.config({ toggleClass: Styles.resolve('toolbar-button-selected'), toggleOnExecute: false, aria: { mode: 'pressed' } }), Receiving.config({ channels: Objects.wrapAll([ Receivers.receive(TinyChannels.orientationChanged(), Toggling.off), Receivers.receive(TinyChannels.dropupDismissed(), Toggling.off) ]) }) ])); }; const feature = function (prereq, sketch) { return { isSupported () { // NOTE: forall is true for none return prereq.forall(function (p) { return Objects.hasKey(editor.buttons, p); }); }, sketch }; }; return { undo: feature(Option.none(), undo), redo: feature(Option.none(), redo), bold: feature(Option.none(), bold), italic: feature(Option.none(), italic), underline: feature(Option.none(), underline), removeformat: feature(Option.none(), removeformat), link: feature(Option.none(), link), unlink: feature(Option.none(), unlink), image: feature(Option.none(), image), // NOTE: Requires "lists" plugin. bullist: feature(Option.some('bullist'), bullist), numlist: feature(Option.some('numlist'), numlist), fontsizeselect: feature(Option.none(), fontsizeselect), forecolor: feature(Option.none(), forecolor), styleselect: feature(Option.none(), styleselect) }; };
import { Arr, Fun, Option } from '@ephox/katamari'; import { CopyRows, TableFill, TableLookup } from '@ephox/snooker'; import { Element, Insert, Remove, Replication } from '@ephox/sugar'; import Tools from 'tinymce/core/api/util/Tools'; import Util from '../alien/Util'; import TableTargets from '../queries/TableTargets'; import CellDialog from '../ui/CellDialog'; import RowDialog from '../ui/RowDialog'; import TableDialog from '../ui/TableDialog'; const each = Tools.each; let clipboardRows = Option.none(); const getClipboardRows = function () { return clipboardRows.fold(function () { return; }, function (rows) { return Arr.map(rows, function (row) { return row.dom(); }); }); }; const setClipboardRows = function (rows) { const sugarRows = Arr.map(rows, Element.fromDom); clipboardRows = Option.from(sugarRows); };