{"version":3,"sources":["webpack:///./node_modules/prosemirror-transform/dist/index.es.js","webpack:///./node_modules/prosemirror-state/dist/index.es.js","webpack:///./node_modules/prosemirror-tables/dist/index.es.js"],"names":["lower16","factor16","Math","pow","makeRecover","index","offset","recoverIndex","value","recoverOffset","MapResult","pos","deleted","recover","this","StepMap","ranges","inverted","prototype","diff","i","mapResult","assoc","_map","map","simple","oldIndex","newIndex","length","start","oldSize","newSize","end","side","result","touches","forEach","f","oldStart","newStart","invert","toString","JSON","stringify","n","empty","Mapping","maps","mirror","from","to","TransformError","message","err","Error","call","__proto__","slice","copy","appendMap","mirrors","push","setMirror","appendMapping","mapping","startSize","mirr","getMirror","m","appendMappingInverted","totalSize","inverse","corr","Object","create","constructor","name","Transform","doc","steps","docs","prototypeAccessors","before","configurable","docChanged","mustOverride","get","step","object","maybeStep","failed","apply","addStep","getMap","defineProperties","stepsByID","Step","_doc","_mapping","merge","_other","toJSON","fromJSON","schema","json","stepType","RangeError","type","jsonID","id","stepClass","StepResult","ok","fail","fromReplace","replace","e","ReplaceStep","structure","contentBetween","size","max","other","openEnd","openStart","slice$1","content","append","ReplaceAroundStep","gapFrom","gapTo","insert","gap","inserted","insertAt","removeBetween","$from","resolve","dist","depth","indexAfter","node","childCount","next","maybeChild","isLeaf","firstChild","canCut","canReplace","liftTarget","range","parent","cutByIndex","startIndex","endIndex","$to","spec","isolating","findWrapping","nodeType","attrs","innerRange","around","findWrappingOutside","inner","findWrappingInside","withAttrs","concat","contentMatchAt","outer","canReplaceWith","child","inside","contentMatch","lastType","innerMatch","matchType","validEnd","canChangeType","$pos","canSplit","typesAfter","base","innerType","validContent","d","index$1","rest","after","replaceChild","baseType","canJoin","joinable","nodeBefore","nodeAfter","a","b","canAppend","joinPoint","dir","isTextblock","insertPoint","parentOffset","d$1","dropPoint","pass","bias","insertPos","fits","wrapping","mapFragment","fragment","mapped","isInline","fromArray","lift","target","gapStart","gapEnd","splitting","splitting$1","wrap","wrappers","setBlockType","this$1","mapFrom","nodesBetween","hasMarkup","clearIncompatible","startM","endM","nodeSize","marks","setNodeMarkup","nodeAt","newNode","replaceWith","split","typeAfter","join","AddMarkStep","mark","oldSlice","sharedDepth","isAtom","allowsMarkType","addToSet","RemoveMarkStep","eq","min","markFromJSON","removeFromSet","replaceStep","fitsTrivially","Fitter","fit","addMark","removed","added","removing","adding","isInSet","newSet","s","removeMark","matched","toRemove","found","set","style","found$1","j","parentType","match","delSteps","cur","allowed","fill","fillBefore","i$1","delete","unplaced","frontier","placed","prototypeAccessors$1","dropFromFragment","count","addToFragment","lastChild","contentAt","closeNodeStart","frag","matchFragment","contentAfterFits","open","compatibleContent","invalidMarks","allowsMarks","closeFragment","oldOpen","newOpen","first","coveredDepths","minDepth","inlineContent","findFittable","placeNodes","openMore","dropNode","moveInline","mustMoveInline","placedSize","close","sliceDepth","frontierDepth","ref","inject","openAtEnd","closeFrontierNode","openFrontierNode","taken","add","ref$1","openEndCount","matches","allowedMarks","toEnd","i$2","level","top","findCloseLevel","scan","dropInner","match$1","type$1","move","pop","replaceRange","deleteRange","targetDepths","preferredTarget","unshift","defining","indexOf","splice","preferredTargetIndex","leftNodes","preferredDepth","openDepth","targetDepth","expand","startSteps","replaceRangeWith","point","covered","last","classesById","Selection","$anchor","$head","SelectionRange","anchor","head","tr","lastNode","lastParent","selectionToInsertionEnd","findFrom","textOnly","TextSelection","findSelectionIn","near","AllSelection","atStart","atEnd","cls","selectionClass","getBookmark","between","visible","$cursor","marksAcross","ensureMarks","TextBookmark","dPos","NodeSelection","$end","NodeBookmark","isSelectable","isText","selectable","sel","selection","setSelection","AllBookmark","text","startLen","_from","_to","_newFrom","newTo","UPDATED_SEL","UPDATED_MARKS","UPDATED_SCROLL","Transaction","state","time","Date","now","curSelection","curSelectionFor","storedMarks","updated","meta","selectionSet","storedMarksSet","isGeneric","scrolledIntoView","setStoredMarks","sameSet","addStoredMark","removeStoredMark","setTime","replaceSelection","replaceSelectionWith","inheritMarks","none","deleteSelection","insertText","setMeta","key","getMeta","_","scrollIntoView","bind","self","FieldDesc","desc","init","baseFields","config","topNodeType","createAndFill","instance","_marks","_old","prev","Configuration","plugins","fields","pluginsByKey","plugin","EditorState","applyTransaction","filterTransaction","ignore","rootTr","transactions","trs","newState","applyInner","seen","haveNew","appendTransaction","oldState","newInstance","field","applyListeners","$config","reconfigure","hasOwnProperty","pluginFields","prop","addApplyListener","removeApplyListener","bindProps","obj","val","Function","Plugin","props","createKey","getState","keys","PluginKey","readFromCache","addToCache","WeakMap","cache","cache$1","cacheSize","cachePos","Rect","left","right","bottom","TableMap","width","height","problems","computeMap","table","tableRole","findWidth","mapPos","colWidths","row","rowNode","cellNode","colspan","rowspan","colwidth","h","w","colW","widthIndex","expectedPos","missing","tableMap","badWidths","findBadColWidths","hasRowSpan","rowWidth","prevRow","cell","cell$1","col","colWidth","freshColWidth","getCellAttrs","dom","extraAttrs","widthAttr","getAttribute","widths","test","Number","getter","getFromDOM","setCellAttrs","setter","setDOMAttr","tableNodes","options","cellAttributes","cellAttrs","default","group","tableGroup","parseDOM","tag","toDOM","table_row","table_cell","cellContent","getAttrs","table_header","tableNodeTypes","cached","nodes","role","findCell","curPos","j$1","colCount","nextCell","axis","rectBetween","leftA","rightA","topA","bottomA","leftB","rightB","topB","bottomB","cellsInRect","rect","positionAt","rowStart","rowEnd","rowEndIndex","cellAround","cellWrapping","isInTable","selectionCell","$anchorCell","$headCell","cellNear","pos$1","role$1","pointsAtCell","moveCellForward","inSameTable","$a","$b","moved","setAttr","removeColSpan","some","addColSpan","columnIsHeader","headerCell","header_cell","CellSelection","cells","filter","p","tableChanged","isRowSelection","rowSelection","isColSelection","colSelection","rows","rowContent","cellRect","extraLeft","extraRight","attrs$1","forEachCell","anchorTop","headTop","anchorBot","headBot","anchorRect","headRect","anchorLeft","headLeft","anchorRight","headRight","anchorCell","headCell","CellBookmark","drawCellSelection","class","isCellBoundarySelection","afterFrom","beforeTo","isTextSelectionAcrossCells","fromCellBoundaryNode","toCellBoundaryNode","node$1","normalizeSelection","allowTableNodeSelection","normalize","$cell","lastCell","pastedCells","fitSlice","ensureRectangular","r","r$1","r$2","clipCells","newWidth","newHeight","newRows","newRows$1","row$1","cells$1","source","growTable","emptyHead","types","start$1","header","emptyRow","isolateHorizontal","cellTop","cellLeft","isolateVertical","updatePos","insertCells","dispatch","tableStart","recomp","handleKeyDown","arrow","shiftArrow","deleteCellSelection","maybeSetSelection","view","atEndOfCell","newSel","$next","baseContent","handleTripleClick","handlePaste","handleMouseDown","startEvent","ctrlKey","metaKey","startDOMCell","domInCell","shiftKey","setCellSelection","preventDefault","cellUnderMouse","root","addEventListener","stop","event","starting","removeEventListener","cellPos","dirStr","endOfTextblock","parentNode","nodeName","mousePos","posAtCoords","clientX","clientY","fixTablesKey","changedDescendants","old","curSize","sameMarkup","fixTables","check","fixTable","descendants","tablePos","mustAdd","prob","cell$2","i$3","tableNodeType","selectedRect","addColumn","refColumn","addColumnBefore","addColumnAfter","removeColumn","mapStart","deleteColumn","rowIsHeader","addRow","rowPos","refRow","addRowBefore","addRowAfter","removeRow","nextRow","newPos","deleteRow","isEmpty","c","cellsOverlapRectangle","indexTop","indexLeft","indexBottom","indexRight","mergeCells","mergedPos","mergedCell","splitCell","nodeTypes","splitCellWithType","getCellType","baseAttrs","setCellAttr","deprecated_toggleHeader","isHeaderEnabledByType","cellPositions","toggleHeader","useDeprecatedLogic","isHeaderRowEnabled","isHeaderColumnEnabled","isHeaderEnabled","selectionStartsAt","cellsRect","newType","relativeCellPos","toggleHeaderRow","toggleHeaderColumn","toggleHeaderCell","findNextCell","rowNode$1","goToNextCell","direction","deleteTable","TableView","cellMinWidth","document","createElement","className","appendChild","colgroup","updateColumns","contentDOM","overrideCol","overrideValue","totalWidth","fixedWidth","nextDOM","hasWidth","cssWidth","nextSibling","removeChild","minWidth","update","ignoreMutation","record","contains","key$1","columnResizing","handleWidth","View","lastColumnResizable","nodeViews","ResizeState","attributes","pluginState","activeHandle","handleDOMEvents","mousemove","handleMouseMove","mouseleave","handleMouseLeave","mousedown","handleMouseDown$1","decorations","handleDecorations","dragging","domCellAround","getBoundingClientRect","edgeCell","updateHandle","currentColWidth","finish","window","updateColumnWidth","draggedWidth","setDragging","which","dragged","displayColumnWidth","startX","startWidth","domAtPos","childNodes","domWidth","offsetWidth","parts","classList","setHandle","mapIndex","zeroes","widget","tableEditing","createSelectionBetween","action","undefined","handle"],"mappings":"0HAAA,sYA8BIA,EAAU,MACVC,EAAWC,KAAKC,IAAI,EAAG,IAE3B,SAASC,EAAYC,EAAOC,GAAU,OAAOD,EAAQC,EAASL,EAC9D,SAASM,EAAaC,GAAS,OAAOA,EAAQR,EAC9C,SAASS,EAAcD,GAAS,OAAQA,GAASA,EAAQR,IAAYC,EAIrE,IAAIS,EAAY,SAAmBC,EAAKC,EAASC,QAC9B,IAAZD,IAAqBA,GAAU,QACnB,IAAZC,IAAqBA,EAAU,MAGpCC,KAAKH,IAAMA,EAGXG,KAAKF,QAAUA,EACfE,KAAKD,QAAUA,GAQbE,EAAU,SAAiBC,EAAQC,QACnB,IAAbA,IAAsBA,GAAW,GAEtCH,KAAKE,OAASA,EACdF,KAAKG,SAAWA,GAGlBF,EAAQG,UAAUL,QAAU,SAAkBL,GAC5C,IAAIW,EAAO,EAAGd,EAAQE,EAAaC,GACnC,IAAKM,KAAKG,SAAY,IAAK,IAAIG,EAAI,EAAGA,EAAIf,EAAOe,IAC7CD,GAAQL,KAAKE,OAAW,EAAJI,EAAQ,GAAKN,KAAKE,OAAW,EAAJI,EAAQ,GACzD,OAAON,KAAKE,OAAe,EAARX,GAAac,EAAOV,EAAcD,IAIvDO,EAAQG,UAAUG,UAAY,SAAoBV,EAAKW,GAEtD,YADgB,IAAVA,IAAmBA,EAAQ,GAC1BR,KAAKS,KAAKZ,EAAKW,GAAO,IAG9BP,EAAQG,UAAUM,IAAM,SAAcb,EAAKW,GAE1C,YADgB,IAAVA,IAAmBA,EAAQ,GAC1BR,KAAKS,KAAKZ,EAAKW,GAAO,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7OnEwK,GAAYzxB,UAAUyE,MAAQ,SAAgBgR,GAC5C,IAAI0C,EAAQvY,KAAMs0B,EAASze,EAAGoE,QAAQsX,IACtC,GAAI+C,GAA8B,MAApBA,EAAON,UACjB,OAAO,IAAInC,GAAYyC,EAAON,UAAW,MAC7C,GAAIM,QAAiCC,IAAvBD,EAAOlB,YACjB,OAAO,IAAIvB,GAAYtZ,EAAMyZ,aAAcsC,EAAOlB,aACtD,GAAI7a,EAAMyZ,cAAgB,GAAKnc,EAAGvR,WAAY,CAC5C,IAAIkwB,EAAS3e,EAAG3S,QAAQxC,IAAI6X,EAAMyZ,cAAe,GAC5C/N,EAAapO,EAAG7R,IAAI2D,QAAQ6sB,MAAYA,EAAS,MACtDjc,EAAQ,IAAIsZ,GAAY2C,EAAQjc,EAAMma,UAExC,OAAOna","file":"js/chunk-vendors~281a44dd.fe2ff058.js","sourcesContent":["import { ReplaceError, Slice, Fragment, MarkType } from 'prosemirror-model';\n\n// Mappable:: interface\n// There are several things that positions can be mapped through.\n// Such objects conform to this interface.\n//\n//   map:: (pos: number, assoc: ?number) → number\n//   Map a position through this object. When given, `assoc` (should\n//   be -1 or 1, defaults to 1) determines with which side the\n//   position is associated, which determines in which direction to\n//   move when a chunk of content is inserted at the mapped position.\n//\n//   mapResult:: (pos: number, assoc: ?number) → MapResult\n//   Map a position, and return an object containing additional\n//   information about the mapping. The result's `deleted` field tells\n//   you whether the position was deleted (completely enclosed in a\n//   replaced range) during the mapping. When content on only one side\n//   is deleted, the position itself is only considered deleted when\n//   `assoc` points in the direction of the deleted content.\n\n// Recovery values encode a range index and an offset. They are\n// represented as numbers, because tons of them will be created when\n// mapping, for example, a large number of decorations. The number's\n// lower 16 bits provide the index, the remaining bits the offset.\n//\n// Note: We intentionally don't use bit shift operators to en- and\n// decode these, since those clip to 32 bits, which we might in rare\n// cases want to overflow. A 64-bit float can represent 48-bit\n// integers precisely.\n\nvar lower16 = 0xffff;\nvar factor16 = Math.pow(2, 16);\n\nfunction makeRecover(index, offset) { return index + offset * factor16 }\nfunction recoverIndex(value) { return value & lower16 }\nfunction recoverOffset(value) { return (value - (value & lower16)) / factor16 }\n\n// ::- An object representing a mapped position with extra\n// information.\nvar MapResult = function MapResult(pos, deleted, recover) {\n  if ( deleted === void 0 ) deleted = false;\n  if ( recover === void 0 ) recover = null;\n\n  // :: number The mapped version of the position.\n  this.pos = pos;\n  // :: bool Tells you whether the position was deleted, that is,\n  // whether the step removed its surroundings from the document.\n  this.deleted = deleted;\n  this.recover = recover;\n};\n\n// :: class extends Mappable\n// A map describing the deletions and insertions made by a step, which\n// can be used to find the correspondence between positions in the\n// pre-step version of a document and the same position in the\n// post-step version.\nvar StepMap = function StepMap(ranges, inverted) {\n  if ( inverted === void 0 ) inverted = false;\n\n  this.ranges = ranges;\n  this.inverted = inverted;\n};\n\nStepMap.prototype.recover = function recover (value) {\n  var diff = 0, index = recoverIndex(value);\n  if (!this.inverted) { for (var i = 0; i < index; i++)\n    { diff += this.ranges[i * 3 + 2] - this.ranges[i * 3 + 1]; } }\n  return this.ranges[index * 3] + diff + recoverOffset(value)\n};\n\n// : (number, ?number) → MapResult\nStepMap.prototype.mapResult = function mapResult (pos, assoc) {\n  if ( assoc === void 0 ) assoc = 1;\n return this._map(pos, assoc, false) };\n\n// : (number, ?number) → number\nStepMap.prototype.map = function map (pos, assoc) {\n  if ( assoc === void 0 ) assoc = 1;\n return this._map(pos, assoc, true) };\n\nStepMap.prototype._map = function _map (pos, assoc, simple) {\n  var diff = 0, oldIndex = this.inverted ? 2 : 1, newIndex = this.inverted ? 1 : 2;\n  for (var i = 0; i < this.ranges.length; i += 3) {\n    var start = this.ranges[i] - (this.inverted ? diff : 0);\n    if (start > pos) { break }\n    var oldSize = this.ranges[i + oldIndex], newSize = this.ranges[i + newIndex], end = start + oldSize;\n    if (pos <= end) {\n      var side = !oldSize ? assoc : pos == start ? -1 : pos == end ? 1 : assoc;\n      var result = start + diff + (side < 0 ? 0 : newSize);\n      if (simple) { return result }\n      var recover = pos == (assoc < 0 ? start : end) ? null : makeRecover(i / 3, pos - start);\n      return new MapResult(result, assoc < 0 ? pos != start : pos != end, recover)\n    }\n    diff += newSize - oldSize;\n  }\n  return simple ? pos + diff : new MapResult(pos + diff)\n};\n\nStepMap.prototype.touches = function touches (pos, recover) {\n  var diff = 0, index = recoverIndex(recover);\n  var oldIndex = this.inverted ? 2 : 1, newIndex = this.inverted ? 1 : 2;\n  for (var i = 0; i < this.ranges.length; i += 3) {\n    var start = this.ranges[i] - (this.inverted ? diff : 0);\n    if (start > pos) { break }\n    var oldSize = this.ranges[i + oldIndex], end = start + oldSize;\n    if (pos <= end && i == index * 3) { return true }\n    diff += this.ranges[i + newIndex] - oldSize;\n  }\n  return false\n};\n\n// :: ((oldStart: number, oldEnd: number, newStart: number, newEnd: number))\n// Calls the given function on each of the changed ranges included in\n// this map.\nStepMap.prototype.forEach = function forEach (f) {\n  var oldIndex = this.inverted ? 2 : 1, newIndex = this.inverted ? 1 : 2;\n  for (var i = 0, diff = 0; i < this.ranges.length; i += 3) {\n    var start = this.ranges[i], oldStart = start - (this.inverted ? diff : 0), newStart = start + (this.inverted ? 0 : diff);\n    var oldSize = this.ranges[i + oldIndex], newSize = this.ranges[i + newIndex];\n    f(oldStart, oldStart + oldSize, newStart, newStart + newSize);\n    diff += newSize - oldSize;\n  }\n};\n\n// :: () → StepMap\n// Create an inverted version of this map. The result can be used to\n// map positions in the post-step document to the pre-step document.\nStepMap.prototype.invert = function invert () {\n  return new StepMap(this.ranges, !this.inverted)\n};\n\nStepMap.prototype.toString = function toString () {\n  return (this.inverted ? \"-\" : \"\") + JSON.stringify(this.ranges)\n};\n\n// :: (n: number) → StepMap\n// Create a map that moves all positions by offset `n` (which may be\n// negative). This can be useful when applying steps meant for a\n// sub-document to a larger document, or vice-versa.\nStepMap.offset = function offset (n) {\n  return n == 0 ? StepMap.empty : new StepMap(n < 0 ? [0, -n, 0] : [0, 0, n])\n};\n\nStepMap.empty = new StepMap([]);\n\n// :: class extends Mappable\n// A mapping represents a pipeline of zero or more [step\n// maps](#transform.StepMap). It has special provisions for losslessly\n// handling mapping positions through a series of steps in which some\n// steps are inverted versions of earlier steps. (This comes up when\n// ‘[rebasing](/docs/guide/#transform.rebasing)’ steps for\n// collaboration or history management.)\nvar Mapping = function Mapping(maps, mirror, from, to) {\n  // :: [StepMap]\n  // The step maps in this mapping.\n  this.maps = maps || [];\n  // :: number\n  // The starting position in the `maps` array, used when `map` or\n  // `mapResult` is called.\n  this.from = from || 0;\n  // :: number\n  // The end position in the `maps` array.\n  this.to = to == null ? this.maps.length : to;\n  this.mirror = mirror;\n};\n\n// :: (?number, ?number) → Mapping\n// Create a mapping that maps only through a part of this one.\nMapping.prototype.slice = function slice (from, to) {\n    if ( from === void 0 ) from = 0;\n    if ( to === void 0 ) to = this.maps.length;\n\n  return new Mapping(this.maps, this.mirror, from, to)\n};\n\nMapping.prototype.copy = function copy () {\n  return new Mapping(this.maps.slice(), this.mirror && this.mirror.slice(), this.from, this.to)\n};\n\n// :: (StepMap, ?number)\n// Add a step map to the end of this mapping. If `mirrors` is\n// given, it should be the index of the step map that is the mirror\n// image of this one.\nMapping.prototype.appendMap = function appendMap (map, mirrors) {\n  this.to = this.maps.push(map);\n  if (mirrors != null) { this.setMirror(this.maps.length - 1, mirrors); }\n};\n\n// :: (Mapping)\n// Add all the step maps in a given mapping to this one (preserving\n// mirroring information).\nMapping.prototype.appendMapping = function appendMapping (mapping) {\n  for (var i = 0, startSize = this.maps.length; i < mapping.maps.length; i++) {\n    var mirr = mapping.getMirror(i);\n    this.appendMap(mapping.maps[i], mirr != null && mirr < i ? startSize + mirr : null);\n  }\n};\n\n// :: (number) → ?number\n// Finds the offset of the step map that mirrors the map at the\n// given offset, in this mapping (as per the second argument to\n// `appendMap`).\nMapping.prototype.getMirror = function getMirror (n) {\n  if (this.mirror) { for (var i = 0; i < this.mirror.length; i++)\n    { if (this.mirror[i] == n) { return this.mirror[i + (i % 2 ? -1 : 1)] } } }\n};\n\nMapping.prototype.setMirror = function setMirror (n, m) {\n  if (!this.mirror) { this.mirror = []; }\n  this.mirror.push(n, m);\n};\n\n// :: (Mapping)\n// Append the inverse of the given mapping to this one.\nMapping.prototype.appendMappingInverted = function appendMappingInverted (mapping) {\n  for (var i = mapping.maps.length - 1, totalSize = this.maps.length + mapping.maps.length; i >= 0; i--) {\n    var mirr = mapping.getMirror(i);\n    this.appendMap(mapping.maps[i].invert(), mirr != null && mirr > i ? totalSize - mirr - 1 : null);\n  }\n};\n\n// :: () → Mapping\n// Create an inverted version of this mapping.\nMapping.prototype.invert = function invert () {\n  var inverse = new Mapping;\n  inverse.appendMappingInverted(this);\n  return inverse\n};\n\n// : (number, ?number) → number\n// Map a position through this mapping.\nMapping.prototype.map = function map (pos, assoc) {\n    if ( assoc === void 0 ) assoc = 1;\n\n  if (this.mirror) { return this._map(pos, assoc, true) }\n  for (var i = this.from; i < this.to; i++)\n    { pos = this.maps[i].map(pos, assoc); }\n  return pos\n};\n\n// : (number, ?number) → MapResult\n// Map a position through this mapping, returning a mapping\n// result.\nMapping.prototype.mapResult = function mapResult (pos, assoc) {\n  if ( assoc === void 0 ) assoc = 1;\n return this._map(pos, assoc, false) };\n\nMapping.prototype._map = function _map (pos, assoc, simple) {\n  var deleted = false;\n\n  for (var i = this.from; i < this.to; i++) {\n    var map = this.maps[i], result = map.mapResult(pos, assoc);\n    if (result.recover != null) {\n      var corr = this.getMirror(i);\n      if (corr != null && corr > i && corr < this.to) {\n        i = corr;\n        pos = this.maps[corr].recover(result.recover);\n        continue\n      }\n    }\n\n    if (result.deleted) { deleted = true; }\n    pos = result.pos;\n  }\n\n  return simple ? pos : new MapResult(pos, deleted)\n};\n\nfunction TransformError(message) {\n  var err = Error.call(this, message);\n  err.__proto__ = TransformError.prototype;\n  return err\n}\n\nTransformError.prototype = Object.create(Error.prototype);\nTransformError.prototype.constructor = TransformError;\nTransformError.prototype.name = \"TransformError\";\n\n// ::- Abstraction to build up and track an array of\n// [steps](#transform.Step) representing a document transformation.\n//\n// Most transforming methods return the `Transform` object itself, so\n// that they can be chained.\nvar Transform = function Transform(doc) {\n  // :: Node\n  // The current document (the result of applying the steps in the\n  // transform).\n  this.doc = doc;\n  // :: [Step]\n  // The steps in this transform.\n  this.steps = [];\n  // :: [Node]\n  // The documents before each of the steps.\n  this.docs = [];\n  // :: Mapping\n  // A mapping with the maps for each of the steps in this transform.\n  this.mapping = new Mapping;\n};\n\nvar prototypeAccessors = { before: { configurable: true },docChanged: { configurable: true } };\n\n// :: Node The starting document.\nprototypeAccessors.before.get = function () { return this.docs.length ? this.docs[0] : this.doc };\n\n// :: (step: Step) → this\n// Apply a new step in this transform, saving the result. Throws an\n// error when the step fails.\nTransform.prototype.step = function step (object) {\n  var result = this.maybeStep(object);\n  if (result.failed) { throw new TransformError(result.failed) }\n  return this\n};\n\n// :: (Step) → StepResult\n// Try to apply a step in this transformation, ignoring it if it\n// fails. Returns the step result.\nTransform.prototype.maybeStep = function maybeStep (step) {\n  var result = step.apply(this.doc);\n  if (!result.failed) { this.addStep(step, result.doc); }\n  return result\n};\n\n// :: bool\n// True when the document has been changed (when there are any\n// steps).\nprototypeAccessors.docChanged.get = function () {\n  return this.steps.length > 0\n};\n\nTransform.prototype.addStep = function addStep (step, doc) {\n  this.docs.push(this.doc);\n  this.steps.push(step);\n  this.mapping.appendMap(step.getMap());\n  this.doc = doc;\n};\n\nObject.defineProperties( Transform.prototype, prototypeAccessors );\n\nfunction mustOverride() { throw new Error(\"Override me\") }\n\nvar stepsByID = Object.create(null);\n\n// ::- A step object represents an atomic change. It generally applies\n// only to the document it was created for, since the positions\n// stored in it will only make sense for that document.\n//\n// New steps are defined by creating classes that extend `Step`,\n// overriding the `apply`, `invert`, `map`, `getMap` and `fromJSON`\n// methods, and registering your class with a unique\n// JSON-serialization identifier using\n// [`Step.jsonID`](#transform.Step^jsonID).\nvar Step = function Step () {};\n\nStep.prototype.apply = function apply (_doc) { return mustOverride() };\n\n// :: () → StepMap\n// Get the step map that represents the changes made by this step,\n// and which can be used to transform between positions in the old\n// and the new document.\nStep.prototype.getMap = function getMap () { return StepMap.empty };\n\n// :: (doc: Node) → Step\n// Create an inverted version of this step. Needs the document as it\n// was before the step as argument.\nStep.prototype.invert = function invert (_doc) { return mustOverride() };\n\n// :: (mapping: Mappable) → ?Step\n// Map this step through a mappable thing, returning either a\n// version of that step with its positions adjusted, or `null` if\n// the step was entirely deleted by the mapping.\nStep.prototype.map = function map (_mapping) { return mustOverride() };\n\n// :: (other: Step) → ?Step\n// Try to merge this step with another one, to be applied directly\n// after it. Returns the merged step when possible, null if the\n// steps can't be merged.\nStep.prototype.merge = function merge (_other) { return null };\n\n// :: () → Object\n// Create a JSON-serializeable representation of this step. When\n// defining this for a custom subclass, make sure the result object\n// includes the step type's [JSON id](#transform.Step^jsonID) under\n// the `stepType` property.\nStep.prototype.toJSON = function toJSON () { return mustOverride() };\n\n// :: (Schema, Object) → Step\n// Deserialize a step from its JSON representation. Will call\n// through to the step class' own implementation of this method.\nStep.fromJSON = function fromJSON (schema, json) {\n  if (!json || !json.stepType) { throw new RangeError(\"Invalid input for Step.fromJSON\") }\n  var type = stepsByID[json.stepType];\n  if (!type) { throw new RangeError((\"No step type \" + (json.stepType) + \" defined\")) }\n  return type.fromJSON(schema, json)\n};\n\n// :: (string, constructor<Step>)\n// To be able to serialize steps to JSON, each step needs a string\n// ID to attach to its JSON representation. Use this method to\n// register an ID for your step classes. Try to pick something\n// that's unlikely to clash with steps from other modules.\nStep.jsonID = function jsonID (id, stepClass) {\n  if (id in stepsByID) { throw new RangeError(\"Duplicate use of step JSON ID \" + id) }\n  stepsByID[id] = stepClass;\n  stepClass.prototype.jsonID = id;\n  return stepClass\n};\n\n// ::- The result of [applying](#transform.Step.apply) a step. Contains either a\n// new document or a failure value.\nvar StepResult = function StepResult(doc, failed) {\n  // :: ?Node The transformed document.\n  this.doc = doc;\n  // :: ?string Text providing information about a failed step.\n  this.failed = failed;\n};\n\n// :: (Node) → StepResult\n// Create a successful step result.\nStepResult.ok = function ok (doc) { return new StepResult(doc, null) };\n\n// :: (string) → StepResult\n// Create a failed step result.\nStepResult.fail = function fail (message) { return new StepResult(null, message) };\n\n// :: (Node, number, number, Slice) → StepResult\n// Call [`Node.replace`](#model.Node.replace) with the given\n// arguments. Create a successful result if it succeeds, and a\n// failed one if it throws a `ReplaceError`.\nStepResult.fromReplace = function fromReplace (doc, from, to, slice) {\n  try {\n    return StepResult.ok(doc.replace(from, to, slice))\n  } catch (e) {\n    if (e instanceof ReplaceError) { return StepResult.fail(e.message) }\n    throw e\n  }\n};\n\n// ::- Replace a part of the document with a slice of new content.\nvar ReplaceStep = /*@__PURE__*/(function (Step) {\n  function ReplaceStep(from, to, slice, structure) {\n    Step.call(this);\n    // :: number\n    // The start position of the replaced range.\n    this.from = from;\n    // :: number\n    // The end position of the replaced range.\n    this.to = to;\n    // :: Slice\n    // The slice to insert.\n    this.slice = slice;\n    this.structure = !!structure;\n  }\n\n  if ( Step ) ReplaceStep.__proto__ = Step;\n  ReplaceStep.prototype = Object.create( Step && Step.prototype );\n  ReplaceStep.prototype.constructor = ReplaceStep;\n\n  ReplaceStep.prototype.apply = function apply (doc) {\n    if (this.structure && contentBetween(doc, this.from, this.to))\n      { return StepResult.fail(\"Structure replace would overwrite content\") }\n    return StepResult.fromReplace(doc, this.from, this.to, this.slice)\n  };\n\n  ReplaceStep.prototype.getMap = function getMap () {\n    return new StepMap([this.from, this.to - this.from, this.slice.size])\n  };\n\n  ReplaceStep.prototype.invert = function invert (doc) {\n    return new ReplaceStep(this.from, this.from + this.slice.size, doc.slice(this.from, this.to))\n  };\n\n  ReplaceStep.prototype.map = function map (mapping) {\n    var from = mapping.mapResult(this.from, 1), to = mapping.mapResult(this.to, -1);\n    if (from.deleted && to.deleted) { return null }\n    return new ReplaceStep(from.pos, Math.max(from.pos, to.pos), this.slice)\n  };\n\n  ReplaceStep.prototype.merge = function merge (other) {\n    if (!(other instanceof ReplaceStep) || other.structure || this.structure) { return null }\n\n    if (this.from + this.slice.size == other.from && !this.slice.openEnd && !other.slice.openStart) {\n      var slice = this.slice.size + other.slice.size == 0 ? Slice.empty\n          : new Slice(this.slice.content.append(other.slice.content), this.slice.openStart, other.slice.openEnd);\n      return new ReplaceStep(this.from, this.to + (other.to - other.from), slice, this.structure)\n    } else if (other.to == this.from && !this.slice.openStart && !other.slice.openEnd) {\n      var slice$1 = this.slice.size + other.slice.size == 0 ? Slice.empty\n          : new Slice(other.slice.content.append(this.slice.content), other.slice.openStart, this.slice.openEnd);\n      return new ReplaceStep(other.from, this.to, slice$1, this.structure)\n    } else {\n      return null\n    }\n  };\n\n  ReplaceStep.prototype.toJSON = function toJSON () {\n    var json = {stepType: \"replace\", from: this.from, to: this.to};\n    if (this.slice.size) { json.slice = this.slice.toJSON(); }\n    if (this.structure) { json.structure = true; }\n    return json\n  };\n\n  ReplaceStep.fromJSON = function fromJSON (schema, json) {\n    if (typeof json.from != \"number\" || typeof json.to != \"number\")\n      { throw new RangeError(\"Invalid input for ReplaceStep.fromJSON\") }\n    return new ReplaceStep(json.from, json.to, Slice.fromJSON(schema, json.slice), !!json.structure)\n  };\n\n  return ReplaceStep;\n}(Step));\n\nStep.jsonID(\"replace\", ReplaceStep);\n\n// ::- Replace a part of the document with a slice of content, but\n// preserve a range of the replaced content by moving it into the\n// slice.\nvar ReplaceAroundStep = /*@__PURE__*/(function (Step) {\n  function ReplaceAroundStep(from, to, gapFrom, gapTo, slice, insert, structure) {\n    Step.call(this);\n    // :: number\n    // The start position of the replaced range.\n    this.from = from;\n    // :: number\n    // The end position of the replaced range.\n    this.to = to;\n    // :: number\n    // The start of preserved range.\n    this.gapFrom = gapFrom;\n    // :: number\n    // The end of preserved range.\n    this.gapTo = gapTo;\n    // :: Slice\n    // The slice to insert.\n    this.slice = slice;\n    // :: number\n    // The position in the slice where the preserved range should be\n    // inserted.\n    this.insert = insert;\n    this.structure = !!structure;\n  }\n\n  if ( Step ) ReplaceAroundStep.__proto__ = Step;\n  ReplaceAroundStep.prototype = Object.create( Step && Step.prototype );\n  ReplaceAroundStep.prototype.constructor = ReplaceAroundStep;\n\n  ReplaceAroundStep.prototype.apply = function apply (doc) {\n    if (this.structure && (contentBetween(doc, this.from, this.gapFrom) ||\n                           contentBetween(doc, this.gapTo, this.to)))\n      { return StepResult.fail(\"Structure gap-replace would overwrite content\") }\n\n    var gap = doc.slice(this.gapFrom, this.gapTo);\n    if (gap.openStart || gap.openEnd)\n      { return StepResult.fail(\"Gap is not a flat range\") }\n    var inserted = this.slice.insertAt(this.insert, gap.content);\n    if (!inserted) { return StepResult.fail(\"Content does not fit in gap\") }\n    return StepResult.fromReplace(doc, this.from, this.to, inserted)\n  };\n\n  ReplaceAroundStep.prototype.getMap = function getMap () {\n    return new StepMap([this.from, this.gapFrom - this.from, this.insert,\n                        this.gapTo, this.to - this.gapTo, this.slice.size - this.insert])\n  };\n\n  ReplaceAroundStep.prototype.invert = function invert (doc) {\n    var gap = this.gapTo - this.gapFrom;\n    return new ReplaceAroundStep(this.from, this.from + this.slice.size + gap,\n                                 this.from + this.insert, this.from + this.insert + gap,\n                                 doc.slice(this.from, this.to).removeBetween(this.gapFrom - this.from, this.gapTo - this.from),\n                                 this.gapFrom - this.from, this.structure)\n  };\n\n  ReplaceAroundStep.prototype.map = function map (mapping) {\n    var from = mapping.mapResult(this.from, 1), to = mapping.mapResult(this.to, -1);\n    var gapFrom = mapping.map(this.gapFrom, -1), gapTo = mapping.map(this.gapTo, 1);\n    if ((from.deleted && to.deleted) || gapFrom < from.pos || gapTo > to.pos) { return null }\n    return new ReplaceAroundStep(from.pos, to.pos, gapFrom, gapTo, this.slice, this.insert, this.structure)\n  };\n\n  ReplaceAroundStep.prototype.toJSON = function toJSON () {\n    var json = {stepType: \"replaceAround\", from: this.from, to: this.to,\n                gapFrom: this.gapFrom, gapTo: this.gapTo, insert: this.insert};\n    if (this.slice.size) { json.slice = this.slice.toJSON(); }\n    if (this.structure) { json.structure = true; }\n    return json\n  };\n\n  ReplaceAroundStep.fromJSON = function fromJSON (schema, json) {\n    if (typeof json.from != \"number\" || typeof json.to != \"number\" ||\n        typeof json.gapFrom != \"number\" || typeof json.gapTo != \"number\" || typeof json.insert != \"number\")\n      { throw new RangeError(\"Invalid input for ReplaceAroundStep.fromJSON\") }\n    return new ReplaceAroundStep(json.from, json.to, json.gapFrom, json.gapTo,\n                                 Slice.fromJSON(schema, json.slice), json.insert, !!json.structure)\n  };\n\n  return ReplaceAroundStep;\n}(Step));\n\nStep.jsonID(\"replaceAround\", ReplaceAroundStep);\n\nfunction contentBetween(doc, from, to) {\n  var $from = doc.resolve(from), dist = to - from, depth = $from.depth;\n  while (dist > 0 && depth > 0 && $from.indexAfter(depth) == $from.node(depth).childCount) {\n    depth--;\n    dist--;\n  }\n  if (dist > 0) {\n    var next = $from.node(depth).maybeChild($from.indexAfter(depth));\n    while (dist > 0) {\n      if (!next || next.isLeaf) { return true }\n      next = next.firstChild;\n      dist--;\n    }\n  }\n  return false\n}\n\nfunction canCut(node, start, end) {\n  return (start == 0 || node.canReplace(start, node.childCount)) &&\n    (end == node.childCount || node.canReplace(0, end))\n}\n\n// :: (NodeRange) → ?number\n// Try to find a target depth to which the content in the given range\n// can be lifted. Will not go across\n// [isolating](#model.NodeSpec.isolating) parent nodes.\nfunction liftTarget(range) {\n  var parent = range.parent;\n  var content = parent.content.cutByIndex(range.startIndex, range.endIndex);\n  for (var depth = range.depth;; --depth) {\n    var node = range.$from.node(depth);\n    var index = range.$from.index(depth), endIndex = range.$to.indexAfter(depth);\n    if (depth < range.depth && node.canReplace(index, endIndex, content))\n      { return depth }\n    if (depth == 0 || node.type.spec.isolating || !canCut(node, index, endIndex)) { break }\n  }\n}\n\n// :: (NodeRange, number) → this\n// Split the content in the given range off from its parent, if there\n// is sibling content before or after it, and move it up the tree to\n// the depth specified by `target`. You'll probably want to use\n// [`liftTarget`](#transform.liftTarget) to compute `target`, to make\n// sure the lift is valid.\nTransform.prototype.lift = function(range, target) {\n  var $from = range.$from;\n  var $to = range.$to;\n  var depth = range.depth;\n\n  var gapStart = $from.before(depth + 1), gapEnd = $to.after(depth + 1);\n  var start = gapStart, end = gapEnd;\n\n  var before = Fragment.empty, openStart = 0;\n  for (var d = depth, splitting = false; d > target; d--)\n    { if (splitting || $from.index(d) > 0) {\n      splitting = true;\n      before = Fragment.from($from.node(d).copy(before));\n      openStart++;\n    } else {\n      start--;\n    } }\n  var after = Fragment.empty, openEnd = 0;\n  for (var d$1 = depth, splitting$1 = false; d$1 > target; d$1--)\n    { if (splitting$1 || $to.after(d$1 + 1) < $to.end(d$1)) {\n      splitting$1 = true;\n      after = Fragment.from($to.node(d$1).copy(after));\n      openEnd++;\n    } else {\n      end++;\n    } }\n\n  return this.step(new ReplaceAroundStep(start, end, gapStart, gapEnd,\n                                         new Slice(before.append(after), openStart, openEnd),\n                                         before.size - openStart, true))\n};\n\n// :: (NodeRange, NodeType, ?Object, ?NodeRange) → ?[{type: NodeType, attrs: ?Object}]\n// Try to find a valid way to wrap the content in the given range in a\n// node of the given type. May introduce extra nodes around and inside\n// the wrapper node, if necessary. Returns null if no valid wrapping\n// could be found. When `innerRange` is given, that range's content is\n// used as the content to fit into the wrapping, instead of the\n// content of `range`.\nfunction findWrapping(range, nodeType, attrs, innerRange) {\n  if ( innerRange === void 0 ) innerRange = range;\n\n  var around = findWrappingOutside(range, nodeType);\n  var inner = around && findWrappingInside(innerRange, nodeType);\n  if (!inner) { return null }\n  return around.map(withAttrs).concat({type: nodeType, attrs: attrs}).concat(inner.map(withAttrs))\n}\n\nfunction withAttrs(type) { return {type: type, attrs: null} }\n\nfunction findWrappingOutside(range, type) {\n  var parent = range.parent;\n  var startIndex = range.startIndex;\n  var endIndex = range.endIndex;\n  var around = parent.contentMatchAt(startIndex).findWrapping(type);\n  if (!around) { return null }\n  var outer = around.length ? around[0] : type;\n  return parent.canReplaceWith(startIndex, endIndex, outer) ? around : null\n}\n\nfunction findWrappingInside(range, type) {\n  var parent = range.parent;\n  var startIndex = range.startIndex;\n  var endIndex = range.endIndex;\n  var inner = parent.child(startIndex);\n  var inside = type.contentMatch.findWrapping(inner.type);\n  if (!inside) { return null }\n  var lastType = inside.length ? inside[inside.length - 1] : type;\n  var innerMatch = lastType.contentMatch;\n  for (var i = startIndex; innerMatch && i < endIndex; i++)\n    { innerMatch = innerMatch.matchType(parent.child(i).type); }\n  if (!innerMatch || !innerMatch.validEnd) { return null }\n  return inside\n}\n\n// :: (NodeRange, [{type: NodeType, attrs: ?Object}]) → this\n// Wrap the given [range](#model.NodeRange) in the given set of wrappers.\n// The wrappers are assumed to be valid in this position, and should\n// probably be computed with [`findWrapping`](#transform.findWrapping).\nTransform.prototype.wrap = function(range, wrappers) {\n  var content = Fragment.empty;\n  for (var i = wrappers.length - 1; i >= 0; i--)\n    { content = Fragment.from(wrappers[i].type.create(wrappers[i].attrs, content)); }\n\n  var start = range.start, end = range.end;\n  return this.step(new ReplaceAroundStep(start, end, start, end, new Slice(content, 0, 0), wrappers.length, true))\n};\n\n// :: (number, ?number, NodeType, ?Object) → this\n// Set the type of all textblocks (partly) between `from` and `to` to\n// the given node type with the given attributes.\nTransform.prototype.setBlockType = function(from, to, type, attrs) {\n  var this$1 = this;\n  if ( to === void 0 ) to = from;\n\n  if (!type.isTextblock) { throw new RangeError(\"Type given to setBlockType should be a textblock\") }\n  var mapFrom = this.steps.length;\n  this.doc.nodesBetween(from, to, function (node, pos) {\n    if (node.isTextblock && !node.hasMarkup(type, attrs) && canChangeType(this$1.doc, this$1.mapping.slice(mapFrom).map(pos), type)) {\n      // Ensure all markup that isn't allowed in the new node type is cleared\n      this$1.clearIncompatible(this$1.mapping.slice(mapFrom).map(pos, 1), type);\n      var mapping = this$1.mapping.slice(mapFrom);\n      var startM = mapping.map(pos, 1), endM = mapping.map(pos + node.nodeSize, 1);\n      this$1.step(new ReplaceAroundStep(startM, endM, startM + 1, endM - 1,\n                                      new Slice(Fragment.from(type.create(attrs, null, node.marks)), 0, 0), 1, true));\n      return false\n    }\n  });\n  return this\n};\n\nfunction canChangeType(doc, pos, type) {\n  var $pos = doc.resolve(pos), index = $pos.index();\n  return $pos.parent.canReplaceWith(index, index + 1, type)\n}\n\n// :: (number, ?NodeType, ?Object, ?[Mark]) → this\n// Change the type, attributes, and/or marks of the node at `pos`.\n// When `type` isn't given, the existing node type is preserved,\nTransform.prototype.setNodeMarkup = function(pos, type, attrs, marks) {\n  var node = this.doc.nodeAt(pos);\n  if (!node) { throw new RangeError(\"No node at given position\") }\n  if (!type) { type = node.type; }\n  var newNode = type.create(attrs, null, marks || node.marks);\n  if (node.isLeaf)\n    { return this.replaceWith(pos, pos + node.nodeSize, newNode) }\n\n  if (!type.validContent(node.content))\n    { throw new RangeError(\"Invalid content for node type \" + type.name) }\n\n  return this.step(new ReplaceAroundStep(pos, pos + node.nodeSize, pos + 1, pos + node.nodeSize - 1,\n                                         new Slice(Fragment.from(newNode), 0, 0), 1, true))\n};\n\n// :: (Node, number, number, ?[?{type: NodeType, attrs: ?Object}]) → bool\n// Check whether splitting at the given position is allowed.\nfunction canSplit(doc, pos, depth, typesAfter) {\n  if ( depth === void 0 ) depth = 1;\n\n  var $pos = doc.resolve(pos), base = $pos.depth - depth;\n  var innerType = (typesAfter && typesAfter[typesAfter.length - 1]) || $pos.parent;\n  if (base < 0 || $pos.parent.type.spec.isolating ||\n      !$pos.parent.canReplace($pos.index(), $pos.parent.childCount) ||\n      !innerType.type.validContent($pos.parent.content.cutByIndex($pos.index(), $pos.parent.childCount)))\n    { return false }\n  for (var d = $pos.depth - 1, i = depth - 2; d > base; d--, i--) {\n    var node = $pos.node(d), index$1 = $pos.index(d);\n    if (node.type.spec.isolating) { return false }\n    var rest = node.content.cutByIndex(index$1, node.childCount);\n    var after = (typesAfter && typesAfter[i]) || node;\n    if (after != node) { rest = rest.replaceChild(0, after.type.create(after.attrs)); }\n    if (!node.canReplace(index$1 + 1, node.childCount) || !after.type.validContent(rest))\n      { return false }\n  }\n  var index = $pos.indexAfter(base);\n  var baseType = typesAfter && typesAfter[0];\n  return $pos.node(base).canReplaceWith(index, index, baseType ? baseType.type : $pos.node(base + 1).type)\n}\n\n// :: (number, ?number, ?[?{type: NodeType, attrs: ?Object}]) → this\n// Split the node at the given position, and optionally, if `depth` is\n// greater than one, any number of nodes above that. By default, the\n// parts split off will inherit the node type of the original node.\n// This can be changed by passing an array of types and attributes to\n// use after the split.\nTransform.prototype.split = function(pos, depth, typesAfter) {\n  if ( depth === void 0 ) depth = 1;\n\n  var $pos = this.doc.resolve(pos), before = Fragment.empty, after = Fragment.empty;\n  for (var d = $pos.depth, e = $pos.depth - depth, i = depth - 1; d > e; d--, i--) {\n    before = Fragment.from($pos.node(d).copy(before));\n    var typeAfter = typesAfter && typesAfter[i];\n    after = Fragment.from(typeAfter ? typeAfter.type.create(typeAfter.attrs, after) : $pos.node(d).copy(after));\n  }\n  return this.step(new ReplaceStep(pos, pos, new Slice(before.append(after), depth, depth), true))\n};\n\n// :: (Node, number) → bool\n// Test whether the blocks before and after a given position can be\n// joined.\nfunction canJoin(doc, pos) {\n  var $pos = doc.resolve(pos), index = $pos.index();\n  return joinable($pos.nodeBefore, $pos.nodeAfter) &&\n    $pos.parent.canReplace(index, index + 1)\n}\n\nfunction joinable(a, b) {\n  return a && b && !a.isLeaf && a.canAppend(b)\n}\n\n// :: (Node, number, ?number) → ?number\n// Find an ancestor of the given position that can be joined to the\n// block before (or after if `dir` is positive). Returns the joinable\n// point, if any.\nfunction joinPoint(doc, pos, dir) {\n  if ( dir === void 0 ) dir = -1;\n\n  var $pos = doc.resolve(pos);\n  for (var d = $pos.depth;; d--) {\n    var before = (void 0), after = (void 0), index = $pos.index(d);\n    if (d == $pos.depth) {\n      before = $pos.nodeBefore;\n      after = $pos.nodeAfter;\n    } else if (dir > 0) {\n      before = $pos.node(d + 1);\n      index++;\n      after = $pos.node(d).maybeChild(index);\n    } else {\n      before = $pos.node(d).maybeChild(index - 1);\n      after = $pos.node(d + 1);\n    }\n    if (before && !before.isTextblock && joinable(before, after) &&\n        $pos.node(d).canReplace(index, index + 1)) { return pos }\n    if (d == 0) { break }\n    pos = dir < 0 ? $pos.before(d) : $pos.after(d);\n  }\n}\n\n// :: (number, ?number) → this\n// Join the blocks around the given position. If depth is 2, their\n// last and first siblings are also joined, and so on.\nTransform.prototype.join = function(pos, depth) {\n  if ( depth === void 0 ) depth = 1;\n\n  var step = new ReplaceStep(pos - depth, pos + depth, Slice.empty, true);\n  return this.step(step)\n};\n\n// :: (Node, number, NodeType) → ?number\n// Try to find a point where a node of the given type can be inserted\n// near `pos`, by searching up the node hierarchy when `pos` itself\n// isn't a valid place but is at the start or end of a node. Return\n// null if no position was found.\nfunction insertPoint(doc, pos, nodeType) {\n  var $pos = doc.resolve(pos);\n  if ($pos.parent.canReplaceWith($pos.index(), $pos.index(), nodeType)) { return pos }\n\n  if ($pos.parentOffset == 0)\n    { for (var d = $pos.depth - 1; d >= 0; d--) {\n      var index = $pos.index(d);\n      if ($pos.node(d).canReplaceWith(index, index, nodeType)) { return $pos.before(d + 1) }\n      if (index > 0) { return null }\n    } }\n  if ($pos.parentOffset == $pos.parent.content.size)\n    { for (var d$1 = $pos.depth - 1; d$1 >= 0; d$1--) {\n      var index$1 = $pos.indexAfter(d$1);\n      if ($pos.node(d$1).canReplaceWith(index$1, index$1, nodeType)) { return $pos.after(d$1 + 1) }\n      if (index$1 < $pos.node(d$1).childCount) { return null }\n    } }\n}\n\n// :: (Node, number, Slice) → ?number\n// Finds a position at or around the given position where the given\n// slice can be inserted. Will look at parent nodes' nearest boundary\n// and try there, even if the original position wasn't directly at the\n// start or end of that node. Returns null when no position was found.\nfunction dropPoint(doc, pos, slice) {\n  var $pos = doc.resolve(pos);\n  if (!slice.content.size) { return pos }\n  var content = slice.content;\n  for (var i = 0; i < slice.openStart; i++) { content = content.firstChild.content; }\n  for (var pass = 1; pass <= (slice.openStart == 0 && slice.size ? 2 : 1); pass++) {\n    for (var d = $pos.depth; d >= 0; d--) {\n      var bias = d == $pos.depth ? 0 : $pos.pos <= ($pos.start(d + 1) + $pos.end(d + 1)) / 2 ? -1 : 1;\n      var insertPos = $pos.index(d) + (bias > 0 ? 1 : 0);\n      var parent = $pos.node(d), fits = false;\n      if (pass == 1) {\n        fits = parent.canReplace(insertPos, insertPos, content);\n      } else {\n        var wrapping = parent.contentMatchAt(insertPos).findWrapping(content.firstChild.type);\n        fits = wrapping && parent.canReplaceWith(insertPos, insertPos, wrapping[0]);\n      }\n      if (fits)\n        { return bias == 0 ? $pos.pos : bias < 0 ? $pos.before(d + 1) : $pos.after(d + 1) }\n    }\n  }\n  return null\n}\n\nfunction mapFragment(fragment, f, parent) {\n  var mapped = [];\n  for (var i = 0; i < fragment.childCount; i++) {\n    var child = fragment.child(i);\n    if (child.content.size) { child = child.copy(mapFragment(child.content, f, child)); }\n    if (child.isInline) { child = f(child, parent, i); }\n    mapped.push(child);\n  }\n  return Fragment.fromArray(mapped)\n}\n\n// ::- Add a mark to all inline content between two positions.\nvar AddMarkStep = /*@__PURE__*/(function (Step) {\n  function AddMarkStep(from, to, mark) {\n    Step.call(this);\n    // :: number\n    // The start of the marked range.\n    this.from = from;\n    // :: number\n    // The end of the marked range.\n    this.to = to;\n    // :: Mark\n    // The mark to add.\n    this.mark = mark;\n  }\n\n  if ( Step ) AddMarkStep.__proto__ = Step;\n  AddMarkStep.prototype = Object.create( Step && Step.prototype );\n  AddMarkStep.prototype.constructor = AddMarkStep;\n\n  AddMarkStep.prototype.apply = function apply (doc) {\n    var this$1 = this;\n\n    var oldSlice = doc.slice(this.from, this.to), $from = doc.resolve(this.from);\n    var parent = $from.node($from.sharedDepth(this.to));\n    var slice = new Slice(mapFragment(oldSlice.content, function (node, parent) {\n      if (!node.isAtom || !parent.type.allowsMarkType(this$1.mark.type)) { return node }\n      return node.mark(this$1.mark.addToSet(node.marks))\n    }, parent), oldSlice.openStart, oldSlice.openEnd);\n    return StepResult.fromReplace(doc, this.from, this.to, slice)\n  };\n\n  AddMarkStep.prototype.invert = function invert () {\n    return new RemoveMarkStep(this.from, this.to, this.mark)\n  };\n\n  AddMarkStep.prototype.map = function map (mapping) {\n    var from = mapping.mapResult(this.from, 1), to = mapping.mapResult(this.to, -1);\n    if (from.deleted && to.deleted || from.pos >= to.pos) { return null }\n    return new AddMarkStep(from.pos, to.pos, this.mark)\n  };\n\n  AddMarkStep.prototype.merge = function merge (other) {\n    if (other instanceof AddMarkStep &&\n        other.mark.eq(this.mark) &&\n        this.from <= other.to && this.to >= other.from)\n      { return new AddMarkStep(Math.min(this.from, other.from),\n                             Math.max(this.to, other.to), this.mark) }\n  };\n\n  AddMarkStep.prototype.toJSON = function toJSON () {\n    return {stepType: \"addMark\", mark: this.mark.toJSON(),\n            from: this.from, to: this.to}\n  };\n\n  AddMarkStep.fromJSON = function fromJSON (schema, json) {\n    if (typeof json.from != \"number\" || typeof json.to != \"number\")\n      { throw new RangeError(\"Invalid input for AddMarkStep.fromJSON\") }\n    return new AddMarkStep(json.from, json.to, schema.markFromJSON(json.mark))\n  };\n\n  return AddMarkStep;\n}(Step));\n\nStep.jsonID(\"addMark\", AddMarkStep);\n\n// ::- Remove a mark from all inline content between two positions.\nvar RemoveMarkStep = /*@__PURE__*/(function (Step) {\n  function RemoveMarkStep(from, to, mark) {\n    Step.call(this);\n    // :: number\n    // The start of the unmarked range.\n    this.from = from;\n    // :: number\n    // The end of the unmarked range.\n    this.to = to;\n    // :: Mark\n    // The mark to remove.\n    this.mark = mark;\n  }\n\n  if ( Step ) RemoveMarkStep.__proto__ = Step;\n  RemoveMarkStep.prototype = Object.create( Step && Step.prototype );\n  RemoveMarkStep.prototype.constructor = RemoveMarkStep;\n\n  RemoveMarkStep.prototype.apply = function apply (doc) {\n    var this$1 = this;\n\n    var oldSlice = doc.slice(this.from, this.to);\n    var slice = new Slice(mapFragment(oldSlice.content, function (node) {\n      return node.mark(this$1.mark.removeFromSet(node.marks))\n    }), oldSlice.openStart, oldSlice.openEnd);\n    return StepResult.fromReplace(doc, this.from, this.to, slice)\n  };\n\n  RemoveMarkStep.prototype.invert = function invert () {\n    return new AddMarkStep(this.from, this.to, this.mark)\n  };\n\n  RemoveMarkStep.prototype.map = function map (mapping) {\n    var from = mapping.mapResult(this.from, 1), to = mapping.mapResult(this.to, -1);\n    if (from.deleted && to.deleted || from.pos >= to.pos) { return null }\n    return new RemoveMarkStep(from.pos, to.pos, this.mark)\n  };\n\n  RemoveMarkStep.prototype.merge = function merge (other) {\n    if (other instanceof RemoveMarkStep &&\n        other.mark.eq(this.mark) &&\n        this.from <= other.to && this.to >= other.from)\n      { return new RemoveMarkStep(Math.min(this.from, other.from),\n                                Math.max(this.to, other.to), this.mark) }\n  };\n\n  RemoveMarkStep.prototype.toJSON = function toJSON () {\n    return {stepType: \"removeMark\", mark: this.mark.toJSON(),\n            from: this.from, to: this.to}\n  };\n\n  RemoveMarkStep.fromJSON = function fromJSON (schema, json) {\n    if (typeof json.from != \"number\" || typeof json.to != \"number\")\n      { throw new RangeError(\"Invalid input for RemoveMarkStep.fromJSON\") }\n    return new RemoveMarkStep(json.from, json.to, schema.markFromJSON(json.mark))\n  };\n\n  return RemoveMarkStep;\n}(Step));\n\nStep.jsonID(\"removeMark\", RemoveMarkStep);\n\n// :: (number, number, Mark) → this\n// Add the given mark to the inline content between `from` and `to`.\nTransform.prototype.addMark = function(from, to, mark) {\n  var this$1 = this;\n\n  var removed = [], added = [], removing = null, adding = null;\n  this.doc.nodesBetween(from, to, function (node, pos, parent) {\n    if (!node.isInline) { return }\n    var marks = node.marks;\n    if (!mark.isInSet(marks) && parent.type.allowsMarkType(mark.type)) {\n      var start = Math.max(pos, from), end = Math.min(pos + node.nodeSize, to);\n      var newSet = mark.addToSet(marks);\n\n      for (var i = 0; i < marks.length; i++) {\n        if (!marks[i].isInSet(newSet)) {\n          if (removing && removing.to == start && removing.mark.eq(marks[i]))\n            { removing.to = end; }\n          else\n            { removed.push(removing = new RemoveMarkStep(start, end, marks[i])); }\n        }\n      }\n\n      if (adding && adding.to == start)\n        { adding.to = end; }\n      else\n        { added.push(adding = new AddMarkStep(start, end, mark)); }\n    }\n  });\n\n  removed.forEach(function (s) { return this$1.step(s); });\n  added.forEach(function (s) { return this$1.step(s); });\n  return this\n};\n\n// :: (number, number, ?union<Mark, MarkType>) → this\n// Remove marks from inline nodes between `from` and `to`. When `mark`\n// is a single mark, remove precisely that mark. When it is a mark type,\n// remove all marks of that type. When it is null, remove all marks of\n// any type.\nTransform.prototype.removeMark = function(from, to, mark) {\n  var this$1 = this;\n  if ( mark === void 0 ) mark = null;\n\n  var matched = [], step = 0;\n  this.doc.nodesBetween(from, to, function (node, pos) {\n    if (!node.isInline) { return }\n    step++;\n    var toRemove = null;\n    if (mark instanceof MarkType) {\n      var set = node.marks, found;\n      while (found = mark.isInSet(set)) {\n(toRemove || (toRemove = [])).push(found);\n        set = found.removeFromSet(set);\n      }\n    } else if (mark) {\n      if (mark.isInSet(node.marks)) { toRemove = [mark]; }\n    } else {\n      toRemove = node.marks;\n    }\n    if (toRemove && toRemove.length) {\n      var end = Math.min(pos + node.nodeSize, to);\n      for (var i = 0; i < toRemove.length; i++) {\n        var style = toRemove[i], found$1 = (void 0);\n        for (var j = 0; j < matched.length; j++) {\n          var m = matched[j];\n          if (m.step == step - 1 && style.eq(matched[j].style)) { found$1 = m; }\n        }\n        if (found$1) {\n          found$1.to = end;\n          found$1.step = step;\n        } else {\n          matched.push({style: style, from: Math.max(pos, from), to: end, step: step});\n        }\n      }\n    }\n  });\n  matched.forEach(function (m) { return this$1.step(new RemoveMarkStep(m.from, m.to, m.style)); });\n  return this\n};\n\n// :: (number, NodeType, ?ContentMatch) → this\n// Removes all marks and nodes from the content of the node at `pos`\n// that don't match the given new parent node type. Accepts an\n// optional starting [content match](#model.ContentMatch) as third\n// argument.\nTransform.prototype.clearIncompatible = function(pos, parentType, match) {\n  if ( match === void 0 ) match = parentType.contentMatch;\n\n  var node = this.doc.nodeAt(pos);\n  var delSteps = [], cur = pos + 1;\n  for (var i = 0; i < node.childCount; i++) {\n    var child = node.child(i), end = cur + child.nodeSize;\n    var allowed = match.matchType(child.type, child.attrs);\n    if (!allowed) {\n      delSteps.push(new ReplaceStep(cur, end, Slice.empty));\n    } else {\n      match = allowed;\n      for (var j = 0; j < child.marks.length; j++) { if (!parentType.allowsMarkType(child.marks[j].type))\n        { this.step(new RemoveMarkStep(cur, end, child.marks[j])); } }\n    }\n    cur = end;\n  }\n  if (!match.validEnd) {\n    var fill = match.fillBefore(Fragment.empty, true);\n    this.replace(cur, cur, new Slice(fill, 0, 0));\n  }\n  for (var i$1 = delSteps.length - 1; i$1 >= 0; i$1--) { this.step(delSteps[i$1]); }\n  return this\n};\n\n// :: (Node, number, ?number, ?Slice) → ?Step\n// ‘Fit’ a slice into a given position in the document, producing a\n// [step](#transform.Step) that inserts it. Will return null if\n// there's no meaningful way to insert the slice here, or inserting it\n// would be a no-op (an empty slice over an empty range).\nfunction replaceStep(doc, from, to, slice) {\n  if ( to === void 0 ) to = from;\n  if ( slice === void 0 ) slice = Slice.empty;\n\n  if (from == to && !slice.size) { return null }\n\n  var $from = doc.resolve(from), $to = doc.resolve(to);\n  // Optimization -- avoid work if it's obvious that it's not needed.\n  if (fitsTrivially($from, $to, slice)) { return new ReplaceStep(from, to, slice) }\n  return new Fitter($from, $to, slice).fit()\n}\n\n// :: (number, ?number, ?Slice) → this\n// Replace the part of the document between `from` and `to` with the\n// given `slice`.\nTransform.prototype.replace = function(from, to, slice) {\n  if ( to === void 0 ) to = from;\n  if ( slice === void 0 ) slice = Slice.empty;\n\n  var step = replaceStep(this.doc, from, to, slice);\n  if (step) { this.step(step); }\n  return this\n};\n\n// :: (number, number, union<Fragment, Node, [Node]>) → this\n// Replace the given range with the given content, which may be a\n// fragment, node, or array of nodes.\nTransform.prototype.replaceWith = function(from, to, content) {\n  return this.replace(from, to, new Slice(Fragment.from(content), 0, 0))\n};\n\n// :: (number, number) → this\n// Delete the content between the given positions.\nTransform.prototype.delete = function(from, to) {\n  return this.replace(from, to, Slice.empty)\n};\n\n// :: (number, union<Fragment, Node, [Node]>) → this\n// Insert the given content at the given position.\nTransform.prototype.insert = function(pos, content) {\n  return this.replaceWith(pos, pos, content)\n};\n\nfunction fitsTrivially($from, $to, slice) {\n  return !slice.openStart && !slice.openEnd && $from.start() == $to.start() &&\n    $from.parent.canReplace($from.index(), $to.index(), slice.content)\n}\n\n// Algorithm for 'placing' the elements of a slice into a gap:\n//\n// We consider the content of each node that is open to the left to be\n// independently placeable. I.e. in <p(\"foo\"), p(\"bar\")>, when the\n// paragraph on the left is open, \"foo\" can be placed (somewhere on\n// the left side of the replacement gap) independently from p(\"bar\").\n//\n// This class tracks the state of the placement progress in the\n// following properties:\n//\n//  - `frontier` holds a stack of `{type, match}` objects that\n//    represent the open side of the replacement. It starts at\n//    `$from`, then moves forward as content is placed, and is finally\n//    reconciled with `$to`.\n//\n//  - `unplaced` is a slice that represents the content that hasn't\n//    been placed yet.\n//\n//  - `placed` is a fragment of placed content. Its open-start value\n//    is implicit in `$from`, and its open-end value in `frontier`.\nvar Fitter = function Fitter($from, $to, slice) {\n  this.$to = $to;\n  this.$from = $from;\n  this.unplaced = slice;\n\n  this.frontier = [];\n  for (var i = 0; i <= $from.depth; i++) {\n    var node = $from.node(i);\n    this.frontier.push({\n      type: node.type,\n      match: node.contentMatchAt($from.indexAfter(i))\n    });\n  }\n\n  this.placed = Fragment.empty;\n  for (var i$1 = $from.depth; i$1 > 0; i$1--)\n    { this.placed = Fragment.from($from.node(i$1).copy(this.placed)); }\n};\n\nvar prototypeAccessors$1 = { depth: { configurable: true } };\n\nprototypeAccessors$1.depth.get = function () { return this.frontier.length - 1 };\n\nFitter.prototype.fit = function fit () {\n  // As long as there's unplaced content, try to place some of it.\n  // If that fails, either increase the open score of the unplaced\n  // slice, or drop nodes from it, and then try again.\n  while (this.unplaced.size) {\n    var fit = this.findFittable();\n    if (fit) { this.placeNodes(fit); }\n    else { this.openMore() || this.dropNode(); }\n  }\n  // When there's inline content directly after the frontier _and_\n  // directly after `this.$to`, we must generate a `ReplaceAround`\n  // step that pulls that content into the node after the frontier.\n  // That means the fitting must be done to the end of the textblock\n  // node after `this.$to`, not `this.$to` itself.\n  var moveInline = this.mustMoveInline(), placedSize = this.placed.size - this.depth - this.$from.depth;\n  var $from = this.$from, $to = this.close(moveInline < 0 ? this.$to : $from.doc.resolve(moveInline));\n  if (!$to) { return null }\n\n  // If closing to `$to` succeeded, create a step\n  var content = this.placed, openStart = $from.depth, openEnd = $to.depth;\n  while (openStart && openEnd && content.childCount == 1) { // Normalize by dropping open parent nodes\n    content = content.firstChild.content;\n    openStart--; openEnd--;\n  }\n  var slice = new Slice(content, openStart, openEnd);\n  if (moveInline > -1)\n    { return new ReplaceAroundStep($from.pos, moveInline, this.$to.pos, this.$to.end(), slice, placedSize) }\n  if (slice.size || $from.pos != this.$to.pos) // Don't generate no-op steps\n    { return new ReplaceStep($from.pos, $to.pos, slice) }\n};\n\n// Find a position on the start spine of `this.unplaced` that has\n// content that can be moved somewhere on the frontier. Returns two\n// depths, one for the slice and one for the frontier.\nFitter.prototype.findFittable = function findFittable () {\n  // Only try wrapping nodes (pass 2) after finding a place without\n  // wrapping failed.\n  for (var pass = 1; pass <= 2; pass++) {\n    for (var sliceDepth = this.unplaced.openStart; sliceDepth >= 0; sliceDepth--) {\n      var fragment = (void 0), parent = (void 0);\n      if (sliceDepth) {\n        parent = contentAt(this.unplaced.content, sliceDepth - 1).firstChild;\n        fragment = parent.content;\n      } else {\n        fragment = this.unplaced.content;\n      }\n      var first = fragment.firstChild;\n      for (var frontierDepth = this.depth; frontierDepth >= 0; frontierDepth--) {\n        var ref = this.frontier[frontierDepth];\n          var type = ref.type;\n          var match = ref.match;\n          var wrap = (void 0), inject = (void 0);\n        // In pass 1, if the next node matches, or there is no next\n        // node but the parents look compatible, we've found a\n        // place.\n        if (pass == 1 && (first ? match.matchType(first.type) || (inject = match.fillBefore(Fragment.from(first), false))\n                          : type.compatibleContent(parent.type)))\n          { return {sliceDepth: sliceDepth, frontierDepth: frontierDepth, parent: parent, inject: inject} }\n        // In pass 2, look for a set of wrapping nodes that make\n        // `first` fit here.\n        else if (pass == 2 && first && (wrap = match.findWrapping(first.type)))\n          { return {sliceDepth: sliceDepth, frontierDepth: frontierDepth, parent: parent, wrap: wrap} }\n        // Don't continue looking further up if the parent node\n        // would fit here.\n        if (parent && match.matchType(parent.type)) { break }\n      }\n    }\n  }\n};\n\nFitter.prototype.openMore = function openMore () {\n  var ref = this.unplaced;\n    var content = ref.content;\n    var openStart = ref.openStart;\n    var openEnd = ref.openEnd;\n  var inner = contentAt(content, openStart);\n  if (!inner.childCount || inner.firstChild.isLeaf) { return false }\n  this.unplaced = new Slice(content, openStart + 1,\n                            Math.max(openEnd, inner.size + openStart >= content.size - openEnd ? openStart + 1 : 0));\n  return true\n};\n\nFitter.prototype.dropNode = function dropNode () {\n  var ref = this.unplaced;\n    var content = ref.content;\n    var openStart = ref.openStart;\n    var openEnd = ref.openEnd;\n  var inner = contentAt(content, openStart);\n  if (inner.childCount <= 1 && openStart > 0) {\n    var openAtEnd = content.size - openStart <= openStart + inner.size;\n    this.unplaced = new Slice(dropFromFragment(content, openStart - 1, 1), openStart - 1,\n                              openAtEnd ? openStart - 1 : openEnd);\n  } else {\n    this.unplaced = new Slice(dropFromFragment(content, openStart, 1), openStart, openEnd);\n  }\n};\n\n// : ({sliceDepth: number, frontierDepth: number, parent: ?Node, wrap: ?[NodeType], inject: ?Fragment})\n// Move content from the unplaced slice at `sliceDepth` to the\n// frontier node at `frontierDepth`. Close that frontier node when\n// applicable.\nFitter.prototype.placeNodes = function placeNodes (ref) {\n    var sliceDepth = ref.sliceDepth;\n    var frontierDepth = ref.frontierDepth;\n    var parent = ref.parent;\n    var inject = ref.inject;\n    var wrap = ref.wrap;\n\n  while (this.depth > frontierDepth) { this.closeFrontierNode(); }\n  if (wrap) { for (var i = 0; i < wrap.length; i++) { this.openFrontierNode(wrap[i]); } }\n\n  var slice = this.unplaced, fragment = parent ? parent.content : slice.content;\n  var openStart = slice.openStart - sliceDepth;\n  var taken = 0, add = [];\n  var ref$1 = this.frontier[frontierDepth];\n    var match = ref$1.match;\n    var type = ref$1.type;\n  if (inject) {\n    for (var i$1 = 0; i$1 < inject.childCount; i$1++) { add.push(inject.child(i$1)); }\n    match = match.matchFragment(inject);\n  }\n  // Computes the amount of (end) open nodes at the end of the\n  // fragment. When 0, the parent is open, but no more. When\n  // negative, nothing is open.\n  var openEndCount = (fragment.size + sliceDepth) - (slice.content.size - slice.openEnd);\n  // Scan over the fragment, fitting as many child nodes as\n  // possible.\n  while (taken < fragment.childCount) {\n    var next = fragment.child(taken), matches = match.matchType(next.type);\n    if (!matches) { break }\n    taken++;\n    if (taken > 1 || openStart == 0 || next.content.size) { // Drop empty open nodes\n      match = matches;\n      add.push(closeNodeStart(next.mark(type.allowedMarks(next.marks)), taken == 1 ? openStart : 0,\n                              taken == fragment.childCount ? openEndCount : -1));\n    }\n  }\n  var toEnd = taken == fragment.childCount;\n  if (!toEnd) { openEndCount = -1; }\n\n  this.placed = addToFragment(this.placed, frontierDepth, Fragment.from(add));\n  this.frontier[frontierDepth].match = match;\n\n  // If the parent types match, and the entire node was moved, and\n  // it's not open, close this frontier node right away.\n  if (toEnd && openEndCount < 0 && parent && parent.type == this.frontier[this.depth].type && this.frontier.length > 1)\n    { this.closeFrontierNode(); }\n\n  // Add new frontier nodes for any open nodes at the end.\n  for (var i$2 = 0, cur = fragment; i$2 < openEndCount; i$2++) {\n    var node = cur.lastChild;\n    this.frontier.push({type: node.type, match: node.contentMatchAt(node.childCount)});\n    cur = node.content;\n  }\n\n  // Update `this.unplaced`. Drop the entire node from which we\n  // placed it we got to its end, otherwise just drop the placed\n  // nodes.\n  this.unplaced = !toEnd ? new Slice(dropFromFragment(slice.content, sliceDepth, taken), slice.openStart, slice.openEnd)\n    : sliceDepth == 0 ? Slice.empty\n    : new Slice(dropFromFragment(slice.content, sliceDepth - 1, 1),\n                sliceDepth - 1, openEndCount < 0 ? slice.openEnd : sliceDepth - 1);\n};\n\nFitter.prototype.mustMoveInline = function mustMoveInline () {\n  if (!this.$to.parent.isTextblock || this.$to.end() == this.$to.pos) { return -1 }\n  var top = this.frontier[this.depth], level;\n  if (!top.type.isTextblock || !contentAfterFits(this.$to, this.$to.depth, top.type, top.match, false) ||\n      (this.$to.depth == this.depth && (level = this.findCloseLevel(this.$to)) && level.depth == this.depth)) { return -1 }\n\n  var ref = this.$to;\n    var depth = ref.depth;\n    var after = this.$to.after(depth);\n  while (depth > 1 && after == this.$to.end(--depth)) { ++after; }\n  return after\n};\n\nFitter.prototype.findCloseLevel = function findCloseLevel ($to) {\n  scan: for (var i = Math.min(this.depth, $to.depth); i >= 0; i--) {\n    var ref = this.frontier[i];\n      var match = ref.match;\n      var type = ref.type;\n    var dropInner = i < $to.depth && $to.end(i + 1) == $to.pos + ($to.depth - (i + 1));\n    var fit = contentAfterFits($to, i, type, match, dropInner);\n    if (!fit) { continue }\n    for (var d = i - 1; d >= 0; d--) {\n      var ref$1 = this.frontier[d];\n        var match$1 = ref$1.match;\n        var type$1 = ref$1.type;\n      var matches = contentAfterFits($to, d, type$1, match$1, true);\n      if (!matches || matches.childCount) { continue scan }\n    }\n    return {depth: i, fit: fit, move: dropInner ? $to.doc.resolve($to.after(i + 1)) : $to}\n  }\n};\n\nFitter.prototype.close = function close ($to) {\n  var close = this.findCloseLevel($to);\n  if (!close) { return null }\n\n  while (this.depth > close.depth) { this.closeFrontierNode(); }\n  if (close.fit.childCount) { this.placed = addToFragment(this.placed, close.depth, close.fit); }\n  $to = close.move;\n  for (var d = close.depth + 1; d <= $to.depth; d++) {\n    var node = $to.node(d), add = node.type.contentMatch.fillBefore(node.content, true, $to.index(d));\n    this.openFrontierNode(node.type, node.attrs, add);\n  }\n  return $to\n};\n\nFitter.prototype.openFrontierNode = function openFrontierNode (type, attrs, content) {\n  var top = this.frontier[this.depth];\n  top.match = top.match.matchType(type);\n  this.placed = addToFragment(this.placed, this.depth, Fragment.from(type.create(attrs, content)));\n  this.frontier.push({type: type, match: type.contentMatch});\n};\n\nFitter.prototype.closeFrontierNode = function closeFrontierNode () {\n  var open = this.frontier.pop();\n  var add = open.match.fillBefore(Fragment.empty, true);\n  if (add.childCount) { this.placed = addToFragment(this.placed, this.frontier.length, add); }\n};\n\nObject.defineProperties( Fitter.prototype, prototypeAccessors$1 );\n\nfunction dropFromFragment(fragment, depth, count) {\n  if (depth == 0) { return fragment.cutByIndex(count) }\n  return fragment.replaceChild(0, fragment.firstChild.copy(dropFromFragment(fragment.firstChild.content, depth - 1, count)))\n}\n\nfunction addToFragment(fragment, depth, content) {\n  if (depth == 0) { return fragment.append(content) }\n  return fragment.replaceChild(fragment.childCount - 1,\n                               fragment.lastChild.copy(addToFragment(fragment.lastChild.content, depth - 1, content)))\n}\n\nfunction contentAt(fragment, depth) {\n  for (var i = 0; i < depth; i++) { fragment = fragment.firstChild.content; }\n  return fragment\n}\n\nfunction closeNodeStart(node, openStart, openEnd) {\n  if (openStart <= 0) { return node }\n  var frag = node.content;\n  if (openStart > 1)\n    { frag = frag.replaceChild(0, closeNodeStart(frag.firstChild, openStart - 1, frag.childCount == 1 ? openEnd - 1 : 0)); }\n  if (openStart > 0) {\n    frag = node.type.contentMatch.fillBefore(frag).append(frag);\n    if (openEnd <= 0) { frag = frag.append(node.type.contentMatch.matchFragment(frag).fillBefore(Fragment.empty, true)); }\n  }\n  return node.copy(frag)\n}\n\nfunction contentAfterFits($to, depth, type, match, open) {\n  var node = $to.node(depth), index = open ? $to.indexAfter(depth) : $to.index(depth);\n  if (index == node.childCount && !type.compatibleContent(node.type)) { return null }\n  var fit = match.fillBefore(node.content, true, index);\n  return fit && !invalidMarks(type, node.content, index) ? fit : null\n}\n\nfunction invalidMarks(type, fragment, start) {\n  for (var i = start; i < fragment.childCount; i++)\n    { if (!type.allowsMarks(fragment.child(i).marks)) { return true } }\n  return false\n}\n\n// :: (number, number, Slice) → this\n// Replace a range of the document with a given slice, using `from`,\n// `to`, and the slice's [`openStart`](#model.Slice.openStart) property\n// as hints, rather than fixed start and end points. This method may\n// grow the replaced area or close open nodes in the slice in order to\n// get a fit that is more in line with WYSIWYG expectations, by\n// dropping fully covered parent nodes of the replaced region when\n// they are marked [non-defining](#model.NodeSpec.defining), or\n// including an open parent node from the slice that _is_ marked as\n// [defining](#model.NodeSpec.defining).\n//\n// This is the method, for example, to handle paste. The similar\n// [`replace`](#transform.Transform.replace) method is a more\n// primitive tool which will _not_ move the start and end of its given\n// range, and is useful in situations where you need more precise\n// control over what happens.\nTransform.prototype.replaceRange = function(from, to, slice) {\n  if (!slice.size) { return this.deleteRange(from, to) }\n\n  var $from = this.doc.resolve(from), $to = this.doc.resolve(to);\n  if (fitsTrivially($from, $to, slice))\n    { return this.step(new ReplaceStep(from, to, slice)) }\n\n  var targetDepths = coveredDepths($from, this.doc.resolve(to));\n  // Can't replace the whole document, so remove 0 if it's present\n  if (targetDepths[targetDepths.length - 1] == 0) { targetDepths.pop(); }\n  // Negative numbers represent not expansion over the whole node at\n  // that depth, but replacing from $from.before(-D) to $to.pos.\n  var preferredTarget = -($from.depth + 1);\n  targetDepths.unshift(preferredTarget);\n  // This loop picks a preferred target depth, if one of the covering\n  // depths is not outside of a defining node, and adds negative\n  // depths for any depth that has $from at its start and does not\n  // cross a defining node.\n  for (var d = $from.depth, pos = $from.pos - 1; d > 0; d--, pos--) {\n    var spec = $from.node(d).type.spec;\n    if (spec.defining || spec.isolating) { break }\n    if (targetDepths.indexOf(d) > -1) { preferredTarget = d; }\n    else if ($from.before(d) == pos) { targetDepths.splice(1, 0, -d); }\n  }\n  // Try to fit each possible depth of the slice into each possible\n  // target depth, starting with the preferred depths.\n  var preferredTargetIndex = targetDepths.indexOf(preferredTarget);\n\n  var leftNodes = [], preferredDepth = slice.openStart;\n  for (var content = slice.content, i = 0;; i++) {\n    var node = content.firstChild;\n    leftNodes.push(node);\n    if (i == slice.openStart) { break }\n    content = node.content;\n  }\n  // Back up if the node directly above openStart, or the node above\n  // that separated only by a non-defining textblock node, is defining.\n  if (preferredDepth > 0 && leftNodes[preferredDepth - 1].type.spec.defining &&\n      $from.node(preferredTargetIndex).type != leftNodes[preferredDepth - 1].type)\n    { preferredDepth -= 1; }\n  else if (preferredDepth >= 2 && leftNodes[preferredDepth - 1].isTextblock && leftNodes[preferredDepth - 2].type.spec.defining &&\n           $from.node(preferredTargetIndex).type != leftNodes[preferredDepth - 2].type)\n    { preferredDepth -= 2; }\n\n  for (var j = slice.openStart; j >= 0; j--) {\n    var openDepth = (j + preferredDepth + 1) % (slice.openStart + 1);\n    var insert = leftNodes[openDepth];\n    if (!insert) { continue }\n    for (var i$1 = 0; i$1 < targetDepths.length; i$1++) {\n      // Loop over possible expansion levels, starting with the\n      // preferred one\n      var targetDepth = targetDepths[(i$1 + preferredTargetIndex) % targetDepths.length], expand = true;\n      if (targetDepth < 0) { expand = false; targetDepth = -targetDepth; }\n      var parent = $from.node(targetDepth - 1), index = $from.index(targetDepth - 1);\n      if (parent.canReplaceWith(index, index, insert.type, insert.marks))\n        { return this.replace($from.before(targetDepth), expand ? $to.after(targetDepth) : to,\n                            new Slice(closeFragment(slice.content, 0, slice.openStart, openDepth),\n                                      openDepth, slice.openEnd)) }\n    }\n  }\n\n  var startSteps = this.steps.length;\n  for (var i$2 = targetDepths.length - 1; i$2 >= 0; i$2--) {\n    this.replace(from, to, slice);\n    if (this.steps.length > startSteps) { break }\n    var depth = targetDepths[i$2];\n    if (depth < 0) { continue }\n    from = $from.before(depth); to = $to.after(depth);\n  }\n  return this\n};\n\nfunction closeFragment(fragment, depth, oldOpen, newOpen, parent) {\n  if (depth < oldOpen) {\n    var first = fragment.firstChild;\n    fragment = fragment.replaceChild(0, first.copy(closeFragment(first.content, depth + 1, oldOpen, newOpen, first)));\n  }\n  if (depth > newOpen) {\n    var match = parent.contentMatchAt(0);\n    var start = match.fillBefore(fragment).append(fragment);\n    fragment = start.append(match.matchFragment(start).fillBefore(Fragment.empty, true));\n  }\n  return fragment\n}\n\n// :: (number, number, Node) → this\n// Replace the given range with a node, but use `from` and `to` as\n// hints, rather than precise positions. When from and to are the same\n// and are at the start or end of a parent node in which the given\n// node doesn't fit, this method may _move_ them out towards a parent\n// that does allow the given node to be placed. When the given range\n// completely covers a parent node, this method may completely replace\n// that parent node.\nTransform.prototype.replaceRangeWith = function(from, to, node) {\n  if (!node.isInline && from == to && this.doc.resolve(from).parent.content.size) {\n    var point = insertPoint(this.doc, from, node.type);\n    if (point != null) { from = to = point; }\n  }\n  return this.replaceRange(from, to, new Slice(Fragment.from(node), 0, 0))\n};\n\n// :: (number, number) → this\n// Delete the given range, expanding it to cover fully covered\n// parent nodes until a valid replace is found.\nTransform.prototype.deleteRange = function(from, to) {\n  var $from = this.doc.resolve(from), $to = this.doc.resolve(to);\n  var covered = coveredDepths($from, $to);\n  for (var i = 0; i < covered.length; i++) {\n    var depth = covered[i], last = i == covered.length - 1;\n    if ((last && depth == 0) || $from.node(depth).type.contentMatch.validEnd)\n      { return this.delete($from.start(depth), $to.end(depth)) }\n    if (depth > 0 && (last || $from.node(depth - 1).canReplace($from.index(depth - 1), $to.indexAfter(depth - 1))))\n      { return this.delete($from.before(depth), $to.after(depth)) }\n  }\n  for (var d = 1; d <= $from.depth && d <= $to.depth; d++) {\n    if (from - $from.start(d) == $from.depth - d && to > $from.end(d) && $to.end(d) - to != $to.depth - d)\n      { return this.delete($from.before(d), to) }\n  }\n  return this.delete(from, to)\n};\n\n// : (ResolvedPos, ResolvedPos) → [number]\n// Returns an array of all depths for which $from - $to spans the\n// whole content of the nodes at that depth.\nfunction coveredDepths($from, $to) {\n  var result = [], minDepth = Math.min($from.depth, $to.depth);\n  for (var d = minDepth; d >= 0; d--) {\n    var start = $from.start(d);\n    if (start < $from.pos - ($from.depth - d) ||\n        $to.end(d) > $to.pos + ($to.depth - d) ||\n        $from.node(d).type.spec.isolating ||\n        $to.node(d).type.spec.isolating) { break }\n    if (start == $to.start(d) ||\n        (d == $from.depth && d == $to.depth && $from.parent.inlineContent && $to.parent.inlineContent &&\n         d && $to.start(d - 1) == start - 1))\n      { result.push(d); }\n  }\n  return result\n}\n\nexport { AddMarkStep, MapResult, Mapping, RemoveMarkStep, ReplaceAroundStep, ReplaceStep, Step, StepMap, StepResult, Transform, TransformError, canJoin, canSplit, dropPoint, findWrapping, insertPoint, joinPoint, liftTarget, replaceStep };\n//# sourceMappingURL=index.es.js.map\n","import { Slice, Fragment, Mark, Node } from 'prosemirror-model';\nimport { ReplaceStep, ReplaceAroundStep, Transform } from 'prosemirror-transform';\n\nvar classesById = Object.create(null);\n\n// ::- Superclass for editor selections. Every selection type should\n// extend this. Should not be instantiated directly.\nvar Selection = function Selection($anchor, $head, ranges) {\n  // :: [SelectionRange]\n  // The ranges covered by the selection.\n  this.ranges = ranges || [new SelectionRange($anchor.min($head), $anchor.max($head))];\n  // :: ResolvedPos\n  // The resolved anchor of the selection (the side that stays in\n  // place when the selection is modified).\n  this.$anchor = $anchor;\n  // :: ResolvedPos\n  // The resolved head of the selection (the side that moves when\n  // the selection is modified).\n  this.$head = $head;\n};\n\nvar prototypeAccessors = { anchor: { configurable: true },head: { configurable: true },from: { configurable: true },to: { configurable: true },$from: { configurable: true },$to: { configurable: true },empty: { configurable: true } };\n\n// :: number\n// The selection's anchor, as an unresolved position.\nprototypeAccessors.anchor.get = function () { return this.$anchor.pos };\n\n// :: number\n// The selection's head.\nprototypeAccessors.head.get = function () { return this.$head.pos };\n\n// :: number\n// The lower bound of the selection's main range.\nprototypeAccessors.from.get = function () { return this.$from.pos };\n\n// :: number\n// The upper bound of the selection's main range.\nprototypeAccessors.to.get = function () { return this.$to.pos };\n\n// :: ResolvedPos\n// The resolved lowerbound of the selection's main range.\nprototypeAccessors.$from.get = function () {\n  return this.ranges[0].$from\n};\n\n// :: ResolvedPos\n// The resolved upper bound of the selection's main range.\nprototypeAccessors.$to.get = function () {\n  return this.ranges[0].$to\n};\n\n// :: bool\n// Indicates whether the selection contains any content.\nprototypeAccessors.empty.get = function () {\n  var ranges = this.ranges;\n  for (var i = 0; i < ranges.length; i++)\n    { if (ranges[i].$from.pos != ranges[i].$to.pos) { return false } }\n  return true\n};\n\n// eq:: (Selection) → bool\n// Test whether the selection is the same as another selection.\n\n// map:: (doc: Node, mapping: Mappable) → Selection\n// Map this selection through a [mappable](#transform.Mappable) thing. `doc`\n// should be the new document to which we are mapping.\n\n// :: () → Slice\n// Get the content of this selection as a slice.\nSelection.prototype.content = function content () {\n  return this.$from.node(0).slice(this.from, this.to, true)\n};\n\n// :: (Transaction, ?Slice)\n// Replace the selection with a slice or, if no slice is given,\n// delete the selection. Will append to the given transaction.\nSelection.prototype.replace = function replace (tr, content) {\n    if ( content === void 0 ) content = Slice.empty;\n\n  // Put the new selection at the position after the inserted\n  // content. When that ended in an inline node, search backwards,\n  // to get the position after that node. If not, search forward.\n  var lastNode = content.content.lastChild, lastParent = null;\n  for (var i = 0; i < content.openEnd; i++) {\n    lastParent = lastNode;\n    lastNode = lastNode.lastChild;\n  }\n\n  var mapFrom = tr.steps.length, ranges = this.ranges;\n  for (var i$1 = 0; i$1 < ranges.length; i$1++) {\n    var ref = ranges[i$1];\n      var $from = ref.$from;\n      var $to = ref.$to;\n      var mapping = tr.mapping.slice(mapFrom);\n    tr.replaceRange(mapping.map($from.pos), mapping.map($to.pos), i$1 ? Slice.empty : content);\n    if (i$1 == 0)\n      { selectionToInsertionEnd(tr, mapFrom, (lastNode ? lastNode.isInline : lastParent && lastParent.isTextblock) ? -1 : 1); }\n  }\n};\n\n// :: (Transaction, Node)\n// Replace the selection with the given node, appending the changes\n// to the given transaction.\nSelection.prototype.replaceWith = function replaceWith (tr, node) {\n  var mapFrom = tr.steps.length, ranges = this.ranges;\n  for (var i = 0; i < ranges.length; i++) {\n    var ref = ranges[i];\n      var $from = ref.$from;\n      var $to = ref.$to;\n      var mapping = tr.mapping.slice(mapFrom);\n    var from = mapping.map($from.pos), to = mapping.map($to.pos);\n    if (i) {\n      tr.deleteRange(from, to);\n    } else {\n      tr.replaceRangeWith(from, to, node);\n      selectionToInsertionEnd(tr, mapFrom, node.isInline ? -1 : 1);\n    }\n  }\n};\n\n// toJSON:: () → Object\n// Convert the selection to a JSON representation. When implementing\n// this for a custom selection class, make sure to give the object a\n// `type` property whose value matches the ID under which you\n// [registered](#state.Selection^jsonID) your class.\n\n// :: (ResolvedPos, number, ?bool) → ?Selection\n// Find a valid cursor or leaf node selection starting at the given\n// position and searching back if `dir` is negative, and forward if\n// positive. When `textOnly` is true, only consider cursor\n// selections. Will return null when no valid selection position is\n// found.\nSelection.findFrom = function findFrom ($pos, dir, textOnly) {\n  var inner = $pos.parent.inlineContent ? new TextSelection($pos)\n      : findSelectionIn($pos.node(0), $pos.parent, $pos.pos, $pos.index(), dir, textOnly);\n  if (inner) { return inner }\n\n  for (var depth = $pos.depth - 1; depth >= 0; depth--) {\n    var found = dir < 0\n        ? findSelectionIn($pos.node(0), $pos.node(depth), $pos.before(depth + 1), $pos.index(depth), dir, textOnly)\n        : findSelectionIn($pos.node(0), $pos.node(depth), $pos.after(depth + 1), $pos.index(depth) + 1, dir, textOnly);\n    if (found) { return found }\n  }\n};\n\n// :: (ResolvedPos, ?number) → Selection\n// Find a valid cursor or leaf node selection near the given\n// position. Searches forward first by default, but if `bias` is\n// negative, it will search backwards first.\nSelection.near = function near ($pos, bias) {\n    if ( bias === void 0 ) bias = 1;\n\n  return this.findFrom($pos, bias) || this.findFrom($pos, -bias) || new AllSelection($pos.node(0))\n};\n\n// :: (Node) → Selection\n// Find the cursor or leaf node selection closest to the start of\n// the given document. Will return an\n// [`AllSelection`](#state.AllSelection) if no valid position\n// exists.\nSelection.atStart = function atStart (doc) {\n  return findSelectionIn(doc, doc, 0, 0, 1) || new AllSelection(doc)\n};\n\n// :: (Node) → Selection\n// Find the cursor or leaf node selection closest to the end of the\n// given document.\nSelection.atEnd = function atEnd (doc) {\n  return findSelectionIn(doc, doc, doc.content.size, doc.childCount, -1) || new AllSelection(doc)\n};\n\n// :: (Node, Object) → Selection\n// Deserialize the JSON representation of a selection. Must be\n// implemented for custom classes (as a static class method).\nSelection.fromJSON = function fromJSON (doc, json) {\n  if (!json || !json.type) { throw new RangeError(\"Invalid input for Selection.fromJSON\") }\n  var cls = classesById[json.type];\n  if (!cls) { throw new RangeError((\"No selection type \" + (json.type) + \" defined\")) }\n  return cls.fromJSON(doc, json)\n};\n\n// :: (string, constructor<Selection>)\n// To be able to deserialize selections from JSON, custom selection\n// classes must register themselves with an ID string, so that they\n// can be disambiguated. Try to pick something that's unlikely to\n// clash with classes from other modules.\nSelection.jsonID = function jsonID (id, selectionClass) {\n  if (id in classesById) { throw new RangeError(\"Duplicate use of selection JSON ID \" + id) }\n  classesById[id] = selectionClass;\n  selectionClass.prototype.jsonID = id;\n  return selectionClass\n};\n\n// :: () → SelectionBookmark\n// Get a [bookmark](#state.SelectionBookmark) for this selection,\n// which is a value that can be mapped without having access to a\n// current document, and later resolved to a real selection for a\n// given document again. (This is used mostly by the history to\n// track and restore old selections.) The default implementation of\n// this method just converts the selection to a text selection and\n// returns the bookmark for that.\nSelection.prototype.getBookmark = function getBookmark () {\n  return TextSelection.between(this.$anchor, this.$head).getBookmark()\n};\n\nObject.defineProperties( Selection.prototype, prototypeAccessors );\n\n// :: bool\n// Controls whether, when a selection of this type is active in the\n// browser, the selected range should be visible to the user. Defaults\n// to `true`.\nSelection.prototype.visible = true;\n\n// SelectionBookmark:: interface\n// A lightweight, document-independent representation of a selection.\n// You can define a custom bookmark type for a custom selection class\n// to make the history handle it well.\n//\n//   map:: (mapping: Mapping) → SelectionBookmark\n//   Map the bookmark through a set of changes.\n//\n//   resolve:: (doc: Node) → Selection\n//   Resolve the bookmark to a real selection again. This may need to\n//   do some error checking and may fall back to a default (usually\n//   [`TextSelection.between`](#state.TextSelection^between)) if\n//   mapping made the bookmark invalid.\n\n// ::- Represents a selected range in a document.\nvar SelectionRange = function SelectionRange($from, $to) {\n  // :: ResolvedPos\n  // The lower bound of the range.\n  this.$from = $from;\n  // :: ResolvedPos\n  // The upper bound of the range.\n  this.$to = $to;\n};\n\n// ::- A text selection represents a classical editor selection, with\n// a head (the moving side) and anchor (immobile side), both of which\n// point into textblock nodes. It can be empty (a regular cursor\n// position).\nvar TextSelection = /*@__PURE__*/(function (Selection) {\n  function TextSelection($anchor, $head) {\n    if ( $head === void 0 ) $head = $anchor;\n\n    Selection.call(this, $anchor, $head);\n  }\n\n  if ( Selection ) TextSelection.__proto__ = Selection;\n  TextSelection.prototype = Object.create( Selection && Selection.prototype );\n  TextSelection.prototype.constructor = TextSelection;\n\n  var prototypeAccessors$1 = { $cursor: { configurable: true } };\n\n  // :: ?ResolvedPos\n  // Returns a resolved position if this is a cursor selection (an\n  // empty text selection), and null otherwise.\n  prototypeAccessors$1.$cursor.get = function () { return this.$anchor.pos == this.$head.pos ? this.$head : null };\n\n  TextSelection.prototype.map = function map (doc, mapping) {\n    var $head = doc.resolve(mapping.map(this.head));\n    if (!$head.parent.inlineContent) { return Selection.near($head) }\n    var $anchor = doc.resolve(mapping.map(this.anchor));\n    return new TextSelection($anchor.parent.inlineContent ? $anchor : $head, $head)\n  };\n\n  TextSelection.prototype.replace = function replace (tr, content) {\n    if ( content === void 0 ) content = Slice.empty;\n\n    Selection.prototype.replace.call(this, tr, content);\n    if (content == Slice.empty) {\n      var marks = this.$from.marksAcross(this.$to);\n      if (marks) { tr.ensureMarks(marks); }\n    }\n  };\n\n  TextSelection.prototype.eq = function eq (other) {\n    return other instanceof TextSelection && other.anchor == this.anchor && other.head == this.head\n  };\n\n  TextSelection.prototype.getBookmark = function getBookmark () {\n    return new TextBookmark(this.anchor, this.head)\n  };\n\n  TextSelection.prototype.toJSON = function toJSON () {\n    return {type: \"text\", anchor: this.anchor, head: this.head}\n  };\n\n  TextSelection.fromJSON = function fromJSON (doc, json) {\n    if (typeof json.anchor != \"number\" || typeof json.head != \"number\")\n      { throw new RangeError(\"Invalid input for TextSelection.fromJSON\") }\n    return new TextSelection(doc.resolve(json.anchor), doc.resolve(json.head))\n  };\n\n  // :: (Node, number, ?number) → TextSelection\n  // Create a text selection from non-resolved positions.\n  TextSelection.create = function create (doc, anchor, head) {\n    if ( head === void 0 ) head = anchor;\n\n    var $anchor = doc.resolve(anchor);\n    return new this($anchor, head == anchor ? $anchor : doc.resolve(head))\n  };\n\n  // :: (ResolvedPos, ResolvedPos, ?number) → Selection\n  // Return a text selection that spans the given positions or, if\n  // they aren't text positions, find a text selection near them.\n  // `bias` determines whether the method searches forward (default)\n  // or backwards (negative number) first. Will fall back to calling\n  // [`Selection.near`](#state.Selection^near) when the document\n  // doesn't contain a valid text position.\n  TextSelection.between = function between ($anchor, $head, bias) {\n    var dPos = $anchor.pos - $head.pos;\n    if (!bias || dPos) { bias = dPos >= 0 ? 1 : -1; }\n    if (!$head.parent.inlineContent) {\n      var found = Selection.findFrom($head, bias, true) || Selection.findFrom($head, -bias, true);\n      if (found) { $head = found.$head; }\n      else { return Selection.near($head, bias) }\n    }\n    if (!$anchor.parent.inlineContent) {\n      if (dPos == 0) {\n        $anchor = $head;\n      } else {\n        $anchor = (Selection.findFrom($anchor, -bias, true) || Selection.findFrom($anchor, bias, true)).$anchor;\n        if (($anchor.pos < $head.pos) != (dPos < 0)) { $anchor = $head; }\n      }\n    }\n    return new TextSelection($anchor, $head)\n  };\n\n  Object.defineProperties( TextSelection.prototype, prototypeAccessors$1 );\n\n  return TextSelection;\n}(Selection));\n\nSelection.jsonID(\"text\", TextSelection);\n\nvar TextBookmark = function TextBookmark(anchor, head) {\n  this.anchor = anchor;\n  this.head = head;\n};\nTextBookmark.prototype.map = function map (mapping) {\n  return new TextBookmark(mapping.map(this.anchor), mapping.map(this.head))\n};\nTextBookmark.prototype.resolve = function resolve (doc) {\n  return TextSelection.between(doc.resolve(this.anchor), doc.resolve(this.head))\n};\n\n// ::- A node selection is a selection that points at a single node.\n// All nodes marked [selectable](#model.NodeSpec.selectable) can be\n// the target of a node selection. In such a selection, `from` and\n// `to` point directly before and after the selected node, `anchor`\n// equals `from`, and `head` equals `to`..\nvar NodeSelection = /*@__PURE__*/(function (Selection) {\n  function NodeSelection($pos) {\n    var node = $pos.nodeAfter;\n    var $end = $pos.node(0).resolve($pos.pos + node.nodeSize);\n    Selection.call(this, $pos, $end);\n    // :: Node The selected node.\n    this.node = node;\n  }\n\n  if ( Selection ) NodeSelection.__proto__ = Selection;\n  NodeSelection.prototype = Object.create( Selection && Selection.prototype );\n  NodeSelection.prototype.constructor = NodeSelection;\n\n  NodeSelection.prototype.map = function map (doc, mapping) {\n    var ref = mapping.mapResult(this.anchor);\n    var deleted = ref.deleted;\n    var pos = ref.pos;\n    var $pos = doc.resolve(pos);\n    if (deleted) { return Selection.near($pos) }\n    return new NodeSelection($pos)\n  };\n\n  NodeSelection.prototype.content = function content () {\n    return new Slice(Fragment.from(this.node), 0, 0)\n  };\n\n  NodeSelection.prototype.eq = function eq (other) {\n    return other instanceof NodeSelection && other.anchor == this.anchor\n  };\n\n  NodeSelection.prototype.toJSON = function toJSON () {\n    return {type: \"node\", anchor: this.anchor}\n  };\n\n  NodeSelection.prototype.getBookmark = function getBookmark () { return new NodeBookmark(this.anchor) };\n\n  NodeSelection.fromJSON = function fromJSON (doc, json) {\n    if (typeof json.anchor != \"number\")\n      { throw new RangeError(\"Invalid input for NodeSelection.fromJSON\") }\n    return new NodeSelection(doc.resolve(json.anchor))\n  };\n\n  // :: (Node, number) → NodeSelection\n  // Create a node selection from non-resolved positions.\n  NodeSelection.create = function create (doc, from) {\n    return new this(doc.resolve(from))\n  };\n\n  // :: (Node) → bool\n  // Determines whether the given node may be selected as a node\n  // selection.\n  NodeSelection.isSelectable = function isSelectable (node) {\n    return !node.isText && node.type.spec.selectable !== false\n  };\n\n  return NodeSelection;\n}(Selection));\n\nNodeSelection.prototype.visible = false;\n\nSelection.jsonID(\"node\", NodeSelection);\n\nvar NodeBookmark = function NodeBookmark(anchor) {\n  this.anchor = anchor;\n};\nNodeBookmark.prototype.map = function map (mapping) {\n  var ref = mapping.mapResult(this.anchor);\n    var deleted = ref.deleted;\n    var pos = ref.pos;\n  return deleted ? new TextBookmark(pos, pos) : new NodeBookmark(pos)\n};\nNodeBookmark.prototype.resolve = function resolve (doc) {\n  var $pos = doc.resolve(this.anchor), node = $pos.nodeAfter;\n  if (node && NodeSelection.isSelectable(node)) { return new NodeSelection($pos) }\n  return Selection.near($pos)\n};\n\n// ::- A selection type that represents selecting the whole document\n// (which can not necessarily be expressed with a text selection, when\n// there are for example leaf block nodes at the start or end of the\n// document).\nvar AllSelection = /*@__PURE__*/(function (Selection) {\n  function AllSelection(doc) {\n    Selection.call(this, doc.resolve(0), doc.resolve(doc.content.size));\n  }\n\n  if ( Selection ) AllSelection.__proto__ = Selection;\n  AllSelection.prototype = Object.create( Selection && Selection.prototype );\n  AllSelection.prototype.constructor = AllSelection;\n\n  AllSelection.prototype.replace = function replace (tr, content) {\n    if ( content === void 0 ) content = Slice.empty;\n\n    if (content == Slice.empty) {\n      tr.delete(0, tr.doc.content.size);\n      var sel = Selection.atStart(tr.doc);\n      if (!sel.eq(tr.selection)) { tr.setSelection(sel); }\n    } else {\n      Selection.prototype.replace.call(this, tr, content);\n    }\n  };\n\n  AllSelection.prototype.toJSON = function toJSON () { return {type: \"all\"} };\n\n  AllSelection.fromJSON = function fromJSON (doc) { return new AllSelection(doc) };\n\n  AllSelection.prototype.map = function map (doc) { return new AllSelection(doc) };\n\n  AllSelection.prototype.eq = function eq (other) { return other instanceof AllSelection };\n\n  AllSelection.prototype.getBookmark = function getBookmark () { return AllBookmark };\n\n  return AllSelection;\n}(Selection));\n\nSelection.jsonID(\"all\", AllSelection);\n\nvar AllBookmark = {\n  map: function map() { return this },\n  resolve: function resolve(doc) { return new AllSelection(doc) }\n};\n\n// FIXME we'll need some awareness of text direction when scanning for selections\n\n// Try to find a selection inside the given node. `pos` points at the\n// position where the search starts. When `text` is true, only return\n// text selections.\nfunction findSelectionIn(doc, node, pos, index, dir, text) {\n  if (node.inlineContent) { return TextSelection.create(doc, pos) }\n  for (var i = index - (dir > 0 ? 0 : 1); dir > 0 ? i < node.childCount : i >= 0; i += dir) {\n    var child = node.child(i);\n    if (!child.isAtom) {\n      var inner = findSelectionIn(doc, child, pos + dir, dir < 0 ? child.childCount : 0, dir, text);\n      if (inner) { return inner }\n    } else if (!text && NodeSelection.isSelectable(child)) {\n      return NodeSelection.create(doc, pos - (dir < 0 ? child.nodeSize : 0))\n    }\n    pos += child.nodeSize * dir;\n  }\n}\n\nfunction selectionToInsertionEnd(tr, startLen, bias) {\n  var last = tr.steps.length - 1;\n  if (last < startLen) { return }\n  var step = tr.steps[last];\n  if (!(step instanceof ReplaceStep || step instanceof ReplaceAroundStep)) { return }\n  var map = tr.mapping.maps[last], end;\n  map.forEach(function (_from, _to, _newFrom, newTo) { if (end == null) { end = newTo; } });\n  tr.setSelection(Selection.near(tr.doc.resolve(end), bias));\n}\n\nvar UPDATED_SEL = 1, UPDATED_MARKS = 2, UPDATED_SCROLL = 4;\n\n// ::- An editor state transaction, which can be applied to a state to\n// create an updated state. Use\n// [`EditorState.tr`](#state.EditorState.tr) to create an instance.\n//\n// Transactions track changes to the document (they are a subclass of\n// [`Transform`](#transform.Transform)), but also other state changes,\n// like selection updates and adjustments of the set of [stored\n// marks](#state.EditorState.storedMarks). In addition, you can store\n// metadata properties in a transaction, which are extra pieces of\n// information that client code or plugins can use to describe what a\n// transacion represents, so that they can update their [own\n// state](#state.StateField) accordingly.\n//\n// The [editor view](#view.EditorView) uses a few metadata properties:\n// it will attach a property `\"pointer\"` with the value `true` to\n// selection transactions directly caused by mouse or touch input, and\n// a `\"uiEvent\"` property of that may be `\"paste\"`, `\"cut\"`, or `\"drop\"`.\nvar Transaction = /*@__PURE__*/(function (Transform) {\n  function Transaction(state) {\n    Transform.call(this, state.doc);\n    // :: number\n    // The timestamp associated with this transaction, in the same\n    // format as `Date.now()`.\n    this.time = Date.now();\n    this.curSelection = state.selection;\n    // The step count for which the current selection is valid.\n    this.curSelectionFor = 0;\n    // :: ?[Mark]\n    // The stored marks set by this transaction, if any.\n    this.storedMarks = state.storedMarks;\n    // Bitfield to track which aspects of the state were updated by\n    // this transaction.\n    this.updated = 0;\n    // Object used to store metadata properties for the transaction.\n    this.meta = Object.create(null);\n  }\n\n  if ( Transform ) Transaction.__proto__ = Transform;\n  Transaction.prototype = Object.create( Transform && Transform.prototype );\n  Transaction.prototype.constructor = Transaction;\n\n  var prototypeAccessors = { selection: { configurable: true },selectionSet: { configurable: true },storedMarksSet: { configurable: true },isGeneric: { configurable: true },scrolledIntoView: { configurable: true } };\n\n  // :: Selection\n  // The transaction's current selection. This defaults to the editor\n  // selection [mapped](#state.Selection.map) through the steps in the\n  // transaction, but can be overwritten with\n  // [`setSelection`](#state.Transaction.setSelection).\n  prototypeAccessors.selection.get = function () {\n    if (this.curSelectionFor < this.steps.length) {\n      this.curSelection = this.curSelection.map(this.doc, this.mapping.slice(this.curSelectionFor));\n      this.curSelectionFor = this.steps.length;\n    }\n    return this.curSelection\n  };\n\n  // :: (Selection) → Transaction\n  // Update the transaction's current selection. Will determine the\n  // selection that the editor gets when the transaction is applied.\n  Transaction.prototype.setSelection = function setSelection (selection) {\n    if (selection.$from.doc != this.doc)\n      { throw new RangeError(\"Selection passed to setSelection must point at the current document\") }\n    this.curSelection = selection;\n    this.curSelectionFor = this.steps.length;\n    this.updated = (this.updated | UPDATED_SEL) & ~UPDATED_MARKS;\n    this.storedMarks = null;\n    return this\n  };\n\n  // :: bool\n  // Whether the selection was explicitly updated by this transaction.\n  prototypeAccessors.selectionSet.get = function () {\n    return (this.updated & UPDATED_SEL) > 0\n  };\n\n  // :: (?[Mark]) → Transaction\n  // Set the current stored marks.\n  Transaction.prototype.setStoredMarks = function setStoredMarks (marks) {\n    this.storedMarks = marks;\n    this.updated |= UPDATED_MARKS;\n    return this\n  };\n\n  // :: ([Mark]) → Transaction\n  // Make sure the current stored marks or, if that is null, the marks\n  // at the selection, match the given set of marks. Does nothing if\n  // this is already the case.\n  Transaction.prototype.ensureMarks = function ensureMarks (marks) {\n    if (!Mark.sameSet(this.storedMarks || this.selection.$from.marks(), marks))\n      { this.setStoredMarks(marks); }\n    return this\n  };\n\n  // :: (Mark) → Transaction\n  // Add a mark to the set of stored marks.\n  Transaction.prototype.addStoredMark = function addStoredMark (mark) {\n    return this.ensureMarks(mark.addToSet(this.storedMarks || this.selection.$head.marks()))\n  };\n\n  // :: (union<Mark, MarkType>) → Transaction\n  // Remove a mark or mark type from the set of stored marks.\n  Transaction.prototype.removeStoredMark = function removeStoredMark (mark) {\n    return this.ensureMarks(mark.removeFromSet(this.storedMarks || this.selection.$head.marks()))\n  };\n\n  // :: bool\n  // Whether the stored marks were explicitly set for this transaction.\n  prototypeAccessors.storedMarksSet.get = function () {\n    return (this.updated & UPDATED_MARKS) > 0\n  };\n\n  Transaction.prototype.addStep = function addStep (step, doc) {\n    Transform.prototype.addStep.call(this, step, doc);\n    this.updated = this.updated & ~UPDATED_MARKS;\n    this.storedMarks = null;\n  };\n\n  // :: (number) → Transaction\n  // Update the timestamp for the transaction.\n  Transaction.prototype.setTime = function setTime (time) {\n    this.time = time;\n    return this\n  };\n\n  // :: (Slice) → Transaction\n  // Replace the current selection with the given slice.\n  Transaction.prototype.replaceSelection = function replaceSelection (slice) {\n    this.selection.replace(this, slice);\n    return this\n  };\n\n  // :: (Node, ?bool) → Transaction\n  // Replace the selection with the given node. When `inheritMarks` is\n  // true and the content is inline, it inherits the marks from the\n  // place where it is inserted.\n  Transaction.prototype.replaceSelectionWith = function replaceSelectionWith (node, inheritMarks) {\n    var selection = this.selection;\n    if (inheritMarks !== false)\n      { node = node.mark(this.storedMarks || (selection.empty ? selection.$from.marks() : (selection.$from.marksAcross(selection.$to) || Mark.none))); }\n    selection.replaceWith(this, node);\n    return this\n  };\n\n  // :: () → Transaction\n  // Delete the selection.\n  Transaction.prototype.deleteSelection = function deleteSelection () {\n    this.selection.replace(this);\n    return this\n  };\n\n  // :: (string, from: ?number, to: ?number) → Transaction\n  // Replace the given range, or the selection if no range is given,\n  // with a text node containing the given string.\n  Transaction.prototype.insertText = function insertText (text, from, to) {\n    if ( to === void 0 ) to = from;\n\n    var schema = this.doc.type.schema;\n    if (from == null) {\n      if (!text) { return this.deleteSelection() }\n      return this.replaceSelectionWith(schema.text(text), true)\n    } else {\n      if (!text) { return this.deleteRange(from, to) }\n      var marks = this.storedMarks;\n      if (!marks) {\n        var $from = this.doc.resolve(from);\n        marks = to == from ? $from.marks() : $from.marksAcross(this.doc.resolve(to));\n      }\n      this.replaceRangeWith(from, to, schema.text(text, marks));\n      if (!this.selection.empty) { this.setSelection(Selection.near(this.selection.$to)); }\n      return this\n    }\n  };\n\n  // :: (union<string, Plugin, PluginKey>, any) → Transaction\n  // Store a metadata property in this transaction, keyed either by\n  // name or by plugin.\n  Transaction.prototype.setMeta = function setMeta (key, value) {\n    this.meta[typeof key == \"string\" ? key : key.key] = value;\n    return this\n  };\n\n  // :: (union<string, Plugin, PluginKey>) → any\n  // Retrieve a metadata property for a given name or plugin.\n  Transaction.prototype.getMeta = function getMeta (key) {\n    return this.meta[typeof key == \"string\" ? key : key.key]\n  };\n\n  // :: bool\n  // Returns true if this transaction doesn't contain any metadata,\n  // and can thus safely be extended.\n  prototypeAccessors.isGeneric.get = function () {\n    for (var _ in this.meta) { return false }\n    return true\n  };\n\n  // :: () → Transaction\n  // Indicate that the editor should scroll the selection into view\n  // when updated to the state produced by this transaction.\n  Transaction.prototype.scrollIntoView = function scrollIntoView () {\n    this.updated |= UPDATED_SCROLL;\n    return this\n  };\n\n  prototypeAccessors.scrolledIntoView.get = function () {\n    return (this.updated & UPDATED_SCROLL) > 0\n  };\n\n  Object.defineProperties( Transaction.prototype, prototypeAccessors );\n\n  return Transaction;\n}(Transform));\n\nfunction bind(f, self) {\n  return !self || !f ? f : f.bind(self)\n}\n\nvar FieldDesc = function FieldDesc(name, desc, self) {\n  this.name = name;\n  this.init = bind(desc.init, self);\n  this.apply = bind(desc.apply, self);\n};\n\nvar baseFields = [\n  new FieldDesc(\"doc\", {\n    init: function init(config) { return config.doc || config.schema.topNodeType.createAndFill() },\n    apply: function apply(tr) { return tr.doc }\n  }),\n\n  new FieldDesc(\"selection\", {\n    init: function init(config, instance) { return config.selection || Selection.atStart(instance.doc) },\n    apply: function apply(tr) { return tr.selection }\n  }),\n\n  new FieldDesc(\"storedMarks\", {\n    init: function init(config) { return config.storedMarks || null },\n    apply: function apply(tr, _marks, _old, state) { return state.selection.$cursor ? tr.storedMarks : null }\n  }),\n\n  new FieldDesc(\"scrollToSelection\", {\n    init: function init() { return 0 },\n    apply: function apply(tr, prev) { return tr.scrolledIntoView ? prev + 1 : prev }\n  })\n];\n\n// Object wrapping the part of a state object that stays the same\n// across transactions. Stored in the state's `config` property.\nvar Configuration = function Configuration(schema, plugins) {\n  var this$1 = this;\n\n  this.schema = schema;\n  this.fields = baseFields.concat();\n  this.plugins = [];\n  this.pluginsByKey = Object.create(null);\n  if (plugins) { plugins.forEach(function (plugin) {\n    if (this$1.pluginsByKey[plugin.key])\n      { throw new RangeError(\"Adding different instances of a keyed plugin (\" + plugin.key + \")\") }\n    this$1.plugins.push(plugin);\n    this$1.pluginsByKey[plugin.key] = plugin;\n    if (plugin.spec.state)\n      { this$1.fields.push(new FieldDesc(plugin.key, plugin.spec.state, plugin)); }\n  }); }\n};\n\n// ::- The state of a ProseMirror editor is represented by an object\n// of this type. A state is a persistent data structure—it isn't\n// updated, but rather a new state value is computed from an old one\n// using the [`apply`](#state.EditorState.apply) method.\n//\n// A state holds a number of built-in fields, and plugins can\n// [define](#state.PluginSpec.state) additional fields.\nvar EditorState = function EditorState(config) {\n  this.config = config;\n};\n\nvar prototypeAccessors$1 = { schema: { configurable: true },plugins: { configurable: true },tr: { configurable: true } };\n\n// doc:: Node\n// The current document.\n\n// selection:: Selection\n// The selection.\n\n// storedMarks:: ?[Mark]\n// A set of marks to apply to the next input. Will be null when\n// no explicit marks have been set.\n\n// :: Schema\n// The schema of the state's document.\nprototypeAccessors$1.schema.get = function () {\n  return this.config.schema\n};\n\n// :: [Plugin]\n// The plugins that are active in this state.\nprototypeAccessors$1.plugins.get = function () {\n  return this.config.plugins\n};\n\n// :: (Transaction) → EditorState\n// Apply the given transaction to produce a new state.\nEditorState.prototype.apply = function apply (tr) {\n  return this.applyTransaction(tr).state\n};\n\n// : (Transaction) → bool\nEditorState.prototype.filterTransaction = function filterTransaction (tr, ignore) {\n    if ( ignore === void 0 ) ignore = -1;\n\n  for (var i = 0; i < this.config.plugins.length; i++) { if (i != ignore) {\n    var plugin = this.config.plugins[i];\n    if (plugin.spec.filterTransaction && !plugin.spec.filterTransaction.call(plugin, tr, this))\n      { return false }\n  } }\n  return true\n};\n\n// :: (Transaction) → {state: EditorState, transactions: [Transaction]}\n// Verbose variant of [`apply`](#state.EditorState.apply) that\n// returns the precise transactions that were applied (which might\n// be influenced by the [transaction\n// hooks](#state.PluginSpec.filterTransaction) of\n// plugins) along with the new state.\nEditorState.prototype.applyTransaction = function applyTransaction (rootTr) {\n  if (!this.filterTransaction(rootTr)) { return {state: this, transactions: []} }\n\n  var trs = [rootTr], newState = this.applyInner(rootTr), seen = null;\n  // This loop repeatedly gives plugins a chance to respond to\n  // transactions as new transactions are added, making sure to only\n  // pass the transactions the plugin did not see before.\n   for (;;) {\n    var haveNew = false;\n    for (var i = 0; i < this.config.plugins.length; i++) {\n      var plugin = this.config.plugins[i];\n      if (plugin.spec.appendTransaction) {\n        var n = seen ? seen[i].n : 0, oldState = seen ? seen[i].state : this;\n        var tr = n < trs.length &&\n            plugin.spec.appendTransaction.call(plugin, n ? trs.slice(n) : trs, oldState, newState);\n        if (tr && newState.filterTransaction(tr, i)) {\n          tr.setMeta(\"appendedTransaction\", rootTr);\n          if (!seen) {\n            seen = [];\n            for (var j = 0; j < this.config.plugins.length; j++)\n              { seen.push(j < i ? {state: newState, n: trs.length} : {state: this, n: 0}); }\n          }\n          trs.push(tr);\n          newState = newState.applyInner(tr);\n          haveNew = true;\n        }\n        if (seen) { seen[i] = {state: newState, n: trs.length}; }\n      }\n    }\n    if (!haveNew) { return {state: newState, transactions: trs} }\n  }\n};\n\n// : (Transaction) → EditorState\nEditorState.prototype.applyInner = function applyInner (tr) {\n  if (!tr.before.eq(this.doc)) { throw new RangeError(\"Applying a mismatched transaction\") }\n  var newInstance = new EditorState(this.config), fields = this.config.fields;\n  for (var i = 0; i < fields.length; i++) {\n    var field = fields[i];\n    newInstance[field.name] = field.apply(tr, this[field.name], this, newInstance);\n  }\n  for (var i$1 = 0; i$1 < applyListeners.length; i$1++) { applyListeners[i$1](this, tr, newInstance); }\n  return newInstance\n};\n\n// :: Transaction\n// Start a [transaction](#state.Transaction) from this state.\nprototypeAccessors$1.tr.get = function () { return new Transaction(this) };\n\n// :: (Object) → EditorState\n// Create a new state.\n//\n// config::- Configuration options. Must contain `schema` or `doc` (or both).\n//\n//    schema:: ?Schema\n//    The schema to use (only relevant if no `doc` is specified).\n//\n//    doc:: ?Node\n//    The starting document.\n//\n//    selection:: ?Selection\n//    A valid selection in the document.\n//\n//    storedMarks:: ?[Mark]\n//    The initial set of [stored marks](#state.EditorState.storedMarks).\n//\n//    plugins:: ?[Plugin]\n//    The plugins that should be active in this state.\nEditorState.create = function create (config) {\n  var $config = new Configuration(config.doc ? config.doc.type.schema : config.schema, config.plugins);\n  var instance = new EditorState($config);\n  for (var i = 0; i < $config.fields.length; i++)\n    { instance[$config.fields[i].name] = $config.fields[i].init(config, instance); }\n  return instance\n};\n\n// :: (Object) → EditorState\n// Create a new state based on this one, but with an adjusted set of\n// active plugins. State fields that exist in both sets of plugins\n// are kept unchanged. Those that no longer exist are dropped, and\n// those that are new are initialized using their\n// [`init`](#state.StateField.init) method, passing in the new\n// configuration object..\n//\n// config::- configuration options\n//\n//   plugins:: [Plugin]\n//   New set of active plugins.\nEditorState.prototype.reconfigure = function reconfigure (config) {\n  var $config = new Configuration(this.schema, config.plugins);\n  var fields = $config.fields, instance = new EditorState($config);\n  for (var i = 0; i < fields.length; i++) {\n    var name = fields[i].name;\n    instance[name] = this.hasOwnProperty(name) ? this[name] : fields[i].init(config, instance);\n  }\n  return instance\n};\n\n// :: (?union<Object<Plugin>, string, number>) → Object\n// Serialize this state to JSON. If you want to serialize the state\n// of plugins, pass an object mapping property names to use in the\n// resulting JSON object to plugin objects. The argument may also be\n// a string or number, in which case it is ignored, to support the\n// way `JSON.stringify` calls `toString` methods.\nEditorState.prototype.toJSON = function toJSON (pluginFields) {\n  var result = {doc: this.doc.toJSON(), selection: this.selection.toJSON()};\n  if (this.storedMarks) { result.storedMarks = this.storedMarks.map(function (m) { return m.toJSON(); }); }\n  if (pluginFields && typeof pluginFields == 'object') { for (var prop in pluginFields) {\n    if (prop == \"doc\" || prop == \"selection\")\n      { throw new RangeError(\"The JSON fields `doc` and `selection` are reserved\") }\n    var plugin = pluginFields[prop], state = plugin.spec.state;\n    if (state && state.toJSON) { result[prop] = state.toJSON.call(plugin, this[plugin.key]); }\n  } }\n  return result\n};\n\n// :: (Object, Object, ?Object<Plugin>) → EditorState\n// Deserialize a JSON representation of a state. `config` should\n// have at least a `schema` field, and should contain array of\n// plugins to initialize the state with. `pluginFields` can be used\n// to deserialize the state of plugins, by associating plugin\n// instances with the property names they use in the JSON object.\n//\n// config::- configuration options\n//\n//   schema:: Schema\n//   The schema to use.\n//\n//   plugins:: ?[Plugin]\n//   The set of active plugins.\nEditorState.fromJSON = function fromJSON (config, json, pluginFields) {\n  if (!json) { throw new RangeError(\"Invalid input for EditorState.fromJSON\") }\n  if (!config.schema) { throw new RangeError(\"Required config field 'schema' missing\") }\n  var $config = new Configuration(config.schema, config.plugins);\n  var instance = new EditorState($config);\n  $config.fields.forEach(function (field) {\n    if (field.name == \"doc\") {\n      instance.doc = Node.fromJSON(config.schema, json.doc);\n    } else if (field.name == \"selection\") {\n      instance.selection = Selection.fromJSON(instance.doc, json.selection);\n    } else if (field.name == \"storedMarks\") {\n      if (json.storedMarks) { instance.storedMarks = json.storedMarks.map(config.schema.markFromJSON); }\n    } else {\n      if (pluginFields) { for (var prop in pluginFields) {\n        var plugin = pluginFields[prop], state = plugin.spec.state;\n        if (plugin.key == field.name && state && state.fromJSON &&\n            Object.prototype.hasOwnProperty.call(json, prop)) {\n          // This field belongs to a plugin mapped to a JSON field, read it from there.\n          instance[field.name] = state.fromJSON.call(plugin, config, json[prop], instance);\n          return\n        }\n      } }\n      instance[field.name] = field.init(config, instance);\n    }\n  });\n  return instance\n};\n\n// Kludge to allow the view to track mappings between different\n// instances of a state.\n//\n// FIXME this is no longer needed as of prosemirror-view 1.9.0,\n// though due to backwards-compat we should probably keep it around\n// for a while (if only as a no-op)\nEditorState.addApplyListener = function addApplyListener (f) {\n  applyListeners.push(f);\n};\nEditorState.removeApplyListener = function removeApplyListener (f) {\n  var found = applyListeners.indexOf(f);\n  if (found > -1) { applyListeners.splice(found, 1); }\n};\n\nObject.defineProperties( EditorState.prototype, prototypeAccessors$1 );\n\nvar applyListeners = [];\n\n// PluginSpec:: interface\n//\n// This is the type passed to the [`Plugin`](#state.Plugin)\n// constructor. It provides a definition for a plugin.\n//\n//   props:: ?EditorProps\n//   The [view props](#view.EditorProps) added by this plugin. Props\n//   that are functions will be bound to have the plugin instance as\n//   their `this` binding.\n//\n//   state:: ?StateField<any>\n//   Allows a plugin to define a [state field](#state.StateField), an\n//   extra slot in the state object in which it can keep its own data.\n//\n//   key:: ?PluginKey\n//   Can be used to make this a keyed plugin. You can have only one\n//   plugin with a given key in a given state, but it is possible to\n//   access the plugin's configuration and state through the key,\n//   without having access to the plugin instance object.\n//\n//   view:: ?(EditorView) → Object\n//   When the plugin needs to interact with the editor view, or\n//   set something up in the DOM, use this field. The function\n//   will be called when the plugin's state is associated with an\n//   editor view.\n//\n//     return::-\n//     Should return an object with the following optional\n//     properties:\n//\n//       update:: ?(view: EditorView, prevState: EditorState)\n//       Called whenever the view's state is updated.\n//\n//       destroy:: ?()\n//       Called when the view is destroyed or receives a state\n//       with different plugins.\n//\n//   filterTransaction:: ?(Transaction, EditorState) → bool\n//   When present, this will be called before a transaction is\n//   applied by the state, allowing the plugin to cancel it (by\n//   returning false).\n//\n//   appendTransaction:: ?(transactions: [Transaction], oldState: EditorState, newState: EditorState) → ?Transaction\n//   Allows the plugin to append another transaction to be applied\n//   after the given array of transactions. When another plugin\n//   appends a transaction after this was called, it is called again\n//   with the new state and new transactions—but only the new\n//   transactions, i.e. it won't be passed transactions that it\n//   already saw.\n\nfunction bindProps(obj, self, target) {\n  for (var prop in obj) {\n    var val = obj[prop];\n    if (val instanceof Function) { val = val.bind(self); }\n    else if (prop == \"handleDOMEvents\") { val = bindProps(val, self, {}); }\n    target[prop] = val;\n  }\n  return target\n}\n\n// ::- Plugins bundle functionality that can be added to an editor.\n// They are part of the [editor state](#state.EditorState) and\n// may influence that state and the view that contains it.\nvar Plugin = function Plugin(spec) {\n  // :: EditorProps\n  // The [props](#view.EditorProps) exported by this plugin.\n  this.props = {};\n  if (spec.props) { bindProps(spec.props, this, this.props); }\n  // :: Object\n  // The plugin's [spec object](#state.PluginSpec).\n  this.spec = spec;\n  this.key = spec.key ? spec.key.key : createKey(\"plugin\");\n};\n\n// :: (EditorState) → any\n// Extract the plugin's state field from an editor state.\nPlugin.prototype.getState = function getState (state) { return state[this.key] };\n\n// StateField:: interface<T>\n// A plugin spec may provide a state field (under its\n// [`state`](#state.PluginSpec.state) property) of this type, which\n// describes the state it wants to keep. Functions provided here are\n// always called with the plugin instance as their `this` binding.\n//\n//   init:: (config: Object, instance: EditorState) → T\n//   Initialize the value of the field. `config` will be the object\n//   passed to [`EditorState.create`](#state.EditorState^create). Note\n//   that `instance` is a half-initialized state instance, and will\n//   not have values for plugin fields initialized after this one.\n//\n//   apply:: (tr: Transaction, value: T, oldState: EditorState, newState: EditorState) → T\n//   Apply the given transaction to this state field, producing a new\n//   field value. Note that the `newState` argument is again a partially\n//   constructed state does not yet contain the state from plugins\n//   coming after this one.\n//\n//   toJSON:: ?(value: T) → *\n//   Convert this field to JSON. Optional, can be left off to disable\n//   JSON serialization for the field.\n//\n//   fromJSON:: ?(config: Object, value: *, state: EditorState) → T\n//   Deserialize the JSON representation of this field. Note that the\n//   `state` argument is again a half-initialized state.\n\nvar keys = Object.create(null);\n\nfunction createKey(name) {\n  if (name in keys) { return name + \"$\" + ++keys[name] }\n  keys[name] = 0;\n  return name + \"$\"\n}\n\n// ::- A key is used to [tag](#state.PluginSpec.key)\n// plugins in a way that makes it possible to find them, given an\n// editor state. Assigning a key does mean only one plugin of that\n// type can be active in a state.\nvar PluginKey = function PluginKey(name) {\nif ( name === void 0 ) name = \"key\";\n this.key = createKey(name); };\n\n// :: (EditorState) → ?Plugin\n// Get the active plugin with this key, if any, from an editor\n// state.\nPluginKey.prototype.get = function get (state) { return state.config.pluginsByKey[this.key] };\n\n// :: (EditorState) → ?any\n// Get the plugin's state from an editor state.\nPluginKey.prototype.getState = function getState (state) { return state[this.key] };\n\nexport { AllSelection, EditorState, NodeSelection, Plugin, PluginKey, Selection, SelectionRange, TextSelection, Transaction };\n//# sourceMappingURL=index.es.js.map\n","import { PluginKey, TextSelection, Selection, SelectionRange, NodeSelection, Plugin } from 'prosemirror-state';\nimport { Fragment, Slice } from 'prosemirror-model';\nimport { keydownHandler } from 'prosemirror-keymap';\nimport { Decoration, DecorationSet } from 'prosemirror-view';\nimport { Transform } from 'prosemirror-transform';\n\n// Because working with row and column-spanning cells is not quite\n// trivial, this code builds up a descriptive structure for a given\n// table node. The structures are cached with the (persistent) table\n// nodes as key, so that they only have to be recomputed when the\n// content of the table changes.\n//\n// This does mean that they have to store table-relative, not\n// document-relative positions. So code that uses them will typically\n// compute the start position of the table and offset positions passed\n// to or gotten from this structure by that amount.\n\nvar readFromCache, addToCache;\n// Prefer using a weak map to cache table maps. Fall back on a\n// fixed-size cache if that's not supported.\nif (typeof WeakMap != \"undefined\") {\n  var cache = new WeakMap;\n  readFromCache = function (key) { return cache.get(key); };\n  addToCache = function (key, value) {\n    cache.set(key, value);\n    return value\n  };\n} else {\n  var cache$1 = [], cacheSize = 10, cachePos = 0;\n  readFromCache = function (key) {\n    for (var i = 0; i < cache$1.length; i += 2)\n      { if (cache$1[i] == key) { return cache$1[i + 1] } }\n  };\n  addToCache = function (key, value) {\n    if (cachePos == cacheSize) { cachePos = 0; }\n    cache$1[cachePos++] = key;\n    return cache$1[cachePos++] = value\n  };\n}\n\nvar Rect = function Rect(left, top, right, bottom) {\n  this.left = left; this.top = top; this.right = right; this.bottom = bottom;\n};\n\n// ::- A table map describes the structore of a given table. To avoid\n// recomputing them all the time, they are cached per table node. To\n// be able to do that, positions saved in the map are relative to the\n// start of the table, rather than the start of the document.\nvar TableMap = function TableMap(width, height, map, problems) {\n  // :: number The width of the table\n  this.width = width;\n  // :: number The table's height\n  this.height = height;\n  // :: [number] A width * height array with the start position of\n  // the cell covering that part of the table in each slot\n  this.map = map;\n  // An optional array of problems (cell overlap or non-rectangular\n  // shape) for the table, used by the table normalizer.\n  this.problems = problems;\n};\n\n// :: (number) → Rect\n// Find the dimensions of the cell at the given position.\nTableMap.prototype.findCell = function findCell (pos) {\n  for (var i = 0; i < this.map.length; i++) {\n    var curPos = this.map[i];\n    if (curPos != pos) { continue }\n    var left = i % this.width, top = (i / this.width) | 0;\n    var right = left + 1, bottom = top + 1;\n    for (var j = 1; right < this.width && this.map[i + j] == curPos; j++) { right++; }\n    for (var j$1 = 1; bottom < this.height && this.map[i + (this.width * j$1)] == curPos; j$1++) { bottom++; }\n    return new Rect(left, top, right, bottom)\n  }\n  throw new RangeError(\"No cell with offset \" + pos + \" found\")\n};\n\n// :: (number) → number\n// Find the left side of the cell at the given position.\nTableMap.prototype.colCount = function colCount (pos) {\n  for (var i = 0; i < this.map.length; i++)\n    { if (this.map[i] == pos) { return i % this.width } }\n  throw new RangeError(\"No cell with offset \" + pos + \" found\")\n};\n\n// :: (number, string, number) → ?number\n// Find the next cell in the given direction, starting from the cell\n// at `pos`, if any.\nTableMap.prototype.nextCell = function nextCell (pos, axis, dir) {\n  var ref = this.findCell(pos);\n    var left = ref.left;\n    var right = ref.right;\n    var top = ref.top;\n    var bottom = ref.bottom;\n  if (axis == \"horiz\") {\n    if (dir < 0 ? left == 0 : right == this.width) { return null }\n    return this.map[top * this.width + (dir < 0 ? left - 1 : right)]\n  } else {\n    if (dir < 0 ? top == 0 : bottom == this.height) { return null }\n    return this.map[left + this.width * (dir < 0 ? top - 1 : bottom)]\n  }\n};\n\n// :: (number, number) → Rect\n// Get the rectangle spanning the two given cells.\nTableMap.prototype.rectBetween = function rectBetween (a, b) {\n  var ref = this.findCell(a);\n    var leftA = ref.left;\n    var rightA = ref.right;\n    var topA = ref.top;\n    var bottomA = ref.bottom;\n  var ref$1 = this.findCell(b);\n    var leftB = ref$1.left;\n    var rightB = ref$1.right;\n    var topB = ref$1.top;\n    var bottomB = ref$1.bottom;\n  return new Rect(Math.min(leftA, leftB), Math.min(topA, topB),\n                  Math.max(rightA, rightB), Math.max(bottomA, bottomB))\n};\n\n// :: (Rect) → [number]\n// Return the position of all cells that have the top left corner in\n// the given rectangle.\nTableMap.prototype.cellsInRect = function cellsInRect (rect) {\n  var result = [], seen = {};\n  for (var row = rect.top; row < rect.bottom; row++) {\n    for (var col = rect.left; col < rect.right; col++) {\n      var index = row * this.width + col, pos = this.map[index];\n      if (seen[pos]) { continue }\n      seen[pos] = true;\n      if ((col != rect.left || !col || this.map[index - 1] != pos) &&\n          (row != rect.top || !row || this.map[index - this.width] != pos))\n        { result.push(pos); }\n    }\n  }\n  return result\n};\n\n// :: (number, number, Node) → number\n// Return the position at which the cell at the given row and column\n// starts, or would start, if a cell started there.\nTableMap.prototype.positionAt = function positionAt (row, col, table) {\n  for (var i = 0, rowStart = 0;; i++) {\n    var rowEnd = rowStart + table.child(i).nodeSize;\n    if (i == row) {\n      var index = col + row * this.width, rowEndIndex = (row + 1) * this.width;\n      // Skip past cells from previous rows (via rowspan)\n      while (index < rowEndIndex && this.map[index] < rowStart) { index++; }\n      return index == rowEndIndex ? rowEnd - 1 : this.map[index]\n    }\n    rowStart = rowEnd;\n  }\n};\n\n// :: (Node) → TableMap\n// Find the table map for the given table node.\nTableMap.get = function get (table) {\n  return readFromCache(table) || addToCache(table, computeMap(table))\n};\n\n// Compute a table map.\nfunction computeMap(table) {\n  if (table.type.spec.tableRole != \"table\") { throw new RangeError(\"Not a table node: \" + table.type.name) }\n  var width = findWidth(table), height = table.childCount;\n  var map = [], mapPos = 0, problems = null, colWidths = [];\n  for (var i = 0, e = width * height; i < e; i++) { map[i] = 0; }\n\n  for (var row = 0, pos = 0; row < height; row++) {\n    var rowNode = table.child(row);\n    pos++;\n    for (var i$1 = 0;; i$1++) {\n      while (mapPos < map.length && map[mapPos] != 0) { mapPos++; }\n      if (i$1 == rowNode.childCount) { break }\n      var cellNode = rowNode.child(i$1);\n      var ref = cellNode.attrs;\n      var colspan = ref.colspan;\n      var rowspan = ref.rowspan;\n      var colwidth = ref.colwidth;\n      for (var h = 0; h < rowspan; h++) {\n        if (h + row >= height) {\n          (problems || (problems = [])).push({type: \"overlong_rowspan\", pos: pos, n: rowspan - h});\n          break\n        }\n        var start = mapPos + (h * width);\n        for (var w = 0; w < colspan; w++) {\n          if (map[start + w] == 0)\n            { map[start + w] = pos; }\n          else\n            { (problems || (problems = [])).push({type: \"collision\", row: row, pos: pos, n: colspan - w}); }\n          var colW = colwidth && colwidth[w];\n          if (colW) {\n            var widthIndex = ((start + w) % width) * 2, prev = colWidths[widthIndex];\n            if (prev == null || (prev != colW && colWidths[widthIndex + 1] == 1)) {\n              colWidths[widthIndex] = colW;\n              colWidths[widthIndex + 1] = 1;\n            } else if (prev == colW) {\n              colWidths[widthIndex + 1]++;\n            }\n          }\n        }\n      }\n      mapPos += colspan;\n      pos += cellNode.nodeSize;\n    }\n    var expectedPos = (row + 1) * width, missing = 0;\n    while (mapPos < expectedPos) { if (map[mapPos++] == 0) { missing++; } }\n    if (missing) { (problems || (problems = [])).push({type: \"missing\", row: row, n: missing}); }\n    pos++;\n  }\n\n  var tableMap = new TableMap(width, height, map, problems), badWidths = false;\n\n  // For columns that have defined widths, but whose widths disagree\n  // between rows, fix up the cells whose width doesn't match the\n  // computed one.\n  for (var i$2 = 0; !badWidths && i$2 < colWidths.length; i$2 += 2)\n    { if (colWidths[i$2] != null && colWidths[i$2 + 1] < height) { badWidths = true; } }\n  if (badWidths) { findBadColWidths(tableMap, colWidths, table); }\n\n  return tableMap\n}\n\nfunction findWidth(table) {\n  var width = -1, hasRowSpan = false;\n  for (var row = 0; row < table.childCount; row++) {\n    var rowNode = table.child(row), rowWidth = 0;\n    if (hasRowSpan) { for (var j = 0; j < row; j++) {\n      var prevRow = table.child(j);\n      for (var i = 0; i < prevRow.childCount; i++) {\n        var cell = prevRow.child(i);\n        if (j + cell.attrs.rowspan > row) { rowWidth += cell.attrs.colspan; }\n      }\n    } }\n    for (var i$1 = 0; i$1 < rowNode.childCount; i$1++) {\n      var cell$1 = rowNode.child(i$1);\n      rowWidth += cell$1.attrs.colspan;\n      if (cell$1.attrs.rowspan > 1) { hasRowSpan = true; }\n    }\n    if (width == -1)\n      { width = rowWidth; }\n    else if (width != rowWidth)\n      { width = Math.max(width, rowWidth); }\n  }\n  return width\n}\n\nfunction findBadColWidths(map, colWidths, table) {\n  if (!map.problems) { map.problems = []; }\n  for (var i = 0, seen = {}; i < map.map.length; i++) {\n    var pos = map.map[i];\n    if (seen[pos]) { continue }\n    seen[pos] = true;\n    var node = table.nodeAt(pos), updated = null;\n    for (var j = 0; j < node.attrs.colspan; j++) {\n      var col = (i + j) % map.width, colWidth = colWidths[col * 2];\n      if (colWidth != null && (!node.attrs.colwidth || node.attrs.colwidth[j] != colWidth))\n        { (updated || (updated = freshColWidth(node.attrs)))[j] = colWidth; }\n    }\n    if (updated) { map.problems.unshift({type: \"colwidth mismatch\", pos: pos, colwidth: updated}); }\n  }\n}\n\nfunction freshColWidth(attrs) {\n  if (attrs.colwidth) { return attrs.colwidth.slice() }\n  var result = [];\n  for (var i = 0; i < attrs.colspan; i++) { result.push(0); }\n  return result\n}\n\n// Helper for creating a schema that supports tables.\n\nfunction getCellAttrs(dom, extraAttrs) {\n  var widthAttr = dom.getAttribute(\"data-colwidth\");\n  var widths = widthAttr && /^\\d+(,\\d+)*$/.test(widthAttr) ? widthAttr.split(\",\").map(function (s) { return Number(s); }) : null;\n  var colspan = Number(dom.getAttribute(\"colspan\") || 1);\n  var result = {\n    colspan: colspan,\n    rowspan: Number(dom.getAttribute(\"rowspan\") || 1),\n    colwidth: widths && widths.length == colspan ? widths : null\n  };\n  for (var prop in extraAttrs) {\n    var getter = extraAttrs[prop].getFromDOM;\n    var value = getter && getter(dom);\n    if (value != null) { result[prop] = value; }\n  }\n  return result\n}\n\nfunction setCellAttrs(node, extraAttrs) {\n  var attrs = {};\n  if (node.attrs.colspan != 1) { attrs.colspan = node.attrs.colspan; }\n  if (node.attrs.rowspan != 1) { attrs.rowspan = node.attrs.rowspan; }\n  if (node.attrs.colwidth)\n    { attrs[\"data-colwidth\"] = node.attrs.colwidth.join(\",\"); }\n  for (var prop in extraAttrs) {\n    var setter = extraAttrs[prop].setDOMAttr;\n    if (setter) { setter(node.attrs[prop], attrs); }\n  }\n  return attrs\n}\n\n// :: (Object) → Object\n//\n// This function creates a set of [node\n// specs](http://prosemirror.net/docs/ref/#model.SchemaSpec.nodes) for\n// `table`, `table_row`, and `table_cell` nodes types as used by this\n// module. The result can then be added to the set of nodes when\n// creating a a schema.\n//\n//   options::- The following options are understood:\n//\n//     tableGroup:: ?string\n//     A group name (something like `\"block\"`) to add to the table\n//     node type.\n//\n//     cellContent:: string\n//     The content expression for table cells.\n//\n//     cellAttributes:: ?Object\n//     Additional attributes to add to cells. Maps attribute names to\n//     objects with the following properties:\n//\n//       default:: any\n//       The attribute's default value.\n//\n//       getFromDOM:: ?(dom.Node) → any\n//       A function to read the attribute's value from a DOM node.\n//\n//       setDOMAttr:: ?(value: any, attrs: Object)\n//       A function to add the attribute's value to an attribute\n//       object that's used to render the cell's DOM.\nfunction tableNodes(options) {\n  var extraAttrs = options.cellAttributes || {};\n  var cellAttrs = {\n    colspan: {default: 1},\n    rowspan: {default: 1},\n    colwidth: {default: null}\n  };\n  for (var prop in extraAttrs)\n    { cellAttrs[prop] = {default: extraAttrs[prop].default}; }\n\n  return {\n    table: {\n      content: \"table_row+\",\n      tableRole: \"table\",\n      isolating: true,\n      group: options.tableGroup,\n      parseDOM: [{tag: \"table\"}],\n      toDOM: function toDOM() { return [\"table\", [\"tbody\", 0]] }\n    },\n    table_row: {\n      content: \"(table_cell | table_header)*\",\n      tableRole: \"row\",\n      parseDOM: [{tag: \"tr\"}],\n      toDOM: function toDOM() { return [\"tr\", 0] }\n    },\n    table_cell: {\n      content: options.cellContent,\n      attrs: cellAttrs,\n      tableRole: \"cell\",\n      isolating: true,\n      parseDOM: [{tag: \"td\", getAttrs: function (dom) { return getCellAttrs(dom, extraAttrs); }}],\n      toDOM: function toDOM(node) { return [\"td\", setCellAttrs(node, extraAttrs), 0] }\n    },\n    table_header: {\n      content: options.cellContent,\n      attrs: cellAttrs,\n      tableRole: \"header_cell\",\n      isolating: true,\n      parseDOM: [{tag: \"th\", getAttrs: function (dom) { return getCellAttrs(dom, extraAttrs); }}],\n      toDOM: function toDOM(node) { return [\"th\", setCellAttrs(node, extraAttrs), 0] }\n    }\n  }\n}\n\nfunction tableNodeTypes(schema) {\n  var result = schema.cached.tableNodeTypes;\n  if (!result) {\n    result = schema.cached.tableNodeTypes = {};\n    for (var name in schema.nodes) {\n      var type = schema.nodes[name], role = type.spec.tableRole;\n      if (role) { result[role] = type; }\n    }\n  }\n  return result\n}\n\n// Various helper function for working with tables\n\nvar key = new PluginKey(\"selectingCells\");\n\nfunction cellAround($pos) {\n  for (var d = $pos.depth - 1; d > 0; d--)\n    { if ($pos.node(d).type.spec.tableRole == \"row\") { return $pos.node(0).resolve($pos.before(d + 1)) } }\n  return null\n}\n\nfunction cellWrapping($pos) {\n  for (var d = $pos.depth; d > 0; d--) { // Sometimes the cell can be in the same depth.\n    var role = $pos.node(d).type.spec.tableRole;\n    if (role === \"cell\" || role === 'header_cell') { return $pos.node(d) }\n  }\n  return null\n}\n\nfunction isInTable(state) {\n  var $head = state.selection.$head;\n  for (var d = $head.depth; d > 0; d--) { if ($head.node(d).type.spec.tableRole == \"row\") { return true } }\n  return false\n}\n\nfunction selectionCell(state) {\n  var sel = state.selection;\n  if (sel.$anchorCell) {\n    return sel.$anchorCell.pos > sel.$headCell.pos ? sel.$anchorCell : sel.$headCell;\n  } else if (sel.node && sel.node.type.spec.tableRole == \"cell\") {\n    return sel.$anchor\n  }\n  return cellAround(sel.$head) || cellNear(sel.$head)\n}\n\nfunction cellNear($pos) {\n  for (var after = $pos.nodeAfter, pos = $pos.pos; after; after = after.firstChild, pos++) {\n    var role = after.type.spec.tableRole;\n    if (role == \"cell\" || role == \"header_cell\") { return $pos.doc.resolve(pos) }\n  }\n  for (var before = $pos.nodeBefore, pos$1 = $pos.pos; before; before = before.lastChild, pos$1--) {\n    var role$1 = before.type.spec.tableRole;\n    if (role$1 == \"cell\" || role$1 == \"header_cell\") { return $pos.doc.resolve(pos$1 - before.nodeSize) }\n  }\n}\n\nfunction pointsAtCell($pos) {\n  return $pos.parent.type.spec.tableRole == \"row\" && $pos.nodeAfter\n}\n\nfunction moveCellForward($pos) {\n  return $pos.node(0).resolve($pos.pos + $pos.nodeAfter.nodeSize)\n}\n\nfunction inSameTable($a, $b) {\n  return $a.depth == $b.depth && $a.pos >= $b.start(-1) && $a.pos <= $b.end(-1)\n}\n\nfunction findCell($pos) {\n  return TableMap.get($pos.node(-1)).findCell($pos.pos - $pos.start(-1))\n}\n\nfunction colCount($pos) {\n  return TableMap.get($pos.node(-1)).colCount($pos.pos - $pos.start(-1))\n}\n\nfunction nextCell($pos, axis, dir) {\n  var start = $pos.start(-1), map = TableMap.get($pos.node(-1));\n  var moved = map.nextCell($pos.pos - start, axis, dir);\n  return moved == null ? null : $pos.node(0).resolve(start + moved)\n}\n\nfunction setAttr(attrs, name, value) {\n  var result = {};\n  for (var prop in attrs) { result[prop] = attrs[prop]; }\n  result[name] = value;\n  return result\n}\n\nfunction removeColSpan(attrs, pos, n) {\n  if ( n === void 0 ) n=1;\n\n  var result = setAttr(attrs, \"colspan\", attrs.colspan - n);\n  if (result.colwidth) {\n    result.colwidth = result.colwidth.slice();\n    result.colwidth.splice(pos, n);\n    if (!result.colwidth.some(function (w) { return w > 0; })) { result.colwidth = null; }\n  }\n  return result\n}\n\nfunction addColSpan(attrs, pos, n) {\n  if ( n === void 0 ) n=1;\n\n  var result = setAttr(attrs, \"colspan\", attrs.colspan + n);\n  if (result.colwidth) {\n    result.colwidth = result.colwidth.slice();\n    for (var i = 0; i < n; i++) { result.colwidth.splice(pos, 0, 0); }\n  }\n  return result\n}\n\nfunction columnIsHeader(map, table, col) {\n  var headerCell = tableNodeTypes(table.type.schema).header_cell;\n  for (var row = 0; row < map.height; row++)\n    { if (table.nodeAt(map.map[col + row * map.width]).type != headerCell)\n      { return false } }\n  return true\n}\n\n// This file defines a ProseMirror selection subclass that models\n\n// ::- A [`Selection`](http://prosemirror.net/docs/ref/#state.Selection)\n// subclass that represents a cell selection spanning part of a table.\n// With the plugin enabled, these will be created when the user\n// selects across cells, and will be drawn by giving selected cells a\n// `selectedCell` CSS class.\nvar CellSelection = /*@__PURE__*/(function (Selection) {\n  function CellSelection($anchorCell, $headCell) {\n    if ( $headCell === void 0 ) $headCell = $anchorCell;\n\n    var table = $anchorCell.node(-1), map = TableMap.get(table), start = $anchorCell.start(-1);\n    var rect = map.rectBetween($anchorCell.pos - start, $headCell.pos - start);\n    var doc = $anchorCell.node(0);\n    var cells = map.cellsInRect(rect).filter(function (p) { return p != $headCell.pos - start; });\n    // Make the head cell the first range, so that it counts as the\n    // primary part of the selection\n    cells.unshift($headCell.pos - start);\n    var ranges = cells.map(function (pos) {\n      var cell = table.nodeAt(pos), from = pos + start + 1;\n      return new SelectionRange(doc.resolve(from), doc.resolve(from + cell.content.size))\n    });\n    Selection.call(this, ranges[0].$from, ranges[0].$to, ranges);\n    // :: ResolvedPos\n    // A resolved position pointing _in front of_ the anchor cell (the one\n    // that doesn't move when extending the selection).\n    this.$anchorCell = $anchorCell;\n    // :: ResolvedPos\n    // A resolved position pointing in front of the head cell (the one\n    // moves when extending the selection).\n    this.$headCell = $headCell;\n  }\n\n  if ( Selection ) CellSelection.__proto__ = Selection;\n  CellSelection.prototype = Object.create( Selection && Selection.prototype );\n  CellSelection.prototype.constructor = CellSelection;\n\n  CellSelection.prototype.map = function map (doc, mapping) {\n    var $anchorCell = doc.resolve(mapping.map(this.$anchorCell.pos));\n    var $headCell = doc.resolve(mapping.map(this.$headCell.pos));\n    if (pointsAtCell($anchorCell) && pointsAtCell($headCell) && inSameTable($anchorCell, $headCell)) {\n      var tableChanged = this.$anchorCell.node(-1) != $anchorCell.node(-1);\n      if (tableChanged && this.isRowSelection())\n        { return CellSelection.rowSelection($anchorCell, $headCell) }\n      else if (tableChanged && this.isColSelection())\n        { return CellSelection.colSelection($anchorCell, $headCell) }\n      else\n        { return new CellSelection($anchorCell, $headCell) }\n    }\n    return TextSelection.between($anchorCell, $headCell)\n  };\n\n  // :: () → Slice\n  // Returns a rectangular slice of table rows containing the selected\n  // cells.\n  CellSelection.prototype.content = function content () {\n    var table = this.$anchorCell.node(-1), map = TableMap.get(table), start = this.$anchorCell.start(-1);\n    var rect = map.rectBetween(this.$anchorCell.pos - start, this.$headCell.pos - start);\n    var seen = {}, rows = [];\n    for (var row = rect.top; row < rect.bottom; row++) {\n      var rowContent = [];\n      for (var index = row * map.width + rect.left, col = rect.left; col < rect.right; col++, index++) {\n        var pos = map.map[index];\n        if (!seen[pos]) {\n          seen[pos] = true;\n          var cellRect = map.findCell(pos), cell = table.nodeAt(pos);\n          var extraLeft = rect.left - cellRect.left, extraRight = cellRect.right - rect.right;\n          if (extraLeft > 0 || extraRight > 0) {\n            var attrs = cell.attrs;\n            if (extraLeft > 0) { attrs = removeColSpan(attrs, 0, extraLeft); }\n            if (extraRight > 0) { attrs = removeColSpan(attrs, attrs.colspan - extraRight, extraRight); }\n            if (cellRect.left < rect.left) { cell = cell.type.createAndFill(attrs); }\n            else { cell = cell.type.create(attrs, cell.content); }\n          }\n          if (cellRect.top < rect.top || cellRect.bottom > rect.bottom) {\n            var attrs$1 = setAttr(cell.attrs, \"rowspan\", Math.min(cellRect.bottom, rect.bottom) - Math.max(cellRect.top, rect.top));\n            if (cellRect.top < rect.top) { cell = cell.type.createAndFill(attrs$1); }\n            else { cell = cell.type.create(attrs$1, cell.content); }\n          }\n          rowContent.push(cell);\n        }\n      }\n      rows.push(table.child(row).copy(Fragment.from(rowContent)));\n    }\n\n    var fragment = this.isColSelection() && this.isRowSelection() ? table : rows;\n    return new Slice(Fragment.from(fragment), 1, 1)\n  };\n\n  CellSelection.prototype.replace = function replace (tr, content) {\n    if ( content === void 0 ) content = Slice.empty;\n\n    var mapFrom = tr.steps.length, ranges = this.ranges;\n    for (var i = 0; i < ranges.length; i++) {\n      var ref = ranges[i];\n      var $from = ref.$from;\n      var $to = ref.$to;\n      var mapping = tr.mapping.slice(mapFrom);\n      tr.replace(mapping.map($from.pos), mapping.map($to.pos), i ? Slice.empty : content);\n    }\n    var sel = Selection.findFrom(tr.doc.resolve(tr.mapping.slice(mapFrom).map(this.to)), -1);\n    if (sel) { tr.setSelection(sel); }\n  };\n\n  CellSelection.prototype.replaceWith = function replaceWith (tr, node) {\n    this.replace(tr, new Slice(Fragment.from(node), 0, 0));\n  };\n\n  CellSelection.prototype.forEachCell = function forEachCell (f) {\n    var table = this.$anchorCell.node(-1), map = TableMap.get(table), start = this.$anchorCell.start(-1);\n    var cells = map.cellsInRect(map.rectBetween(this.$anchorCell.pos - start, this.$headCell.pos - start));\n    for (var i = 0; i < cells.length; i++)\n      { f(table.nodeAt(cells[i]), start + cells[i]); }\n  };\n\n  // :: () → bool\n  // True if this selection goes all the way from the top to the\n  // bottom of the table.\n  CellSelection.prototype.isColSelection = function isColSelection () {\n    var anchorTop = this.$anchorCell.index(-1), headTop = this.$headCell.index(-1);\n    if (Math.min(anchorTop, headTop) > 0) { return false }\n    var anchorBot = anchorTop + this.$anchorCell.nodeAfter.attrs.rowspan,\n        headBot = headTop + this.$headCell.nodeAfter.attrs.rowspan;\n    return Math.max(anchorBot, headBot) == this.$headCell.node(-1).childCount\n  };\n\n  // :: (ResolvedPos, ?ResolvedPos) → CellSelection\n  // Returns the smallest column selection that covers the given anchor\n  // and head cell.\n  CellSelection.colSelection = function colSelection ($anchorCell, $headCell) {\n    if ( $headCell === void 0 ) $headCell = $anchorCell;\n\n    var map = TableMap.get($anchorCell.node(-1)), start = $anchorCell.start(-1);\n    var anchorRect = map.findCell($anchorCell.pos - start), headRect = map.findCell($headCell.pos - start);\n    var doc = $anchorCell.node(0);\n    if (anchorRect.top <= headRect.top) {\n      if (anchorRect.top > 0)\n        { $anchorCell = doc.resolve(start + map.map[anchorRect.left]); }\n      if (headRect.bottom < map.height)\n        { $headCell = doc.resolve(start + map.map[map.width * (map.height - 1) + headRect.right - 1]); }\n    } else {\n      if (headRect.top > 0)\n        { $headCell = doc.resolve(start + map.map[headRect.left]); }\n      if (anchorRect.bottom < map.height)\n        { $anchorCell = doc.resolve(start + map.map[map.width * (map.height - 1) + anchorRect.right - 1]); }\n    }\n    return new CellSelection($anchorCell, $headCell)\n  };\n\n  // :: () → bool\n  // True if this selection goes all the way from the left to the\n  // right of the table.\n  CellSelection.prototype.isRowSelection = function isRowSelection () {\n    var map = TableMap.get(this.$anchorCell.node(-1)), start = this.$anchorCell.start(-1);\n    var anchorLeft = map.colCount(this.$anchorCell.pos - start),\n        headLeft = map.colCount(this.$headCell.pos - start);\n    if (Math.min(anchorLeft, headLeft) > 0) { return false }\n    var anchorRight = anchorLeft + this.$anchorCell.nodeAfter.attrs.colspan,\n        headRight = headLeft + this.$headCell.nodeAfter.attrs.colspan;\n    return Math.max(anchorRight, headRight) == map.width\n  };\n\n  CellSelection.prototype.eq = function eq (other) {\n    return other instanceof CellSelection && other.$anchorCell.pos == this.$anchorCell.pos &&\n      other.$headCell.pos == this.$headCell.pos\n  };\n\n  // :: (ResolvedPos, ?ResolvedPos) → CellSelection\n  // Returns the smallest row selection that covers the given anchor\n  // and head cell.\n  CellSelection.rowSelection = function rowSelection ($anchorCell, $headCell) {\n    if ( $headCell === void 0 ) $headCell = $anchorCell;\n\n    var map = TableMap.get($anchorCell.node(-1)), start = $anchorCell.start(-1);\n    var anchorRect = map.findCell($anchorCell.pos - start), headRect = map.findCell($headCell.pos - start);\n    var doc = $anchorCell.node(0);\n    if (anchorRect.left <= headRect.left) {\n      if (anchorRect.left > 0)\n        { $anchorCell = doc.resolve(start + map.map[anchorRect.top * map.width]); }\n      if (headRect.right < map.width)\n        { $headCell = doc.resolve(start + map.map[map.width * (headRect.top + 1) - 1]); }\n    } else {\n      if (headRect.left > 0)\n        { $headCell = doc.resolve(start + map.map[headRect.top * map.width]); }\n      if (anchorRect.right < map.width)\n        { $anchorCell = doc.resolve(start + map.map[map.width * (anchorRect.top + 1) - 1]); }\n    }\n    return new CellSelection($anchorCell, $headCell)\n  };\n\n  CellSelection.prototype.toJSON = function toJSON () {\n    return {type: \"cell\", anchor: this.$anchorCell.pos, head: this.$headCell.pos}\n  };\n\n  CellSelection.fromJSON = function fromJSON (doc, json) {\n    return new CellSelection(doc.resolve(json.anchor), doc.resolve(json.head))\n  };\n\n  // :: (Node, number, ?number) → CellSelection\n  CellSelection.create = function create (doc, anchorCell, headCell) {\n    if ( headCell === void 0 ) headCell = anchorCell;\n\n    return new CellSelection(doc.resolve(anchorCell), doc.resolve(headCell))\n  };\n\n  CellSelection.prototype.getBookmark = function getBookmark () { return new CellBookmark(this.$anchorCell.pos, this.$headCell.pos) };\n\n  return CellSelection;\n}(Selection));\n\nCellSelection.prototype.visible = false;\n\nSelection.jsonID(\"cell\", CellSelection);\n\nvar CellBookmark = function CellBookmark(anchor, head) {\n  this.anchor = anchor;\n  this.head = head;\n};\nCellBookmark.prototype.map = function map (mapping) {\n  return new CellBookmark(mapping.map(this.anchor), mapping.map(this.head))\n};\nCellBookmark.prototype.resolve = function resolve (doc) {\n  var $anchorCell = doc.resolve(this.anchor), $headCell = doc.resolve(this.head);\n  if ($anchorCell.parent.type.spec.tableRole == \"row\" &&\n      $headCell.parent.type.spec.tableRole == \"row\" &&\n      $anchorCell.index() < $anchorCell.parent.childCount &&\n      $headCell.index() < $headCell.parent.childCount &&\n      inSameTable($anchorCell, $headCell))\n    { return new CellSelection($anchorCell, $headCell) }\n  else\n    { return Selection.near($headCell, 1) }\n};\n\nfunction drawCellSelection(state) {\n  if (!(state.selection instanceof CellSelection)) { return null }\n  var cells = [];\n  state.selection.forEachCell(function (node, pos) {\n    cells.push(Decoration.node(pos, pos + node.nodeSize, {class: \"selectedCell\"}));\n  });\n  return DecorationSet.create(state.doc, cells)\n}\n\nfunction isCellBoundarySelection(ref) {\n  var $from = ref.$from;\n  var $to = ref.$to;\n\n  if ($from.pos == $to.pos || $from.pos < $from.pos - 6) { return false } // Cheap elimination\n  var afterFrom = $from.pos, beforeTo = $to.pos, depth = $from.depth;\n  for (; depth >= 0; depth--, afterFrom++)\n    { if ($from.after(depth + 1) < $from.end(depth)) { break } }\n  for (var d = $to.depth; d >= 0; d--, beforeTo--)\n    { if ($to.before(d + 1) > $to.start(d)) { break } }\n  return afterFrom == beforeTo && /row|table/.test($from.node(depth).type.spec.tableRole)\n}\n\nfunction isTextSelectionAcrossCells(ref) {\n  var $from = ref.$from;\n  var $to = ref.$to;\n\n  var fromCellBoundaryNode;\n  var toCellBoundaryNode;\n\n  for (var i = $from.depth; i > 0; i--) {\n    var node = $from.node(i);\n    if (node.type.spec.tableRole === 'cell' || node.type.spec.tableRole === 'header_cell') {\n      fromCellBoundaryNode = node;\n      break;\n    }\n  }\n\n  for (var i$1 = $to.depth; i$1 > 0; i$1--) {\n    var node$1 = $to.node(i$1);\n    if (node$1.type.spec.tableRole === 'cell' || node$1.type.spec.tableRole === 'header_cell') {\n      toCellBoundaryNode = node$1;\n      break;\n    }\n  }\n\n  return fromCellBoundaryNode !== toCellBoundaryNode && $to.parentOffset === 0\n}\n\nfunction normalizeSelection(state, tr, allowTableNodeSelection) {\n  var sel = (tr || state).selection, doc = (tr || state).doc, normalize, role;\n  if (sel instanceof NodeSelection && (role = sel.node.type.spec.tableRole)) {\n    if (role == \"cell\" || role == \"header_cell\") {\n      normalize = CellSelection.create(doc, sel.from);\n    } else if (role == \"row\") {\n      var $cell = doc.resolve(sel.from + 1);\n      normalize = CellSelection.rowSelection($cell, $cell);\n    } else if (!allowTableNodeSelection) {\n      var map = TableMap.get(sel.node), start = sel.from + 1;\n      var lastCell = start + map.map[map.width * map.height - 1];\n      normalize = CellSelection.create(doc, start + 1, lastCell);\n    }\n  } else if (sel instanceof TextSelection && isCellBoundarySelection(sel)) {\n    normalize = TextSelection.create(doc, sel.from);\n  } else if (sel instanceof TextSelection && isTextSelectionAcrossCells(sel)) {\n    normalize = TextSelection.create(doc, sel.$from.start(), sel.$from.end());\n  }\n  if (normalize)\n    { (tr || (tr = state.tr)).setSelection(normalize); }\n  return tr\n}\n\n// Utilities used for copy/paste handling.\n\n// Utilities to help with copying and pasting table cells\n\n// : (Slice) → ?{width: number, height: number, rows: [Fragment]}\n// Get a rectangular area of cells from a slice, or null if the outer\n// nodes of the slice aren't table cells or rows.\nfunction pastedCells(slice) {\n  if (!slice.size) { return null }\n  var content = slice.content;\n  var openStart = slice.openStart;\n  var openEnd = slice.openEnd;\n  while (content.childCount == 1 && (openStart > 0 && openEnd > 0 || content.firstChild.type.spec.tableRole == \"table\")) {\n    openStart--;\n    openEnd--;\n    content = content.firstChild.content;\n  }\n  var first = content.firstChild, role = first.type.spec.tableRole;\n  var schema = first.type.schema, rows = [];\n  if (role == \"row\") {\n    for (var i = 0; i < content.childCount; i++) {\n      var cells = content.child(i).content;\n      var left = i ? 0 : Math.max(0, openStart - 1);\n      var right = i < content.childCount - 1 ? 0 : Math.max(0, openEnd - 1);\n      if (left || right) { cells = fitSlice(tableNodeTypes(schema).row, new Slice(cells, left, right)).content; }\n      rows.push(cells);\n    }\n  } else if (role == \"cell\" || role == \"header_cell\") {\n    rows.push(openStart || openEnd ? fitSlice(tableNodeTypes(schema).row, new Slice(content, openStart, openEnd)).content : content);\n  } else {\n    return null\n  }\n  return ensureRectangular(schema, rows)\n}\n\n// : (Schema, [Fragment]) → {width: number, height: number, rows: [Fragment]}\n// Compute the width and height of a set of cells, and make sure each\n// row has the same number of cells.\nfunction ensureRectangular(schema, rows) {\n  var widths = [];\n  for (var i = 0; i < rows.length; i++) {\n    var row = rows[i];\n    for (var j = row.childCount - 1; j >= 0; j--) {\n      var ref = row.child(j).attrs;\n      var rowspan = ref.rowspan;\n      var colspan = ref.colspan;\n      for (var r = i; r < i + rowspan; r++)\n        { widths[r] = (widths[r] || 0) + colspan; }\n    }\n  }\n  var width = 0;\n  for (var r$1 = 0; r$1 < widths.length; r$1++) { width = Math.max(width, widths[r$1]); }\n  for (var r$2 = 0; r$2 < widths.length; r$2++) {\n    if (r$2 >= rows.length) { rows.push(Fragment.empty); }\n    if (widths[r$2] < width) {\n      var empty = tableNodeTypes(schema).cell.createAndFill(), cells = [];\n      for (var i$1 = widths[r$2]; i$1 < width; i$1++) { cells.push(empty); }\n      rows[r$2] = rows[r$2].append(Fragment.from(cells));\n    }\n  }\n  return {height: rows.length, width: width, rows: rows}\n}\n\nfunction fitSlice(nodeType, slice) {\n  var node = nodeType.createAndFill();\n  var tr = new Transform(node).replace(0, node.content.size, slice);\n  return tr.doc\n}\n\n// : ({width: number, height: number, rows: [Fragment]}, number, number) → {width: number, height: number, rows: [Fragment]}\n// Clip or extend (repeat) the given set of cells to cover the given\n// width and height. Will clip rowspan/colspan cells at the edges when\n// they stick out.\nfunction clipCells(ref, newWidth, newHeight) {\n  var width = ref.width;\n  var height = ref.height;\n  var rows = ref.rows;\n\n  if (width != newWidth) {\n    var added = [], newRows = [];\n    for (var row = 0; row < rows.length; row++) {\n      var frag = rows[row], cells = [];\n      for (var col = added[row] || 0, i = 0; col < newWidth; i++) {\n        var cell = frag.child(i % frag.childCount);\n        if (col + cell.attrs.colspan > newWidth)\n          { cell = cell.type.create(removeColSpan(cell.attrs, cell.attrs.colspan, col + cell.attrs.colspan - newWidth), cell.content); }\n        cells.push(cell);\n        col += cell.attrs.colspan;\n        for (var j = 1; j < cell.attrs.rowspan; j++)\n          { added[row + j] = (added[row + j] || 0) + cell.attrs.colspan; }\n      }\n      newRows.push(Fragment.from(cells));\n    }\n    rows = newRows;\n    width = newWidth;\n  }\n\n  if (height != newHeight) {\n    var newRows$1 = [];\n    for (var row$1 = 0, i$1 = 0; row$1 < newHeight; row$1++, i$1++) {\n      var cells$1 = [], source = rows[i$1 % height];\n      for (var j$1 = 0; j$1 < source.childCount; j$1++) {\n        var cell$1 = source.child(j$1);\n        if (row$1 + cell$1.attrs.rowspan > newHeight)\n          { cell$1 = cell$1.type.create(setAttr(cell$1.attrs, \"rowspan\", Math.max(1, newHeight - cell$1.attrs.rowspan)), cell$1.content); }\n        cells$1.push(cell$1);\n      }\n      newRows$1.push(Fragment.from(cells$1));\n    }\n    rows = newRows$1;\n    height = newHeight;\n  }\n\n  return {width: width, height: height, rows: rows}\n}\n\n// Make sure a table has at least the given width and height. Return\n// true if something was changed.\nfunction growTable(tr, map, table, start, width, height, mapFrom) {\n  var schema = tr.doc.type.schema, types = tableNodeTypes(schema), empty, emptyHead;\n  if (width > map.width) {\n    for (var row = 0, rowEnd = 0; row < map.height; row++) {\n      var rowNode = table.child(row);\n      rowEnd += rowNode.nodeSize;\n      var cells = [], add = (void 0);\n      if (rowNode.lastChild == null || rowNode.lastChild.type == types.cell)\n        { add = empty || (empty = types.cell.createAndFill()); }\n      else\n        { add = emptyHead || (emptyHead = types.header_cell.createAndFill()); }\n      for (var i = map.width; i < width; i++) { cells.push(add); }\n      tr.insert(tr.mapping.slice(mapFrom).map(rowEnd - 1 + start), cells);\n    }\n  }\n  if (height > map.height) {\n    var cells$1 = [];\n    for (var i$1 = 0, start$1 = (map.height - 1) * map.width; i$1 < Math.max(map.width, width); i$1++) {\n      var header = i$1 >= map.width ? false :\n          table.nodeAt(map.map[start$1 + i$1]).type == types.header_cell;\n      cells$1.push(header\n                 ? (emptyHead || (emptyHead = types.header_cell.createAndFill()))\n                 : (empty || (empty = types.cell.createAndFill())));\n    }\n\n    var emptyRow = types.row.create(null, Fragment.from(cells$1)), rows = [];\n    for (var i$2 = map.height; i$2 < height; i$2++) { rows.push(emptyRow); }\n    tr.insert(tr.mapping.slice(mapFrom).map(start + table.nodeSize - 2), rows);\n  }\n  return !!(empty || emptyHead)\n}\n\n// Make sure the given line (left, top) to (right, top) doesn't cross\n// any rowspan cells by splitting cells that cross it. Return true if\n// something changed.\nfunction isolateHorizontal(tr, map, table, start, left, right, top, mapFrom) {\n  if (top == 0 || top == map.height) { return false }\n  var found = false;\n  for (var col = left; col < right; col++) {\n    var index = top * map.width + col, pos = map.map[index];\n    if (map.map[index - map.width] == pos) {\n      found = true;\n      var cell = table.nodeAt(pos);\n      var ref = map.findCell(pos);\n      var cellTop = ref.top;\n      var cellLeft = ref.left;\n      tr.setNodeMarkup(tr.mapping.slice(mapFrom).map(pos + start), null, setAttr(cell.attrs, \"rowspan\", top - cellTop));\n      tr.insert(tr.mapping.slice(mapFrom).map(map.positionAt(top, cellLeft, table)),\n                cell.type.createAndFill(setAttr(cell.attrs, \"rowspan\", (cellTop + cell.attrs.rowspan) - top)));\n      col += cell.attrs.colspan - 1;\n    }\n  }\n  return found\n}\n\n// Make sure the given line (left, top) to (left, bottom) doesn't\n// cross any colspan cells by splitting cells that cross it. Return\n// true if something changed.\nfunction isolateVertical(tr, map, table, start, top, bottom, left, mapFrom) {\n  if (left == 0 || left == map.width) { return false }\n  var found = false;\n  for (var row = top; row < bottom; row++) {\n    var index = row * map.width + left, pos = map.map[index];\n    if (map.map[index - 1] == pos) {\n      found = true;\n      var cell = table.nodeAt(pos), cellLeft = map.colCount(pos);\n      var updatePos = tr.mapping.slice(mapFrom).map(pos + start);\n      tr.setNodeMarkup(updatePos, null, removeColSpan(cell.attrs, left - cellLeft, cell.attrs.colspan - (left - cellLeft)));\n      tr.insert(updatePos + cell.nodeSize, cell.type.createAndFill(removeColSpan(cell.attrs, 0, left - cellLeft)));\n      row += cell.attrs.rowspan - 1;\n    }\n  }\n  return found\n}\n\n// Insert the given set of cells (as returned by `pastedCells`) into a\n// table, at the position pointed at by rect.\nfunction insertCells(state, dispatch, tableStart, rect, cells) {\n  var table = tableStart ? state.doc.nodeAt(tableStart - 1) : state.doc, map = TableMap.get(table);\n  var top = rect.top;\n  var left = rect.left;\n  var right = left + cells.width, bottom = top + cells.height;\n  var tr = state.tr, mapFrom = 0;\n  function recomp() {\n    table = tableStart ? tr.doc.nodeAt(tableStart - 1) : tr.doc;\n    map = TableMap.get(table);\n    mapFrom = tr.mapping.maps.length;\n  }\n  // Prepare the table to be large enough and not have any cells\n  // crossing the boundaries of the rectangle that we want to\n  // insert into. If anything about it changes, recompute the table\n  // map so that subsequent operations can see the current shape.\n  if (growTable(tr, map, table, tableStart, right, bottom, mapFrom)) { recomp(); }\n  if (isolateHorizontal(tr, map, table, tableStart, left, right, top, mapFrom)) { recomp(); }\n  if (isolateHorizontal(tr, map, table, tableStart, left, right, bottom, mapFrom)) { recomp(); }\n  if (isolateVertical(tr, map, table, tableStart, top, bottom, left, mapFrom)) { recomp(); }\n  if (isolateVertical(tr, map, table, tableStart, top, bottom, right, mapFrom)) { recomp(); }\n\n  for (var row = top; row < bottom; row++) {\n    var from = map.positionAt(row, left, table), to = map.positionAt(row, right, table);\n    tr.replace(tr.mapping.slice(mapFrom).map(from + tableStart), tr.mapping.slice(mapFrom).map(to + tableStart),\n               new Slice(cells.rows[row - top], 0, 0));\n  }\n  recomp();\n  tr.setSelection(new CellSelection(tr.doc.resolve(tableStart + map.positionAt(top, left, table)),\n                                    tr.doc.resolve(tableStart + map.positionAt(bottom - 1, right - 1, table))));\n  dispatch(tr);\n}\n\n// This file defines a number of helpers for wiring up user input to\n\nvar handleKeyDown = keydownHandler({\n  \"ArrowLeft\": arrow(\"horiz\", -1),\n  \"ArrowRight\": arrow(\"horiz\", 1),\n  \"ArrowUp\": arrow(\"vert\", -1),\n  \"ArrowDown\": arrow(\"vert\", 1),\n\n  \"Shift-ArrowLeft\": shiftArrow(\"horiz\", -1),\n  \"Shift-ArrowRight\": shiftArrow(\"horiz\", 1),\n  \"Shift-ArrowUp\": shiftArrow(\"vert\", -1),\n  \"Shift-ArrowDown\": shiftArrow(\"vert\", 1),\n\n  \"Backspace\": deleteCellSelection,\n  \"Mod-Backspace\": deleteCellSelection,\n  \"Delete\": deleteCellSelection,\n  \"Mod-Delete\": deleteCellSelection\n});\n\nfunction maybeSetSelection(state, dispatch, selection) {\n  if (selection.eq(state.selection)) { return false }\n  if (dispatch) { dispatch(state.tr.setSelection(selection).scrollIntoView()); }\n  return true\n}\n\nfunction arrow(axis, dir) {\n  return function (state, dispatch, view) {\n    var sel = state.selection;\n    if (sel instanceof CellSelection) {\n      return maybeSetSelection(state, dispatch, Selection.near(sel.$headCell, dir))\n    }\n    if (axis != \"horiz\" && !sel.empty) { return false }\n    var end = atEndOfCell(view, axis, dir);\n    if (end == null) { return false }\n    if (axis == \"horiz\") {\n      return maybeSetSelection(state, dispatch, Selection.near(state.doc.resolve(sel.head + dir), dir))\n    } else {\n      var $cell = state.doc.resolve(end), $next = nextCell($cell, axis, dir), newSel;\n      if ($next) { newSel = Selection.near($next, 1); }\n      else if (dir < 0) { newSel = Selection.near(state.doc.resolve($cell.before(-1)), -1); }\n      else { newSel = Selection.near(state.doc.resolve($cell.after(-1)), 1); }\n      return maybeSetSelection(state, dispatch, newSel)\n    }\n  }\n}\n\nfunction shiftArrow(axis, dir) {\n  return function (state, dispatch, view) {\n    var sel = state.selection;\n    if (!(sel instanceof CellSelection)) {\n      var end = atEndOfCell(view, axis, dir);\n      if (end == null) { return false }\n      sel = new CellSelection(state.doc.resolve(end));\n    }\n    var $head = nextCell(sel.$headCell, axis, dir);\n    if (!$head) { return false }\n    return maybeSetSelection(state, dispatch, new CellSelection(sel.$anchorCell, $head))\n  }\n}\n\nfunction deleteCellSelection(state, dispatch) {\n  var sel = state.selection;\n  if (!(sel instanceof CellSelection)) { return false }\n  if (dispatch) {\n    var tr = state.tr, baseContent = tableNodeTypes(state.schema).cell.createAndFill().content;\n    sel.forEachCell(function (cell, pos) {\n      if (!cell.content.eq(baseContent))\n        { tr.replace(tr.mapping.map(pos + 1), tr.mapping.map(pos + cell.nodeSize - 1),\n                   new Slice(baseContent, 0, 0)); }\n    });\n    if (tr.docChanged) { dispatch(tr); }\n  }\n  return true\n}\n\nfunction handleTripleClick(view, pos) {\n  var doc = view.state.doc, $cell = cellAround(doc.resolve(pos));\n  if (!$cell) { return false }\n  view.dispatch(view.state.tr.setSelection(new CellSelection($cell)));\n  return true\n}\n\nfunction handlePaste(view, _, slice) {\n  if (!isInTable(view.state)) { return false }\n  var cells = pastedCells(slice), sel = view.state.selection;\n  if (sel instanceof CellSelection) {\n    if (!cells) { cells = {width: 1, height: 1, rows: [Fragment.from(fitSlice(tableNodeTypes(view.state.schema).cell, slice))]}; }\n    var table = sel.$anchorCell.node(-1), start = sel.$anchorCell.start(-1);\n    var rect = TableMap.get(table).rectBetween(sel.$anchorCell.pos - start, sel.$headCell.pos - start);\n    cells = clipCells(cells, rect.right - rect.left, rect.bottom - rect.top);\n    insertCells(view.state, view.dispatch, start, rect, cells);\n    return true\n  } else if (cells) {\n    var $cell = selectionCell(view.state), start$1 = $cell.start(-1);\n    insertCells(view.state, view.dispatch, start$1, TableMap.get($cell.node(-1)).findCell($cell.pos - start$1), cells);\n    return true\n  } else {\n    return false\n  }\n}\n\nfunction handleMouseDown(view, startEvent) {\n  if (startEvent.ctrlKey || startEvent.metaKey) { return }\n\n  var startDOMCell = domInCell(view, startEvent.target), $anchor;\n  if (startEvent.shiftKey && (view.state.selection instanceof CellSelection)) {\n    // Adding to an existing cell selection\n    setCellSelection(view.state.selection.$anchorCell, startEvent);\n    startEvent.preventDefault();\n  } else if (startEvent.shiftKey && startDOMCell &&\n             ($anchor = cellAround(view.state.selection.$anchor)) != null &&\n             cellUnderMouse(view, startEvent).pos != $anchor.pos) {\n    // Adding to a selection that starts in another cell (causing a\n    // cell selection to be created).\n    setCellSelection($anchor, startEvent);\n    startEvent.preventDefault();\n  } else if (!startDOMCell) {\n    // Not in a cell, let the default behavior happen.\n    return\n  }\n\n  // Create and dispatch a cell selection between the given anchor and\n  // the position under the mouse.\n  function setCellSelection($anchor, event) {\n    var $head = cellUnderMouse(view, event);\n    var starting = key.getState(view.state) == null;\n    if (!$head || !inSameTable($anchor, $head)) {\n      if (starting) { $head = $anchor; }\n      else { return }\n    }\n    var selection = new CellSelection($anchor, $head);\n    if (starting || !view.state.selection.eq(selection)) {\n      var tr = view.state.tr.setSelection(selection);\n      if (starting) { tr.setMeta(key, $anchor.pos); }\n      view.dispatch(tr);\n    }\n  }\n\n  // Stop listening to mouse motion events.\n  function stop() {\n    view.root.removeEventListener(\"mouseup\", stop);\n    view.root.removeEventListener(\"dragstart\", stop);\n    view.root.removeEventListener(\"mousemove\", move);\n    if (key.getState(view.state) != null) { view.dispatch(view.state.tr.setMeta(key, -1)); }\n  }\n\n  function move(event) {\n    var anchor = key.getState(view.state), $anchor;\n    if (anchor != null) {\n      // Continuing an existing cross-cell selection\n      $anchor = view.state.doc.resolve(anchor);\n    } else if (domInCell(view, event.target) != startDOMCell) {\n      // Moving out of the initial cell -- start a new cell selection\n      $anchor = cellUnderMouse(view, startEvent);\n      if (!$anchor) { return stop() }\n    }\n    if ($anchor) { setCellSelection($anchor, event); }\n  }\n  view.root.addEventListener(\"mouseup\", stop);\n  view.root.addEventListener(\"dragstart\", stop);\n  view.root.addEventListener(\"mousemove\", move);\n}\n\n// Check whether the cursor is at the end of a cell (so that further\n// motion would move out of the cell)\nfunction atEndOfCell(view, axis, dir) {\n  if (!(view.state.selection instanceof TextSelection)) { return null }\n  var ref = view.state.selection;\n  var $head = ref.$head;\n  for (var d = $head.depth - 1; d >= 0; d--) {\n    var parent = $head.node(d), index = dir < 0 ? $head.index(d) : $head.indexAfter(d);\n    if (index != (dir < 0 ? 0 : parent.childCount)) { return null }\n    if (parent.type.spec.tableRole == \"cell\" || parent.type.spec.tableRole == \"header_cell\") {\n      var cellPos = $head.before(d);\n      var dirStr = axis == \"vert\" ? (dir > 0 ? \"down\" : \"up\") : (dir > 0 ? \"right\" : \"left\");\n      return view.endOfTextblock(dirStr) ? cellPos : null\n    }\n  }\n  return null\n}\n\nfunction domInCell(view, dom) {\n  for (; dom && dom != view.dom; dom = dom.parentNode)\n    { if (dom.nodeName == \"TD\" || dom.nodeName == \"TH\") { return dom } }\n}\n\nfunction cellUnderMouse(view, event) {\n  var mousePos = view.posAtCoords({left: event.clientX, top: event.clientY});\n  if (!mousePos) { return null }\n  return mousePos ? cellAround(view.state.doc.resolve(mousePos.pos)) : null\n}\n\n// This file defines helpers for normalizing tables, making sure no\n\nvar fixTablesKey = new PluginKey(\"fix-tables\");\n\n// Helper for iterating through the nodes in a document that changed\n// compared to the given previous document. Useful for avoiding\n// duplicate work on each transaction.\nfunction changedDescendants(old, cur, offset, f) {\n  var oldSize = old.childCount, curSize = cur.childCount;\n  outer: for (var i = 0, j = 0; i < curSize; i++) {\n    var child = cur.child(i);\n    for (var scan = j, e = Math.min(oldSize, i + 3); scan < e; scan++) {\n      if (old.child(scan) == child) {\n        j = scan + 1;\n        offset += child.nodeSize;\n        continue outer\n      }\n    }\n    f(child, offset);\n    if (j < oldSize && old.child(j).sameMarkup(child))\n      { changedDescendants(old.child(j), child, offset + 1, f); }\n    else\n      { child.nodesBetween(0, child.content.size, f, offset + 1); }\n    offset += child.nodeSize;\n  }\n}\n\n// :: (EditorState, ?EditorState) → ?Transaction\n// Inspect all tables in the given state's document and return a\n// transaction that fixes them, if necessary. If `oldState` was\n// provided, that is assumed to hold a previous, known-good state,\n// which will be used to avoid re-scanning unchanged parts of the\n// document.\nfunction fixTables(state, oldState) {\n  var tr, check = function (node, pos) {\n    if (node.type.spec.tableRole == \"table\") { tr = fixTable(state, node, pos, tr); }\n  };\n  if (!oldState) { state.doc.descendants(check); }\n  else if (oldState.doc != state.doc) { changedDescendants(oldState.doc, state.doc, 0, check); }\n  return tr\n}\n\n// : (EditorState, Node, number, ?Transaction) → ?Transaction\n// Fix the given table, if necessary. Will append to the transaction\n// it was given, if non-null, or create a new one if necessary.\nfunction fixTable(state, table, tablePos, tr) {\n  var map = TableMap.get(table);\n  if (!map.problems) { return tr }\n  if (!tr) { tr = state.tr; }\n\n  // Track which rows we must add cells to, so that we can adjust that\n  // when fixing collisions.\n  var mustAdd = [];\n  for (var i = 0; i < map.height; i++) { mustAdd.push(0); }\n  for (var i$1 = 0; i$1 < map.problems.length; i$1++) {\n    var prob = map.problems[i$1];\n    if (prob.type == \"collision\") {\n      var cell = table.nodeAt(prob.pos);\n      for (var j = 0; j < cell.attrs.rowspan; j++) { mustAdd[prob.row + j] += prob.n; }\n      tr.setNodeMarkup(tr.mapping.map(tablePos + 1 + prob.pos), null, removeColSpan(cell.attrs, cell.attrs.colspan - prob.n, prob.n));\n    } else if (prob.type == \"missing\") {\n      mustAdd[prob.row] += prob.n;\n    } else if (prob.type == \"overlong_rowspan\") {\n      var cell$1 = table.nodeAt(prob.pos);\n      tr.setNodeMarkup(tr.mapping.map(tablePos + 1 + prob.pos), null, setAttr(cell$1.attrs, \"rowspan\", cell$1.attrs.rowspan - prob.n));\n    } else if (prob.type == \"colwidth mismatch\") {\n      var cell$2 = table.nodeAt(prob.pos);\n      tr.setNodeMarkup(tr.mapping.map(tablePos + 1 + prob.pos), null, setAttr(cell$2.attrs, \"colwidth\", prob.colwidth));\n    }\n  }\n  var first, last;\n  for (var i$2 = 0; i$2 < mustAdd.length; i$2++) { if (mustAdd[i$2]) {\n    if (first == null) { first = i$2; }\n    last = i$2;\n  } }\n  // Add the necessary cells, using a heuristic for whether to add the\n  // cells at the start or end of the rows (if it looks like a 'bite'\n  // was taken out of the table, add cells at the start of the row\n  // after the bite. Otherwise add them at the end).\n  for (var i$3 = 0, pos = tablePos + 1; i$3 < map.height; i$3++) {\n    var row = table.child(i$3);\n    var end = pos + row.nodeSize;\n    var add = mustAdd[i$3];\n    if (add > 0) {\n      var tableNodeType = 'cell';\n      if (row.firstChild) {\n        tableNodeType = row.firstChild.type.spec.tableRole;\n      }\n      var nodes = [];\n      for (var j$1 = 0; j$1 < add; j$1++)\n        { nodes.push(tableNodeTypes(state.schema)[tableNodeType].createAndFill()); }\n      var side = (i$3 == 0 || first == i$3 - 1) && last == i$3 ? pos + 1 : end - 1;\n      tr.insert(tr.mapping.map(side), nodes);\n    }\n    pos = end;\n  }\n  return tr.setMeta(fixTablesKey, { fixTables: true })\n}\n\n// This file defines a number of table-related commands.\n\n// Helper to get the selected rectangle in a table, if any. Adds table\n// map, table node, and table start offset to the object for\n// convenience.\nfunction selectedRect(state) {\n  var sel = state.selection, $pos = selectionCell(state);\n  var table = $pos.node(-1), tableStart = $pos.start(-1), map = TableMap.get(table);\n  var rect;\n  if (sel instanceof CellSelection)\n    { rect = map.rectBetween(sel.$anchorCell.pos - tableStart, sel.$headCell.pos - tableStart); }\n  else\n    { rect = map.findCell($pos.pos - tableStart); }\n  rect.tableStart = tableStart;\n  rect.map = map;\n  rect.table = table;\n  return rect\n}\n\n// Add a column at the given position in a table.\nfunction addColumn(tr, ref, col) {\n  var map = ref.map;\n  var tableStart = ref.tableStart;\n  var table = ref.table;\n\n  var refColumn = col > 0 ? -1 : 0;\n  if (columnIsHeader(map, table, col + refColumn))\n    { refColumn = col == 0 || col == map.width ? null : 0; }\n\n  for (var row = 0; row < map.height; row++) {\n    var index = row * map.width + col;\n    // If this position falls inside a col-spanning cell\n    if (col > 0 && col < map.width && map.map[index - 1] == map.map[index]) {\n      var pos = map.map[index], cell = table.nodeAt(pos);\n      tr.setNodeMarkup(tr.mapping.map(tableStart + pos), null,\n                       addColSpan(cell.attrs, col - map.colCount(pos)));\n      // Skip ahead if rowspan > 1\n      row += cell.attrs.rowspan - 1;\n    } else {\n      var type = refColumn == null ? tableNodeTypes(table.type.schema).cell\n          : table.nodeAt(map.map[index + refColumn]).type;\n      var pos$1 = map.positionAt(row, col, table);\n      tr.insert(tr.mapping.map(tableStart + pos$1), type.createAndFill());\n    }\n  }\n  return tr\n}\n\n// :: (EditorState, dispatch: ?(tr: Transaction)) → bool\n// Command to add a column before the column with the selection.\nfunction addColumnBefore(state, dispatch) {\n  if (!isInTable(state)) { return false }\n  if (dispatch) {\n    var rect = selectedRect(state);\n    dispatch(addColumn(state.tr, rect, rect.left));\n  }\n  return true\n}\n\n// :: (EditorState, dispatch: ?(tr: Transaction)) → bool\n// Command to add a column after the column with the selection.\nfunction addColumnAfter(state, dispatch) {\n  if (!isInTable(state)) { return false }\n  if (dispatch) {\n    var rect = selectedRect(state);\n    dispatch(addColumn(state.tr, rect, rect.right));\n  }\n  return true\n}\n\nfunction removeColumn(tr, ref, col) {\n  var map = ref.map;\n  var table = ref.table;\n  var tableStart = ref.tableStart;\n\n  var mapStart = tr.mapping.maps.length;\n  for (var row = 0; row < map.height;) {\n    var index = row * map.width + col, pos = map.map[index], cell = table.nodeAt(pos);\n    // If this is part of a col-spanning cell\n    if ((col > 0 && map.map[index - 1] == pos) || (col < map.width - 1 && map.map[index + 1] == pos)) {\n      tr.setNodeMarkup(tr.mapping.slice(mapStart).map(tableStart + pos), null,\n                       removeColSpan(cell.attrs, col - map.colCount(pos)));\n    } else {\n      var start = tr.mapping.slice(mapStart).map(tableStart + pos);\n      tr.delete(start, start + cell.nodeSize);\n    }\n    row += cell.attrs.rowspan;\n  }\n}\n\n// :: (EditorState, dispatch: ?(tr: Transaction)) → bool\n// Command function that removes the selected columns from a table.\nfunction deleteColumn(state, dispatch) {\n  if (!isInTable(state)) { return false }\n  if (dispatch) {\n    var rect = selectedRect(state), tr = state.tr;\n    if (rect.left == 0 && rect.right == rect.map.width) { return false }\n    for (var i = rect.right - 1;; i--) {\n      removeColumn(tr, rect, i);\n      if (i == rect.left) { break }\n      rect.table = rect.tableStart ? tr.doc.nodeAt(rect.tableStart - 1) : tr.doc;\n      rect.map = TableMap.get(rect.table);\n    }\n    dispatch(tr);\n  }\n  return true\n}\n\nfunction rowIsHeader(map, table, row) {\n  var headerCell = tableNodeTypes(table.type.schema).header_cell;\n  for (var col = 0; col < map.width; col++)\n    { if (table.nodeAt(map.map[col + row * map.width]).type != headerCell)\n      { return false } }\n  return true\n}\n\nfunction addRow(tr, ref, row) {\n  var map = ref.map;\n  var tableStart = ref.tableStart;\n  var table = ref.table;\n\n  var rowPos = tableStart;\n  for (var i = 0; i < row; i++) { rowPos += table.child(i).nodeSize; }\n  var cells = [], refRow = row > 0 ? -1 : 0;\n  if (rowIsHeader(map, table, row + refRow))\n    { refRow = row == 0 || row == map.height ? null : 0; }\n  for (var col = 0, index = map.width * row; col < map.width; col++, index++) {\n    // Covered by a rowspan cell\n    if (row > 0 && row < map.height && map.map[index] == map.map[index - map.width]) {\n      var pos = map.map[index], attrs = table.nodeAt(pos).attrs;\n      tr.setNodeMarkup(tableStart + pos, null, setAttr(attrs, \"rowspan\", attrs.rowspan + 1));\n      col += attrs.colspan - 1;\n    } else {\n      var type = refRow == null ? tableNodeTypes(table.type.schema).cell\n          : table.nodeAt(map.map[index + refRow * map.width]).type;\n      cells.push(type.createAndFill());\n    }\n  }\n  tr.insert(rowPos, tableNodeTypes(table.type.schema).row.create(null, cells));\n  return tr\n}\n\n// :: (EditorState, dispatch: ?(tr: Transaction)) → bool\n// Add a table row before the selection.\nfunction addRowBefore(state, dispatch) {\n  if (!isInTable(state)) { return false }\n  if (dispatch) {\n    var rect = selectedRect(state);\n    dispatch(addRow(state.tr, rect, rect.top));\n  }\n  return true\n}\n\n// :: (EditorState, dispatch: ?(tr: Transaction)) → bool\n// Add a table row after the selection.\nfunction addRowAfter(state, dispatch) {\n  if (!isInTable(state)) { return false }\n  if (dispatch) {\n    var rect = selectedRect(state);\n    dispatch(addRow(state.tr, rect, rect.bottom));\n  }\n  return true\n}\n\nfunction removeRow(tr, ref, row) {\n  var map = ref.map;\n  var table = ref.table;\n  var tableStart = ref.tableStart;\n\n  var rowPos = 0;\n  for (var i = 0; i < row; i++) { rowPos += table.child(i).nodeSize; }\n  var nextRow = rowPos + table.child(row).nodeSize;\n\n  var mapFrom = tr.mapping.maps.length;\n  tr.delete(rowPos + tableStart, nextRow + tableStart);\n\n  for (var col = 0, index = row * map.width; col < map.width; col++, index++) {\n    var pos = map.map[index];\n    if (row > 0 && pos == map.map[index - map.width]) {\n      // If this cell starts in the row above, simply reduce its rowspan\n      var attrs = table.nodeAt(pos).attrs;\n      tr.setNodeMarkup(tr.mapping.slice(mapFrom).map(pos + tableStart), null, setAttr(attrs, \"rowspan\", attrs.rowspan - 1));\n      col += attrs.colspan - 1;\n    } else if (row < map.width && pos == map.map[index + map.width]) {\n      // Else, if it continues in the row below, it has to be moved down\n      var cell = table.nodeAt(pos);\n      var copy = cell.type.create(setAttr(cell.attrs, \"rowspan\", cell.attrs.rowspan - 1), cell.content);\n      var newPos = map.positionAt(row + 1, col, table);\n      tr.insert(tr.mapping.slice(mapFrom).map(tableStart + newPos), copy);\n      col += cell.attrs.colspan - 1;\n    }\n  }\n}\n\n// :: (EditorState, dispatch: ?(tr: Transaction)) → bool\n// Remove the selected rows from a table.\nfunction deleteRow(state, dispatch) {\n  if (!isInTable(state)) { return false }\n  if (dispatch) {\n    var rect = selectedRect(state), tr = state.tr;\n    if (rect.top == 0 && rect.bottom == rect.map.height) { return false }\n    for (var i = rect.bottom - 1;; i--) {\n      removeRow(tr, rect, i);\n      if (i == rect.top) { break }\n      rect.table = rect.tableStart ? tr.doc.nodeAt(rect.tableStart - 1) : tr.doc;\n      rect.map = TableMap.get(rect.table);\n    }\n    dispatch(tr);\n  }\n  return true\n}\n\nfunction isEmpty(cell) {\n  var c = cell.content;\n  return c.childCount == 1 && c.firstChild.isTextblock && c.firstChild.childCount == 0\n}\n\nfunction cellsOverlapRectangle(ref, rect) {\n  var width = ref.width;\n  var height = ref.height;\n  var map = ref.map;\n\n  var indexTop = rect.top * width + rect.left, indexLeft = indexTop;\n  var indexBottom = (rect.bottom - 1) * width + rect.left, indexRight = indexTop + (rect.right - rect.left - 1);\n  for (var i = rect.top; i < rect.bottom; i++) {\n    if (rect.left > 0 && map[indexLeft] == map[indexLeft - 1] ||\n        rect.right < width && map[indexRight] == map[indexRight + 1]) { return true }\n    indexLeft += width; indexRight += width;\n  }\n  for (var i$1 = rect.left; i$1 < rect.right; i$1++) {\n    if (rect.top > 0 && map[indexTop] == map[indexTop - width] ||\n        rect.bottom < height && map[indexBottom] == map[indexBottom + width]) { return true }\n    indexTop++; indexBottom++;\n  }\n  return false\n}\n\n// :: (EditorState, dispatch: ?(tr: Transaction)) → bool\n// Merge the selected cells into a single cell. Only available when\n// the selected cells' outline forms a rectangle.\nfunction mergeCells(state, dispatch) {\n  var sel = state.selection;\n  if (!(sel instanceof CellSelection) || sel.$anchorCell.pos == sel.$headCell.pos) { return false }\n  var rect = selectedRect(state);\n  var map = rect.map;\n  if (cellsOverlapRectangle(map, rect)) { return false }\n  if (dispatch) {\n    var tr = state.tr, seen = {}, content = Fragment.empty, mergedPos, mergedCell;\n    for (var row = rect.top; row < rect.bottom; row++) {\n      for (var col = rect.left; col < rect.right; col++) {\n        var cellPos = map.map[row * map.width + col], cell = rect.table.nodeAt(cellPos);\n        if (seen[cellPos]) { continue }\n        seen[cellPos] = true;\n        if (mergedPos == null) {\n          mergedPos = cellPos;\n          mergedCell = cell;\n        } else {\n          if (!isEmpty(cell)) { content = content.append(cell.content); }\n          var mapped = tr.mapping.map(cellPos + rect.tableStart);\n          tr.delete(mapped, mapped + cell.nodeSize);\n        }\n      }\n    }\n    tr.setNodeMarkup(mergedPos + rect.tableStart, null,\n                     setAttr(addColSpan(mergedCell.attrs, mergedCell.attrs.colspan, (rect.right - rect.left) - mergedCell.attrs.colspan),\n                             \"rowspan\", rect.bottom - rect.top));\n    if (content.size) {\n      var end = mergedPos + 1 + mergedCell.content.size;\n      var start = isEmpty(mergedCell) ? mergedPos + 1 : end;\n      tr.replaceWith(start + rect.tableStart, end + rect.tableStart, content);\n    }\n    tr.setSelection(new CellSelection(tr.doc.resolve(mergedPos + rect.tableStart)));\n    dispatch(tr);\n  }\n  return true\n}\n// :: (EditorState, dispatch: ?(tr: Transaction)) → bool\n// Split a selected cell, whose rowpan or colspan is greater than one,\n// into smaller cells. Use the first cell type for the new cells.\nfunction splitCell(state, dispatch) {\n  var nodeTypes = tableNodeTypes(state.schema);\n  return splitCellWithType(function (ref) {\n    var node = ref.node;\n\n    return nodeTypes[node.type.spec.tableRole]\n  })(state, dispatch)\n}\n\n// :: (getCellType: ({ row: number, col: number, node: Node}) → NodeType) → (EditorState, dispatch: ?(tr: Transaction)) → bool\n// Split a selected cell, whose rowpan or colspan is greater than one,\n// into smaller cells with the cell type (th, td) returned by getType function.\nfunction splitCellWithType(getCellType) {\n  return function (state, dispatch) {\n    var sel = state.selection;\n    var cellNode, cellPos;\n    if (!(sel instanceof CellSelection)) {\n      cellNode = cellWrapping(sel.$from);\n      if (!cellNode) { return false }\n      cellPos = cellAround(sel.$from).pos;\n    } else {\n      if (sel.$anchorCell.pos != sel.$headCell.pos) { return false }\n      cellNode = sel.$anchorCell.nodeAfter;\n      cellPos = sel.$anchorCell.pos;\n    }\n    if (cellNode.attrs.colspan == 1 && cellNode.attrs.rowspan == 1) {return false}\n    if (dispatch) {\n      var baseAttrs = cellNode.attrs, attrs = [], colwidth = baseAttrs.colwidth;\n      if (baseAttrs.rowspan > 1) { baseAttrs = setAttr(baseAttrs, \"rowspan\", 1); }\n      if (baseAttrs.colspan > 1) { baseAttrs = setAttr(baseAttrs, \"colspan\", 1); }\n      var rect = selectedRect(state), tr = state.tr;\n      for (var i = 0; i < rect.right - rect.left; i++)\n        { attrs.push(colwidth ? setAttr(baseAttrs, \"colwidth\", colwidth && colwidth[i] ? [colwidth[i]] : null) : baseAttrs); }\n      var lastCell;\n      for (var row = rect.top; row < rect.bottom; row++) {\n        var pos = rect.map.positionAt(row, rect.left, rect.table);\n        if (row == rect.top) { pos += cellNode.nodeSize; }\n        for (var col = rect.left, i$1 = 0; col < rect.right; col++, i$1++) {\n          if (col == rect.left && row == rect.top) { continue }\n          tr.insert(lastCell = tr.mapping.map(pos + rect.tableStart, 1), getCellType({ node: cellNode, row: row, col: col}).createAndFill(attrs[i$1]));\n        }\n      }\n      tr.setNodeMarkup(cellPos, getCellType({ node: cellNode, row: rect.top, col: rect.left}), attrs[0]);\n      if (sel instanceof CellSelection)\n        { tr.setSelection(new CellSelection(tr.doc.resolve(sel.$anchorCell.pos),\n                                          lastCell && tr.doc.resolve(lastCell))); }\n      dispatch(tr);\n    }\n    return true\n  }\n}\n\n// :: (string, any) → (EditorState, dispatch: ?(tr: Transaction)) → bool\n// Returns a command that sets the given attribute to the given value,\n// and is only available when the currently selected cell doesn't\n// already have that attribute set to that value.\nfunction setCellAttr(name, value) {\n  return function(state, dispatch) {\n    if (!isInTable(state)) { return false }\n    var $cell = selectionCell(state);\n    if ($cell.nodeAfter.attrs[name] === value) { return false }\n    if (dispatch) {\n      var tr = state.tr;\n      if (state.selection instanceof CellSelection)\n        { state.selection.forEachCell(function (node, pos) {\n          if (node.attrs[name] !== value)\n            { tr.setNodeMarkup(pos, null, setAttr(node.attrs, name, value)); }\n        }); }\n      else\n        { tr.setNodeMarkup($cell.pos, null, setAttr($cell.nodeAfter.attrs, name, value)); }\n      dispatch(tr);\n    }\n    return true\n  }\n}\n\nfunction deprecated_toggleHeader(type) {\n  return function(state, dispatch) {\n    if (!isInTable(state)) { return false }\n    if (dispatch) {\n      var types = tableNodeTypes(state.schema);\n      var rect = selectedRect(state), tr = state.tr;\n      var cells = rect.map.cellsInRect(type == \"column\" ? new Rect(rect.left, 0, rect.right, rect.map.height) :\n                                       type == \"row\" ? new Rect(0, rect.top, rect.map.width, rect.bottom) : rect);\n      var nodes = cells.map(function (pos) { return rect.table.nodeAt(pos); });\n      for (var i = 0; i < cells.length; i++) // Remove headers, if any\n        { if (nodes[i].type == types.header_cell)\n          { tr.setNodeMarkup(rect.tableStart + cells[i], types.cell, nodes[i].attrs); } }\n      if (tr.steps.length == 0) { for (var i$1 = 0; i$1 < cells.length; i$1++) // No headers removed, add instead\n        { tr.setNodeMarkup(rect.tableStart + cells[i$1], types.header_cell, nodes[i$1].attrs); } }\n      dispatch(tr);\n    }\n    return true\n  }\n}\n\nfunction isHeaderEnabledByType(type, rect, types) {\n  // Get cell positions for first row or first column\n  var cellPositions = rect.map.cellsInRect({\n    left: 0,\n    top: 0,\n    right: type == \"row\" ? rect.map.width : 1,\n    bottom: type == \"column\" ? rect.map.height : 1,\n  });\n\n  for (var i = 0; i < cellPositions.length; i++) {\n    var cell = rect.table.nodeAt(cellPositions[i]);\n    if (cell && cell.type !== types.header_cell) {\n      return false\n    }\n  }\n\n  return true\n}\n\n// :: (string, ?{ useDeprecatedLogic: bool }) → (EditorState, dispatch: ?(tr: Transaction)) → bool\n// Toggles between row/column header and normal cells (Only applies to first row/column).\n// For deprecated behavior pass `useDeprecatedLogic` in options with true.\nfunction toggleHeader(type, options) {\n  options = options || { useDeprecatedLogic: false };\n\n  if (options.useDeprecatedLogic)\n    { return deprecated_toggleHeader(type) }\n\n  return function(state, dispatch) {\n    if (!isInTable(state)) { return false }\n    if (dispatch) {\n      var types = tableNodeTypes(state.schema);\n      var rect = selectedRect(state), tr = state.tr;\n\n      var isHeaderRowEnabled = isHeaderEnabledByType(\"row\", rect, types);\n      var isHeaderColumnEnabled = isHeaderEnabledByType(\"column\", rect, types);\n\n      var isHeaderEnabled = type === \"column\" ? isHeaderRowEnabled :\n                            type === \"row\"    ? isHeaderColumnEnabled : false;\n\n      var selectionStartsAt = isHeaderEnabled ? 1 : 0;\n\n      var cellsRect = type == \"column\" ? new Rect(0, selectionStartsAt, 1, rect.map.height) :\n                      type == \"row\" ? new Rect(selectionStartsAt, 0, rect.map.width, 1) : rect;\n\n      var newType = type == \"column\" ? isHeaderColumnEnabled ? types.cell : types.header_cell :\n                    type == \"row\" ? isHeaderRowEnabled ? types.cell : types.header_cell : types.cell;\n\n      rect.map.cellsInRect(cellsRect).forEach(function (relativeCellPos) {\n        var cellPos = relativeCellPos + rect.tableStart;\n        var cell = tr.doc.nodeAt(cellPos);\n\n        if (cell) {\n          tr.setNodeMarkup(cellPos, newType, cell.attrs);\n        }\n      });\n\n      dispatch(tr);\n    }\n    return true\n  }\n}\n\n// :: (EditorState, dispatch: ?(tr: Transaction)) → bool\n// Toggles whether the selected row contains header cells.\nvar toggleHeaderRow = toggleHeader(\"row\", { useDeprecatedLogic: true });\n\n// :: (EditorState, dispatch: ?(tr: Transaction)) → bool\n// Toggles whether the selected column contains header cells.\nvar toggleHeaderColumn = toggleHeader(\"column\", { useDeprecatedLogic: true });\n\n// :: (EditorState, dispatch: ?(tr: Transaction)) → bool\n// Toggles whether the selected cells are header cells.\nvar toggleHeaderCell = toggleHeader(\"cell\", { useDeprecatedLogic: true });\n\nfunction findNextCell($cell, dir) {\n  if (dir < 0) {\n    var before = $cell.nodeBefore;\n    if (before) { return $cell.pos - before.nodeSize }\n    for (var row = $cell.index(-1) - 1, rowEnd = $cell.before(); row >= 0; row--) {\n      var rowNode = $cell.node(-1).child(row);\n      if (rowNode.childCount) { return rowEnd - 1 - rowNode.lastChild.nodeSize }\n      rowEnd -= rowNode.nodeSize;\n    }\n  } else {\n    if ($cell.index() < $cell.parent.childCount - 1) { return $cell.pos + $cell.nodeAfter.nodeSize }\n    var table = $cell.node(-1);\n    for (var row$1 = $cell.indexAfter(-1), rowStart = $cell.after(); row$1 < table.childCount; row$1++) {\n      var rowNode$1 = table.child(row$1);\n      if (rowNode$1.childCount) { return rowStart + 1 }\n      rowStart += rowNode$1.nodeSize;\n    }\n  }\n}\n\n// :: (number) → (EditorState, dispatch: ?(tr: Transaction)) → bool\n// Returns a command for selecting the next (direction=1) or previous\n// (direction=-1) cell in a table.\nfunction goToNextCell(direction) {\n  return function(state, dispatch) {\n    if (!isInTable(state)) { return false }\n    var cell = findNextCell(selectionCell(state), direction);\n    if (cell == null) { return }\n    if (dispatch) {\n      var $cell = state.doc.resolve(cell);\n      dispatch(state.tr.setSelection(TextSelection.between($cell, moveCellForward($cell))).scrollIntoView());\n    }\n    return true\n  }\n}\n\n// :: (EditorState, ?(tr: Transaction)) → bool\n// Deletes the table around the selection, if any.\nfunction deleteTable(state, dispatch) {\n  var $pos = state.selection.$anchor;\n  for (var d = $pos.depth; d > 0; d--) {\n    var node = $pos.node(d);\n    if (node.type.spec.tableRole == \"table\") {\n      if (dispatch) { dispatch(state.tr.delete($pos.before(d), $pos.after(d)).scrollIntoView()); }\n      return true\n    }\n  }\n  return false\n}\n\nvar TableView = function TableView(node, cellMinWidth) {\n  this.node = node;\n  this.cellMinWidth = cellMinWidth;\n  this.dom = document.createElement(\"div\");\n  this.dom.className = \"tableWrapper\";\n  this.table = this.dom.appendChild(document.createElement(\"table\"));\n  this.colgroup = this.table.appendChild(document.createElement(\"colgroup\"));\n  updateColumns(node, this.colgroup, this.table, cellMinWidth);\n  this.contentDOM = this.table.appendChild(document.createElement(\"tbody\"));\n};\n\nTableView.prototype.update = function update (node) {\n  if (node.type != this.node.type) { return false }\n  this.node = node;\n  updateColumns(node, this.colgroup, this.table, this.cellMinWidth);\n  return true\n};\n\nTableView.prototype.ignoreMutation = function ignoreMutation (record) {\n  return record.type == \"attributes\" && (record.target == this.table || this.colgroup.contains(record.target))\n};\n\nfunction updateColumns(node, colgroup, table, cellMinWidth, overrideCol, overrideValue) {\n  var totalWidth = 0, fixedWidth = true;\n  var nextDOM = colgroup.firstChild, row = node.firstChild;\n  for (var i = 0, col = 0; i < row.childCount; i++) {\n    var ref = row.child(i).attrs;\n    var colspan = ref.colspan;\n    var colwidth = ref.colwidth;\n    for (var j = 0; j < colspan; j++, col++) {\n      var hasWidth = overrideCol == col ? overrideValue : colwidth && colwidth[j];\n      var cssWidth = hasWidth ? hasWidth + \"px\" : \"\";\n      totalWidth += hasWidth || cellMinWidth;\n      if (!hasWidth) { fixedWidth = false; }\n      if (!nextDOM) {\n        colgroup.appendChild(document.createElement(\"col\")).style.width = cssWidth;\n      } else {\n        if (nextDOM.style.width != cssWidth) { nextDOM.style.width = cssWidth; }\n        nextDOM = nextDOM.nextSibling;\n      }\n    }\n  }\n\n  while (nextDOM) {\n    var after = nextDOM.nextSibling;\n    nextDOM.parentNode.removeChild(nextDOM);\n    nextDOM = after;\n  }\n\n  if (fixedWidth) {\n    table.style.width = totalWidth + \"px\";\n    table.style.minWidth = \"\";\n  } else {\n    table.style.width = \"\";\n    table.style.minWidth = totalWidth + \"px\";\n  }\n}\n\nvar key$1 = new PluginKey(\"tableColumnResizing\");\n\nfunction columnResizing(ref) {\n  if ( ref === void 0 ) ref = {};\n  var handleWidth = ref.handleWidth; if ( handleWidth === void 0 ) handleWidth = 5;\n  var cellMinWidth = ref.cellMinWidth; if ( cellMinWidth === void 0 ) cellMinWidth = 25;\n  var View = ref.View; if ( View === void 0 ) View = TableView;\n  var lastColumnResizable = ref.lastColumnResizable; if ( lastColumnResizable === void 0 ) lastColumnResizable = true;\n\n  var plugin = new Plugin({\n    key: key$1,\n    state: {\n      init: function init(_, state) {\n        this.spec.props.nodeViews[tableNodeTypes(state.schema).table.name] =\n          function (node, view) { return new View(node, cellMinWidth, view); };\n        return new ResizeState(-1, false)\n      },\n      apply: function apply(tr, prev) {\n        return prev.apply(tr)\n      }\n    },\n    props: {\n      attributes: function attributes(state) {\n        var pluginState = key$1.getState(state);\n        return pluginState.activeHandle > -1 ? {class: \"resize-cursor\"} : null\n      },\n\n      handleDOMEvents: {\n        mousemove: function mousemove(view, event) { handleMouseMove(view, event, handleWidth, cellMinWidth, lastColumnResizable); },\n        mouseleave: function mouseleave(view) { handleMouseLeave(view); },\n        mousedown: function mousedown(view, event) { handleMouseDown$1(view, event, cellMinWidth); }\n      },\n\n      decorations: function decorations(state) {\n        var pluginState = key$1.getState(state);\n        if (pluginState.activeHandle > -1) { return handleDecorations(state, pluginState.activeHandle) }\n      },\n\n      nodeViews: {}\n    }\n  });\n  return plugin\n}\n\nvar ResizeState = function ResizeState(activeHandle, dragging) {\n  this.activeHandle = activeHandle;\n  this.dragging = dragging;\n};\n\nResizeState.prototype.apply = function apply (tr) {\n  var state = this, action = tr.getMeta(key$1);\n  if (action && action.setHandle != null)\n    { return new ResizeState(action.setHandle, null) }\n  if (action && action.setDragging !== undefined)\n    { return new ResizeState(state.activeHandle, action.setDragging) }\n  if (state.activeHandle > -1 && tr.docChanged) {\n    var handle = tr.mapping.map(state.activeHandle, -1);\n    if (!pointsAtCell(tr.doc.resolve(handle))) { handle = null; }\n    state = new ResizeState(handle, state.dragging);\n  }\n  return state\n};\n\nfunction handleMouseMove(view, event, handleWidth, cellMinWidth, lastColumnResizable) {\n  var pluginState = key$1.getState(view.state);\n\n  if (!pluginState.dragging) {\n    var target = domCellAround(event.target), cell = -1;\n    if (target) {\n      var ref = target.getBoundingClientRect();\n      var left = ref.left;\n      var right = ref.right;\n      if (event.clientX - left <= handleWidth)\n        { cell = edgeCell(view, event, \"left\"); }\n      else if (right - event.clientX <= handleWidth)\n        { cell = edgeCell(view, event, \"right\"); }\n    }\n\n    if (cell != pluginState.activeHandle) {\n      if (!lastColumnResizable && cell !== -1) {\n        var $cell = view.state.doc.resolve(cell);\n        var table = $cell.node(-1), map = TableMap.get(table), start = $cell.start(-1);\n        var col = map.colCount($cell.pos - start) + $cell.nodeAfter.attrs.colspan - 1;\n\n        if (col == map.width - 1) {\n          return\n        }\n      }\n\n      updateHandle(view, cell);\n    }\n  }\n}\n\nfunction handleMouseLeave(view) {\n  var pluginState = key$1.getState(view.state);\n  if (pluginState.activeHandle > -1 && !pluginState.dragging) { updateHandle(view, -1); }\n}\n\nfunction handleMouseDown$1(view, event, cellMinWidth) {\n  var pluginState = key$1.getState(view.state);\n  if (pluginState.activeHandle == -1 || pluginState.dragging) { return false }\n\n  var cell = view.state.doc.nodeAt(pluginState.activeHandle);\n  var width = currentColWidth(view, pluginState.activeHandle, cell.attrs);\n  view.dispatch(view.state.tr.setMeta(key$1, {setDragging: {startX: event.clientX, startWidth: width}}));\n\n  function finish(event) {\n    window.removeEventListener(\"mouseup\", finish);\n    window.removeEventListener(\"mousemove\", move);\n    var pluginState = key$1.getState(view.state);\n    if (pluginState.dragging) {\n      updateColumnWidth(view, pluginState.activeHandle, draggedWidth(pluginState.dragging, event, cellMinWidth));\n      view.dispatch(view.state.tr.setMeta(key$1, {setDragging: null}));\n    }\n  }\n  function move(event) {\n    if (!event.which) { return finish(event) }\n    var pluginState = key$1.getState(view.state);\n    var dragged = draggedWidth(pluginState.dragging, event, cellMinWidth);\n    displayColumnWidth(view, pluginState.activeHandle, dragged, cellMinWidth);\n  }\n\n  window.addEventListener(\"mouseup\", finish);\n  window.addEventListener(\"mousemove\", move);\n  event.preventDefault();\n  return true\n}\n\nfunction currentColWidth(view, cellPos, ref) {\n  var colspan = ref.colspan;\n  var colwidth = ref.colwidth;\n\n  var width = colwidth && colwidth[colwidth.length - 1];\n  if (width) { return width }\n  var dom = view.domAtPos(cellPos);\n  var node = dom.node.childNodes[dom.offset];\n  var domWidth = node.offsetWidth, parts = colspan;\n  if (colwidth) { for (var i = 0; i < colspan; i++) { if (colwidth[i]) {\n    domWidth -= colwidth[i];\n    parts--;\n  } } }\n  return domWidth / parts\n}\n\nfunction domCellAround(target) {\n  while (target && target.nodeName != \"TD\" && target.nodeName != \"TH\")\n    { target = target.classList.contains(\"ProseMirror\") ? null : target.parentNode; }\n  return target\n}\n\nfunction edgeCell(view, event, side) {\n  var found = view.posAtCoords({left: event.clientX, top: event.clientY});\n  if (!found) { return -1 }\n  var pos = found.pos;\n  var $cell = cellAround(view.state.doc.resolve(pos));\n  if (!$cell) { return -1 }\n  if (side == \"right\") { return $cell.pos }\n  var map = TableMap.get($cell.node(-1)), start = $cell.start(-1);\n  var index = map.map.indexOf($cell.pos - start);\n  return index % map.width == 0 ? -1 : start + map.map[index - 1]\n}\n\nfunction draggedWidth(dragging, event, cellMinWidth) {\n  var offset = event.clientX - dragging.startX;\n  return Math.max(cellMinWidth, dragging.startWidth + offset)\n}\n\nfunction updateHandle(view, value) {\n  view.dispatch(view.state.tr.setMeta(key$1, {setHandle: value}));\n}\n\nfunction updateColumnWidth(view, cell, width) {\n  var $cell = view.state.doc.resolve(cell);\n  var table = $cell.node(-1), map = TableMap.get(table), start = $cell.start(-1);\n  var col = map.colCount($cell.pos - start) + $cell.nodeAfter.attrs.colspan - 1;\n  var tr = view.state.tr;\n  for (var row = 0; row < map.height; row++) {\n    var mapIndex = row * map.width + col;\n    // Rowspanning cell that has already been handled\n    if (row && map.map[mapIndex] == map.map[mapIndex - map.width]) { continue }\n    var pos = map.map[mapIndex];\n    var ref = table.nodeAt(pos);\n    var attrs = ref.attrs;\n    var index = attrs.colspan == 1 ? 0 : col - map.colCount(pos);\n    if (attrs.colwidth && attrs.colwidth[index] == width) { continue }\n    var colwidth = attrs.colwidth ? attrs.colwidth.slice() : zeroes(attrs.colspan);\n    colwidth[index] = width;\n    tr.setNodeMarkup(start + pos, null, setAttr(attrs, \"colwidth\", colwidth));\n  }\n  if (tr.docChanged) { view.dispatch(tr); }\n}\n\nfunction displayColumnWidth(view, cell, width, cellMinWidth) {\n  var $cell = view.state.doc.resolve(cell);\n  var table = $cell.node(-1), start = $cell.start(-1);\n  var col = TableMap.get(table).colCount($cell.pos - start) + $cell.nodeAfter.attrs.colspan - 1;\n  var dom = view.domAtPos($cell.start(-1)).node;\n  while (dom.nodeName != \"TABLE\") { dom = dom.parentNode; }\n  updateColumns(table, dom.firstChild, dom, cellMinWidth, col, width);\n}\n\nfunction zeroes(n) {\n  var result = [];\n  for (var i = 0; i < n; i++) { result.push(0); }\n  return result\n}\n\nfunction handleDecorations(state, cell) {\n  var decorations = [];\n  var $cell = state.doc.resolve(cell);\n  var table = $cell.node(-1), map = TableMap.get(table), start = $cell.start(-1);\n  var col = map.colCount($cell.pos - start) + $cell.nodeAfter.attrs.colspan;\n  for (var row = 0; row < map.height; row++) {\n    var index = col + row * map.width - 1;\n    // For positions that are have either a different cell or the end\n    // of the table to their right, and either the top of the table or\n    // a different cell above them, add a decoration\n    if ((col == map.width || map.map[index] != map.map[index + 1]) &&\n        (row == 0 || map.map[index - 1] != map.map[index - 1 - map.width])) {\n      var cellPos = map.map[index];\n      var pos = start + cellPos + table.nodeAt(cellPos).nodeSize - 1;\n      var dom = document.createElement(\"div\");\n      dom.className = \"column-resize-handle\";\n      decorations.push(Decoration.widget(pos, dom));\n    }\n  }\n  return DecorationSet.create(state.doc, decorations)\n}\n\n// This file defines a plugin that handles the drawing of cell\n\n// :: () → Plugin\n//\n// Creates a [plugin](http://prosemirror.net/docs/ref/#state.Plugin)\n// that, when added to an editor, enables cell-selection, handles\n// cell-based copy/paste, and makes sure tables stay well-formed (each\n// row has the same width, and cells don't overlap).\n//\n// You should probably put this plugin near the end of your array of\n// plugins, since it handles mouse and arrow key events in tables\n// rather broadly, and other plugins, like the gap cursor or the\n// column-width dragging plugin, might want to get a turn first to\n// perform more specific behavior.\nfunction tableEditing(ref) {\n  if ( ref === void 0 ) ref = {};\n  var allowTableNodeSelection = ref.allowTableNodeSelection; if ( allowTableNodeSelection === void 0 ) allowTableNodeSelection = false;\n\n  return new Plugin({\n    key: key,\n\n    // This piece of state is used to remember when a mouse-drag\n    // cell-selection is happening, so that it can continue even as\n    // transactions (which might move its anchor cell) come in.\n    state: {\n      init: function init() { return null },\n      apply: function apply(tr, cur) {\n        var set = tr.getMeta(key);\n        if (set != null) { return set == -1 ? null : set }\n        if (cur == null || !tr.docChanged) { return cur }\n        var ref = tr.mapping.mapResult(cur);\n        var deleted = ref.deleted;\n        var pos = ref.pos;\n        return deleted ? null : pos\n      }\n    },\n\n    props: {\n      decorations: drawCellSelection,\n\n      handleDOMEvents: {\n        mousedown: handleMouseDown\n      },\n\n      createSelectionBetween: function createSelectionBetween(view) {\n        if (key.getState(view.state) != null) { return view.state.selection }\n      },\n\n      handleTripleClick: handleTripleClick,\n\n      handleKeyDown: handleKeyDown,\n\n      handlePaste: handlePaste\n    },\n\n    appendTransaction: function appendTransaction(_, oldState, state) {\n      return normalizeSelection(state, fixTables(state, oldState), allowTableNodeSelection)\n    }\n  })\n}\n\nexport { CellSelection, TableMap, TableView, clipCells as __clipCells, insertCells as __insertCells, pastedCells as __pastedCells, addColSpan, addColumn, addColumnAfter, addColumnBefore, addRow, addRowAfter, addRowBefore, cellAround, colCount, columnIsHeader, columnResizing, key$1 as columnResizingPluginKey, deleteColumn, deleteRow, deleteTable, findCell, fixTables, fixTablesKey, goToNextCell, handlePaste, inSameTable, isInTable, mergeCells, moveCellForward, nextCell, pointsAtCell, removeColSpan, removeColumn, removeRow, rowIsHeader, selectedRect, selectionCell, setAttr, setCellAttr, splitCell, splitCellWithType, tableEditing, key as tableEditingKey, tableNodeTypes, tableNodes, toggleHeader, toggleHeaderCell, toggleHeaderColumn, toggleHeaderRow, updateColumns as updateColumnsOnResize };\n//# sourceMappingURL=index.es.js.map\n"],"sourceRoot":""}