Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
function flatten(schema, children, f) {
let result = [], pos = 0, tag = noTag
for (let i = 0; i < children.length; i++) {
let child = children[i]
if (child.tag && child.tag != Node.prototype.tag) {
if (tag == noTag) tag = Object.create(null)
for (let id in child.tag)
tag[id] = child.tag[id] + (child.flat || child.isText ? 0 : 1) + pos
}
if (typeof child == "string") {
let re = /<(\w+)>/g, m, at = 0, out = ""
while (m = re.exec(child)) {
out += child.slice(at, m.index)
pos += m.index - at
at = m.index + m[0].length
if (tag == noTag) tag = Object.create(null)
tag[m[1]] = pos
}
out += child.slice(at)
pos += child.length - at
import {Node} from "prosemirror-model"
const noTag = Node.prototype.tag = Object.create(null)
function flatten(schema, children, f) {
let result = [], pos = 0, tag = noTag
for (let i = 0; i < children.length; i++) {
let child = children[i]
if (child.tag && child.tag != Node.prototype.tag) {
if (tag == noTag) tag = Object.create(null)
for (let id in child.tag)
tag[id] = child.tag[id] + (child.flat || child.isText ? 0 : 1) + pos
}
if (typeof child == "string") {
let re = /<(\w+)>/g, m, at = 0, out = ""
while (m = re.exec(child)) {
out += child.slice(at, m.index)