本文整理匯總了TypeScript中@ephox/agar.Cursors類的典型用法代碼示例。如果您正苦於以下問題:TypeScript Cursors類的具體用法?TypeScript Cursors怎麽用?TypeScript Cursors使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
在下文中一共展示了Cursors類的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1: function
const createDomSelection = function (container, sPath, soffset, fPath, foffset) {
const path = Cursors.path({
startPath: sPath,
soffset,
finishPath: fPath,
foffset
});
return toDomRange(Cursors.calculate(container, path));
};
示例2: function
const sTestBookmark = function (html, path) {
const dom = DOMUtils.DOM;
const elm = TinyDom.fromDom(dom.create('div', {}, html));
return Chain.asStep(elm, [
Cursors.cFollowPath(Cursors.pathFrom(path)),
Chain.mapper(toNativeRange),
Chain.mapper(rangeToBookmark(dom)),
Chain.mapper(bookmarkToRange(dom)),
cAssertRangeEq(Cursors.calculate(elm, Cursors.pathFrom(path)))
]);
};
示例3:
return Step.sync(function () {
const x = Cursors.calculateOne(Element.fromDom(editor.getBody()), path);
const rng = editor.dom.createRng();
rng.setStart(x.dom(), offset);
rng.setEnd(x.dom(), offset);
ScrollIntoView.scrollRangeIntoView(editor, rng);
});
示例4: function
const sOpenToolbarOn = function (editor, selector, path) {
return Chain.asStep(TinyDom.fromDom(editor.getBody()), [
UiFinder.cFindIn(selector),
Cursors.cFollow(path),
Chain.op(function (target) {
editor.selection.select(target.dom());
}),
Mouse.cClick
]);
};
示例5: function
const assertPath = function (label, root, expPath, expOffset, actElement, actOffset) {
const expected = Cursors.calculateOne(root, expPath);
const message = function () {
const actual = Element.fromDom(actElement);
const actPath = Hierarchy.path(root, actual).getOrDie('could not find path to root');
return 'Expected path: ' + JSON.stringify(expPath) + '.\nActual path: ' + JSON.stringify(actPath);
};
Assertions.assertEq('Assert incorrect for ' + label + '.\n' + message(), true, expected.dom() === actElement);
Assertions.assertEq('Offset mismatch for ' + label + ' in :\n' + Html.getOuter(expected), expOffset, actOffset);
};
示例6: insert
const sInsertEmptyTextNodesAt = (editor: Editor, count: number, path: number[], insert: (marker: Element, element: Element) => void) => {
return Chain.asStep(Element.fromDom(editor.getBody()), [
Cursors.cFollow(path),
Chain.op((elm) => {
Arr.each(Arr.range(count, Fun.identity), () => {
insert(elm, Element.fromDom(document.createTextNode('')));
});
})
]);
};
示例7:
WindowSelection.getExact(win).orThunk(function () {
const fbody = Element.fromDom(frame.dom().contentWindow.document.body);
const elem = Cursors.calculateOne(fbody, [ 0 ]);
WindowSelection.setExact(win, elem, 0, elem, 0);
return Option.none();
});