本文整理匯總了TypeScript中@ephox/katamari.Obj.keys方法的典型用法代碼示例。如果您正苦於以下問題:TypeScript Obj.keys方法的具體用法?TypeScript Obj.keys怎麽用?TypeScript Obj.keys使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類@ephox/katamari.Obj
的用法示例。
在下文中一共展示了Obj.keys方法的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1: assertMarker
const sAssertGetAll = (editor: Editor, expected: Record<string, number>, name: string) => Step.sync(() => {
const annotations = editor.annotator.getAll(name);
const keys = Obj.keys(annotations);
const sortedKeys = Arr.sort(keys);
const expectedKeys = Arr.sort(Obj.keys(expected));
Assertions.assertEq('Checking keys of getAll response', expectedKeys, sortedKeys);
Obj.each(annotations, (markers, uid) => {
Assertions.assertEq('Checking number of markers for uid', expected[uid], markers.length);
assertMarker(editor, { uid, name }, markers);
});
});
示例2:
const getMultipleToolbarsSetting = (editor: Editor) => {
const keys = Obj.keys(editor.settings);
const toolbarKeys = Arr.filter(keys, (key) => /^toolbar([1-9])$/.test(key));
const toolbars = Arr.map(toolbarKeys, (key) => editor.getParam(key, false, 'string'));
const toolbarArray = Arr.filter(toolbars, (toolbar) => typeof toolbar === 'string');
return toolbarArray.length > 0 ? Option.some(toolbarArray) : Option.none();
};
示例3: updateCallbacks
const onNodeChange = Throttler.last(() => {
const callbackMap = changeCallbacks.get();
const annotations = Arr.sort(Obj.keys(callbackMap));
Arr.each(annotations, (name) => {
updateCallbacks(name, (data) => {
const prev = data.previous.get();
identify(editor, Option.some(name)).fold(
() => {
if (prev.isSome()) {
// Changed from something to nothing.
fireNoAnnotation(name);
data.previous.set(Option.none());
}
},
({ uid, name, elements }) => {
// Changed from a different annotation (or nothing)
if (! prev.is(uid)) {
fireCallbacks(name, uid, elements);
data.previous.set(Option.some(uid));
}
}
);
return {
previous: data.previous,
listeners: data.listeners
};
});
});
}, 30);
示例4: function
const setData = function (mime, content) {
data[mime] = content;
result.types = Obj.keys(data);
result.items = Arr.map(result.types, function (type) {
return createDataTransferItem(type, data[type]);
});
};
示例5:
const normalizeCss = (cssText: string) => {
const css = DOMUtils.DOM.styles.parse(cssText);
const newCss = {};
Arr.each(Obj.keys(css).sort(), (key) => {
newCss[key] = css[key];
});
return DOMUtils.DOM.styles.serialize(newCss);
};
示例6: function
const init = function (realm, editor) {
const allFormats = Obj.keys(editor.formatter.get());
Arr.each(allFormats, function (command) {
editor.formatter.formatChanged(command, function (state) {
fireChange(realm, command, state);
});
});
Arr.each([ 'ul', 'ol' ], function (command) {
editor.selection.selectorChanged(command, function (state, data) {
fireChange(realm, command, state);
});
});
};
示例7: callback
const updateAndFireChangeCallbacks = (editor: Editor, elm: Element, currentFormats: Cell<FormatCallbacks>, formatChangeData: RegisteredFormats) => {
const formatsList = Obj.keys(currentFormats.get());
const newFormats: FormatCallbacks = { };
const matchedFormats: FormatCallbacks = { };
// Ignore bogus nodes like the <a> tag created by moveStart()
const parents = Arr.filter(FormatUtils.getParents(editor.dom, elm), (node) => {
return node.nodeType === 1 && !node.getAttribute('data-mce-bogus');
});
// Check for new formats
Obj.each(formatChangeData, (data: FormatData, format: string) => {
Tools.each(parents, (node: Node) => {
if (editor.formatter.matchNode(node, format, {}, data.similar)) {
if (formatsList.indexOf(format) === -1) {
// Execute callbacks
Arr.each(data.callbacks, (callback: FormatChangeCallback) => {
callback(true, { node, format, parents });
});
newFormats[format] = data.callbacks;
}
matchedFormats[format] = data.callbacks;
return false;
}
if (MatchFormat.matchesUnInheritedFormatSelector(editor, node, format)) {
return false;
}
});
});
// Check if current formats still match
const remainingFormats = filterRemainingFormats(currentFormats.get(), matchedFormats, elm, parents);
// Update the current formats
currentFormats.set({
...newFormats,
...remainingFormats
});
};
示例8:
const getSharedValues = (data) => {
// Mutates baseData to return an object that contains only the values
// that were the same across all objects in data
const baseData = data[0];
const comparisonData = data.slice(1);
const keys = Obj.keys(baseData);
Arr.each(comparisonData, (items) => {
Arr.each(keys, (key) => {
Obj.each(items, (itemValue, itemKey, _) => {
const comparisonValue = baseData[key];
if (comparisonValue !== '' && key === itemKey) {
if (comparisonValue !== itemValue) {
baseData[key] = '';
}
}
});
});
});
return baseData;
};
示例9: doEnrich
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);
}
});
示例10: Cell
const makePanels = (parts: SlotContainerTypes.SlotContainerParts, panelConfigs: SidebarConfig) => {
const specs = Arr.map(Obj.keys(panelConfigs), (name) => {
const spec = panelConfigs[name];
const bridged = ValueSchema.getOrDie(BridgeSidebar.createSidebar(spec));
return {
name,
getApi,
onSetup: bridged.onSetup,
onShow: bridged.onShow,
onHide: bridged.onHide
};
});
return Arr.map(specs, (spec) => {
const editorOffCell = Cell(Fun.noop);
return parts.slot(
spec.name,
{
dom: {
tag: 'div',
classes: ['tox-sidebar__pane']
},
behaviours: SimpleBehaviours.unnamedEvents([
onControlAttached(spec, editorOffCell),
onControlDetached(spec, editorOffCell),
AlloyEvents.run<SystemEvents.AlloySlotVisibilityEvent>(SystemEvents.slotVisibility(), (sidepanel, se) => {
const data = se.event();
const optSidePanelSpec = Arr.find(specs, (config) => config.name === data.name());
optSidePanelSpec.each((sidePanelSpec) => {
const handler = data.visible() ? sidePanelSpec.onShow : sidePanelSpec.onHide;
handler(sidePanelSpec.getApi(sidepanel));
});
})
])
}
);
});
};