本文整理汇总了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();
});