本文整理匯總了TypeScript中@ephox/sugar.Insert類的典型用法代碼示例。如果您正苦於以下問題:TypeScript Insert類的具體用法?TypeScript Insert怎麽用?TypeScript Insert使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
在下文中一共展示了Insert類的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1:
const insertElement = (root: Element, elm: Element, forward: boolean) => {
if (forward) {
Insert.append(root, elm);
} else {
Insert.prepend(root, elm);
}
};
示例2: function
const appendStyle = function (editor: Editor, text: string) {
const head = Element.fromDom(editor.getDoc().head);
const tag = Element.fromTag('style');
Attr.set(tag, 'type', 'text/css');
Insert.append(tag, Element.fromText(text));
Insert.append(head, tag);
};
示例3: getElementFromPosition
return getElementFromPosition(pos).map((elm) => {
const textNode = Element.fromText(text);
if (pos.isAtEnd()) {
Insert.after(elm, textNode);
} else {
Insert.before(elm, textNode);
}
return CaretPosition(textNode.dom(), text.length);
});
示例4: function
const insertBrAfter = function (editor, inline) {
if (!hasBrAfter(editor.getBody(), inline)) {
Insert.after(Element.fromDom(inline), Element.fromTag('br'));
}
const br = Element.fromTag('br');
Insert.after(Element.fromDom(inline), br);
scrollToBr(editor.dom, editor.selection, br.dom());
moveSelectionToBr(editor.dom, editor.selection, br.dom(), false);
editor.undoManager.add();
};
示例5: moveToRange
editor.undoManager.transact(() => {
const element = SugarElement.fromTag(forcedRootBlock);
Attr.setAll(element, Settings.getForcedRootBlockAttrs(editor));
Insert.append(element, SugarElement.fromTag('br'));
if (down) {
Insert.after(SugarElement.fromDom(table), element);
} else {
Insert.before(SugarElement.fromDom(table), element);
}
const rng = editor.dom.createRng();
rng.setStart(element.dom(), 0);
rng.setEnd(element.dom(), 0);
moveToRange(editor, rng);
});
示例6: context
const processElement = (elem) => {
const ctx = context(editor, elem, 'span', Node.name(elem));
switch (ctx) {
case ChildContext.InvalidChild: {
finishWrapper();
const children = Traverse.children(elem);
processElements(children);
finishWrapper();
break;
}
case ChildContext.Valid: {
const w = getOrOpenWrapper();
Insert.wrap(elem, w);
break;
}
// INVESTIGATE: Are these sensible things to do?
case ChildContext.Skipping:
case ChildContext.Existing:
case ChildContext.Caret: {
// Do nothing.
}
}
};
示例7:
const wrapWithSiblings = (dom: DOMUtils, node: Node, next: boolean, name: string, attrs?): Node => {
const start = Element.fromDom(node);
const wrapper = Element.fromDom(dom.create(name, attrs));
const siblings = next ? Traverse.nextSiblings(start) : Traverse.prevSiblings(start);
InsertAll.append(wrapper, siblings);
if (next) {
Insert.before(start, wrapper);
Insert.prepend(wrapper, start);
} else {
Insert.after(start, wrapper);
Insert.append(wrapper, start);
}
return wrapper.dom();
};
示例8: 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);
})),
示例9: function
const replaceWithCaretFormat = function (targetNode, formatNodes) {
const caretContainer = createCaretContainer(false);
const innerMost = insertFormatNodesIntoCaretContainer(formatNodes, caretContainer.dom());
Insert.before(Element.fromDom(targetNode), caretContainer);
Remove.remove(Element.fromDom(targetNode));
return CaretPosition(innerMost, 0);
};
示例10:
const createSegment = (scope: Document, listType: ListType): Segment => {
const segment: Segment = {
list: Element.fromTag(listType, scope),
item: Element.fromTag('li', scope)
};
Insert.append(segment.list, segment.item);
return segment;
};