本文整理匯總了TypeScript中tinymce/core/bookmark/GetBookmark.getPersistentBookmark函數的典型用法代碼示例。如果您正苦於以下問題:TypeScript getPersistentBookmark函數的具體用法?TypeScript getPersistentBookmark怎麽用?TypeScript getPersistentBookmark使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了getPersistentBookmark函數的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1: 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);
}
});
示例2:
return NamedChain.direct('editor', Chain.mapper((editor) => GetBookmark.getPersistentBookmark(editor.selection, true)), 'bookmark');
示例3: function
//.........這裏部分代碼省略.........
};
const mergeStyles = function (node) {
let child, clone;
child = getChildElementNode(node);
// If child was found and of the same type as the current node
if (child && !Bookmarks.isBookmarkNode(child) && MatchFormat.matchName(dom, child, format)) {
clone = dom.clone(child, false);
setElementFormat(clone);
dom.replace(clone, node, true);
dom.remove(child, 1);
}
return clone || node;
};
childCount = getChildCount(node);
// Remove empty nodes but only if there is multiple wrappers and they are not block
// elements so never remove single <h1></h1> since that would remove the
// current empty block element where the caret is at
if ((newWrappers.length > 1 || !dom.isBlock(node)) && childCount === 0) {
dom.remove(node, 1);
return;
}
if (format.inline || format.wrapper) {
// Merges the current node with it's children of similar type to reduce the number of elements
if (!format.exact && childCount === 1) {
node = mergeStyles(node);
}
MergeFormats.mergeWithChildren(ed, formatList, vars, node);
MergeFormats.mergeWithParents(ed, format, name, vars, node);
MergeFormats.mergeBackgroundColorAndFontSize(dom, format, vars, node);
MergeFormats.mergeSubSup(dom, format, vars, node);
MergeFormats.mergeSiblings(dom, format, vars, node);
}
});
};
if (dom.getContentEditable(selection.getNode()) === 'false') {
node = selection.getNode();
for (let i = 0, l = formatList.length; i < l; i++) {
if (formatList[i].ceFalseOverride && dom.is(node, formatList[i].selector)) {
setElementFormat(node, formatList[i]);
return;
}
}
return;
}
if (format) {
if (node) {
if (node.nodeType) {
if (!applyNodeStyle(formatList, node)) {
rng = dom.createRng();
rng.setStartBefore(node);
rng.setEndAfter(node);
applyRngStyle(dom, ExpandRange.expandRng(ed, rng, formatList), null, true);
}
} else {
applyRngStyle(dom, node, null, true);
}
} else {
if (!isCollapsed || !format.inline || dom.select('td[data-mce-selected],th[data-mce-selected]').length) {
// Obtain selection node before selection is unselected by applyRngStyle
const curSelNode = ed.selection.getNode();
// If the formats have a default block and we can't find a parent block then
// start wrapping it with a DIV this is for forced_root_blocks: false
// It's kind of a hack but people should be using the default block type P since all desktop editors work that way
if (!ed.settings.forced_root_block && formatList[0].defaultBlock && !dom.getParent(curSelNode, dom.isBlock)) {
applyFormat(ed, formatList[0].defaultBlock);
}
// Apply formatting to selection
ed.selection.setRng(RangeNormalizer.normalize(ed.selection.getRng()));
bookmark = GetBookmark.getPersistentBookmark(ed.selection, true);
applyRngStyle(dom, ExpandRange.expandRng(ed, selection.getRng(), formatList), bookmark);
if (format.styles) {
MergeFormats.mergeUnderlineAndColor(dom, format, vars, curSelNode);
}
selection.moveToBookmark(bookmark);
FormatUtils.moveStart(dom, selection, selection.getRng());
ed.nodeChanged();
} else {
CaretFormat.applyCaretFormat(ed, name, vars);
}
}
Hooks.postProcess(name, ed);
}
};
示例4: function
//.........這裏部分代碼省略.........
const marker = Option.from(startContainer.firstChild).getOr(startContainer);
splitToFormatRoot(wrapWithSiblings(dom, marker, true, 'span', { 'id': '_start', 'data-mce-type': 'bookmark' }));
unwrap(true);
return;
}
// Wrap and split if nested
if (isChildOfInlineParent(dom, endContainer, startContainer)) {
const marker = Option.from(endContainer.lastChild).getOr(endContainer);
splitToFormatRoot(wrapWithSiblings(dom, marker, false, 'span', { 'id': '_end', 'data-mce-type': 'bookmark' }));
unwrap(false);
return;
}
// Wrap start/end nodes in span element since these might be cloned/moved
startContainer = wrap(dom, startContainer, 'span', { 'id': '_start', 'data-mce-type': 'bookmark' });
endContainer = wrap(dom, endContainer, 'span', { 'id': '_end', 'data-mce-type': 'bookmark' });
// Split start/end
splitToFormatRoot(startContainer);
splitToFormatRoot(endContainer);
// Unwrap start/end to get real elements again
startContainer = unwrap(true);
endContainer = unwrap();
} else {
startContainer = endContainer = splitToFormatRoot(startContainer);
}
// Update range positions since they might have changed after the split operations
rng.startContainer = startContainer.parentNode ? startContainer.parentNode : startContainer;
rng.startOffset = dom.nodeIndex(startContainer);
rng.endContainer = endContainer.parentNode ? endContainer.parentNode : endContainer;
rng.endOffset = dom.nodeIndex(endContainer) + 1;
}
// Remove items between start/end
RangeWalk.walk(dom, rng, function (nodes) {
each(nodes, function (node) {
process(node);
// Remove parent span if it only contains text-decoration: underline, yet a parent node is also underlined.
if (NodeType.isElement(node) && ed.dom.getStyle(node, 'text-decoration') === 'underline' &&
node.parentNode && FormatUtils.getTextDecoration(dom, node.parentNode) === 'underline') {
removeFormat(ed, {
deep: false,
exact: true,
inline: 'span',
styles: {
textDecoration: 'underline'
}
}, null, node);
}
});
});
};
// Handle node
if (node) {
if (node.nodeType) {
rng = dom.createRng();
rng.setStartBefore(node);
rng.setEndAfter(node);
removeRngStyle(rng);
} else {
removeRngStyle(node);
}
return;
}
if (dom.getContentEditable(selection.getNode()) === 'false') {
node = selection.getNode();
for (let i = 0, l = formatList.length; i < l; i++) {
if (formatList[i].ceFalseOverride) {
if (removeFormat(ed, formatList[i], vars, node, node)) {
break;
}
}
}
return;
}
if (!selection.isCollapsed() || !format.inline || dom.select('td[data-mce-selected],th[data-mce-selected]').length) {
bookmark = GetBookmark.getPersistentBookmark(ed.selection, true);
removeRngStyle(selection.getRng());
selection.moveToBookmark(bookmark);
// Check if start element still has formatting then we are at: "<b>text|</b>text"
// and need to move the start into the next text node
if (format.inline && MatchFormat.match(ed, name, vars, selection.getStart())) {
FormatUtils.moveStart(dom, selection, selection.getRng());
}
ed.nodeChanged();
} else {
CaretFormat.removeCaretFormat(ed, name, vars, similar);
}
};