本文整理汇总了TypeScript中@ephox/katamari.Obj.each方法的典型用法代码示例。如果您正苦于以下问题:TypeScript Obj.each方法的具体用法?TypeScript Obj.each怎么用?TypeScript Obj.each使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类@ephox/katamari.Obj
的用法示例。
在下文中一共展示了Obj.each方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: 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);
};
示例2: function
UnitTest.test('tinymce.plugins.paste.browser.NewlinesTest', function () {
Theme();
PastePlugin();
// testing Newlines.isPlainText()
const textCases = [
{
label: 'Basic Chrome markup (including span-wrapped tab)',
content: '<div><span style="white-space:pre"> </span>a</div><div><br></div><div>b</div>',
isText: true
},
{
label: 'Case shouldn\'t matter',
content: '<DIV>a</DIV><DIV><BR></DIV>',
isText: true
},
{
label: 'Support all BR types',
content: '<br><br />',
isText: true
},
{
label: 'Basic IE markup',
content: '<p>a</p><p><br></p><p>b</p>',
isText: true
},
{
label: 'White-space wrapper (Chrome)',
content: '<div><span style="white-space: pre;"> </span>a</div>',
isText: true
},
{
label: 'White-space wrapper (Chrome) with additional styles',
content: '<div><span style="white-space: pre; color: red;"> </span>a</div>',
isText: false
},
{
label: 'Allowed tag but with attributes qualifies string as not a plain text',
content: '<br data-mce-bogus="all" />',
isText: false
}
];
// only DIV,P,BR and SPAN[style="white-space:pre"] tags are allowed in "plain text" string
Arr.each('a,abbr,address,article,aside,audio,b,bdi,bdo,blockquote,button,cite,code,del,details,dfn,dl,em,embed,fieldset,figure,footer,form,h1,h2,h3,h4,h5,h6,header,hgroup,hr,i,ins,label,menu,nav,noscript,object,ol,pre,q,s,script,section,select,small,strong,style,sub,sup,svg,table,textarea,time,u,ul,var,video,wbr'.split(','),
function (tag) {
const content = '<p>a</p><' + tag + '>b</' + tag + '><p>c<br>d</p>';
textCases.push({
label: tag.toUpperCase() + ' tag should qualify content (' + content + ') as not a plain text',
content,
isText: false
});
}
);
Obj.each(textCases, function (c) {
Assertions.assertEq(c.label || 'Asserting: ' + c.content, c.isText, Newlines.isPlainText(c.content));
});
});
示例3: PasteBin
Chain.op(function (editor: any) {
const pasteBin = PasteBin(editor);
Obj.each(cases, function (c, i) {
getPasteBinParent(editor).appendChild(editor.dom.createFragment(c.content));
Assertions.assertEq(c.label || 'Asserting paste bin case ' + i, c.result, pasteBin.getHtml());
pasteBin.remove();
});
}),
示例4: PasteBin
return Chain.op(function (editor) {
const pasteBin = PasteBin(editor);
Obj.each(cases, function (c, i) {
editor.getBody().innerHTML = c.content;
Assertions.assertEq(c.label || 'Asserting paste bin case ' + i, c.result, pasteBin.getHtml());
pasteBin.remove();
});
});
示例5:
Arr.each(keys, (key) => {
Obj.each(items, (itemValue, itemKey, _) => {
const comparisonValue = baseData[key];
if (comparisonValue !== '' && key === itemKey) {
if (comparisonValue !== itemValue) {
baseData[key] = '';
}
}
});
});
示例6: 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);
});
});
示例7: function
const cAssertClipboardPaste = function (expected, data) {
const chains = [];
Obj.each(data, function (data, label) {
chains.push(
cFireFakePasteEvent(data),
Chain.control(
cAssertEditorContent(label, expected),
Guard.tryUntil('Wait for paste to succeed.', 100, 1000)
),
cClearEditor()
);
});
return Chain.fromChains(chains);
};
示例8: getAllOxide
const initIcons = (editor: Editor) => {
const iconPackName: string = Tools.trim(editor.settings.icons);
const currentIcons = editor.ui.registry.getAll().icons;
const defaultIcons = getAllOxide();
const loadIcons = {
...defaultIcons,
...IconManager.get(iconPackName).icons
};
Obj.each(loadIcons, (svgData, icon) => {
// Don't override an icon registered manually
if (!Obj.has(currentIcons, icon)) {
editor.ui.registry.addIcon(icon, svgData);
}
});
};
示例9:
return Chain.op<InlinePatternMatch[]>((actualMatches) => {
Assertions.assertEq('Pattern count does not match', expectedMatches.length, actualMatches.length);
for (let i = 0; i < expectedMatches.length; i++) {
const expected = expectedMatches[i];
const actual = actualMatches[i];
const pattern = actual.pattern;
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');
}
});
// prepend a 0 because we always add a root node
Assertions.assertEq('start path does not match', [0].concat(expected.start), actual.range.start);
Assertions.assertEq('end path does not match', [0].concat(expected.end), actual.range.end);
}
});
示例10: 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
});
};