本文整理汇总了TypeScript中@ephox/sugar.Html.set方法的典型用法代码示例。如果您正苦于以下问题:TypeScript Html.set方法的具体用法?TypeScript Html.set怎么用?TypeScript Html.set使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类@ephox/sugar.Html
的用法示例。
在下文中一共展示了Html.set方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: n
NamedChain.write('container', Chain.async((input, n, die) => {
const container = Element.fromTag('div');
Attr.set(container, 'id', 'test-container-div');
Html.set(container, containerHtml);
Insert.append(Body.body(), container);
n(container);
})),
示例2:
const setContents = (comp, items) => {
const htmlLines = Arr.map(items, (item) => {
const textContent = spec.columns === 1 ? `<div class="tox-collection__item-label">${item.text}</div>` : '';
const iconContent = `<div class="tox-collection__item-icon">${item.icon}</div>`;
// Replacing the hyphens and underscores in collection items with spaces
// to ensure the screen readers pronounce the words correctly.
// This is only for aria purposes. Emoticon and Special Character names will still use _ and - for autocompletion.
const mapItemName = {
'_': ' ',
' - ': ' ',
'-': ' '
};
// Title attribute is added here to provide tooltips which might be helpful to sighted users.
// Using aria-label here overrides the Apple description of emojis and special characters in Mac/ MS description in Windows.
// But if only the title attribute is used instead, the names are read out twice. i.e., the description followed by the item.text.
const ariaLabel = item.text.replace(/\_| \- |\-/g, (match) => {
return mapItemName[match];
});
return `<div class="tox-collection__item" tabindex="-1" data-collection-item-value="${escapeAttribute(item.value)}" title="${ariaLabel}" aria-label="${ariaLabel}">${iconContent}${textContent}</div>`;
});
const chunks = spec.columns > 1 && spec.columns !== 'auto' ? Arr.chunk(htmlLines, spec.columns) : [ htmlLines ];
const html = Arr.map(chunks, (ch) => {
return `<div class="tox-collection__group">${ch.join('')}</div>`;
});
Html.set(comp.element(), html.join(''));
};
示例3: next
return Step.stateful(function (value, next, die) {
const style = Element.fromTag('style');
const head = Element.fromDom(doc.dom().head);
Insert.append(head, style);
Html.set(style, styles.join('\n'));
next(Merger.deepMerge(value, {
style
}));
});
示例4: applyWordGrab
editor.undoManager.transact(() => {
const initialRng = editor.selection.getRng();
if (initialRng.collapsed) {
applyWordGrab(editor, initialRng);
}
// Even after applying word grab, we could not find a selection. Therefore,
// just make a wrapper and insert it at the current cursor
if (editor.selection.getRng().collapsed) {
const wrapper = makeAnnotation(editor.getDoc(), data, name, settings.decorate);
// Put something visible in the marker
Html.set(wrapper, '\u00A0');
editor.selection.getRng().insertNode(wrapper.dom());
editor.selection.select(wrapper.dom());
} else {
// The bookmark is responsible for splitting the nodes beforehand at the selection points
// The "false" here means a zero width cursor is NOT put in the bookmark. It seems to be required
// to stop an empty paragraph splitting into two paragraphs. Probably a better way exists.
const bookmark = GetBookmark.getPersistentBookmark(editor.selection, false);
const rng = editor.selection.getRng();
annotate(editor, rng, name, settings.decorate, data);
editor.selection.moveToBookmark(bookmark);
}
});
示例5:
return Chain.op(function (elm: Element) {
Html.set(elm, html);
});
示例6: lazyTempDocument
const getCleanLevelContent = (level: UndoLevel): string => {
const elm = Element.fromTag('body', lazyTempDocument());
Html.set(elm, getLevelContent(level));
Arr.each(SelectorFilter.descendants(elm, '*[data-mce-bogus]'), Remove.unwrap);
return Html.get(elm);
};