本文整理匯總了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) });
}