Page Menu
Home
Musing Studio
Search
Configure Global Search
Log In
Files
F10493214
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
2 KB
Subscribers
None
View Options
diff --git a/prose/prose.js b/prose/prose.js
index 3bd5b10..6f1d744 100644
--- a/prose/prose.js
+++ b/prose/prose.js
@@ -1,51 +1,52 @@
// class MarkdownView {
// constructor(target, content) {
// this.textarea = target.appendChild(document.createElement("textarea"))
// this.textarea.value = content
// }
// get content() { return this.textarea.value }
// focus() { this.textarea.focus() }
// destroy() { this.textarea.remove() }
// }
import {EditorView} from "prosemirror-view"
import {EditorState} from "prosemirror-state"
import {schema, defaultMarkdownParser, defaultMarkdownSerializer} from "prosemirror-markdown"
import {exampleSetup} from "prosemirror-example-setup"
class ProseMirrorView {
- constructor(target, content) {
- this.view = new EditorView(target, {
- state: EditorState.create({
- doc: defaultMarkdownParser.parse(content),
- plugins: exampleSetup({schema})
- }), dispatchTransaction(transaction) {
- document.querySelector('#content').value = defaultMarkdownSerializer.serialize(transaction.doc)
- let newState = this.state.apply(transaction)
- this.updateState(newState)
- }
- })
- }
+ constructor(target, content) {
+ this.view = new EditorView(target, {
+ state: EditorState.create({
+ doc: defaultMarkdownParser.parse(content),
+ plugins: exampleSetup({schema})
+ }),
+ dispatchTransaction(transaction) {
+ document.querySelector('#content').value = defaultMarkdownSerializer.serialize(transaction.doc)
+ let newState = this.state.apply(transaction)
+ this.updateState(newState)
+ }
+ })
+ }
- get content() {
- return defaultMarkdownSerializer.serialize(this.view.state.doc)
- }
- focus() { this.view.focus() }
- destroy() { this.view.destroy() }
+ get content() {
+ return defaultMarkdownSerializer.serialize(this.view.state.doc)
+ }
+ focus() { this.view.focus() }
+ destroy() { this.view.destroy() }
}
let place = document.querySelector("#editor")
let view = new ProseMirrorView(place, document.querySelector('#content').value)
// document.querySelectorAll("input[type=radio]").forEach(button => {
// button.addEventListener("change", () => {
// if (!button.checked) return
// let View = button.value == "markdown" ? MarkdownView : ProseMirrorView
// if (view instanceof View) return
// let content = view.content
// view.destroy()
// view = new View(place, content)
// view.focus()
// })
// })
File Metadata
Details
Attached
Mime Type
text/x-diff
Expires
Wed, Mar 5, 8:04 PM (18 h, 35 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
3167713
Attached To
rWF WriteFreely
Event Timeline
Log In to Comment