本文整理汇总了TypeScript中@ephox/sugar.Element.fromText方法的典型用法代码示例。如果您正苦于以下问题:TypeScript Element.fromText方法的具体用法?TypeScript Element.fromText怎么用?TypeScript Element.fromText使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类@ephox/sugar.Element
的用法示例。
在下文中一共展示了Element.fromText方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: function
const appendStyle = function (editor: Editor, text: string) {
const head = Element.fromDom(editor.getDoc().head);
const tag = Element.fromTag('style');
Attr.set(tag, 'type', 'text/css');
Insert.append(tag, Element.fromText(text));
Insert.append(head, tag);
};
示例2:
table.filter(Fun.not(isRoot)).each(function (table) {
const cursor = Element.fromText('');
Insert.after(table, cursor);
Remove.remove(table);
const rng = editor.dom.createRng();
rng.setStart(cursor.dom(), 0);
rng.setEnd(cursor.dom(), 0);
editor.selection.setRng(rng);
});
示例3: getElementFromPosition
return getElementFromPosition(pos).map((elm) => {
const textNode = Element.fromText(text);
if (pos.isAtEnd()) {
Insert.after(elm, textNode);
} else {
Insert.before(elm, textNode);
}
return CaretPosition(textNode.dom(), text.length);
});
示例4: function
Logger.sync('getInfo ... ' + scenario.label, function () {
editorState.start.set(Element.fromText(scenario.nodeText).dom());
editorState.content.set(scenario.selection);
const info = LinkBridge.getInfo(editor);
RawAssertions.assertEq('Checking getInfo (no link)', {
url: '',
text: scenario.expected,
title: '',
target: ''
}, Objects.narrow(info, [ 'url', 'text', 'target', 'title' ]));
RawAssertions.assertEq('Checking link is not set', true, info.link.isNone());
});
示例5: function
const createCaretContainer = function (fill) {
const caretContainer = Element.fromTag('span');
Attr.setAll(caretContainer, {
// style: 'color:red',
'id': CARET_ID,
'data-mce-bogus': '1',
'data-mce-type': 'format-caret'
});
if (fill) {
Insert.append(caretContainer, Element.fromText(ZWSP));
}
return caretContainer;
};
示例6:
tableOpt.filter(Fun.not(isRoot)).each((table) => {
const cursor = Element.fromText('');
Insert.after(table, cursor);
Remove.remove(table);
if (editor.dom.isEmpty(editor.getBody())) {
editor.setContent('');
editor.selection.setCursorLocation();
} else {
const rng = editor.dom.createRng();
rng.setStart(cursor.dom(), 0);
rng.setEnd(cursor.dom(), 0);
editor.selection.setRng(rng);
editor.nodeChanged();
}
});
示例7: function
const sTestScenario = function (rawScenario) {
const scenario = ValueSchema.asRawOrDie('Checking scenario', ValueSchema.objOf([
FieldSchema.strict('label'),
FieldSchema.defaulted('content', ''),
FieldSchema.defaulted('node', Element.fromText('')),
FieldSchema.strictObjOf('fields', [
FieldSchema.option('url'),
FieldSchema.option('text'),
FieldSchema.option('title'),
FieldSchema.option('target')
]),
FieldSchema.strict('expected'),
FieldSchema.defaulted('beforeExecute', Step.pass),
FieldSchema.defaulted('mutations', Fun.constant(Step.pass))
]), rawScenario);
return Logger.t(
scenario.label,
GeneralSteps.sequence([
tEditor.sPrepareState(scenario.node.dom(), scenario.content),
sClickLink,
TestUi.sSetFieldOptValue(scenario.fields.url),
sClickNext,
sAssertTextFocused,
TestUi.sSetFieldOptValue(scenario.fields.text),
sClickNext,
sAssertTitleFocused,
TestUi.sSetFieldOptValue(scenario.fields.title),
sClickNext,
sAssertTargetFocused,
TestUi.sSetFieldOptValue(scenario.fields.target),
sClickPrev,
sAssertTitleFocused,
sClickPrev,
sAssertTextFocused,
sClickPrev,
sAssertUrlFocused,
scenario.beforeExecute,
Keyboard.sKeydown(doc, Keys.enter(), { }),
tEditor.sAssertEq('Checking insert content', scenario.expected),
scenario.mutations(scenario.node),
tEditor.sClear
])
);
};
示例8: predicate
return Step.sync(function () {
Assertions.assertEq('Should be false for non element', false, predicate(Element.fromText('text')));
});