本文整理汇总了TypeScript中wed/editor.Editor.save方法的典型用法代码示例。如果您正苦于以下问题:TypeScript Editor.save方法的具体用法?TypeScript Editor.save怎么用?TypeScript Editor.save使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类wed/editor.Editor
的用法示例。
在下文中一共展示了Editor.save方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: Error
"that did nothing", (done) => {
// tslint:disable-next-line:no-floating-promises
editor.save().then(() => {
// We're testing that autosave is not called again after the first
// time.
let autosaved = false;
const interval = 50;
const sub = editor.saver.events
.pipe(filter((x) => x.name === "Autosaved"))
.subscribe(() => {
if (autosaved) {
throw new Error("autosaved more than once");
}
autosaved = true;
assert.deepEqual(server.lastSaveRequest, {
command: "autosave",
version: version,
data: "<TEI xmlns=\"http://www.tei-c.org/ns/1.0\">\
<teiHeader><fileDesc><titleStmt><title>abcd</title></titleStmt>\
<publicationStmt/><sourceDesc><p/></sourceDesc>\
</fileDesc></teiHeader><text><body><p>Blah blah <term>blah</term> blah.</p>\
<p><term>blah</term></p></body></text></TEI>",
});
setTimeout(() => {
sub.unsubscribe();
done();
}, interval * 2);
});
editor.saver.setAutosaveInterval(interval);
setTimeout(() => {
assert.isFalse(autosaved, "should not have been saved yet");
editor.dataUpdater.removeNode(editor.dataRoot.querySelector("p"));
}, interval * 2);
});
});
示例2: it
it("does not autosave if not modified", (done) => {
// tslint:disable-next-line:no-floating-promises
editor.save().then(() => {
const sub = editor.saver.events
.pipe(filter((ev) => ev.name === "Autosaved")).subscribe(() => {
throw new Error("autosaved!");
});
editor.saver.setAutosaveInterval(50);
setTimeout(() => {
sub.unsubscribe();
done();
}, 500);
});
});