Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
iterDeco(this.node, this.innerDeco, (widget, i, insideNode) => {
if (widget.spec.marks)
updater.syncToMarks(widget.spec.marks, inline, view)
else if (widget.type.side >= 0 && !insideNode)
updater.syncToMarks(i == this.node.childCount ? Mark.none : this.node.child(i).marks, inline, view)
// If the next node is a desc matching this widget, reuse it,
// otherwise insert the widget as a new view desc.
updater.placeWidget(widget, view, off)
}, (child, outerDeco, innerDeco, i) => {
// Make sure the wrapping mark descs match the node's marks.
replaceSelectionWith(node, inheritMarks) {
let selection = this.selection
if (inheritMarks !== false)
node = node.mark(this.storedMarks || (selection.empty ? selection.$from.marks() : (selection.$from.marksAcross(selection.$to) || Mark.none)))
selection.replaceWith(this, node)
return this
}
closeNode() {
if (this.marks.length) this.marks = Mark.none
const info = this.stack.pop()
if (!info) return //devWarn("Attempted to close a non-existent node.")
return this.addNode(info.type, info.attrs, info.content)
}
}
import unified from 'unified';
import remarkToMarkdown from 'remark-parse';
import { Mark } from 'prosemirror-model';
import markdownToProseMirror from './markdownToProseMirror';
const state = { activeMarks: Mark.none, textsArray: [] };
/**
* Uses unified to parse markdown and apply plugins.
* @param {string} src raw markdown
* @returns {Node} a ProseMirror Node
*/
function parser(src) {
const result = unified()
.use(remarkToMarkdown, { fences: true, footnotes: true, pedantic: true })
.parse(src);
return unified()
.use(markdownToProseMirror, { state })
.runSync(result);
}
constructor(schema, tokenHandlers) {
this.schema = schema
this.stack = [{type: schema.topNodeType, content: []}]
this.marks = Mark.none
this.tokenHandlers = tokenHandlers
}