本文整理汇总了TypeScript中@ephox/katamari.Option类的典型用法代码示例。如果您正苦于以下问题:TypeScript Option类的具体用法?TypeScript Option怎么用?TypeScript Option使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Option类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: function
const getTopNotification = function () {
return Option.from(notifications[0]);
};
示例2: function
const extractBlob = function (simulatedEvent) {
const event = simulatedEvent.event();
const files = event.raw().target.files || event.raw().dataTransfer.files;
return Option.from(files[0]);
};
示例3:
const toResult = (info, param) => Option.from(info[param]).fold(() => Result.error('Missing ' + param), Result.value);
示例4: function
function (paddPos) {
if (moveCaret) {
setSelection(editor, forward, Option.some(paddPos));
}
}
示例5: isWithinSameTable
(cellRng: any) => isWithinSameTable(isRoot, cellRng) ? Option.none() : getCellRangeFromStartTable(cellRng, isRoot)
示例6: function
function (element) { // After
CaretContainerRemove.remove(caret.get());
const text = CaretContainerInline.insertInlineAfter(element);
caret.set(text);
return Option.some(new CaretPosition(text, 1));
}
示例7: function
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();
};
示例8:
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);
});
示例9: function
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),
//.........这里部分代码省略.........
示例10: function
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);
};