本文整理汇总了TypeScript中@ephox/sugar.Element.default方法的典型用法代码示例。如果您正苦于以下问题:TypeScript Element.default方法的具体用法?TypeScript Element.default怎么用?TypeScript Element.default使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类@ephox/sugar.Element
的用法示例。
在下文中一共展示了Element.default方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: getStart
const getSelectedBlocks = (dom, rng: Range, startElm?: Element, endElm?: Element): Element[] => {
let node, root;
const selectedBlocks = [];
root = dom.getRoot();
startElm = dom.getParent(startElm || getStart(root, rng, false), dom.isBlock);
endElm = dom.getParent(endElm || getEnd(root, rng, false), dom.isBlock);
if (startElm && startElm !== root) {
selectedBlocks.push(startElm);
}
if (startElm && endElm && startElm !== endElm) {
node = startElm;
const walker = new TreeWalker(startElm, root);
while ((node = walker.next()) && node !== endElm) {
if (dom.isBlock(node)) {
selectedBlocks.push(node);
}
}
}
if (endElm && startElm !== endElm && endElm !== root) {
selectedBlocks.push(endElm);
}
return selectedBlocks;
};
示例2: isBeforeSpace
const hasSpaceAfter = (root: Element, pos: CaretPosition): boolean => {
if (isInMiddleOfText(pos)) {
return isBeforeSpace(pos);
} else {
return isBeforeSpace(pos) || CaretFinder.nextPosition(getClosestBlock(root, pos).dom(), pos).exists(isBeforeSpace);
}
};
示例3: getRootElement
onAction: () => {
// Ensure the figure/image is selected before opening the image edit dialog
// as some browsers don't do this when right clicking
const rootElm = getRootElement(Element.fromDom(node));
editor.selection.select(rootElm.dom());
// Open the dialog now that the image is selected
Dialog(editor).open();
}
示例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: makeAnnotation
const annotate = (editor: Editor, rng: Range, annotationName: string, decorate: Decorator, data): any[] => {
// Setup all the wrappers that are going to be used.
const newWrappers = [ ];
// Setup the spans for the comments
const master = makeAnnotation(editor.getDoc(), data, annotationName, decorate);
// Set the current wrapping element
const wrapper = Cell(Option.none());
// Clear the current wrapping element, so that subsequent calls to
// getOrOpenWrapper spawns a new one.
const finishWrapper = () => {
wrapper.set(Option.none());
};
// Get the existing wrapper, or spawn a new one.
const getOrOpenWrapper = () => {
return wrapper.get().getOrThunk(() => {
const nu = Replication.shallow(master);
newWrappers.push(nu);
wrapper.set(Option.some(nu));
return nu;
});
};
const processElements = (elems) => {
Arr.each(elems, processElement);
};
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.
}
}
};
const processNodes = (nodes) => {
const elems = Arr.map(nodes, Element.fromDom);
processElements(elems);
};
RangeWalk.walk(editor.dom, rng, (nodes) => {
finishWrapper();
processNodes(nodes);
});
return newWrappers;
};
示例6: createItem
Arr.last(newCast).each((segment) => {
const item = createItem(scope, entry.itemAttributes, entry.content);
appendItem(segment, item);
normalizeSegment(segment, entry);
});
示例7: setItem
Arr.last(newOutline).each((section) => {
setItem(section, createItem(scope, entry.itemAttributes, entry.content));
normalizeSection(section, entry);
});