本文整理汇总了TypeScript中@ephox/sugar.Element.fromDom方法的典型用法代码示例。如果您正苦于以下问题:TypeScript Element.fromDom方法的具体用法?TypeScript Element.fromDom怎么用?TypeScript Element.fromDom使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类@ephox/sugar.Element
的用法示例。
在下文中一共展示了Element.fromDom方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: TinyApis
TinyLoader.setup(function (editor: Editor, onSuccess, onFailure) {
const tinyApis = TinyApis(editor);
// TODO: Consider testing collapse sections.
const sTestWordGrabIfCollapsed = Logger.t(
'Should word grab with a collapsed selection',
GeneralSteps.sequence([
// '<p>This |is| the first paragraph</p><p>This is the second.</p>'
tinyApis.sSetContent('<p>This is the first paragraph here</p><p>This is the second.</p>'),
tinyApis.sSetSelection([ 0, 0 ], 'This is the first p'.length, [ 0, 0 ], 'This is the first p'.length),
sAnnotate(editor, 'test-annotation', 'test-uid', { anything: 'one-paragraph' }),
sAssertHtmlContent(tinyApis, [
`<p>This is the first <span data-test-anything="one-paragraph" data-mce-annotation="test-annotation" data-mce-annotation-uid="test-uid" class="mce-annotation">paragraph</span> here</p>`,
'<p>This is the second.</p'
]),
tinyApis.sAssertSelection([ 0 ], 1, [ 0 ], 2)
])
);
const sTestCanAnnotateDirectParentOfRoot = Logger.t(
'Should be able to annotate a direct parent of the body (e.g. an empty paragraph)',
GeneralSteps.sequence([
tinyApis.sSetContent('<p>First</p><p><br/></p><p>Third</p>'),
tinyApis.sSetSelection([ 1 ], 0, [ 1 ], 0),
sAnnotate(editor, 'test-annotation', 'test-uid', { anything: 'empty-paragraph' }),
sAssertHtmlContent(tinyApis, [
'<p>First</p>',
'<p><span data-test-anything="empty-paragraph" data-mce-annotation="test-annotation" data-mce-annotation-uid="test-uid" class="mce-annotation"><br /></span></p>',
'<p>Third</p>'
]),
])
);
const sTestCanAnnotateBeforeTwoNonBreakingSpaces = Logger.t(
'Should annotate when the cursor is collapsed before two nbsps',
GeneralSteps.sequence([
tinyApis.sSetContent('<p>Annotation here , please</p>'),
tinyApis.sSetCursor([ 0, 0 ], 'Annotation here '.length),
sAnnotate(editor, 'test-annotation', 'test-uid', { anything: 'nbsp-paragraph' }),
Assertions.sAssertStructure(
'Checking body element',
ApproxStructure.build((s, str, arr) => {
return s.element('body', {
children: [
s.element('p', {
children: [
s.text( str.is('Annotation here ') ),
s.element('span', {
classes: [ arr.has('mce-annotation') ],
html: str.is(' ')
}),
s.text( str.is('\u00A0\u00A0, please'))
]
})
]
});
}),
Element.fromDom(editor.getBody())
)
])
);
const sTestCanAnnotateWithinTwoNonBreakingSpaces = Logger.t(
'Should annotate when the cursor is collapsed between two nbsps',
GeneralSteps.sequence([
tinyApis.sSetContent('<p>Annotation here , please</p>'),
tinyApis.sSetCursor([ 0, 0 ], 'Annotation here '.length),
sAnnotate(editor, 'test-annotation', 'test-uid', { anything: 'nbsp-paragraph' }),
Assertions.sAssertStructure(
'Checking body element',
ApproxStructure.build((s, str, arr) => {
return s.element('body', {
children: [
s.element('p', {
children: [
s.text( str.is('Annotation here \u00A0') ),
s.element('span', {
classes: [ arr.has('mce-annotation') ],
html: str.is(' ')
}),
s.text( str.is('\u00A0, please'))
]
})
]
});
}),
Element.fromDom(editor.getBody())
)
])
);
const sTestCanAnnotateAfterTwoNonBreakingSpaces = Logger.t(
'Should annotate when the cursor is collapsed after two nbsps',
GeneralSteps.sequence([
tinyApis.sSetContent('<p>Annotation here , please</p>'),
tinyApis.sSetCursor([ 0, 0 ], 'Annotation here '.length),
sAnnotate(editor, 'test-annotation', 'test-uid', { anything: 'nbsp-paragraph' }),
Assertions.sAssertStructure(
'Checking body element',
//.........这里部分代码省略.........
示例2: function
}, function (e) {
return Compare.eq(e, Element.fromDom(editor.getBody()));
});
示例3: getPositionsBelow
return Chain.mapper(function (scope) {
const container = Hierarchy.follow(Element.fromDom(scope.get()), path).getOrDie();
const pos = CaretPosition(container.dom(), offset);
return getPositionsBelow(scope.get(), pos);
});
示例4: function
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);
};
示例5: function
const get = function (editor: Editor, container?) {
return editor.inline ? ResizeWire.body(Util.getBody(editor), createContainer()) : ResizeWire.only(Element.fromDom(editor.getDoc()));
};
示例6: function
const store = function (editor) {
const newBookmark = shouldStore(editor) ? getBookmark(Element.fromDom(editor.getBody())) : Option.none();
editor.bookmark = newBookmark.isSome() ? newBookmark : editor.bookmark;
};
示例7: function
return Arr.bind(ranges, function (range) {
const node = RangeNodes.getSelectedNode(range);
return node ? [ Element.fromDom(node) ] : [];
});
示例8:
const sAssertHtmlStructure = (label, expectedHtml) => Chain.asStep({editor}, [ NamedChain.read('editor', Chain.op((editor) => {
const elm = Replication.deep(Element.fromDom(editor.getBody()));
Arr.each(SelectorFilter.descendants(elm, '*[data-mce-bogus="all"]'), Remove.remove);
const actualHtml = Html.get(elm);
Assertions.assertHtmlStructure(label, `<body>${expectedHtml}</body>`, `<body>${actualHtml}</body>`);
}))]);
示例9: function
const insertBrBefore = function (editor, inline) {
const br = Element.fromTag('br');
Insert.before(Element.fromDom(inline), br);
editor.undoManager.add();
};
示例10: function
FieldSchema.state('body', function (spec) {
return Element.fromDom(
spec.socket.dom().ownerDocument.body
);
}),