const captureInput = DomEvent.bind(page, 'keydown', function (evt) { // Think about killing the event. if (! Arr.contains([ 'input', 'textarea' ], Node.name(evt.target()))) { // FIX: Close the menus // closeMenus() toEditing(); } });
const onChange = (getData: () => LinkDialogData, change: { name: string }): Option<Partial<LinkDialogData>> => { if (change.name === 'url') { return onUrlChange(getData()); } else if (Arr.contains([ 'anchor', 'link' ], change.name)) { return onCatalogChange(getData(), change); } else if (change.name === 'text') { // Update the persistent text state, as a user has input custom text persistentText.set(getData().text); return Option.none(); } else { return Option.none(); } };
const register = (mode: string, api: ModeApi) => { if (Arr.contains(defaultModes, mode)) { throw new Error(`Cannot override default mode ${mode}`); } availableModes[mode] = { ...api, deactivate: () => { // wrap custom deactivate APIs so they can't break the editor try { api.deactivate(); } catch (e) { console.error(`problem while deactivating editor mode ${mode}:`); console.error(e); } }, }; };
return Arr.map(items, (item) => { const keys = Obj.keys(item); // If it is a submenu, enrich all the subitems. if (Objects.hasKey(item, 'items')) { const newItems = doEnrich(item.items); return Merger.deepMerge( enrichMenu(item), { getStyleItems: () => newItems } ) as FormatItem; } else if (Objects.hasKey(item, 'format')) { return enrichSupported(item); // NOTE: This branch is added from the original StyleFormats in mobile } else if (keys.length === 1 && Arr.contains(keys, 'title')) { return Merger.deepMerge(item, { type: 'separator' }) as FormatItem; } else { return enrichCustom(item); } });
const isRoot = function (element) { const name = Node.name(element); return Compare.eq(element, body) || Arr.contains(rootElements, name); };
const open = function (settings: NotificationSpec, closeCallback: () => void) { const close = () => { closeCallback(); InlineView.hide(notificationWrapper); }; const notification = GuiFactory.build( Notification.sketch({ text: settings.text, level: Arr.contains(['success', 'error', 'warning', 'info'], settings.type) ? settings.type : undefined, progress: settings.progressBar === true, icon: Option.from(settings.icon), onAction: close, iconProvider: backstage.shared.providers.icons, translationProvider: backstage.shared.providers.translate }) ); const notificationWrapper = GuiFactory.build( InlineView.sketch({ dom: { tag: 'div', classes: [ 'tox-notifications-container' ] }, lazySink: extras.backstage.shared.getSink, fireDismissalEventInstead: { } }) ); uiMothership.add(notificationWrapper); if (settings.timeout) { Delay.setTimeout(() => { close(); }, settings.timeout); } return { close, moveTo: (x: number, y: number) => { InlineView.showAt(notificationWrapper, { anchor: 'makeshift', x, y }, GuiFactory.premade(notification)); }, moveRel: (element: Element, rel) => { // TODO: this should stack, TC-TC, BC-TC InlineView.showAt(notificationWrapper, extras.backstage.shared.anchors.banner(), GuiFactory.premade(notification)); }, text: (nuText: string) => { // check if component is still mounted Notification.updateText(notification, nuText); }, settings, getEl: () => { // TODO: this is required to make stacking banners, should refactor getEl when AP-174 is implemented }, progressBar: { value: (percent: number) => { Notification.updateProgress(notification, percent); } } }; };
const needRtlClass = I18n.isRtl() && info.iconContent.exists((name) => Arr.contains(rtlTransform, name));
return iconName.map((name) => I18n.isRtl() && Arr.contains(rtlIcon, name) ? name + '-rtl' : name);
const inInput = Focus.active().exists(function (elem) { return Arr.contains([ 'input', 'textarea' ], Node.name(elem)); });
const result = Obj.bifilter(settings, function (value, key) { return Arr.contains(keys, key); });