本文整理汇总了TypeScript中@ephox/dom-globals.document.createTextNode方法的典型用法代码示例。如果您正苦于以下问题:TypeScript document.createTextNode方法的具体用法?TypeScript document.createTextNode怎么用?TypeScript document.createTextNode使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类@ephox/dom-globals.document
的用法示例。
在下文中一共展示了document.createTextNode方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: function
suite.test('isCaretContainerInline', function () {
LegacyUnit.equal(CaretContainer.isCaretContainerInline(document.createTextNode('text')), false);
LegacyUnit.equal(CaretContainer.isCaretContainerInline(DomQuery('<span></span>')[0]), false);
LegacyUnit.equal(CaretContainer.isCaretContainerInline(DomQuery('<span data-mce-caret="1"></span>')[0]), false);
LegacyUnit.equal(CaretContainer.isCaretContainerInline(DomQuery('<span data-mce-caret="1">a</span>')[0].firstChild), false);
LegacyUnit.equal(CaretContainer.isCaretContainerInline(document.createTextNode(Zwsp.ZWSP)), true);
});
示例2: function
suite.test('create text index on fragmented text nodes', function () {
setupHtml('a');
getRoot().appendChild(document.createTextNode('b'));
getRoot().appendChild(document.createTextNode('c'));
getRoot().appendChild(document.createElement('b'));
getRoot().appendChild(document.createTextNode('d'));
getRoot().appendChild(document.createTextNode('e'));
LegacyUnit.equal(getRoot().childNodes.length, 6);
LegacyUnit.equal(CaretBookmark.create(getRoot(), createTextPos(getRoot().childNodes[0], 0)), 'text()[0],0');
LegacyUnit.equal(CaretBookmark.create(getRoot(), createTextPos(getRoot().childNodes[1], 0)), 'text()[0],1');
LegacyUnit.equal(CaretBookmark.create(getRoot(), createTextPos(getRoot().childNodes[2], 0)), 'text()[0],2');
LegacyUnit.equal(CaretBookmark.create(getRoot(), createTextPos(getRoot().childNodes[4], 0)), 'text()[1],0');
LegacyUnit.equal(CaretBookmark.create(getRoot(), createTextPos(getRoot().childNodes[5], 0)), 'text()[1],1');
});
示例3: function
suite.test('isBogusAll', function () {
LegacyUnit.strictEqual(NodeType.isBogusAll($('<div data-mce-bogus="1"></div>')[0]), false);
LegacyUnit.strictEqual(NodeType.isBogusAll($('<div data-mce-bogus="all"></div>')[0]), true);
LegacyUnit.strictEqual(NodeType.isBogusAll($('<div></div>')[0]), false);
LegacyUnit.strictEqual(NodeType.isBogusAll(document.createTextNode('test')), false);
LegacyUnit.strictEqual(NodeType.isBogusAll(null), false);
});
示例4: function
suite.test('isCaretCandidate', function () {
$.each('img input textarea hr table iframe video audio object'.split(' '), function (index, name) {
LegacyUnit.equal(CaretCandidate.isCaretCandidate(document.createElement(name)), true);
});
LegacyUnit.equal(CaretCandidate.isCaretCandidate(document.createTextNode('text')), true);
LegacyUnit.equal(CaretCandidate.isCaretCandidate($('<span contentEditable="false"></span>')[0]), true);
LegacyUnit.equal(CaretCandidate.isCaretCandidate($('<span contentEditable="false" unselectable="true"></span>')[0]), false);
LegacyUnit.equal(CaretCandidate.isCaretCandidate($('<div contentEditable="false"></div>')[0]), true);
LegacyUnit.equal(CaretCandidate.isCaretCandidate($('<table><tr><td>X</td></tr></table>')[0]), true);
LegacyUnit.equal(CaretCandidate.isCaretCandidate($('<span contentEditable="true"></span>')[0]), false);
LegacyUnit.equal(CaretCandidate.isCaretCandidate($('<span></span>')[0]), false);
LegacyUnit.equal(CaretCandidate.isCaretCandidate(document.createComment('text')), false);
LegacyUnit.equal(CaretCandidate.isCaretCandidate($('<span data-mce-caret="1"></span>')[0]), false);
LegacyUnit.equal(CaretCandidate.isCaretCandidate(document.createTextNode(Zwsp.ZWSP)), false);
});
示例5: function
const createRng = function (text, startOffset, endOffset) {
const textNode = document.createTextNode(text);
const rng = document.createRange();
rng.setStart(textNode, startOffset);
rng.setEnd(textNode, endOffset);
return rng;
};