mirror of
https://github.com/BookStackApp/BookStack.git
synced 2025-07-21 09:22:09 +03:00
Added source code view/set button
This commit is contained in:
@ -2,11 +2,12 @@ import {EditorState} from "prosemirror-state";
|
||||
import {EditorView} from "prosemirror-view";
|
||||
import {exampleSetup} from "prosemirror-example-setup";
|
||||
|
||||
import {DOMParser, DOMSerializer} from "prosemirror-model";
|
||||
import {DOMParser} from "prosemirror-model";
|
||||
|
||||
import schema from "./schema";
|
||||
import menu from "./menu";
|
||||
import nodeViews from "./node-views";
|
||||
import {stateToHtml} from "./util";
|
||||
|
||||
class ProseMirrorView {
|
||||
constructor(target, content) {
|
||||
@ -28,13 +29,16 @@ class ProseMirrorView {
|
||||
}
|
||||
|
||||
get content() {
|
||||
const fragment = DOMSerializer.fromSchema(schema).serializeFragment(this.view.state.doc.content);
|
||||
const renderDoc = document.implementation.createHTMLDocument();
|
||||
renderDoc.body.appendChild(fragment);
|
||||
return renderDoc.body.innerHTML;
|
||||
return stateToHtml(this.view.state);
|
||||
}
|
||||
|
||||
focus() {
|
||||
this.view.focus()
|
||||
}
|
||||
|
||||
destroy() {
|
||||
this.view.destroy()
|
||||
}
|
||||
focus() { this.view.focus() }
|
||||
destroy() { this.view.destroy() }
|
||||
}
|
||||
|
||||
export default ProseMirrorView;
|
Reference in New Issue
Block a user