本文整理匯總了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');
}
});