本文整理汇总了TypeScript中@ephox/katamari.Obj类的典型用法代码示例。如果您正苦于以下问题:TypeScript Obj类的具体用法?TypeScript Obj怎么用?TypeScript Obj使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Obj类的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: Error
const register = (editor: Editor): AutocompleterDatabase => {
const popups = editor.ui.registry.getAll().popups;
const dataset = Obj.map(popups, (popup) => {
return InlineContent.createAutocompleter(popup).fold(
(err) => {
throw new Error(ValueSchema.formatError(err));
},
(x) => x
);
});
const triggerChars = Unique.stringArray(
Obj.mapToArray(dataset, (v) => v.ch)
);
const datasetValues = Obj.values(dataset);
const lookupByChar = (ch: string): InlineContent.Autocompleter[] => {
return Arr.filter(datasetValues, (dv) => dv.ch === ch);
};
return {
dataset,
triggerChars,
lookupByChar
};
};
示例2:
const getCellPaddingCellSpacing = () => {
const spacing = Obj.get(style, 'border-spacing').or(Obj.get(attrs, 'cellspacing')).fold( () => ({}), (cellspacing) => ({ cellspacing }));
const padding = Obj.get(style, 'border-padding').or(Obj.get(attrs, 'cellpadding')).fold( () => ({}), (cellpadding) => ({ cellpadding }));
return {
...spacing,
...padding
};
};
示例3: cSetFieldValue
const chains = Arr.flatten(Obj.mapToArray(tabSelectors, (value, key): Chain<any, any>[] => {
if (Obj.has(data, key)) {
const newValue = typeof data[key] === 'object' ? data[key].value : data[key];
return [ cSetFieldValue(tabSelectors[key], newValue) ];
} else if (Obj.has(data, 'dimensions') && Obj.has(data.dimensions, key)) {
return [ cSetFieldValue(tabSelectors[key], data.dimensions[key]) ];
} else {
return [];
}
}));
示例4: 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);
});
});
示例5: rgbToHex
const extractAdvancedStyleData = (dom) => {
const rgbToHex = (value: string) => Strings.startsWith(value, 'rgb') ? dom.toHex(value) : value;
const borderStyle = Obj.get(style, 'border-style').getOr('');
const borderColor = Obj.get(style, 'border-color').getOr('');
const bgColor = Obj.get(style, 'background-color').getOr('');
return {
borderstyle: borderStyle,
bordercolor: rgbToHex(borderColor),
backgroundcolor: rgbToHex(bgColor)
};
};
示例6: getDimensions
export const resize = (editor: Editor, deltas, resizeType: ResizeTypes) => {
const container = Element.fromDom(editor.getContainer());
const dimensions = getDimensions(editor, deltas, resizeType, Height.get(container), Width.get(container));
Obj.each(dimensions, (val, dim) => Css.set(container, dim, Utils.numToPx(val)));
Events.fireResizeEditor(editor);
};
示例7:
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();
};
示例8: 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]);
});
};
示例9:
Obj.each(expected.pattern, (value, key) => {
if (Obj.has<any, string>(pattern, key)) {
Assertions.assertEq('Pattern ' + (i + 1) + ' property `' + key + '` is not equal', value, pattern[key]);
} else {
assert.fail('Pattern ' + (i + 1) + ' property `' + key + '` is missing');
}
});