本文整理汇总了TypeScript中wed/editor.Editor类的典型用法代码示例。如果您正苦于以下问题:TypeScript Editor类的具体用法?TypeScript Editor怎么用?TypeScript Editor使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Editor类的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: it
it("undoing an attribute value change undoes the value change", () => {
let initial = getAttributeValuesFor(ps[7])[0].firstChild as Text;
caretManager.setCaret(initial, 4);
assert.equal(initial.data, "rend_value", "initial value");
editor.type("blah");
// We have to refetch because the decorations have been redone.
initial = getAttributeValuesFor(ps[7])[0].firstChild as Text;
assert.equal(initial.data, "rendblah_value");
caretCheck(editor, initial, 8, "caret after text insertion");
// Check that the data is also modified
const dataNode = editor.toDataNode(initial) as Attr;
assert.equal(dataNode.value, "rendblah_value");
editor.undo();
// We have to refetch because the decorations have been redone.
initial = getAttributeValuesFor(ps[7])[0].firstChild as Text;
assert.equal(initial.data, "rend_value");
caretCheck(editor, initial, 4, "caret after undo");
// Check that the data change has been undone.
assert.equal(dataNode.value, "rend_value", "value undone");
});
示例2: waitForSuccess
it("changing label visibility level", async () => {
// Changing label visibility does not merely refresh the errors but
// recreates them because errors that were visible may become invisible or
// errors that were invisible may become visible.
await processRunner.onCompleted();
// tslint:disable-next-line:no-any
const errorLayer = (editor as any).errorLayer.el as Element;
let orig = _slice.call(errorLayer.children);
// Reduce the visibility level.
editor.type(keyConstants.LOWER_LABEL_VISIBILITY);
let after;
await waitForSuccess(() => {
after = _slice.call(errorLayer.children);
assertNewMarkers(orig, after, "decreasing the level");
});
orig = after;
// Increase visibility level
editor.type(keyConstants.INCREASE_LABEL_VISIBILITY);
await waitForSuccess(() => {
assertNewMarkers(orig, _slice.call(errorLayer.children),
"increasing the level");
});
});
示例3: it
it("doing an attribute deletion changes the data", () => {
const p = ps[7];
const dataP = editor.toDataNode(p) as Element;
const attrNames = getAttributeNamesFor(p);
let attrValues = getAttributeValuesFor(p);
const initialLength = attrValues.length;
assert.isTrue(initialLength > 0, "the paragraph should have attributes");
const attr = editor.toDataNode(attrValues[0]) as Attr;
const decodedName = attrNames[0].textContent!;
const trs = editor.modeTree.getMode(attr).getContextualActions(
["delete-attribute"], decodedName, attr);
caretManager.setCaret(attr, 0);
caretCheck(editor, attrValues[0].firstChild!, 0,
"the caret should be in the attribute");
trs[0].execute({ node: attr, name: decodedName });
attrValues = getAttributeValuesFor(p);
assert.equal(attrValues.length, initialLength - 1,
"one attribute should be gone");
caretCheck(editor, attrValues[0].firstChild!, 0,
"the caret should be in the first attribute value");
assert.isNull(attr.ownerElement,
"the old attribute should not have an onwer element");
assert.isNull(dataP.getAttribute(attr.name));
});
示例4: it
it("searches forward", () => {
editor.type(QUICKSEARCH_FORWARD);
editor.type("abc", WedEventTarget.MINIBUFFER);
checkHighlightRanges(firstABCText);
editor.type(QUICKSEARCH_FORWARD, WedEventTarget.MINIBUFFER);
checkHighlightRanges(pFiveFirstThree);
editor.type(ESCAPE, WedEventTarget.MINIBUFFER);
});
示例5: waitForSuccess
it("modification status shows an unmodified document after save", () => {
// Text node inside title.
const initial = titles[0].childNodes[1];
caretManager.setCaret(initial, 0);
editor.type(" ");
assert.isTrue($modificationStatus.hasClass("label-warning"));
editor.type(keyConstants.SAVE);
return waitForSuccess(() => {
assert.isTrue($modificationStatus.hasClass("label-success"));
});
});
示例6: it
it("that takes completions", () => {
const p = ps[9];
const attrVals = getAttributeValuesFor(p);
caretManager.setCaret(attrVals[0].firstChild, 0);
contextMenuHasOption(editor, /^Y$/);
editor.type("Y");
// The context menu should be gone.
const menu = editor.window.document.
getElementsByClassName("wed-context-menu")[0];
assert.isUndefined(menu, "the menu should not exist");
editor.type(keyConstants.REPLACEMENT_MENU);
contextMenuHasOption(editor, /^Y$/);
});
示例7: getAttributeValuesFor
"attribute is not visible", () => {
// Reduce visibility to 0 so that no attribute is visible.
editor.setLabelVisibilityLevel(0);
const attrVals = getAttributeValuesFor(ps[9]);
caretManager.setCaret(attrVals[0].firstChild, 0);
let menu = editor.window.document.
getElementsByClassName("wed-context-menu")[0];
assert.isUndefined(menu, "the menu should not exist");
// The menu won't come up with a the shortcut.
editor.type(keyConstants.REPLACEMENT_MENU);
menu = editor.window.document.
getElementsByClassName("wed-context-menu")[0];
assert.isUndefined(menu, "the menu should not exist");
});
示例8: it
it("typing multiple spaces in an attribute normalizes the space", () => {
// Text node inside title.
let initial = getAttributeValuesFor(ps[7])[0].firstChild as Text;
caretManager.setCaret(initial, 0);
assert.equal(initial.data, "rend_value");
editor.type(" ");
// We have to refetch because the decorations have been redone.
initial = getAttributeValuesFor(ps[7])[0].firstChild as Text;
assert.equal(initial.data, " rend_value");
caretCheck(editor, initial, 1, "caret after text insertion");
// Check that the data is also modified
const dataNode = editor.toDataNode(initial) as Attr;
assert.equal(dataNode.value, " rend_value");
editor.type(" ");
// We have to refetch because the decorations have been redone.
initial = getAttributeValuesFor(ps[7])[0].firstChild as Text;
assert.equal(initial.data, " rend_value");
caretCheck(editor, initial, 1, "caret after text insertion");
// Check that the data is also modified
assert.equal(dataNode.value, " rend_value");
caretManager.setCaret(initial, 11);
editor.type(" ");
// We have to refetch because the decorations have been redone.
initial = getAttributeValuesFor(ps[7])[0].firstChild as Text;
assert.equal(initial.data, " rend_value ");
caretCheck(editor, initial, 12, "caret after text insertion");
// Check that the data is also modified
assert.equal(dataNode.value, " rend_value ");
editor.type(" ");
// We have to refetch because the decorations have been redone.
initial = getAttributeValuesFor(ps[7])[0].firstChild as Text;
assert.equal(initial.data, " rend_value ");
caretCheck(editor, initial, 12, "caret after text insertion");
// Check that the data is also modified
assert.equal(dataNode.value, " rend_value ");
});
示例9: it
it("searches forward", () => {
editor.type(SEARCH_FORWARD);
typeInSearch("abc");
checkHighlightRanges(firstABCText);
clickFind();
checkHighlightRanges(pFiveFirstThree);
});