本文整理汇总了TypeScript中prosemirror-state.EditorState类的典型用法代码示例。如果您正苦于以下问题:TypeScript EditorState类的具体用法?TypeScript EditorState怎么用?TypeScript EditorState使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了EditorState类的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: createState
export function createState(schema: Schema, nodeOrJson: Node | any, plugins?: Plugin[]) {
return EditorState.create({
schema,
doc: nodeOrJson instanceof Node ? nodeOrJson : Node.fromJSON(schema, nodeOrJson.doc),
plugins,
})
}
示例2: save
public save(state: EditorState) {
try {
localStorage.setItem("basic-editor-state", JSON.stringify(state.toJSON()))
} catch (e) {
console.error("Document too large to save or contains errors")
console.error(e)
}
}
示例3: update
update(content: string, images?: ProseMirrorImage[]) {
if (content !== this.content || images) {
this.content = content;
this.images = images || this.images;
let state = EditorState.create(this.stateConfig());
this.view.update(this.viewProps(state));
}
}
示例4: constructor
constructor(private el: ElementRef,
private content: string,
private inputFormat: string,
private outputFormat: string,
private editable: boolean,
private images: ProseMirrorImage[],
private setModel: Function,
private promptForLink: Function) {
this.outputSchema = this.outputFormat === ProseMirrorFormatTypes.HTML ? basicSchema : markdownSchema;
let state = EditorState.create(this.stateConfig());
this.view = new MenuBarEditorView(el.nativeElement, this.viewProps(state));
if (this.inputFormat === ProseMirrorFormatTypes.MARKDOWN && this.outputFormat === ProseMirrorFormatTypes.HTML) {
this.plainTextWithLinks();
this.content = this.removeHTML(this.view.editor.docView.dom.innerHTML);
} else if (this.inputFormat === this.outputFormat) {
if (this.outputFormat === ProseMirrorFormatTypes.MARKDOWN) {
this.content = defaultMarkdownSerializer.serialize(this.view.editor.state.doc);
} else {
this.content = this.removeHTML(this.view.editor.docView.dom.innerHTML);
}
}
}
示例5: createState
function createState(d: pm.TaggedProsemirrorNode) {
return EditorState.create({ doc: d, selection: selectionFor(d) });
}