本文整理汇总了TypeScript中@ephox/sugar.Element.fromHtml方法的典型用法代码示例。如果您正苦于以下问题:TypeScript Element.fromHtml方法的具体用法?TypeScript Element.fromHtml怎么用?TypeScript Element.fromHtml使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类@ephox/sugar.Element
的用法示例。
在下文中一共展示了Element.fromHtml方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1:
Logger.t('isInlineTarget with various editor settings', Step.sync(function () {
Assertions.assertEq('Links should be inline target', true, InlineUtils.isInlineTarget(createFakeEditor({ }), Element.fromHtml('<a href="a">').dom()));
Assertions.assertEq('Code should be inline target', true, InlineUtils.isInlineTarget(createFakeEditor({ }), Element.fromHtml('<code>').dom()));
Assertions.assertEq('None link anchor should not be inline target', false, InlineUtils.isInlineTarget(createFakeEditor({ }), Element.fromHtml('<a>').dom()));
Assertions.assertEq('Bold should not be inline target', false, InlineUtils.isInlineTarget(createFakeEditor({ }), Element.fromHtml('<b>').dom()));
Assertions.assertEq('Bold should be inline target if configured', true, InlineUtils.isInlineTarget(createFakeEditor({
inline_boundaries_selector: 'b'
}), Element.fromHtml('<b>').dom()));
Assertions.assertEq('Italic should be inline target if configured', true, InlineUtils.isInlineTarget(createFakeEditor({
inline_boundaries_selector: 'b,i'
}), Element.fromHtml('<i>').dom()));
})),
示例2: function
const sTestDataToHtml = function (editor, data, expected) {
const actual = Element.fromHtml(DataToHtml.dataToHtml(editor, data));
return Waiter.sTryUntil('Wait for structure check',
Assertions.sAssertStructure('Assert equal', expected, actual),
10, 500);
};
示例3: function
Logger.sync('getInfo ... ' + scenario.label + ', link: ' + scenario.linkHtml, function () {
editorState.start.set(Element.fromHtml(scenario.linkHtml).dom());
editorState.content.set(scenario.selection);
const info = LinkBridge.getInfo(editor);
RawAssertions.assertEq('Checking getInfo (link)', scenario.expected, Objects.narrow(info, [ 'url', 'text', 'target', 'title' ]));
RawAssertions.assertEq('Checking link is set', true, info.link.isSome());
});
示例4: return
onSetup: (api) => {
console.log('onSetup ' + name);
const box = Element.fromHtml('<div style="width: ' + width + 'px; background: ' + background + ';"></div>');
api.element().appendChild(box.dom());
return () => {
api.element().removeChild(box.dom());
};
},
示例5:
Chain.op((editor) => {
const wrapperElm = Element.fromHtml('<div class="tinymce-editor"></div>');
Selectors.one('#' + editor.id).each((textareaElm) => {
Insert.wrap(textareaElm, wrapperElm);
});
Selectors.one('.tinymce-mobile-outer-container').each((editorElm) => {
Insert.wrap(editorElm, wrapperElm);
});
}),
示例6:
Logger.t('getParentCaretContainer', Step.sync(function () {
const body = Element.fromHtml('<div><span id="_mce_caret">a</span></div>');
const caret = Element.fromDom(body.dom().firstChild);
Assertions.assertDomEq('Should be caret element on child', caret, Element.fromDom(CaretFormat.getParentCaretContainer(body.dom(), caret.dom().firstChild)));
Assertions.assertDomEq('Should be caret element on self', caret, Element.fromDom(CaretFormat.getParentCaretContainer(body.dom(), caret.dom())));
Assertions.assertEq('Should not be caret element', null, CaretFormat.getParentCaretContainer(body, Element.fromTag('span').dom()));
Assertions.assertEq('Should not be caret element', null, CaretFormat.getParentCaretContainer(caret.dom(), caret.dom()));
})),
示例7:
return Chain.binder(function (_) {
const tableElm = Element.fromHtml(html);
const startElm = Hierarchy.follow(tableElm, startPath).getOrDie();
const endElm = Hierarchy.follow(tableElm, endPath).getOrDie();
return SimpleTableModel.subsection(SimpleTableModel.fromDom(tableElm), startElm, endElm).fold(
Fun.constant(Result.error('Failed to get the subsection')),
Result.value
);
});
示例8: function
const paddEmptyBlock = function (elm) {
if (Empty.isEmpty(elm)) {
const br = Element.fromHtml('<br data-mce-bogus="1">');
Remove.empty(elm);
Insert.append(elm, br);
return Option.some(CaretPosition.before(br.dom()));
} else {
return Option.none();
}
};
示例9:
return Chain.mapper(function () {
const elm = Element.fromHtml(html);
const sc = Hierarchy.follow(elm, startPath).getOrDie();
const ec = Hierarchy.follow(elm, endPath).getOrDie();
const rng = document.createRange();
rng.setStart(sc.dom(), startOffset);
rng.setEnd(ec.dom(), endOffset);
return TableDeleteAction.getActionFromRange(elm, rng);
});
示例10: createLocation
return Step.sync(function () {
const elm = Element.fromHtml('<div>' + html + '</div>');
const location = createLocation(elm, elementPath, offset);
const caret = Cell(null);
Assertions.assertEq('Should be a valid location: ' + html, true, location.isSome());
const pos = BoundaryCaret.renderCaret(caret, location.getOrDie()).getOrDie();
Assertions.assertHtml('Should be equal html', expectedHtml, elm.dom().innerHTML);
const container = Hierarchy.follow(elm, expectedPath);
Assertions.assertDomEq('Should be equal nodes', container.getOrDie(), Element.fromDom(pos.container()));
});