Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
static create(parent, node, outerDeco, innerDeco, view, pos) {
let custom = view.nodeViews[node.type.name], descObj
let spec = custom && custom(node, view, () => {
// (This is a function that allows the custom view to find its
// own position)
if (!descObj) return pos
if (descObj.parent) return descObj.parent.posBeforeChild(descObj)
}, outerDeco)
let dom = spec && spec.dom, contentDOM = spec && spec.contentDOM
if (node.isText) {
if (!dom) dom = document.createTextNode(node.text)
else if (dom.nodeType != 3) throw new RangeError("Text must be rendered as a DOM text node")
} else if (!dom) {
;({dom, contentDOM} = DOMSerializer.renderSpec(document, node.type.spec.toDOM(node)))
}
if (!contentDOM && !node.isText && dom.nodeName != "BR") { // Chrome gets confused by <br>
if (!dom.hasAttribute("contenteditable")) dom.contentEditable = false
if (node.type.spec.draggable) dom.draggable = true
}
let nodeDOM = dom
dom = applyOuterDeco(dom, outerDeco, node)
if (spec)
return descObj = new CustomNodeViewDesc(parent, node, outerDeco, innerDeco, dom, contentDOM, nodeDOM,
spec, view, pos + 1)
else if (node.isText)
return new TextViewDesc(parent, node, outerDeco, innerDeco, dom, nodeDOM, view)
else
return new NodeViewDesc(parent, node, outerDeco, innerDeco, dom, contentDOM, nodeDOM, view, pos + 1)
static create(parent, mark, inline, view) {
let custom = view.nodeViews[mark.type.name]
let spec = custom && custom(mark, view, inline)
if (!spec || !spec.dom)
spec = DOMSerializer.renderSpec(document, mark.type.spec.toDOM(mark, inline))
return new MarkViewDesc(parent, mark, spec.dom, spec.contentDOM || spec.dom)
}
static create(parent, node, outerDeco, innerDeco, view) {
let custom = customNodeViews(view)[node.type.name], viewObj
let spec = custom && custom(node, view, () => {
if (!viewObj) return parent.posAtStart + parent.size
if (viewObj.parent) return viewObj.parent.posBeforeChild(viewObj)
})
let dom = spec && spec.dom, contentDOM
if (!dom) ({dom, contentDOM} = DOMSerializer.renderSpec(document, node.type.spec.toDOM(node)))
for (let i = 0; i < outerDeco.length; i++)
dom = applyOuterDeco(dom, outerDeco[i].type.attrs, node)
if (spec)
return viewObj = new CustomNodeView(parent, node, outerDeco, innerDeco, dom, contentDOM, spec, view)
else
return new NodeView(parent, node, outerDeco, innerDeco, dom, contentDOM, view)
}
static create(parent, mark, view) {
let custom = customNodeViews(view)[mark.type.name]
let spec = custom && custom(mark, view)
let dom = spec && spec.dom || DOMSerializer.renderSpec(document, mark.type.spec.toDOM(mark)).dom
return new MarkView(parent, mark, dom)
}