reactjs-tiptap-editor 1.0.5 → 1.0.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/{ActionMenuButton-BS1m0efQ.cjs → ActionMenuButton-DYT5chmX.cjs} +1 -1
- package/lib/{ActionMenuButton-CmYQziyT.js → ActionMenuButton-htJNI0Fa.js} +6 -6
- package/lib/Attachment.cjs +1 -1
- package/lib/Attachment.js +1 -1
- package/lib/Blockquote.cjs +1 -1
- package/lib/Blockquote.js +1 -1
- package/lib/Bold.cjs +1 -1
- package/lib/Bold.js +1 -1
- package/lib/BulletList.cjs +1 -1
- package/lib/BulletList.js +1 -1
- package/lib/Clear.cjs +1 -1
- package/lib/Clear.js +1 -1
- package/lib/Code.cjs +1 -1
- package/lib/Code.js +1 -1
- package/lib/CodeBlock.cjs +1 -1
- package/lib/CodeBlock.js +2 -2
- package/lib/CodeView.cjs +1 -1
- package/lib/CodeView.js +1 -1
- package/lib/Color.cjs +1 -1
- package/lib/Color.js +6 -6
- package/lib/Column.cjs +1 -1
- package/lib/Column.js +1 -1
- package/lib/{Drawer-BCMlTDss.js → Drawer-1211urKj.js} +1 -1
- package/lib/{Drawer-DPVStAKs.cjs → Drawer-DUFUd5BW.cjs} +1 -1
- package/lib/Drawer.cjs +1 -1
- package/lib/Drawer.js +1 -1
- package/lib/Emoji.cjs +1 -1
- package/lib/Emoji.js +1 -1
- package/lib/{Excalidraw-BP-xjF6S.cjs → Excalidraw-CajgZDjU.cjs} +1 -1
- package/lib/{Excalidraw-1dKmqI-3.js → Excalidraw-Du3hBR8t.js} +1 -1
- package/lib/Excalidraw.cjs +1 -1
- package/lib/Excalidraw.js +1 -1
- package/lib/ExportPdf.cjs +1 -1
- package/lib/ExportPdf.js +1 -1
- package/lib/ExportWord.cjs +1 -1
- package/lib/ExportWord.js +1 -1
- package/lib/FontFamily.cjs +1 -1
- package/lib/FontFamily.js +1 -1
- package/lib/FontSize.cjs +1 -1
- package/lib/FontSize.js +1 -1
- package/lib/Heading.cjs +1 -1
- package/lib/Heading.js +1 -1
- package/lib/Highlight.cjs +1 -1
- package/lib/Highlight.js +6 -6
- package/lib/History.cjs +1 -1
- package/lib/History.js +2 -2
- package/lib/HorizontalRule.cjs +1 -1
- package/lib/HorizontalRule.js +1 -1
- package/lib/{Iframe-CeasogsD.cjs → Iframe-CM6mRQmv.cjs} +1 -1
- package/lib/{Iframe-B_GAN9lj.js → Iframe-DTYTLQE6.js} +1 -1
- package/lib/Iframe.cjs +1 -1
- package/lib/Iframe.js +1 -1
- package/lib/Image.cjs +1 -1
- package/lib/Image.js +2 -2
- package/lib/ImageGif.cjs +1 -1
- package/lib/ImageGif.js +1 -1
- package/lib/ImportWord.cjs +1 -1
- package/lib/ImportWord.js +1 -1
- package/lib/{Indent-BGmFt7Dc.cjs → Indent-BmhiEb0S.cjs} +1 -1
- package/lib/{Indent-DCTAYr8i.js → Indent-jOPn3eUM.js} +1 -1
- package/lib/Indent.cjs +1 -1
- package/lib/Indent.js +1 -1
- package/lib/Italic.cjs +1 -1
- package/lib/Italic.js +1 -1
- package/lib/{Katex-CxEAc1xw.js → Katex-CERSrcTP.js} +1 -1
- package/lib/{Katex-CFZB-dZq.cjs → Katex-CUd3LxLh.cjs} +1 -1
- package/lib/Katex.cjs +1 -1
- package/lib/Katex.js +1 -1
- package/lib/LineHeight.cjs +1 -1
- package/lib/LineHeight.js +12 -12
- package/lib/Link.cjs +1 -1
- package/lib/Link.js +1 -1
- package/lib/{LinkEditBlock-C8rPUoNH.js → LinkEditBlock-B5SdhOfa.js} +2 -2
- package/lib/{LinkEditBlock-DiSXJpTN.cjs → LinkEditBlock-DaxljgJC.cjs} +1 -1
- package/lib/Mermaid.cjs +1 -1
- package/lib/Mermaid.js +1 -1
- package/lib/MoreMark.cjs +1 -1
- package/lib/MoreMark.js +14 -14
- package/lib/OrderedList.cjs +1 -1
- package/lib/OrderedList.js +1 -1
- package/lib/SearchAndReplace.cjs +1 -1
- package/lib/SearchAndReplace.js +7 -7
- package/lib/SlashCommand.cjs +1 -1
- package/lib/SlashCommand.js +43 -41
- package/lib/Strike.cjs +1 -1
- package/lib/Strike.js +1 -1
- package/lib/{Table-B9w1GsCg.js → Table-39OkCQbu.js} +1 -1
- package/lib/{Table-B4s9CpR4.cjs → Table-3VstSlg4.cjs} +1 -1
- package/lib/Table.cjs +1 -1
- package/lib/Table.js +1 -1
- package/lib/TaskList.cjs +1 -1
- package/lib/TaskList.js +1 -1
- package/lib/TextAlign.cjs +1 -1
- package/lib/TextAlign.js +2 -2
- package/lib/TextDirection.cjs +1 -1
- package/lib/TextDirection.js +2 -2
- package/lib/TextUnderline.cjs +1 -1
- package/lib/TextUnderline.js +1 -1
- package/lib/{Twitter-B-GTNq1g.js → Twitter-D7PhLycr.js} +18 -18
- package/lib/{Twitter-BVlF0vEs.cjs → Twitter-DuHPeVW1.cjs} +1 -1
- package/lib/Twitter.cjs +1 -1
- package/lib/Twitter.js +1 -1
- package/lib/Video.cjs +1 -1
- package/lib/Video.js +1 -1
- package/lib/bubble.cjs +4 -4
- package/lib/bubble.js +267 -254
- package/lib/{toggle-Bo07J-M7.cjs → toggle-DVCNvcqp.cjs} +1 -1
- package/lib/{toggle-MUGlaI1L.js → toggle-xchtz-Kf.js} +9 -9
- package/package.json +1 -1
package/lib/SlashCommand.js
CHANGED
|
@@ -1,19 +1,20 @@
|
|
|
1
1
|
import { E as A, G as D } from "./index-nFjllrEl.js";
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import { a as
|
|
8
|
-
import { d as
|
|
9
|
-
import { m as
|
|
10
|
-
import { L as
|
|
11
|
-
|
|
2
|
+
import { PluginKey as $ } from "@tiptap/pm/state";
|
|
3
|
+
import { S as B, u as b } from "./updatePosition-DpMKxYdN.js";
|
|
4
|
+
import { jsx as m, jsxs as w, Fragment as V } from "react/jsx-runtime";
|
|
5
|
+
import { forwardRef as z, useState as C, useRef as N, useImperativeHandle as G, useEffect as v, Fragment as O } from "react";
|
|
6
|
+
import { c as P } from "./index-DuZCJJSp.js";
|
|
7
|
+
import { a as T } from "./store-ibARMQ3h.js";
|
|
8
|
+
import { d as F, E as U } from "./events.constant-wrlJ_7JZ.js";
|
|
9
|
+
import { m as q, x as K, u as y } from "./index-0OnGZkVF.js";
|
|
10
|
+
import { L as M } from "./label-DC33TZy_.js";
|
|
11
|
+
import { I as j } from "./Icon-C-qYUAS1.js";
|
|
12
|
+
const _ = {
|
|
12
13
|
setOpen: (t, n) => {
|
|
13
|
-
U
|
|
14
|
+
F(U.UPLOAD_VIDEO(t), n);
|
|
14
15
|
}
|
|
15
16
|
};
|
|
16
|
-
function
|
|
17
|
+
function J({ t }) {
|
|
17
18
|
const n = [
|
|
18
19
|
{
|
|
19
20
|
name: "format",
|
|
@@ -87,7 +88,7 @@ function _({ t }) {
|
|
|
87
88
|
aliases: ["image", "tp", "tupian"],
|
|
88
89
|
shouldBeHidden: (e) => e.isActive("columns"),
|
|
89
90
|
action: ({ editor: e, range: o }) => {
|
|
90
|
-
e.chain().focus().deleteRange(o).run(),
|
|
91
|
+
e.chain().focus().deleteRange(o).run(), T.setOpen(e.id, !0);
|
|
91
92
|
}
|
|
92
93
|
}), n[1].commands.push({
|
|
93
94
|
name: "video",
|
|
@@ -97,7 +98,7 @@ function _({ t }) {
|
|
|
97
98
|
aliases: ["video", "sp", "shipin"],
|
|
98
99
|
shouldBeHidden: (e) => e.isActive("columns"),
|
|
99
100
|
action: ({ editor: e, range: o }) => {
|
|
100
|
-
e.chain().focus().deleteRange(o).run(),
|
|
101
|
+
e.chain().focus().deleteRange(o).run(), _.setOpen(e.id, !0);
|
|
101
102
|
}
|
|
102
103
|
}), n[1].commands.push({
|
|
103
104
|
name: "table",
|
|
@@ -128,7 +129,7 @@ function _({ t }) {
|
|
|
128
129
|
}
|
|
129
130
|
}), n;
|
|
130
131
|
}
|
|
131
|
-
function
|
|
132
|
+
function W(t, n) {
|
|
132
133
|
return t.map((l) => ({
|
|
133
134
|
...l,
|
|
134
135
|
commands: l.commands.filter((c) => {
|
|
@@ -141,14 +142,14 @@ function J(t, n) {
|
|
|
141
142
|
})
|
|
142
143
|
})).filter((l) => l.commands.length > 0);
|
|
143
144
|
}
|
|
144
|
-
const
|
|
145
|
-
function
|
|
146
|
-
const [t, n] =
|
|
145
|
+
const X = q([]);
|
|
146
|
+
function R() {
|
|
147
|
+
const [t, n] = K(X);
|
|
147
148
|
return [t, n];
|
|
148
149
|
}
|
|
149
|
-
function
|
|
150
|
-
const [e] =
|
|
151
|
-
|
|
150
|
+
function Y(t, n) {
|
|
151
|
+
const [e] = R(), [o, l] = C(0), [c, u] = C(0), d = N(null), { t: p } = y(), a = W(e, t.query), f = N([]);
|
|
152
|
+
G(n, () => ({
|
|
152
153
|
onKeyDown: h
|
|
153
154
|
})), v(() => {
|
|
154
155
|
if (!d.current)
|
|
@@ -185,10 +186,10 @@ function X(t, n) {
|
|
|
185
186
|
const s = a[r].commands[i];
|
|
186
187
|
t == null || t.command(s);
|
|
187
188
|
}
|
|
188
|
-
function
|
|
189
|
+
function S(r, i) {
|
|
189
190
|
g(r, i);
|
|
190
191
|
}
|
|
191
|
-
function
|
|
192
|
+
function E(r, i, s) {
|
|
192
193
|
f.current[r * 1e3 + i] = s;
|
|
193
194
|
}
|
|
194
195
|
return /* @__PURE__ */ m(
|
|
@@ -197,14 +198,14 @@ function X(t, n) {
|
|
|
197
198
|
className: "richtext-max-h-[min(80vh,24rem)] richtext-flex-wrap richtext-overflow-y-auto richtext-overflow-x-hidden richtext-rounded-md !richtext-border !richtext-border-solid !richtext-border-border richtext-bg-popover richtext-p-1 richtext-text-popover-foreground richtext-shadow-md richtext-outline-none",
|
|
198
199
|
"data-richtext-portal": !0,
|
|
199
200
|
ref: d,
|
|
200
|
-
children: a != null && a.length ? /* @__PURE__ */ m("div", { className: "richtext-grid richtext-min-w-48 richtext-grid-cols-1 richtext-gap-0.5", children: a == null ? void 0 : a.map((r, i) => /* @__PURE__ */ w(
|
|
201
|
-
/* @__PURE__ */ m(
|
|
201
|
+
children: a != null && a.length ? /* @__PURE__ */ m("div", { className: "richtext-grid richtext-min-w-48 richtext-grid-cols-1 richtext-gap-0.5", children: a == null ? void 0 : a.map((r, i) => /* @__PURE__ */ w(O, { children: [
|
|
202
|
+
/* @__PURE__ */ m(M, { className: "richtext-mx-[4px] richtext-mb-[4px] richtext-mt-[8px] !richtext-text-[0.65rem] richtext-uppercase ", children: r.title }),
|
|
202
203
|
r.commands.map((s, x) => /* @__PURE__ */ w(
|
|
203
204
|
"button",
|
|
204
205
|
{
|
|
205
|
-
onClick: () =>
|
|
206
|
-
ref: (H) =>
|
|
207
|
-
className:
|
|
206
|
+
onClick: () => S(i, x),
|
|
207
|
+
ref: (H) => E(i, x, H),
|
|
208
|
+
className: P("richtext-flex richtext-items-center richtext-gap-3 richtext-px-2 richtext-py-1.5 richtext-text-sm richtext-text-foreground richtext-text-left richtext-w-full richtext-rounded-sm !richtext-outline-none !richtext-border-none richtext-transition-colors !richtext-bg-transparent hover:!richtext-bg-accent ", {
|
|
208
209
|
"bg-item-active": c === i && o === x
|
|
209
210
|
}),
|
|
210
211
|
children: [
|
|
@@ -217,7 +218,7 @@ function X(t, n) {
|
|
|
217
218
|
}
|
|
218
219
|
),
|
|
219
220
|
s.iconName && /* @__PURE__ */ m(
|
|
220
|
-
|
|
221
|
+
j,
|
|
221
222
|
{
|
|
222
223
|
className: "!richtext-mr-1 !richtext-text-lg",
|
|
223
224
|
name: s.iconName
|
|
@@ -232,19 +233,19 @@ function X(t, n) {
|
|
|
232
233
|
}
|
|
233
234
|
);
|
|
234
235
|
}
|
|
235
|
-
const
|
|
236
|
-
function
|
|
237
|
-
const [, n] =
|
|
236
|
+
const Z = z(Y);
|
|
237
|
+
function me({ commandList: t }) {
|
|
238
|
+
const [, n] = R(), { t: e } = y();
|
|
238
239
|
return v(() => {
|
|
239
240
|
if (!(t != null && t.length)) {
|
|
240
|
-
const o =
|
|
241
|
+
const o = J({ t: e });
|
|
241
242
|
n(o);
|
|
242
243
|
return;
|
|
243
244
|
}
|
|
244
245
|
n(t);
|
|
245
|
-
}, [e, t]), /* @__PURE__ */ m(
|
|
246
|
+
}, [e, t]), /* @__PURE__ */ m(V, {});
|
|
246
247
|
}
|
|
247
|
-
const
|
|
248
|
+
const de = /* @__PURE__ */ A.create({
|
|
248
249
|
name: "richtextSlashCommand",
|
|
249
250
|
priority: 200,
|
|
250
251
|
// addOptions() {
|
|
@@ -256,7 +257,8 @@ const le = /* @__PURE__ */ A.create({
|
|
|
256
257
|
// },
|
|
257
258
|
addProseMirrorPlugins() {
|
|
258
259
|
return [
|
|
259
|
-
|
|
260
|
+
B({
|
|
261
|
+
pluginKey: new $("richtextSlashCommandPlugin"),
|
|
260
262
|
editor: this.editor,
|
|
261
263
|
char: "/",
|
|
262
264
|
// allowSpaces: true,
|
|
@@ -286,7 +288,7 @@ const le = /* @__PURE__ */ A.create({
|
|
|
286
288
|
let t;
|
|
287
289
|
return {
|
|
288
290
|
onStart: (n) => {
|
|
289
|
-
n.clientRect && (t = new D(
|
|
291
|
+
n.clientRect && (t = new D(Z, {
|
|
290
292
|
props: n,
|
|
291
293
|
editor: n.editor
|
|
292
294
|
}), t.element.style.position = "absolute", document.body.appendChild(t.element), b(n.editor, t.element));
|
|
@@ -308,8 +310,8 @@ const le = /* @__PURE__ */ A.create({
|
|
|
308
310
|
}
|
|
309
311
|
});
|
|
310
312
|
export {
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
313
|
+
de as SlashCommand,
|
|
314
|
+
me as SlashCommandList,
|
|
315
|
+
J as renderCommandListDefault,
|
|
316
|
+
W as useFilterCommandList
|
|
315
317
|
};
|
package/lib/Strike.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("./index-DLqogznp.cjs"),n=require("react/jsx-runtime"),m=require("./toggle-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("./index-DLqogznp.cjs"),n=require("react/jsx-runtime"),m=require("./toggle-DVCNvcqp.cjs");require("react");require("./index-CNzHZDls.cjs");const u=require("./useButtonProps-bei1vI37.cjs");var h=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))$/,S=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))/g,f=r.Mark.create({name:"strike",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"s"},{tag:"del"},{tag:"strike"},{style:"text-decoration",consuming:!1,getAttrs:t=>t.includes("line-through")?{}:!1}]},renderHTML({HTMLAttributes:t}){return["s",r.mergeAttributes(this.options.HTMLAttributes,t),0]},markdownTokenName:"del",parseMarkdown:(t,e)=>e.applyMark("strike",e.parseInline(t.tokens||[])),renderMarkdown:(t,e)=>`~~${e.renderChildren(t)}~~`,addCommands(){return{setStrike:()=>({commands:t})=>t.setMark(this.name),toggleStrike:()=>({commands:t})=>t.toggleMark(this.name),unsetStrike:()=>({commands:t})=>t.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-Shift-s":()=>this.editor.commands.toggleStrike()}},addInputRules(){return[r.markInputRule({find:h,type:this.type})]},addPasteRules(){return[r.markPasteRule({find:S,type:this.type})]}});function v(){const t=u.useButtonProps(d.name),{icon:e=void 0,tooltip:i=void 0,shortcutKeys:s=void 0,tooltipOptions:c={},action:o=void 0,isActive:l=void 0}=(t==null?void 0:t.componentProps)??{},{dataState:p,disabled:a,update:k}=u.useToggleActive(l),g=()=>{a||o&&(o(),k())};return t?n.jsx(m.ActionButton,{action:g,dataState:p,disabled:a,icon:e,shortcutKeys:s,tooltip:i,tooltipOptions:c}):n.jsx(n.Fragment,{})}const d=f.extend({addOptions(){var t;return{...(t=this.parent)==null?void 0:t.call(this),button:({editor:e,t:i,extension:s})=>({componentProps:{action:()=>e.commands.toggleStrike(),isActive:()=>e.isActive("strike")||!1,disabled:!1,icon:"Strikethrough",shortcutKeys:s.options.shortcutKeys??["shift","mod","S"],tooltip:i("editor.strike.tooltip")}})}}});exports.RichTextStrike=v;exports.Strike=d;
|
package/lib/Strike.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { M as c, h as k, j as l, m as g } from "./index-nFjllrEl.js";
|
|
2
2
|
import { jsx as n, Fragment as h } from "react/jsx-runtime";
|
|
3
|
-
import { A as f } from "./toggle-
|
|
3
|
+
import { A as f } from "./toggle-xchtz-Kf.js";
|
|
4
4
|
import "react";
|
|
5
5
|
import "./index-DuZCJJSp.js";
|
|
6
6
|
import { u as M, a as S } from "./useButtonProps-D0SrPzuG.js";
|
|
@@ -2,7 +2,7 @@ import { U as de, S as E, Z as Ve, T as $, F as v, x as L, Q as ke, v as Ke, _ a
|
|
|
2
2
|
import { TextSelection as Ze } from "@tiptap/pm/state";
|
|
3
3
|
import { k as Je, D as oe, a as ne } from "./index-BeUrdBxf.js";
|
|
4
4
|
import { jsxs as ee, jsx as k, Fragment as Ye } from "react/jsx-runtime";
|
|
5
|
-
import { A as Qe } from "./toggle-
|
|
5
|
+
import { A as Qe } from "./toggle-xchtz-Kf.js";
|
|
6
6
|
import { useState as _ } from "react";
|
|
7
7
|
import "./index-DuZCJJSp.js";
|
|
8
8
|
import { T as O, n as F, o as j } from "./index-0OnGZkVF.js";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";const g=require("./index-DLqogznp.cjs"),_e=require("@tiptap/pm/state"),D=require("./index-DCJheRBq.cjs"),A=require("react/jsx-runtime"),Ie=require("./toggle-Bo07J-M7.cjs"),W=require("react");require("./index-CNzHZDls.cjs");const v=require("./index-FSRjMsxW.cjs"),X=require("./popover-CZWSQZ0q.cjs"),Z=require("./useButtonProps-bei1vI37.cjs");let J,Y;if(typeof WeakMap<"u"){let t=new WeakMap;J=e=>t.get(e),Y=(e,n)=>(t.set(e,n),n)}else{const t=[];let n=0;J=o=>{for(let l=0;l<t.length;l+=2)if(t[l]==o)return t[l+1]},Y=(o,l)=>(n==10&&(n=0),t[n++]=o,t[n++]=l)}var y=class{constructor(t,e,n,o){this.width=t,this.height=e,this.map=n,this.problems=o}findCell(t){for(let e=0;e<this.map.length;e++){const n=this.map[e];if(n!=t)continue;const o=e%this.width,l=e/this.width|0;let r=o+1,s=l+1;for(let i=1;r<this.width&&this.map[e+i]==n;i++)r++;for(let i=1;s<this.height&&this.map[e+this.width*i]==n;i++)s++;return{left:o,top:l,right:r,bottom:s}}throw new RangeError(`No cell with offset ${t} found`)}colCount(t){for(let e=0;e<this.map.length;e++)if(this.map[e]==t)return e%this.width;throw new RangeError(`No cell with offset ${t} found`)}nextCell(t,e,n){const{left:o,right:l,top:r,bottom:s}=this.findCell(t);return e=="horiz"?(n<0?o==0:l==this.width)?null:this.map[r*this.width+(n<0?o-1:l)]:(n<0?r==0:s==this.height)?null:this.map[o+this.width*(n<0?r-1:s)]}rectBetween(t,e){const{left:n,right:o,top:l,bottom:r}=this.findCell(t),{left:s,right:i,top:c,bottom:a}=this.findCell(e);return{left:Math.min(n,s),top:Math.min(l,c),right:Math.max(o,i),bottom:Math.max(r,a)}}cellsInRect(t){const e=[],n={};for(let o=t.top;o<t.bottom;o++)for(let l=t.left;l<t.right;l++){const r=o*this.width+l,s=this.map[r];n[s]||(n[s]=!0,!(l==t.left&&l&&this.map[r-1]==s||o==t.top&&o&&this.map[r-this.width]==s)&&e.push(s))}return e}positionAt(t,e,n){for(let o=0,l=0;;o++){const r=l+n.child(o).nodeSize;if(o==t){let s=e+t*this.width;const i=(t+1)*this.width;for(;s<i&&this.map[s]<l;)s++;return s==i?r-1:this.map[s]}l=r}}static get(t){return J(t)||Y(t,Be(t))}};function Be(t){if(t.type.spec.tableRole!="table")throw new RangeError("Not a table node: "+t.type.name);const e=$e(t),n=t.childCount,o=[];let l=0,r=null;const s=[];for(let a=0,d=e*n;a<d;a++)o[a]=0;for(let a=0,d=0;a<n;a++){const u=t.child(a);d++;for(let p=0;;p++){for(;l<o.length&&o[l]!=0;)l++;if(p==u.childCount)break;const m=u.child(p),{colspan:b,rowspan:w,colwidth:x}=m.attrs;for(let R=0;R<w;R++){if(R+a>=n){(r||(r=[])).push({type:"overlong_rowspan",pos:d,n:w-R});break}const L=l+R*e;for(let M=0;M<b;M++){o[L+M]==0?o[L+M]=d:(r||(r=[])).push({type:"collision",row:a,pos:d,n:b-M});const $=x&&x[M];if($){const I=(L+M)%e*2,K=s[I];K==null||K!=$&&s[I+1]==1?(s[I]=$,s[I+1]=1):K==$&&s[I+1]++}}}l+=b,d+=m.nodeSize}const f=(a+1)*e;let h=0;for(;l<f;)o[l++]==0&&h++;h&&(r||(r=[])).push({type:"missing",row:a,n:h}),d++}(e===0||n===0)&&(r||(r=[])).push({type:"zero_sized"});const i=new y(e,n,o,r);let c=!1;for(let a=0;!c&&a<s.length;a+=2)s[a]!=null&&s[a+1]<n&&(c=!0);return c&&We(i,s,t),i}function $e(t){let e=-1,n=!1;for(let o=0;o<t.childCount;o++){const l=t.child(o);let r=0;if(n)for(let s=0;s<o;s++){const i=t.child(s);for(let c=0;c<i.childCount;c++){const a=i.child(c);s+a.attrs.rowspan>o&&(r+=a.attrs.colspan)}}for(let s=0;s<l.childCount;s++){const i=l.child(s);r+=i.attrs.colspan,i.attrs.rowspan>1&&(n=!0)}e==-1?e=r:e!=r&&(e=Math.max(e,r))}return e}function We(t,e,n){t.problems||(t.problems=[]);const o={};for(let l=0;l<t.map.length;l++){const r=t.map[l];if(o[r])continue;o[r]=!0;const s=n.nodeAt(r);if(!s)throw new RangeError(`No cell with offset ${r} found`);let i=null;const c=s.attrs;for(let a=0;a<c.colspan;a++){const d=e[(l+a)%t.width*2];d!=null&&(!c.colwidth||c.colwidth[a]!=d)&&((i||(i=Fe(c)))[a]=d)}i&&t.problems.unshift({type:"colwidth mismatch",pos:r,colwidth:i})}}function Fe(t){if(t.colwidth)return t.colwidth.slice();const e=[];for(let n=0;n<t.colspan;n++)e.push(0);return e}function S(t){let e=t.cached.tableNodeTypes;if(!e){e=t.cached.tableNodeTypes={};for(const n in t.nodes){const o=t.nodes[n],l=o.spec.tableRole;l&&(e[l]=o)}}return e}const z=new g.PluginKey("selectingCells");function _(t){for(let e=t.depth-1;e>0;e--)if(t.node(e).type.spec.tableRole=="row")return t.node(0).resolve(t.before(e+1));return null}function Pe(t){for(let e=t.depth;e>0;e--){const n=t.node(e).type.spec.tableRole;if(n==="cell"||n==="header_cell")return t.node(e)}return null}function E(t){const e=t.selection.$head;for(let n=e.depth;n>0;n--)if(e.node(n).type.spec.tableRole=="row")return!0;return!1}function q(t){const e=t.selection;if("$anchorCell"in e&&e.$anchorCell)return e.$anchorCell.pos>e.$headCell.pos?e.$anchorCell:e.$headCell;if("node"in e&&e.node&&e.node.type.spec.tableRole=="cell")return e.$anchor;const n=_(e.$head)||je(e.$head);if(n)return n;throw new RangeError(`No cell found around position ${e.head}`)}function je(t){for(let e=t.nodeAfter,n=t.pos;e;e=e.firstChild,n++){const o=e.type.spec.tableRole;if(o=="cell"||o=="header_cell")return t.doc.resolve(n)}for(let e=t.nodeBefore,n=t.pos;e;e=e.lastChild,n--){const o=e.type.spec.tableRole;if(o=="cell"||o=="header_cell")return t.doc.resolve(n-e.nodeSize)}}function Q(t){return t.parent.type.spec.tableRole=="row"&&!!t.nodeAfter}function Oe(t){return t.node(0).resolve(t.pos+t.nodeAfter.nodeSize)}function oe(t,e){return t.depth==e.depth&&t.pos>=e.start(-1)&&t.pos<=e.end(-1)}function Se(t,e,n){const o=t.node(-1),l=y.get(o),r=t.start(-1),s=l.nextCell(t.pos-r,e,n);return s==null?null:t.node(0).resolve(r+s)}function H(t,e,n=1){const o={...t,colspan:t.colspan-n};return o.colwidth&&(o.colwidth=o.colwidth.slice(),o.colwidth.splice(e,n),o.colwidth.some(l=>l>0)||(o.colwidth=null)),o}function xe(t,e,n=1){const o={...t,colspan:t.colspan+n};if(o.colwidth){o.colwidth=o.colwidth.slice();for(let l=0;l<n;l++)o.colwidth.splice(e,0,0)}return o}function Ge(t,e,n){const o=S(e.type.schema).header_cell;for(let l=0;l<t.height;l++)if(e.nodeAt(t.map[n+l*t.width]).type!=o)return!1;return!0}var C=class k extends g.Selection{constructor(e,n=e){const o=e.node(-1),l=y.get(o),r=e.start(-1),s=l.rectBetween(e.pos-r,n.pos-r),i=e.node(0),c=l.cellsInRect(s).filter(d=>d!=n.pos-r);c.unshift(n.pos-r);const a=c.map(d=>{const u=o.nodeAt(d);if(!u)throw new RangeError(`No cell with offset ${d} found`);const f=r+d+1;return new g.SelectionRange(i.resolve(f),i.resolve(f+u.content.size))});super(a[0].$from,a[0].$to,a),this.$anchorCell=e,this.$headCell=n}map(e,n){const o=e.resolve(n.map(this.$anchorCell.pos)),l=e.resolve(n.map(this.$headCell.pos));if(Q(o)&&Q(l)&&oe(o,l)){const r=this.$anchorCell.node(-1)!=o.node(-1);return r&&this.isRowSelection()?k.rowSelection(o,l):r&&this.isColSelection()?k.colSelection(o,l):new k(o,l)}return g.TextSelection.between(o,l)}content(){const e=this.$anchorCell.node(-1),n=y.get(e),o=this.$anchorCell.start(-1),l=n.rectBetween(this.$anchorCell.pos-o,this.$headCell.pos-o),r={},s=[];for(let c=l.top;c<l.bottom;c++){const a=[];for(let d=c*n.width+l.left,u=l.left;u<l.right;u++,d++){const f=n.map[d];if(r[f])continue;r[f]=!0;const h=n.findCell(f);let p=e.nodeAt(f);if(!p)throw new RangeError(`No cell with offset ${f} found`);const m=l.left-h.left,b=h.right-l.right;if(m>0||b>0){let w=p.attrs;if(m>0&&(w=H(w,0,m)),b>0&&(w=H(w,w.colspan-b,b)),h.left<l.left){if(p=p.type.createAndFill(w),!p)throw new RangeError(`Could not create cell with attrs ${JSON.stringify(w)}`)}else p=p.type.create(w,p.content)}if(h.top<l.top||h.bottom>l.bottom){const w={...p.attrs,rowspan:Math.min(h.bottom,l.bottom)-Math.max(h.top,l.top)};h.top<l.top?p=p.type.createAndFill(w):p=p.type.create(w,p.content)}a.push(p)}s.push(e.child(c).copy(g.Fragment.from(a)))}const i=this.isColSelection()&&this.isRowSelection()?e:s;return new g.Slice(g.Fragment.from(i),1,1)}replace(e,n=g.Slice.empty){const o=e.steps.length,l=this.ranges;for(let s=0;s<l.length;s++){const{$from:i,$to:c}=l[s],a=e.mapping.slice(o);e.replace(a.map(i.pos),a.map(c.pos),s?g.Slice.empty:n)}const r=g.Selection.findFrom(e.doc.resolve(e.mapping.slice(o).map(this.to)),-1);r&&e.setSelection(r)}replaceWith(e,n){this.replace(e,new g.Slice(g.Fragment.from(n),0,0))}forEachCell(e){const n=this.$anchorCell.node(-1),o=y.get(n),l=this.$anchorCell.start(-1),r=o.cellsInRect(o.rectBetween(this.$anchorCell.pos-l,this.$headCell.pos-l));for(let s=0;s<r.length;s++)e(n.nodeAt(r[s]),l+r[s])}isColSelection(){const e=this.$anchorCell.index(-1),n=this.$headCell.index(-1);if(Math.min(e,n)>0)return!1;const o=e+this.$anchorCell.nodeAfter.attrs.rowspan,l=n+this.$headCell.nodeAfter.attrs.rowspan;return Math.max(o,l)==this.$headCell.node(-1).childCount}static colSelection(e,n=e){const o=e.node(-1),l=y.get(o),r=e.start(-1),s=l.findCell(e.pos-r),i=l.findCell(n.pos-r),c=e.node(0);return s.top<=i.top?(s.top>0&&(e=c.resolve(r+l.map[s.left])),i.bottom<l.height&&(n=c.resolve(r+l.map[l.width*(l.height-1)+i.right-1]))):(i.top>0&&(n=c.resolve(r+l.map[i.left])),s.bottom<l.height&&(e=c.resolve(r+l.map[l.width*(l.height-1)+s.right-1]))),new k(e,n)}isRowSelection(){const e=this.$anchorCell.node(-1),n=y.get(e),o=this.$anchorCell.start(-1),l=n.colCount(this.$anchorCell.pos-o),r=n.colCount(this.$headCell.pos-o);if(Math.min(l,r)>0)return!1;const s=l+this.$anchorCell.nodeAfter.attrs.colspan,i=r+this.$headCell.nodeAfter.attrs.colspan;return Math.max(s,i)==n.width}eq(e){return e instanceof k&&e.$anchorCell.pos==this.$anchorCell.pos&&e.$headCell.pos==this.$headCell.pos}static rowSelection(e,n=e){const o=e.node(-1),l=y.get(o),r=e.start(-1),s=l.findCell(e.pos-r),i=l.findCell(n.pos-r),c=e.node(0);return s.left<=i.left?(s.left>0&&(e=c.resolve(r+l.map[s.top*l.width])),i.right<l.width&&(n=c.resolve(r+l.map[l.width*(i.top+1)-1]))):(i.left>0&&(n=c.resolve(r+l.map[i.top*l.width])),s.right<l.width&&(e=c.resolve(r+l.map[l.width*(s.top+1)-1]))),new k(e,n)}toJSON(){return{type:"cell",anchor:this.$anchorCell.pos,head:this.$headCell.pos}}static fromJSON(e,n){return new k(e.resolve(n.anchor),e.resolve(n.head))}static create(e,n,o=n){return new k(e.resolve(n),e.resolve(o))}getBookmark(){return new Ve(this.$anchorCell.pos,this.$headCell.pos)}};C.prototype.visible=!1;g.Selection.jsonID("cell",C);var Ve=class Ae{constructor(e,n){this.anchor=e,this.head=n}map(e){return new Ae(e.map(this.anchor),e.map(this.head))}resolve(e){const n=e.resolve(this.anchor),o=e.resolve(this.head);return n.parent.type.spec.tableRole=="row"&&o.parent.type.spec.tableRole=="row"&&n.index()<n.parent.childCount&&o.index()<o.parent.childCount&&oe(n,o)?new C(n,o):g.Selection.near(o,1)}};function qe(t){if(!(t.selection instanceof C))return null;const e=[];return t.selection.forEachCell((n,o)=>{e.push(D.Decoration.node(o,o+n.nodeSize,{class:"selectedCell"}))}),D.DecorationSet.create(t.doc,e)}function Ke({$from:t,$to:e}){if(t.pos==e.pos||t.pos<e.pos-6)return!1;let n=t.pos,o=e.pos,l=t.depth;for(;l>=0&&!(t.after(l+1)<t.end(l));l--,n++);for(let r=e.depth;r>=0&&!(e.before(r+1)>e.start(r));r--,o--);return n==o&&/row|table/.test(t.node(l).type.spec.tableRole)}function Xe({$from:t,$to:e}){let n,o;for(let l=t.depth;l>0;l--){const r=t.node(l);if(r.type.spec.tableRole==="cell"||r.type.spec.tableRole==="header_cell"){n=r;break}}for(let l=e.depth;l>0;l--){const r=e.node(l);if(r.type.spec.tableRole==="cell"||r.type.spec.tableRole==="header_cell"){o=r;break}}return n!==o&&e.parentOffset===0}function Ze(t,e,n){const o=(e||t).selection,l=(e||t).doc;let r,s;if(o instanceof g.NodeSelection&&(s=o.node.type.spec.tableRole)){if(s=="cell"||s=="header_cell")r=C.create(l,o.from);else if(s=="row"){const i=l.resolve(o.from+1);r=C.rowSelection(i,i)}else if(!n){const i=y.get(o.node),c=o.from+1,a=c+i.map[i.width*i.height-1];r=C.create(l,c+1,a)}}else o instanceof g.TextSelection&&Ke(o)?r=g.TextSelection.create(l,o.from):o instanceof g.TextSelection&&Xe(o)&&(r=g.TextSelection.create(l,o.$from.start(),o.$from.end()));return r&&(e||(e=t.tr)).setSelection(r),e}const Ue=new g.PluginKey("fix-tables");function Te(t,e,n,o){const l=t.childCount,r=e.childCount;e:for(let s=0,i=0;s<r;s++){const c=e.child(s);for(let a=i,d=Math.min(l,s+3);a<d;a++)if(t.child(a)==c){i=a+1,n+=c.nodeSize;continue e}o(c,n),i<l&&t.child(i).sameMarkup(c)?Te(t.child(i),c,n+1,o):c.nodesBetween(0,c.content.size,o,n+1),n+=c.nodeSize}}function Re(t,e){let n;const o=(l,r)=>{l.type.spec.tableRole=="table"&&(n=Je(t,l,r,n))};return e?e.doc!=t.doc&&Te(e.doc,t.doc,0,o):t.doc.descendants(o),n}function Je(t,e,n,o){const l=y.get(e);if(!l.problems)return o;o||(o=t.tr);const r=[];for(let c=0;c<l.height;c++)r.push(0);for(let c=0;c<l.problems.length;c++){const a=l.problems[c];if(a.type=="collision"){const d=e.nodeAt(a.pos);if(!d)continue;const u=d.attrs;for(let f=0;f<u.rowspan;f++)r[a.row+f]+=a.n;o.setNodeMarkup(o.mapping.map(n+1+a.pos),null,H(u,u.colspan-a.n,a.n))}else if(a.type=="missing")r[a.row]+=a.n;else if(a.type=="overlong_rowspan"){const d=e.nodeAt(a.pos);if(!d)continue;o.setNodeMarkup(o.mapping.map(n+1+a.pos),null,{...d.attrs,rowspan:d.attrs.rowspan-a.n})}else if(a.type=="colwidth mismatch"){const d=e.nodeAt(a.pos);if(!d)continue;o.setNodeMarkup(o.mapping.map(n+1+a.pos),null,{...d.attrs,colwidth:a.colwidth})}else if(a.type=="zero_sized"){const d=o.mapping.map(n);o.delete(d,d+e.nodeSize)}}let s,i;for(let c=0;c<r.length;c++)r[c]&&(s==null&&(s=c),i=c);for(let c=0,a=n+1;c<l.height;c++){const d=e.child(c),u=a+d.nodeSize,f=r[c];if(f>0){let h="cell";d.firstChild&&(h=d.firstChild.type.spec.tableRole);const p=[];for(let b=0;b<f;b++){const w=S(t.schema)[h].createAndFill();w&&p.push(w)}const m=(c==0||s==c-1)&&i==c?a+1:u-1;o.insert(o.mapping.map(m),p)}a=u}return o.setMeta(Ue,{fixTables:!0})}function N(t){const e=t.selection,n=q(t),o=n.node(-1),l=n.start(-1),r=y.get(o);return{...e instanceof C?r.rectBetween(e.$anchorCell.pos-l,e.$headCell.pos-l):r.findCell(n.pos-l),tableStart:l,map:r,table:o}}function ve(t,{map:e,tableStart:n,table:o},l){let r=l>0?-1:0;Ge(e,o,l+r)&&(r=l==0||l==e.width?null:0);for(let s=0;s<e.height;s++){const i=s*e.width+l;if(l>0&&l<e.width&&e.map[i-1]==e.map[i]){const c=e.map[i],a=o.nodeAt(c);t.setNodeMarkup(t.mapping.map(n+c),null,xe(a.attrs,l-e.colCount(c))),s+=a.attrs.rowspan-1}else{const c=r==null?S(o.type.schema).cell:o.nodeAt(e.map[i+r]).type,a=e.positionAt(s,l,o);t.insert(t.mapping.map(n+a),c.createAndFill())}}return t}function Ye(t,e){if(!E(t))return!1;if(e){const n=N(t);e(ve(t.tr,n,n.left))}return!0}function Qe(t,e){if(!E(t))return!1;if(e){const n=N(t);e(ve(t.tr,n,n.right))}return!0}function et(t,{map:e,table:n,tableStart:o},l){const r=t.mapping.maps.length;for(let s=0;s<e.height;){const i=s*e.width+l,c=e.map[i],a=n.nodeAt(c),d=a.attrs;if(l>0&&e.map[i-1]==c||l<e.width-1&&e.map[i+1]==c)t.setNodeMarkup(t.mapping.slice(r).map(o+c),null,H(d,l-e.colCount(c)));else{const u=t.mapping.slice(r).map(o+c);t.delete(u,u+a.nodeSize)}s+=d.rowspan}}function tt(t,e){if(!E(t))return!1;if(e){const n=N(t),o=t.tr;if(n.left==0&&n.right==n.map.width)return!1;for(let l=n.right-1;et(o,n,l),l!=n.left;l--){const r=n.tableStart?o.doc.nodeAt(n.tableStart-1):o.doc;if(!r)throw new RangeError("No table found");n.table=r,n.map=y.get(r)}e(o)}return!0}function nt(t,e,n){var o;const l=S(e.type.schema).header_cell;for(let r=0;r<t.width;r++)if(((o=e.nodeAt(t.map[r+n*t.width]))===null||o===void 0?void 0:o.type)!=l)return!1;return!0}function Me(t,{map:e,tableStart:n,table:o},l){let r=n;for(let a=0;a<l;a++)r+=o.child(a).nodeSize;const s=[];let i=l>0?-1:0;nt(e,o,l+i)&&(i=l==0||l==e.height?null:0);for(let a=0,d=e.width*l;a<e.width;a++,d++)if(l>0&&l<e.height&&e.map[d]==e.map[d-e.width]){const u=e.map[d],f=o.nodeAt(u).attrs;t.setNodeMarkup(n+u,null,{...f,rowspan:f.rowspan+1}),a+=f.colspan-1}else{var c;const u=i==null?S(o.type.schema).cell:(c=o.nodeAt(e.map[d+i*e.width]))===null||c===void 0?void 0:c.type,f=u==null?void 0:u.createAndFill();f&&s.push(f)}return t.insert(r,S(o.type.schema).row.create(null,s)),t}function ot(t,e){if(!E(t))return!1;if(e){const n=N(t);e(Me(t.tr,n,n.top))}return!0}function lt(t,e){if(!E(t))return!1;if(e){const n=N(t);e(Me(t.tr,n,n.bottom))}return!0}function rt(t,{map:e,table:n,tableStart:o},l){let r=0;for(let a=0;a<l;a++)r+=n.child(a).nodeSize;const s=r+n.child(l).nodeSize,i=t.mapping.maps.length;t.delete(r+o,s+o);const c=new Set;for(let a=0,d=l*e.width;a<e.width;a++,d++){const u=e.map[d];if(!c.has(u)){if(c.add(u),l>0&&u==e.map[d-e.width]){const f=n.nodeAt(u).attrs;t.setNodeMarkup(t.mapping.slice(i).map(u+o),null,{...f,rowspan:f.rowspan-1}),a+=f.colspan-1}else if(l<e.height&&u==e.map[d+e.width]){const f=n.nodeAt(u),h=f.attrs,p=f.type.create({...h,rowspan:f.attrs.rowspan-1},f.content),m=e.positionAt(l+1,a,n);t.insert(t.mapping.slice(i).map(o+m),p),a+=h.colspan-1}}}}function st(t,e){if(!E(t))return!1;if(e){const n=N(t),o=t.tr;if(n.top==0&&n.bottom==n.map.height)return!1;for(let l=n.bottom-1;rt(o,n,l),l!=n.top;l--){const r=n.tableStart?o.doc.nodeAt(n.tableStart-1):o.doc;if(!r)throw new RangeError("No table found");n.table=r,n.map=y.get(n.table)}e(o)}return!0}function le(t){const e=t.content;return e.childCount==1&&e.child(0).isTextblock&&e.child(0).childCount==0}function it({width:t,height:e,map:n},o){let l=o.top*t+o.left,r=l,s=(o.bottom-1)*t+o.left,i=l+(o.right-o.left-1);for(let c=o.top;c<o.bottom;c++){if(o.left>0&&n[r]==n[r-1]||o.right<t&&n[i]==n[i+1])return!0;r+=t,i+=t}for(let c=o.left;c<o.right;c++){if(o.top>0&&n[l]==n[l-t]||o.bottom<e&&n[s]==n[s+t])return!0;l++,s++}return!1}function re(t,e){const n=t.selection;if(!(n instanceof C)||n.$anchorCell.pos==n.$headCell.pos)return!1;const o=N(t),{map:l}=o;if(it(l,o))return!1;if(e){const r=t.tr,s={};let i=g.Fragment.empty,c,a;for(let d=o.top;d<o.bottom;d++)for(let u=o.left;u<o.right;u++){const f=l.map[d*l.width+u],h=o.table.nodeAt(f);if(!(s[f]||!h))if(s[f]=!0,c==null)c=f,a=h;else{le(h)||(i=i.append(h.content));const p=r.mapping.map(f+o.tableStart);r.delete(p,p+h.nodeSize)}}if(c==null||a==null)return!0;if(r.setNodeMarkup(c+o.tableStart,null,{...xe(a.attrs,a.attrs.colspan,o.right-o.left-a.attrs.colspan),rowspan:o.bottom-o.top}),i.size>0){const d=c+1+a.content.size,u=le(a)?c+1:d;r.replaceWith(u+o.tableStart,d+o.tableStart,i)}r.setSelection(new C(r.doc.resolve(c+o.tableStart))),e(r)}return!0}function se(t,e){const n=S(t.schema);return ct(({node:o})=>n[o.type.spec.tableRole])(t,e)}function ct(t){return(e,n)=>{const o=e.selection;let l,r;if(o instanceof C){if(o.$anchorCell.pos!=o.$headCell.pos)return!1;l=o.$anchorCell.nodeAfter,r=o.$anchorCell.pos}else{var s;if(l=Pe(o.$from),!l)return!1;r=(s=_(o.$from))===null||s===void 0?void 0:s.pos}if(l==null||r==null||l.attrs.colspan==1&&l.attrs.rowspan==1)return!1;if(n){let i=l.attrs;const c=[],a=i.colwidth;i.rowspan>1&&(i={...i,rowspan:1}),i.colspan>1&&(i={...i,colspan:1});const d=N(e),u=e.tr;for(let h=0;h<d.right-d.left;h++)c.push(a?{...i,colwidth:a&&a[h]?[a[h]]:null}:i);let f;for(let h=d.top;h<d.bottom;h++){let p=d.map.positionAt(h,d.left,d.table);h==d.top&&(p+=l.nodeSize);for(let m=d.left,b=0;m<d.right;m++,b++)m==d.left&&h==d.top||u.insert(f=u.mapping.map(p+d.tableStart,1),t({node:l,row:h,col:m}).createAndFill(c[b]))}u.setNodeMarkup(r,t({node:l,row:d.top,col:d.left}),c[0]),o instanceof C&&u.setSelection(new C(u.doc.resolve(o.$anchorCell.pos),f?u.doc.resolve(f):void 0)),n(u)}return!0}}function at(t,e){return function(n,o){if(!E(n))return!1;const l=q(n);if(l.nodeAfter.attrs[t]===e)return!1;if(o){const r=n.tr;n.selection instanceof C?n.selection.forEachCell((s,i)=>{s.attrs[t]!==e&&r.setNodeMarkup(i,null,{...s.attrs,[t]:e})}):r.setNodeMarkup(l.pos,null,{...l.nodeAfter.attrs,[t]:e}),o(r)}return!0}}function dt(t){return function(e,n){if(!E(e))return!1;if(n){const o=S(e.schema),l=N(e),r=e.tr,s=l.map.cellsInRect(t=="column"?{left:l.left,top:0,right:l.right,bottom:l.map.height}:t=="row"?{left:0,top:l.top,right:l.map.width,bottom:l.bottom}:l),i=s.map(c=>l.table.nodeAt(c));for(let c=0;c<s.length;c++)i[c].type==o.header_cell&&r.setNodeMarkup(l.tableStart+s[c],o.cell,i[c].attrs);if(r.steps.length===0)for(let c=0;c<s.length;c++)r.setNodeMarkup(l.tableStart+s[c],o.header_cell,i[c].attrs);n(r)}return!0}}function ie(t,e,n){const o=e.map.cellsInRect({left:0,top:0,right:t=="row"?e.map.width:1,bottom:t=="column"?e.map.height:1});for(let l=0;l<o.length;l++){const r=e.table.nodeAt(o[l]);if(r&&r.type!==n.header_cell)return!1}return!0}function B(t,e){return e=e||{useDeprecatedLogic:!1},e.useDeprecatedLogic?dt(t):function(n,o){if(!E(n))return!1;if(o){const l=S(n.schema),r=N(n),s=n.tr,i=ie("row",r,l),c=ie("column",r,l),a=(t==="column"?i:t==="row"&&c)?1:0,d=t=="column"?{left:0,top:a,right:1,bottom:r.map.height}:t=="row"?{left:a,top:0,right:r.map.width,bottom:1}:r,u=t=="column"?c?l.cell:l.header_cell:t=="row"?i?l.cell:l.header_cell:l.cell;r.map.cellsInRect(d).forEach(f=>{const h=f+r.tableStart,p=s.doc.nodeAt(h);p&&s.setNodeMarkup(h,u,p.attrs)}),o(s)}return!0}}B("row",{useDeprecatedLogic:!0});B("column",{useDeprecatedLogic:!0});const ut=B("cell",{useDeprecatedLogic:!0});function ft(t,e){if(e<0){const n=t.nodeBefore;if(n)return t.pos-n.nodeSize;for(let o=t.index(-1)-1,l=t.before();o>=0;o--){const r=t.node(-1).child(o),s=r.lastChild;if(s)return l-1-s.nodeSize;l-=r.nodeSize}}else{if(t.index()<t.parent.childCount-1)return t.pos+t.nodeAfter.nodeSize;const n=t.node(-1);for(let o=t.indexAfter(-1),l=t.after();o<n.childCount;o++){const r=n.child(o);if(r.childCount)return l+1;l+=r.nodeSize}}return null}function ce(t){return function(e,n){if(!E(e))return!1;const o=ft(q(e),t);if(o==null)return!1;if(n){const l=e.doc.resolve(o);n(e.tr.setSelection(g.TextSelection.between(l,Oe(l))).scrollIntoView())}return!0}}function ht(t,e){const n=t.selection.$anchor;for(let o=n.depth;o>0;o--)if(n.node(o).type.spec.tableRole=="table")return e&&e(t.tr.delete(n.before(o),n.after(o)).scrollIntoView()),!0;return!1}function F(t,e){const n=t.selection;if(!(n instanceof C))return!1;if(e){const o=t.tr,l=S(t.schema).cell.createAndFill().content;n.forEachCell((r,s)=>{r.content.eq(l)||o.replace(o.mapping.map(s+1),o.mapping.map(s+r.nodeSize-1),new g.Slice(l,0,0))}),o.docChanged&&e(o)}return!0}function pt(t){if(t.size===0)return null;let{content:e,openStart:n,openEnd:o}=t;for(;e.childCount==1&&(n>0&&o>0||e.child(0).type.spec.tableRole=="table");)n--,o--,e=e.child(0).content;const l=e.child(0),r=l.type.spec.tableRole,s=l.type.schema,i=[];if(r=="row")for(let c=0;c<e.childCount;c++){let a=e.child(c).content;const d=c?0:Math.max(0,n-1),u=c<e.childCount-1?0:Math.max(0,o-1);(d||u)&&(a=ee(S(s).row,new g.Slice(a,d,u)).content),i.push(a)}else if(r=="cell"||r=="header_cell")i.push(n||o?ee(S(s).row,new g.Slice(e,n,o)).content:e);else return null;return mt(s,i)}function mt(t,e){const n=[];for(let l=0;l<e.length;l++){const r=e[l];for(let s=r.childCount-1;s>=0;s--){const{rowspan:i,colspan:c}=r.child(s).attrs;for(let a=l;a<l+i;a++)n[a]=(n[a]||0)+c}}let o=0;for(let l=0;l<n.length;l++)o=Math.max(o,n[l]);for(let l=0;l<n.length;l++)if(l>=e.length&&e.push(g.Fragment.empty),n[l]<o){const r=S(t).cell.createAndFill(),s=[];for(let i=n[l];i<o;i++)s.push(r);e[l]=e[l].append(g.Fragment.from(s))}return{height:e.length,width:o,rows:e}}function ee(t,e){const n=t.createAndFill();return new g.Transform(n).replace(0,n.content.size,e).doc}function gt({width:t,height:e,rows:n},o,l){if(t!=o){const r=[],s=[];for(let i=0;i<n.length;i++){const c=n[i],a=[];for(let d=r[i]||0,u=0;d<o;u++){let f=c.child(u%c.childCount);d+f.attrs.colspan>o&&(f=f.type.createChecked(H(f.attrs,f.attrs.colspan,d+f.attrs.colspan-o),f.content)),a.push(f),d+=f.attrs.colspan;for(let h=1;h<f.attrs.rowspan;h++)r[i+h]=(r[i+h]||0)+f.attrs.colspan}s.push(g.Fragment.from(a))}n=s,t=o}if(e!=l){const r=[];for(let s=0,i=0;s<l;s++,i++){const c=[],a=n[i%e];for(let d=0;d<a.childCount;d++){let u=a.child(d);s+u.attrs.rowspan>l&&(u=u.type.create({...u.attrs,rowspan:Math.max(1,l-u.attrs.rowspan)},u.content)),c.push(u)}r.push(g.Fragment.from(c))}n=r,e=l}return{width:t,height:e,rows:n}}function bt(t,e,n,o,l,r,s){const i=t.doc.type.schema,c=S(i);let a,d;if(l>e.width)for(let u=0,f=0;u<e.height;u++){const h=n.child(u);f+=h.nodeSize;const p=[];let m;h.lastChild==null||h.lastChild.type==c.cell?m=a||(a=c.cell.createAndFill()):m=d||(d=c.header_cell.createAndFill());for(let b=e.width;b<l;b++)p.push(m);t.insert(t.mapping.slice(s).map(f-1+o),p)}if(r>e.height){const u=[];for(let p=0,m=(e.height-1)*e.width;p<Math.max(e.width,l);p++){const b=p>=e.width?!1:n.nodeAt(e.map[m+p]).type==c.header_cell;u.push(b?d||(d=c.header_cell.createAndFill()):a||(a=c.cell.createAndFill()))}const f=c.row.create(null,g.Fragment.from(u)),h=[];for(let p=e.height;p<r;p++)h.push(f);t.insert(t.mapping.slice(s).map(o+n.nodeSize-2),h)}return!!(a||d)}function ae(t,e,n,o,l,r,s,i){if(s==0||s==e.height)return!1;let c=!1;for(let a=l;a<r;a++){const d=s*e.width+a,u=e.map[d];if(e.map[d-e.width]==u){c=!0;const f=n.nodeAt(u),{top:h,left:p}=e.findCell(u);t.setNodeMarkup(t.mapping.slice(i).map(u+o),null,{...f.attrs,rowspan:s-h}),t.insert(t.mapping.slice(i).map(e.positionAt(s,p,n)),f.type.createAndFill({...f.attrs,rowspan:h+f.attrs.rowspan-s})),a+=f.attrs.colspan-1}}return c}function de(t,e,n,o,l,r,s,i){if(s==0||s==e.width)return!1;let c=!1;for(let a=l;a<r;a++){const d=a*e.width+s,u=e.map[d];if(e.map[d-1]==u){c=!0;const f=n.nodeAt(u),h=e.colCount(u),p=t.mapping.slice(i).map(u+o);t.setNodeMarkup(p,null,H(f.attrs,s-h,f.attrs.colspan-(s-h))),t.insert(p+f.nodeSize,f.type.createAndFill(H(f.attrs,0,s-h))),a+=f.attrs.rowspan-1}}return c}function ue(t,e,n,o,l){let r=n?t.doc.nodeAt(n-1):t.doc;if(!r)throw new Error("No table found");let s=y.get(r);const{top:i,left:c}=o,a=c+l.width,d=i+l.height,u=t.tr;let f=0;function h(){if(r=n?u.doc.nodeAt(n-1):u.doc,!r)throw new Error("No table found");s=y.get(r),f=u.mapping.maps.length}bt(u,s,r,n,a,d,f)&&h(),ae(u,s,r,n,c,a,i,f)&&h(),ae(u,s,r,n,c,a,d,f)&&h(),de(u,s,r,n,i,d,c,f)&&h(),de(u,s,r,n,i,d,a,f)&&h();for(let p=i;p<d;p++){const m=s.positionAt(p,c,r),b=s.positionAt(p,a,r);u.replace(u.mapping.slice(f).map(m+n),u.mapping.slice(f).map(b+n),new g.Slice(l.rows[p-i],0,0))}h(),u.setSelection(new C(u.doc.resolve(n+s.positionAt(i,c,r)),u.doc.resolve(n+s.positionAt(d-1,a-1,r)))),e(u)}const wt=D.keydownHandler({ArrowLeft:P("horiz",-1),ArrowRight:P("horiz",1),ArrowUp:P("vert",-1),ArrowDown:P("vert",1),"Shift-ArrowLeft":j("horiz",-1),"Shift-ArrowRight":j("horiz",1),"Shift-ArrowUp":j("vert",-1),"Shift-ArrowDown":j("vert",1),Backspace:F,"Mod-Backspace":F,Delete:F,"Mod-Delete":F});function G(t,e,n){return n.eq(t.selection)?!1:(e&&e(t.tr.setSelection(n).scrollIntoView()),!0)}function P(t,e){return(n,o,l)=>{if(!l)return!1;const r=n.selection;if(r instanceof C)return G(n,o,g.Selection.near(r.$headCell,e));if(t!="horiz"&&!r.empty)return!1;const s=Ee(l,t,e);if(s==null)return!1;if(t=="horiz")return G(n,o,g.Selection.near(n.doc.resolve(r.head+e),e));{const i=n.doc.resolve(s),c=Se(i,t,e);let a;return c?a=g.Selection.near(c,1):e<0?a=g.Selection.near(n.doc.resolve(i.before(-1)),-1):a=g.Selection.near(n.doc.resolve(i.after(-1)),1),G(n,o,a)}}}function j(t,e){return(n,o,l)=>{if(!l)return!1;const r=n.selection;let s;if(r instanceof C)s=r;else{const c=Ee(l,t,e);if(c==null)return!1;s=new C(n.doc.resolve(c))}const i=Se(s.$headCell,t,e);return i?G(n,o,new C(s.$anchorCell,i)):!1}}function Ct(t,e){const n=t.state.doc,o=_(n.resolve(e));return o?(t.dispatch(t.state.tr.setSelection(new C(o))),!0):!1}function yt(t,e,n){if(!E(t.state))return!1;let o=pt(n);const l=t.state.selection;if(l instanceof C){o||(o={width:1,height:1,rows:[g.Fragment.from(ee(S(t.state.schema).cell,n))]});const r=l.$anchorCell.node(-1),s=l.$anchorCell.start(-1),i=y.get(r).rectBetween(l.$anchorCell.pos-s,l.$headCell.pos-s);return o=gt(o,i.right-i.left,i.bottom-i.top),ue(t.state,t.dispatch,s,i,o),!0}else if(o){const r=q(t.state),s=r.start(-1);return ue(t.state,t.dispatch,s,y.get(r.node(-1)).findCell(r.pos-s),o),!0}else return!1}function St(t,e){var n;if(e.ctrlKey||e.metaKey)return;const o=fe(t,e.target);let l;if(e.shiftKey&&t.state.selection instanceof C)r(t.state.selection.$anchorCell,e),e.preventDefault();else if(e.shiftKey&&o&&(l=_(t.state.selection.$anchor))!=null&&((n=U(t,e))===null||n===void 0?void 0:n.pos)!=l.pos)r(l,e),e.preventDefault();else if(!o)return;function r(c,a){let d=U(t,a);const u=z.getState(t.state)==null;if(!d||!oe(c,d))if(u)d=c;else return;const f=new C(c,d);if(u||!t.state.selection.eq(f)){const h=t.state.tr.setSelection(f);u&&h.setMeta(z,c.pos),t.dispatch(h)}}function s(){t.root.removeEventListener("mouseup",s),t.root.removeEventListener("dragstart",s),t.root.removeEventListener("mousemove",i),z.getState(t.state)!=null&&t.dispatch(t.state.tr.setMeta(z,-1))}function i(c){const a=c,d=z.getState(t.state);let u;if(d!=null)u=t.state.doc.resolve(d);else if(fe(t,a.target)!=o&&(u=U(t,e),!u))return s();u&&r(u,a)}t.root.addEventListener("mouseup",s),t.root.addEventListener("dragstart",s),t.root.addEventListener("mousemove",i)}function Ee(t,e,n){if(!(t.state.selection instanceof g.TextSelection))return null;const{$head:o}=t.state.selection;for(let l=o.depth-1;l>=0;l--){const r=o.node(l);if((n<0?o.index(l):o.indexAfter(l))!=(n<0?0:r.childCount))return null;if(r.type.spec.tableRole=="cell"||r.type.spec.tableRole=="header_cell"){const s=o.before(l),i=e=="vert"?n>0?"down":"up":n>0?"right":"left";return t.endOfTextblock(i)?s:null}}return null}function fe(t,e){for(;e&&e!=t.dom;e=e.parentNode)if(e.nodeName=="TD"||e.nodeName=="TH")return e;return null}function U(t,e){const n=t.posAtCoords({left:e.clientX,top:e.clientY});if(!n)return null;const o=n.inside>=0?n.inside:n.pos;return _(t.state.doc.resolve(o))}var xt=class{constructor(e,n){this.node=e,this.defaultCellMinWidth=n,this.dom=document.createElement("div"),this.dom.className="tableWrapper",this.table=this.dom.appendChild(document.createElement("table")),this.table.style.setProperty("--default-cell-min-width",`${n}px`),this.colgroup=this.table.appendChild(document.createElement("colgroup")),te(e,this.colgroup,this.table,n),this.contentDOM=this.table.appendChild(document.createElement("tbody"))}update(e){return e.type!=this.node.type?!1:(this.node=e,te(e,this.colgroup,this.table,this.defaultCellMinWidth),!0)}ignoreMutation(e){return e.type=="attributes"&&(e.target==this.table||this.colgroup.contains(e.target))}};function te(t,e,n,o,l,r){let s=0,i=!0,c=e.firstChild;const a=t.firstChild;if(a){for(let u=0,f=0;u<a.childCount;u++){const{colspan:h,colwidth:p}=a.child(u).attrs;for(let m=0;m<h;m++,f++){const b=l==f?r:p&&p[m],w=b?b+"px":"";if(s+=b||o,b||(i=!1),c)c.style.width!=w&&(c.style.width=w),c=c.nextSibling;else{const x=document.createElement("col");x.style.width=w,e.appendChild(x)}}}for(;c;){var d;const u=c.nextSibling;(d=c.parentNode)===null||d===void 0||d.removeChild(c),c=u}i?(n.style.width=s+"px",n.style.minWidth=""):(n.style.width="",n.style.minWidth=s+"px")}}const T=new g.PluginKey("tableColumnResizing");function At({handleWidth:t=5,cellMinWidth:e=25,defaultCellMinWidth:n=100,View:o=xt,lastColumnResizable:l=!0}={}){const r=new g.Plugin({key:T,state:{init(s,i){var c;const a=(c=r.spec)===null||c===void 0||(c=c.props)===null||c===void 0?void 0:c.nodeViews,d=S(i.schema).table.name;return o&&a&&(a[d]=(u,f)=>new o(u,n,f)),new Tt(-1,!1)},apply(s,i){return i.apply(s)}},props:{attributes:s=>{const i=T.getState(s);return i&&i.activeHandle>-1?{class:"resize-cursor"}:{}},handleDOMEvents:{mousemove:(s,i)=>{Rt(s,i,t,l)},mouseleave:s=>{vt(s)},mousedown:(s,i)=>{Mt(s,i,e,n)}},decorations:s=>{const i=T.getState(s);if(i&&i.activeHandle>-1)return zt(s,i.activeHandle)},nodeViews:{}}});return r}var Tt=class V{constructor(e,n){this.activeHandle=e,this.dragging=n}apply(e){const n=this,o=e.getMeta(T);if(o&&o.setHandle!=null)return new V(o.setHandle,!1);if(o&&o.setDragging!==void 0)return new V(n.activeHandle,o.setDragging);if(n.activeHandle>-1&&e.docChanged){let l=e.mapping.map(n.activeHandle,-1);return Q(e.doc.resolve(l))||(l=-1),new V(l,n.dragging)}return n}};function Rt(t,e,n,o){if(!t.editable)return;const l=T.getState(t.state);if(l&&!l.dragging){const r=Nt(e.target);let s=-1;if(r){const{left:i,right:c}=r.getBoundingClientRect();e.clientX-i<=n?s=he(t,e,"left",n):c-e.clientX<=n&&(s=he(t,e,"right",n))}if(s!=l.activeHandle){if(!o&&s!==-1){const i=t.state.doc.resolve(s),c=i.node(-1),a=y.get(c),d=i.start(-1);if(a.colCount(i.pos-d)+i.nodeAfter.attrs.colspan-1==a.width-1)return}Ne(t,s)}}}function vt(t){if(!t.editable)return;const e=T.getState(t.state);e&&e.activeHandle>-1&&!e.dragging&&Ne(t,-1)}function Mt(t,e,n,o){var l;if(!t.editable)return!1;const r=(l=t.dom.ownerDocument.defaultView)!==null&&l!==void 0?l:window,s=T.getState(t.state);if(!s||s.activeHandle==-1||s.dragging)return!1;const i=t.state.doc.nodeAt(s.activeHandle),c=Et(t,s.activeHandle,i.attrs);t.dispatch(t.state.tr.setMeta(T,{setDragging:{startX:e.clientX,startWidth:c}}));function a(u){r.removeEventListener("mouseup",a),r.removeEventListener("mousemove",d);const f=T.getState(t.state);f!=null&&f.dragging&&(kt(t,f.activeHandle,pe(f.dragging,u,n)),t.dispatch(t.state.tr.setMeta(T,{setDragging:null})))}function d(u){if(!u.which)return a(u);const f=T.getState(t.state);if(f&&f.dragging){const h=pe(f.dragging,u,n);me(t,f.activeHandle,h,o)}}return me(t,s.activeHandle,c,o),r.addEventListener("mouseup",a),r.addEventListener("mousemove",d),e.preventDefault(),!0}function Et(t,e,{colspan:n,colwidth:o}){const l=o&&o[o.length-1];if(l)return l;const r=t.domAtPos(e);let s=r.node.childNodes[r.offset].offsetWidth,i=n;if(o)for(let c=0;c<n;c++)o[c]&&(s-=o[c],i--);return s/i}function Nt(t){for(;t&&t.nodeName!="TD"&&t.nodeName!="TH";)t=t.classList&&t.classList.contains("ProseMirror")?null:t.parentNode;return t}function he(t,e,n,o){const l=n=="right"?-o:o,r=t.posAtCoords({left:e.clientX+l,top:e.clientY});if(!r)return-1;const{pos:s}=r,i=_(t.state.doc.resolve(s));if(!i)return-1;if(n=="right")return i.pos;const c=y.get(i.node(-1)),a=i.start(-1),d=c.map.indexOf(i.pos-a);return d%c.width==0?-1:a+c.map[d-1]}function pe(t,e,n){const o=e.clientX-t.startX;return Math.max(n,t.startWidth+o)}function Ne(t,e){t.dispatch(t.state.tr.setMeta(T,{setHandle:e}))}function kt(t,e,n){const o=t.state.doc.resolve(e),l=o.node(-1),r=y.get(l),s=o.start(-1),i=r.colCount(o.pos-s)+o.nodeAfter.attrs.colspan-1,c=t.state.tr;for(let a=0;a<r.height;a++){const d=a*r.width+i;if(a&&r.map[d]==r.map[d-r.width])continue;const u=r.map[d],f=l.nodeAt(u).attrs,h=f.colspan==1?0:i-r.colCount(u);if(f.colwidth&&f.colwidth[h]==n)continue;const p=f.colwidth?f.colwidth.slice():Lt(f.colspan);p[h]=n,c.setNodeMarkup(s+u,null,{...f,colwidth:p})}c.docChanged&&t.dispatch(c)}function me(t,e,n,o){const l=t.state.doc.resolve(e),r=l.node(-1),s=l.start(-1),i=y.get(r).colCount(l.pos-s)+l.nodeAfter.attrs.colspan-1;let c=t.domAtPos(l.start(-1)).node;for(;c&&c.nodeName!="TABLE";)c=c.parentNode;c&&te(r,c.firstChild,c,o,i,n)}function Lt(t){return Array(t).fill(0)}function zt(t,e){const n=[],o=t.doc.resolve(e),l=o.node(-1);if(!l)return D.DecorationSet.empty;const r=y.get(l),s=o.start(-1),i=r.colCount(o.pos-s)+o.nodeAfter.attrs.colspan-1;for(let a=0;a<r.height;a++){const d=i+a*r.width;if((i==r.width-1||r.map[d]!=r.map[d+1])&&(a==0||r.map[d]!=r.map[d-r.width])){var c;const u=r.map[d],f=s+u+l.nodeAt(u).nodeSize-1,h=document.createElement("div");h.className="column-resize-handle",!((c=T.getState(t))===null||c===void 0)&&c.dragging&&n.push(D.Decoration.node(s+u,s+u+l.nodeAt(u).nodeSize,{class:"column-resize-dragging"})),n.push(D.Decoration.widget(f,h))}}return D.DecorationSet.create(t.doc,n)}function Dt({allowTableNodeSelection:t=!1}={}){return new g.Plugin({key:z,state:{init(){return null},apply(e,n){const o=e.getMeta(z);if(o!=null)return o==-1?null:o;if(n==null||!e.docChanged)return n;const{deleted:l,pos:r}=e.mapping.mapResult(n);return l?null:r}},props:{decorations:qe,handleDOMEvents:{mousedown:St},createSelectionBetween(e){return z.getState(e.state)!=null?e.state.selection:null},handleTripleClick:Ct,handleKeyDown:wt,handlePaste:yt},appendTransaction(e,n,o){return Ze(o,Re(o,n),t)}})}var ke=g.Node3.create({name:"tableCell",addOptions(){return{HTMLAttributes:{}}},content:"block+",addAttributes(){return{colspan:{default:1},rowspan:{default:1},colwidth:{default:null,parseHTML:t=>{var e,n;const o=t.getAttribute("colwidth"),l=o?o.split(",").map(r=>parseInt(r,10)):null;if(!l){const r=(e=t.closest("table"))==null?void 0:e.querySelectorAll("colgroup > col"),s=Array.from(((n=t.parentElement)==null?void 0:n.children)||[]).indexOf(t);if(s&&s>-1&&r&&r[s]){const i=r[s].getAttribute("width");return i?[parseInt(i,10)]:null}}return l}}}},tableRole:"cell",isolating:!0,parseHTML(){return[{tag:"td"}]},renderHTML({HTMLAttributes:t}){return["td",g.mergeAttributes(this.options.HTMLAttributes,t),0]}}),Le=g.Node3.create({name:"tableHeader",addOptions(){return{HTMLAttributes:{}}},content:"block+",addAttributes(){return{colspan:{default:1},rowspan:{default:1},colwidth:{default:null,parseHTML:t=>{const e=t.getAttribute("colwidth");return e?e.split(",").map(o=>parseInt(o,10)):null}}}},tableRole:"header_cell",isolating:!0,parseHTML(){return[{tag:"th"}]},renderHTML({HTMLAttributes:t}){return["th",g.mergeAttributes(this.options.HTMLAttributes,t),0]}}),ze=g.Node3.create({name:"tableRow",addOptions(){return{HTMLAttributes:{}}},content:"(tableCell | tableHeader)*",tableRole:"row",parseHTML(){return[{tag:"tr"}]},renderHTML({HTMLAttributes:t}){return["tr",g.mergeAttributes(this.options.HTMLAttributes,t),0]}});function ne(t,e){return e?["width",`${Math.max(e,t)}px`]:["min-width",`${t}px`]}function ge(t,e,n,o,l,r){var s;let i=0,c=!0,a=e.firstChild;const d=t.firstChild;if(d!==null)for(let f=0,h=0;f<d.childCount;f+=1){const{colspan:p,colwidth:m}=d.child(f).attrs;for(let b=0;b<p;b+=1,h+=1){const w=l===h?r:m&&m[b],x=w?`${w}px`:"";if(i+=w||o,w||(c=!1),a){if(a.style.width!==x){const[R,L]=ne(o,w);a.style.setProperty(R,L)}a=a.nextSibling}else{const R=document.createElement("col"),[L,M]=ne(o,w);R.style.setProperty(L,M),e.appendChild(R)}}}for(;a;){const f=a.nextSibling;(s=a.parentNode)==null||s.removeChild(a),a=f}const u=t.attrs.style&&typeof t.attrs.style=="string"&&/\bwidth\s*:/i.test(t.attrs.style);c&&!u?(n.style.width=`${i}px`,n.style.minWidth=""):(n.style.width="",n.style.minWidth=`${i}px`)}var Ht=class{constructor(t,e){this.node=t,this.cellMinWidth=e,this.dom=document.createElement("div"),this.dom.className="tableWrapper",this.table=this.dom.appendChild(document.createElement("table")),t.attrs.style&&(this.table.style.cssText=t.attrs.style),this.colgroup=this.table.appendChild(document.createElement("colgroup")),ge(t,this.colgroup,this.table,e),this.contentDOM=this.table.appendChild(document.createElement("tbody"))}update(t){return t.type!==this.node.type?!1:(this.node=t,ge(t,this.colgroup,this.table,this.cellMinWidth),!0)}ignoreMutation(t){const e=t.target,n=this.dom.contains(e),o=this.contentDOM.contains(e);return!!(n&&!o&&(t.type==="attributes"||t.type==="childList"||t.type==="characterData"))}};function _t(t,e,n,o){let l=0,r=!0;const s=[],i=t.firstChild;if(!i)return{};for(let u=0,f=0;u<i.childCount;u+=1){const{colspan:h,colwidth:p}=i.child(u).attrs;for(let m=0;m<h;m+=1,f+=1){const b=n===f?o:p&&p[m];l+=b||e,b||(r=!1);const[w,x]=ne(e,b);s.push(["col",{style:`${w}: ${x}`}])}}const c=r?`${l}px`:"",a=r?"":`${l}px`;return{colgroup:["colgroup",{},...s],tableWidth:c,tableMinWidth:a}}function be(t,e){return t.createAndFill()}function It(t){if(t.cached.tableNodeTypes)return t.cached.tableNodeTypes;const e={};return Object.keys(t.nodes).forEach(n=>{const o=t.nodes[n];o.spec.tableRole&&(e[o.spec.tableRole]=o)}),t.cached.tableNodeTypes=e,e}function Bt(t,e,n,o,l){const r=It(t),s=[],i=[];for(let a=0;a<n;a+=1){const d=be(r.cell);if(d&&i.push(d),o){const u=be(r.header_cell);u&&s.push(u)}}const c=[];for(let a=0;a<e;a+=1)c.push(r.row.createChecked(null,o&&a===0?s:i));return r.table.createChecked(null,c)}function $t(t){return t instanceof C}var O=({editor:t})=>{const{selection:e}=t.state;if(!$t(e))return!1;let n=0;const o=g.findParentNodeClosestToPos(e.ranges[0].$from,r=>r.type.name==="table");return o==null||o.node.descendants(r=>{if(r.type.name==="table")return!1;["tableCell","tableHeader"].includes(r.type.name)&&(n+=1)}),n===e.ranges.length?(t.commands.deleteTable(),!0):!1},Wt="";function Ft(t){return(t||"").replace(/\s+/g," ").trim()}function Pt(t,e,n={}){var o;const l=(o=n.cellLineSeparator)!=null?o:Wt;if(!t||!t.content||t.content.length===0)return"";const r=[];t.content.forEach(p=>{const m=[];p.content&&p.content.forEach(b=>{let w="";b.content&&Array.isArray(b.content)&&b.content.length>1?w=b.content.map(M=>e.renderChildren(M)).join(l):w=b.content?e.renderChildren(b.content):"";const x=Ft(w),R=b.type==="tableHeader";m.push({text:x,isHeader:R})}),r.push(m)});const s=r.reduce((p,m)=>Math.max(p,m.length),0);if(s===0)return"";const i=new Array(s).fill(0);r.forEach(p=>{var m;for(let b=0;b<s;b+=1){const x=(((m=p[b])==null?void 0:m.text)||"").length;x>i[b]&&(i[b]=x),i[b]<3&&(i[b]=3)}});const c=(p,m)=>p+" ".repeat(Math.max(0,m-p.length)),a=r[0],d=a.some(p=>p.isHeader);let u=`
|
|
1
|
+
"use strict";const g=require("./index-DLqogznp.cjs"),_e=require("@tiptap/pm/state"),D=require("./index-DCJheRBq.cjs"),A=require("react/jsx-runtime"),Ie=require("./toggle-DVCNvcqp.cjs"),W=require("react");require("./index-CNzHZDls.cjs");const v=require("./index-FSRjMsxW.cjs"),X=require("./popover-CZWSQZ0q.cjs"),Z=require("./useButtonProps-bei1vI37.cjs");let J,Y;if(typeof WeakMap<"u"){let t=new WeakMap;J=e=>t.get(e),Y=(e,n)=>(t.set(e,n),n)}else{const t=[];let n=0;J=o=>{for(let l=0;l<t.length;l+=2)if(t[l]==o)return t[l+1]},Y=(o,l)=>(n==10&&(n=0),t[n++]=o,t[n++]=l)}var y=class{constructor(t,e,n,o){this.width=t,this.height=e,this.map=n,this.problems=o}findCell(t){for(let e=0;e<this.map.length;e++){const n=this.map[e];if(n!=t)continue;const o=e%this.width,l=e/this.width|0;let r=o+1,s=l+1;for(let i=1;r<this.width&&this.map[e+i]==n;i++)r++;for(let i=1;s<this.height&&this.map[e+this.width*i]==n;i++)s++;return{left:o,top:l,right:r,bottom:s}}throw new RangeError(`No cell with offset ${t} found`)}colCount(t){for(let e=0;e<this.map.length;e++)if(this.map[e]==t)return e%this.width;throw new RangeError(`No cell with offset ${t} found`)}nextCell(t,e,n){const{left:o,right:l,top:r,bottom:s}=this.findCell(t);return e=="horiz"?(n<0?o==0:l==this.width)?null:this.map[r*this.width+(n<0?o-1:l)]:(n<0?r==0:s==this.height)?null:this.map[o+this.width*(n<0?r-1:s)]}rectBetween(t,e){const{left:n,right:o,top:l,bottom:r}=this.findCell(t),{left:s,right:i,top:c,bottom:a}=this.findCell(e);return{left:Math.min(n,s),top:Math.min(l,c),right:Math.max(o,i),bottom:Math.max(r,a)}}cellsInRect(t){const e=[],n={};for(let o=t.top;o<t.bottom;o++)for(let l=t.left;l<t.right;l++){const r=o*this.width+l,s=this.map[r];n[s]||(n[s]=!0,!(l==t.left&&l&&this.map[r-1]==s||o==t.top&&o&&this.map[r-this.width]==s)&&e.push(s))}return e}positionAt(t,e,n){for(let o=0,l=0;;o++){const r=l+n.child(o).nodeSize;if(o==t){let s=e+t*this.width;const i=(t+1)*this.width;for(;s<i&&this.map[s]<l;)s++;return s==i?r-1:this.map[s]}l=r}}static get(t){return J(t)||Y(t,Be(t))}};function Be(t){if(t.type.spec.tableRole!="table")throw new RangeError("Not a table node: "+t.type.name);const e=$e(t),n=t.childCount,o=[];let l=0,r=null;const s=[];for(let a=0,d=e*n;a<d;a++)o[a]=0;for(let a=0,d=0;a<n;a++){const u=t.child(a);d++;for(let p=0;;p++){for(;l<o.length&&o[l]!=0;)l++;if(p==u.childCount)break;const m=u.child(p),{colspan:b,rowspan:w,colwidth:x}=m.attrs;for(let R=0;R<w;R++){if(R+a>=n){(r||(r=[])).push({type:"overlong_rowspan",pos:d,n:w-R});break}const L=l+R*e;for(let M=0;M<b;M++){o[L+M]==0?o[L+M]=d:(r||(r=[])).push({type:"collision",row:a,pos:d,n:b-M});const $=x&&x[M];if($){const I=(L+M)%e*2,K=s[I];K==null||K!=$&&s[I+1]==1?(s[I]=$,s[I+1]=1):K==$&&s[I+1]++}}}l+=b,d+=m.nodeSize}const f=(a+1)*e;let h=0;for(;l<f;)o[l++]==0&&h++;h&&(r||(r=[])).push({type:"missing",row:a,n:h}),d++}(e===0||n===0)&&(r||(r=[])).push({type:"zero_sized"});const i=new y(e,n,o,r);let c=!1;for(let a=0;!c&&a<s.length;a+=2)s[a]!=null&&s[a+1]<n&&(c=!0);return c&&We(i,s,t),i}function $e(t){let e=-1,n=!1;for(let o=0;o<t.childCount;o++){const l=t.child(o);let r=0;if(n)for(let s=0;s<o;s++){const i=t.child(s);for(let c=0;c<i.childCount;c++){const a=i.child(c);s+a.attrs.rowspan>o&&(r+=a.attrs.colspan)}}for(let s=0;s<l.childCount;s++){const i=l.child(s);r+=i.attrs.colspan,i.attrs.rowspan>1&&(n=!0)}e==-1?e=r:e!=r&&(e=Math.max(e,r))}return e}function We(t,e,n){t.problems||(t.problems=[]);const o={};for(let l=0;l<t.map.length;l++){const r=t.map[l];if(o[r])continue;o[r]=!0;const s=n.nodeAt(r);if(!s)throw new RangeError(`No cell with offset ${r} found`);let i=null;const c=s.attrs;for(let a=0;a<c.colspan;a++){const d=e[(l+a)%t.width*2];d!=null&&(!c.colwidth||c.colwidth[a]!=d)&&((i||(i=Fe(c)))[a]=d)}i&&t.problems.unshift({type:"colwidth mismatch",pos:r,colwidth:i})}}function Fe(t){if(t.colwidth)return t.colwidth.slice();const e=[];for(let n=0;n<t.colspan;n++)e.push(0);return e}function S(t){let e=t.cached.tableNodeTypes;if(!e){e=t.cached.tableNodeTypes={};for(const n in t.nodes){const o=t.nodes[n],l=o.spec.tableRole;l&&(e[l]=o)}}return e}const z=new g.PluginKey("selectingCells");function _(t){for(let e=t.depth-1;e>0;e--)if(t.node(e).type.spec.tableRole=="row")return t.node(0).resolve(t.before(e+1));return null}function Pe(t){for(let e=t.depth;e>0;e--){const n=t.node(e).type.spec.tableRole;if(n==="cell"||n==="header_cell")return t.node(e)}return null}function E(t){const e=t.selection.$head;for(let n=e.depth;n>0;n--)if(e.node(n).type.spec.tableRole=="row")return!0;return!1}function q(t){const e=t.selection;if("$anchorCell"in e&&e.$anchorCell)return e.$anchorCell.pos>e.$headCell.pos?e.$anchorCell:e.$headCell;if("node"in e&&e.node&&e.node.type.spec.tableRole=="cell")return e.$anchor;const n=_(e.$head)||je(e.$head);if(n)return n;throw new RangeError(`No cell found around position ${e.head}`)}function je(t){for(let e=t.nodeAfter,n=t.pos;e;e=e.firstChild,n++){const o=e.type.spec.tableRole;if(o=="cell"||o=="header_cell")return t.doc.resolve(n)}for(let e=t.nodeBefore,n=t.pos;e;e=e.lastChild,n--){const o=e.type.spec.tableRole;if(o=="cell"||o=="header_cell")return t.doc.resolve(n-e.nodeSize)}}function Q(t){return t.parent.type.spec.tableRole=="row"&&!!t.nodeAfter}function Oe(t){return t.node(0).resolve(t.pos+t.nodeAfter.nodeSize)}function oe(t,e){return t.depth==e.depth&&t.pos>=e.start(-1)&&t.pos<=e.end(-1)}function Se(t,e,n){const o=t.node(-1),l=y.get(o),r=t.start(-1),s=l.nextCell(t.pos-r,e,n);return s==null?null:t.node(0).resolve(r+s)}function H(t,e,n=1){const o={...t,colspan:t.colspan-n};return o.colwidth&&(o.colwidth=o.colwidth.slice(),o.colwidth.splice(e,n),o.colwidth.some(l=>l>0)||(o.colwidth=null)),o}function xe(t,e,n=1){const o={...t,colspan:t.colspan+n};if(o.colwidth){o.colwidth=o.colwidth.slice();for(let l=0;l<n;l++)o.colwidth.splice(e,0,0)}return o}function Ge(t,e,n){const o=S(e.type.schema).header_cell;for(let l=0;l<t.height;l++)if(e.nodeAt(t.map[n+l*t.width]).type!=o)return!1;return!0}var C=class k extends g.Selection{constructor(e,n=e){const o=e.node(-1),l=y.get(o),r=e.start(-1),s=l.rectBetween(e.pos-r,n.pos-r),i=e.node(0),c=l.cellsInRect(s).filter(d=>d!=n.pos-r);c.unshift(n.pos-r);const a=c.map(d=>{const u=o.nodeAt(d);if(!u)throw new RangeError(`No cell with offset ${d} found`);const f=r+d+1;return new g.SelectionRange(i.resolve(f),i.resolve(f+u.content.size))});super(a[0].$from,a[0].$to,a),this.$anchorCell=e,this.$headCell=n}map(e,n){const o=e.resolve(n.map(this.$anchorCell.pos)),l=e.resolve(n.map(this.$headCell.pos));if(Q(o)&&Q(l)&&oe(o,l)){const r=this.$anchorCell.node(-1)!=o.node(-1);return r&&this.isRowSelection()?k.rowSelection(o,l):r&&this.isColSelection()?k.colSelection(o,l):new k(o,l)}return g.TextSelection.between(o,l)}content(){const e=this.$anchorCell.node(-1),n=y.get(e),o=this.$anchorCell.start(-1),l=n.rectBetween(this.$anchorCell.pos-o,this.$headCell.pos-o),r={},s=[];for(let c=l.top;c<l.bottom;c++){const a=[];for(let d=c*n.width+l.left,u=l.left;u<l.right;u++,d++){const f=n.map[d];if(r[f])continue;r[f]=!0;const h=n.findCell(f);let p=e.nodeAt(f);if(!p)throw new RangeError(`No cell with offset ${f} found`);const m=l.left-h.left,b=h.right-l.right;if(m>0||b>0){let w=p.attrs;if(m>0&&(w=H(w,0,m)),b>0&&(w=H(w,w.colspan-b,b)),h.left<l.left){if(p=p.type.createAndFill(w),!p)throw new RangeError(`Could not create cell with attrs ${JSON.stringify(w)}`)}else p=p.type.create(w,p.content)}if(h.top<l.top||h.bottom>l.bottom){const w={...p.attrs,rowspan:Math.min(h.bottom,l.bottom)-Math.max(h.top,l.top)};h.top<l.top?p=p.type.createAndFill(w):p=p.type.create(w,p.content)}a.push(p)}s.push(e.child(c).copy(g.Fragment.from(a)))}const i=this.isColSelection()&&this.isRowSelection()?e:s;return new g.Slice(g.Fragment.from(i),1,1)}replace(e,n=g.Slice.empty){const o=e.steps.length,l=this.ranges;for(let s=0;s<l.length;s++){const{$from:i,$to:c}=l[s],a=e.mapping.slice(o);e.replace(a.map(i.pos),a.map(c.pos),s?g.Slice.empty:n)}const r=g.Selection.findFrom(e.doc.resolve(e.mapping.slice(o).map(this.to)),-1);r&&e.setSelection(r)}replaceWith(e,n){this.replace(e,new g.Slice(g.Fragment.from(n),0,0))}forEachCell(e){const n=this.$anchorCell.node(-1),o=y.get(n),l=this.$anchorCell.start(-1),r=o.cellsInRect(o.rectBetween(this.$anchorCell.pos-l,this.$headCell.pos-l));for(let s=0;s<r.length;s++)e(n.nodeAt(r[s]),l+r[s])}isColSelection(){const e=this.$anchorCell.index(-1),n=this.$headCell.index(-1);if(Math.min(e,n)>0)return!1;const o=e+this.$anchorCell.nodeAfter.attrs.rowspan,l=n+this.$headCell.nodeAfter.attrs.rowspan;return Math.max(o,l)==this.$headCell.node(-1).childCount}static colSelection(e,n=e){const o=e.node(-1),l=y.get(o),r=e.start(-1),s=l.findCell(e.pos-r),i=l.findCell(n.pos-r),c=e.node(0);return s.top<=i.top?(s.top>0&&(e=c.resolve(r+l.map[s.left])),i.bottom<l.height&&(n=c.resolve(r+l.map[l.width*(l.height-1)+i.right-1]))):(i.top>0&&(n=c.resolve(r+l.map[i.left])),s.bottom<l.height&&(e=c.resolve(r+l.map[l.width*(l.height-1)+s.right-1]))),new k(e,n)}isRowSelection(){const e=this.$anchorCell.node(-1),n=y.get(e),o=this.$anchorCell.start(-1),l=n.colCount(this.$anchorCell.pos-o),r=n.colCount(this.$headCell.pos-o);if(Math.min(l,r)>0)return!1;const s=l+this.$anchorCell.nodeAfter.attrs.colspan,i=r+this.$headCell.nodeAfter.attrs.colspan;return Math.max(s,i)==n.width}eq(e){return e instanceof k&&e.$anchorCell.pos==this.$anchorCell.pos&&e.$headCell.pos==this.$headCell.pos}static rowSelection(e,n=e){const o=e.node(-1),l=y.get(o),r=e.start(-1),s=l.findCell(e.pos-r),i=l.findCell(n.pos-r),c=e.node(0);return s.left<=i.left?(s.left>0&&(e=c.resolve(r+l.map[s.top*l.width])),i.right<l.width&&(n=c.resolve(r+l.map[l.width*(i.top+1)-1]))):(i.left>0&&(n=c.resolve(r+l.map[i.top*l.width])),s.right<l.width&&(e=c.resolve(r+l.map[l.width*(s.top+1)-1]))),new k(e,n)}toJSON(){return{type:"cell",anchor:this.$anchorCell.pos,head:this.$headCell.pos}}static fromJSON(e,n){return new k(e.resolve(n.anchor),e.resolve(n.head))}static create(e,n,o=n){return new k(e.resolve(n),e.resolve(o))}getBookmark(){return new Ve(this.$anchorCell.pos,this.$headCell.pos)}};C.prototype.visible=!1;g.Selection.jsonID("cell",C);var Ve=class Ae{constructor(e,n){this.anchor=e,this.head=n}map(e){return new Ae(e.map(this.anchor),e.map(this.head))}resolve(e){const n=e.resolve(this.anchor),o=e.resolve(this.head);return n.parent.type.spec.tableRole=="row"&&o.parent.type.spec.tableRole=="row"&&n.index()<n.parent.childCount&&o.index()<o.parent.childCount&&oe(n,o)?new C(n,o):g.Selection.near(o,1)}};function qe(t){if(!(t.selection instanceof C))return null;const e=[];return t.selection.forEachCell((n,o)=>{e.push(D.Decoration.node(o,o+n.nodeSize,{class:"selectedCell"}))}),D.DecorationSet.create(t.doc,e)}function Ke({$from:t,$to:e}){if(t.pos==e.pos||t.pos<e.pos-6)return!1;let n=t.pos,o=e.pos,l=t.depth;for(;l>=0&&!(t.after(l+1)<t.end(l));l--,n++);for(let r=e.depth;r>=0&&!(e.before(r+1)>e.start(r));r--,o--);return n==o&&/row|table/.test(t.node(l).type.spec.tableRole)}function Xe({$from:t,$to:e}){let n,o;for(let l=t.depth;l>0;l--){const r=t.node(l);if(r.type.spec.tableRole==="cell"||r.type.spec.tableRole==="header_cell"){n=r;break}}for(let l=e.depth;l>0;l--){const r=e.node(l);if(r.type.spec.tableRole==="cell"||r.type.spec.tableRole==="header_cell"){o=r;break}}return n!==o&&e.parentOffset===0}function Ze(t,e,n){const o=(e||t).selection,l=(e||t).doc;let r,s;if(o instanceof g.NodeSelection&&(s=o.node.type.spec.tableRole)){if(s=="cell"||s=="header_cell")r=C.create(l,o.from);else if(s=="row"){const i=l.resolve(o.from+1);r=C.rowSelection(i,i)}else if(!n){const i=y.get(o.node),c=o.from+1,a=c+i.map[i.width*i.height-1];r=C.create(l,c+1,a)}}else o instanceof g.TextSelection&&Ke(o)?r=g.TextSelection.create(l,o.from):o instanceof g.TextSelection&&Xe(o)&&(r=g.TextSelection.create(l,o.$from.start(),o.$from.end()));return r&&(e||(e=t.tr)).setSelection(r),e}const Ue=new g.PluginKey("fix-tables");function Te(t,e,n,o){const l=t.childCount,r=e.childCount;e:for(let s=0,i=0;s<r;s++){const c=e.child(s);for(let a=i,d=Math.min(l,s+3);a<d;a++)if(t.child(a)==c){i=a+1,n+=c.nodeSize;continue e}o(c,n),i<l&&t.child(i).sameMarkup(c)?Te(t.child(i),c,n+1,o):c.nodesBetween(0,c.content.size,o,n+1),n+=c.nodeSize}}function Re(t,e){let n;const o=(l,r)=>{l.type.spec.tableRole=="table"&&(n=Je(t,l,r,n))};return e?e.doc!=t.doc&&Te(e.doc,t.doc,0,o):t.doc.descendants(o),n}function Je(t,e,n,o){const l=y.get(e);if(!l.problems)return o;o||(o=t.tr);const r=[];for(let c=0;c<l.height;c++)r.push(0);for(let c=0;c<l.problems.length;c++){const a=l.problems[c];if(a.type=="collision"){const d=e.nodeAt(a.pos);if(!d)continue;const u=d.attrs;for(let f=0;f<u.rowspan;f++)r[a.row+f]+=a.n;o.setNodeMarkup(o.mapping.map(n+1+a.pos),null,H(u,u.colspan-a.n,a.n))}else if(a.type=="missing")r[a.row]+=a.n;else if(a.type=="overlong_rowspan"){const d=e.nodeAt(a.pos);if(!d)continue;o.setNodeMarkup(o.mapping.map(n+1+a.pos),null,{...d.attrs,rowspan:d.attrs.rowspan-a.n})}else if(a.type=="colwidth mismatch"){const d=e.nodeAt(a.pos);if(!d)continue;o.setNodeMarkup(o.mapping.map(n+1+a.pos),null,{...d.attrs,colwidth:a.colwidth})}else if(a.type=="zero_sized"){const d=o.mapping.map(n);o.delete(d,d+e.nodeSize)}}let s,i;for(let c=0;c<r.length;c++)r[c]&&(s==null&&(s=c),i=c);for(let c=0,a=n+1;c<l.height;c++){const d=e.child(c),u=a+d.nodeSize,f=r[c];if(f>0){let h="cell";d.firstChild&&(h=d.firstChild.type.spec.tableRole);const p=[];for(let b=0;b<f;b++){const w=S(t.schema)[h].createAndFill();w&&p.push(w)}const m=(c==0||s==c-1)&&i==c?a+1:u-1;o.insert(o.mapping.map(m),p)}a=u}return o.setMeta(Ue,{fixTables:!0})}function N(t){const e=t.selection,n=q(t),o=n.node(-1),l=n.start(-1),r=y.get(o);return{...e instanceof C?r.rectBetween(e.$anchorCell.pos-l,e.$headCell.pos-l):r.findCell(n.pos-l),tableStart:l,map:r,table:o}}function ve(t,{map:e,tableStart:n,table:o},l){let r=l>0?-1:0;Ge(e,o,l+r)&&(r=l==0||l==e.width?null:0);for(let s=0;s<e.height;s++){const i=s*e.width+l;if(l>0&&l<e.width&&e.map[i-1]==e.map[i]){const c=e.map[i],a=o.nodeAt(c);t.setNodeMarkup(t.mapping.map(n+c),null,xe(a.attrs,l-e.colCount(c))),s+=a.attrs.rowspan-1}else{const c=r==null?S(o.type.schema).cell:o.nodeAt(e.map[i+r]).type,a=e.positionAt(s,l,o);t.insert(t.mapping.map(n+a),c.createAndFill())}}return t}function Ye(t,e){if(!E(t))return!1;if(e){const n=N(t);e(ve(t.tr,n,n.left))}return!0}function Qe(t,e){if(!E(t))return!1;if(e){const n=N(t);e(ve(t.tr,n,n.right))}return!0}function et(t,{map:e,table:n,tableStart:o},l){const r=t.mapping.maps.length;for(let s=0;s<e.height;){const i=s*e.width+l,c=e.map[i],a=n.nodeAt(c),d=a.attrs;if(l>0&&e.map[i-1]==c||l<e.width-1&&e.map[i+1]==c)t.setNodeMarkup(t.mapping.slice(r).map(o+c),null,H(d,l-e.colCount(c)));else{const u=t.mapping.slice(r).map(o+c);t.delete(u,u+a.nodeSize)}s+=d.rowspan}}function tt(t,e){if(!E(t))return!1;if(e){const n=N(t),o=t.tr;if(n.left==0&&n.right==n.map.width)return!1;for(let l=n.right-1;et(o,n,l),l!=n.left;l--){const r=n.tableStart?o.doc.nodeAt(n.tableStart-1):o.doc;if(!r)throw new RangeError("No table found");n.table=r,n.map=y.get(r)}e(o)}return!0}function nt(t,e,n){var o;const l=S(e.type.schema).header_cell;for(let r=0;r<t.width;r++)if(((o=e.nodeAt(t.map[r+n*t.width]))===null||o===void 0?void 0:o.type)!=l)return!1;return!0}function Me(t,{map:e,tableStart:n,table:o},l){let r=n;for(let a=0;a<l;a++)r+=o.child(a).nodeSize;const s=[];let i=l>0?-1:0;nt(e,o,l+i)&&(i=l==0||l==e.height?null:0);for(let a=0,d=e.width*l;a<e.width;a++,d++)if(l>0&&l<e.height&&e.map[d]==e.map[d-e.width]){const u=e.map[d],f=o.nodeAt(u).attrs;t.setNodeMarkup(n+u,null,{...f,rowspan:f.rowspan+1}),a+=f.colspan-1}else{var c;const u=i==null?S(o.type.schema).cell:(c=o.nodeAt(e.map[d+i*e.width]))===null||c===void 0?void 0:c.type,f=u==null?void 0:u.createAndFill();f&&s.push(f)}return t.insert(r,S(o.type.schema).row.create(null,s)),t}function ot(t,e){if(!E(t))return!1;if(e){const n=N(t);e(Me(t.tr,n,n.top))}return!0}function lt(t,e){if(!E(t))return!1;if(e){const n=N(t);e(Me(t.tr,n,n.bottom))}return!0}function rt(t,{map:e,table:n,tableStart:o},l){let r=0;for(let a=0;a<l;a++)r+=n.child(a).nodeSize;const s=r+n.child(l).nodeSize,i=t.mapping.maps.length;t.delete(r+o,s+o);const c=new Set;for(let a=0,d=l*e.width;a<e.width;a++,d++){const u=e.map[d];if(!c.has(u)){if(c.add(u),l>0&&u==e.map[d-e.width]){const f=n.nodeAt(u).attrs;t.setNodeMarkup(t.mapping.slice(i).map(u+o),null,{...f,rowspan:f.rowspan-1}),a+=f.colspan-1}else if(l<e.height&&u==e.map[d+e.width]){const f=n.nodeAt(u),h=f.attrs,p=f.type.create({...h,rowspan:f.attrs.rowspan-1},f.content),m=e.positionAt(l+1,a,n);t.insert(t.mapping.slice(i).map(o+m),p),a+=h.colspan-1}}}}function st(t,e){if(!E(t))return!1;if(e){const n=N(t),o=t.tr;if(n.top==0&&n.bottom==n.map.height)return!1;for(let l=n.bottom-1;rt(o,n,l),l!=n.top;l--){const r=n.tableStart?o.doc.nodeAt(n.tableStart-1):o.doc;if(!r)throw new RangeError("No table found");n.table=r,n.map=y.get(n.table)}e(o)}return!0}function le(t){const e=t.content;return e.childCount==1&&e.child(0).isTextblock&&e.child(0).childCount==0}function it({width:t,height:e,map:n},o){let l=o.top*t+o.left,r=l,s=(o.bottom-1)*t+o.left,i=l+(o.right-o.left-1);for(let c=o.top;c<o.bottom;c++){if(o.left>0&&n[r]==n[r-1]||o.right<t&&n[i]==n[i+1])return!0;r+=t,i+=t}for(let c=o.left;c<o.right;c++){if(o.top>0&&n[l]==n[l-t]||o.bottom<e&&n[s]==n[s+t])return!0;l++,s++}return!1}function re(t,e){const n=t.selection;if(!(n instanceof C)||n.$anchorCell.pos==n.$headCell.pos)return!1;const o=N(t),{map:l}=o;if(it(l,o))return!1;if(e){const r=t.tr,s={};let i=g.Fragment.empty,c,a;for(let d=o.top;d<o.bottom;d++)for(let u=o.left;u<o.right;u++){const f=l.map[d*l.width+u],h=o.table.nodeAt(f);if(!(s[f]||!h))if(s[f]=!0,c==null)c=f,a=h;else{le(h)||(i=i.append(h.content));const p=r.mapping.map(f+o.tableStart);r.delete(p,p+h.nodeSize)}}if(c==null||a==null)return!0;if(r.setNodeMarkup(c+o.tableStart,null,{...xe(a.attrs,a.attrs.colspan,o.right-o.left-a.attrs.colspan),rowspan:o.bottom-o.top}),i.size>0){const d=c+1+a.content.size,u=le(a)?c+1:d;r.replaceWith(u+o.tableStart,d+o.tableStart,i)}r.setSelection(new C(r.doc.resolve(c+o.tableStart))),e(r)}return!0}function se(t,e){const n=S(t.schema);return ct(({node:o})=>n[o.type.spec.tableRole])(t,e)}function ct(t){return(e,n)=>{const o=e.selection;let l,r;if(o instanceof C){if(o.$anchorCell.pos!=o.$headCell.pos)return!1;l=o.$anchorCell.nodeAfter,r=o.$anchorCell.pos}else{var s;if(l=Pe(o.$from),!l)return!1;r=(s=_(o.$from))===null||s===void 0?void 0:s.pos}if(l==null||r==null||l.attrs.colspan==1&&l.attrs.rowspan==1)return!1;if(n){let i=l.attrs;const c=[],a=i.colwidth;i.rowspan>1&&(i={...i,rowspan:1}),i.colspan>1&&(i={...i,colspan:1});const d=N(e),u=e.tr;for(let h=0;h<d.right-d.left;h++)c.push(a?{...i,colwidth:a&&a[h]?[a[h]]:null}:i);let f;for(let h=d.top;h<d.bottom;h++){let p=d.map.positionAt(h,d.left,d.table);h==d.top&&(p+=l.nodeSize);for(let m=d.left,b=0;m<d.right;m++,b++)m==d.left&&h==d.top||u.insert(f=u.mapping.map(p+d.tableStart,1),t({node:l,row:h,col:m}).createAndFill(c[b]))}u.setNodeMarkup(r,t({node:l,row:d.top,col:d.left}),c[0]),o instanceof C&&u.setSelection(new C(u.doc.resolve(o.$anchorCell.pos),f?u.doc.resolve(f):void 0)),n(u)}return!0}}function at(t,e){return function(n,o){if(!E(n))return!1;const l=q(n);if(l.nodeAfter.attrs[t]===e)return!1;if(o){const r=n.tr;n.selection instanceof C?n.selection.forEachCell((s,i)=>{s.attrs[t]!==e&&r.setNodeMarkup(i,null,{...s.attrs,[t]:e})}):r.setNodeMarkup(l.pos,null,{...l.nodeAfter.attrs,[t]:e}),o(r)}return!0}}function dt(t){return function(e,n){if(!E(e))return!1;if(n){const o=S(e.schema),l=N(e),r=e.tr,s=l.map.cellsInRect(t=="column"?{left:l.left,top:0,right:l.right,bottom:l.map.height}:t=="row"?{left:0,top:l.top,right:l.map.width,bottom:l.bottom}:l),i=s.map(c=>l.table.nodeAt(c));for(let c=0;c<s.length;c++)i[c].type==o.header_cell&&r.setNodeMarkup(l.tableStart+s[c],o.cell,i[c].attrs);if(r.steps.length===0)for(let c=0;c<s.length;c++)r.setNodeMarkup(l.tableStart+s[c],o.header_cell,i[c].attrs);n(r)}return!0}}function ie(t,e,n){const o=e.map.cellsInRect({left:0,top:0,right:t=="row"?e.map.width:1,bottom:t=="column"?e.map.height:1});for(let l=0;l<o.length;l++){const r=e.table.nodeAt(o[l]);if(r&&r.type!==n.header_cell)return!1}return!0}function B(t,e){return e=e||{useDeprecatedLogic:!1},e.useDeprecatedLogic?dt(t):function(n,o){if(!E(n))return!1;if(o){const l=S(n.schema),r=N(n),s=n.tr,i=ie("row",r,l),c=ie("column",r,l),a=(t==="column"?i:t==="row"&&c)?1:0,d=t=="column"?{left:0,top:a,right:1,bottom:r.map.height}:t=="row"?{left:a,top:0,right:r.map.width,bottom:1}:r,u=t=="column"?c?l.cell:l.header_cell:t=="row"?i?l.cell:l.header_cell:l.cell;r.map.cellsInRect(d).forEach(f=>{const h=f+r.tableStart,p=s.doc.nodeAt(h);p&&s.setNodeMarkup(h,u,p.attrs)}),o(s)}return!0}}B("row",{useDeprecatedLogic:!0});B("column",{useDeprecatedLogic:!0});const ut=B("cell",{useDeprecatedLogic:!0});function ft(t,e){if(e<0){const n=t.nodeBefore;if(n)return t.pos-n.nodeSize;for(let o=t.index(-1)-1,l=t.before();o>=0;o--){const r=t.node(-1).child(o),s=r.lastChild;if(s)return l-1-s.nodeSize;l-=r.nodeSize}}else{if(t.index()<t.parent.childCount-1)return t.pos+t.nodeAfter.nodeSize;const n=t.node(-1);for(let o=t.indexAfter(-1),l=t.after();o<n.childCount;o++){const r=n.child(o);if(r.childCount)return l+1;l+=r.nodeSize}}return null}function ce(t){return function(e,n){if(!E(e))return!1;const o=ft(q(e),t);if(o==null)return!1;if(n){const l=e.doc.resolve(o);n(e.tr.setSelection(g.TextSelection.between(l,Oe(l))).scrollIntoView())}return!0}}function ht(t,e){const n=t.selection.$anchor;for(let o=n.depth;o>0;o--)if(n.node(o).type.spec.tableRole=="table")return e&&e(t.tr.delete(n.before(o),n.after(o)).scrollIntoView()),!0;return!1}function F(t,e){const n=t.selection;if(!(n instanceof C))return!1;if(e){const o=t.tr,l=S(t.schema).cell.createAndFill().content;n.forEachCell((r,s)=>{r.content.eq(l)||o.replace(o.mapping.map(s+1),o.mapping.map(s+r.nodeSize-1),new g.Slice(l,0,0))}),o.docChanged&&e(o)}return!0}function pt(t){if(t.size===0)return null;let{content:e,openStart:n,openEnd:o}=t;for(;e.childCount==1&&(n>0&&o>0||e.child(0).type.spec.tableRole=="table");)n--,o--,e=e.child(0).content;const l=e.child(0),r=l.type.spec.tableRole,s=l.type.schema,i=[];if(r=="row")for(let c=0;c<e.childCount;c++){let a=e.child(c).content;const d=c?0:Math.max(0,n-1),u=c<e.childCount-1?0:Math.max(0,o-1);(d||u)&&(a=ee(S(s).row,new g.Slice(a,d,u)).content),i.push(a)}else if(r=="cell"||r=="header_cell")i.push(n||o?ee(S(s).row,new g.Slice(e,n,o)).content:e);else return null;return mt(s,i)}function mt(t,e){const n=[];for(let l=0;l<e.length;l++){const r=e[l];for(let s=r.childCount-1;s>=0;s--){const{rowspan:i,colspan:c}=r.child(s).attrs;for(let a=l;a<l+i;a++)n[a]=(n[a]||0)+c}}let o=0;for(let l=0;l<n.length;l++)o=Math.max(o,n[l]);for(let l=0;l<n.length;l++)if(l>=e.length&&e.push(g.Fragment.empty),n[l]<o){const r=S(t).cell.createAndFill(),s=[];for(let i=n[l];i<o;i++)s.push(r);e[l]=e[l].append(g.Fragment.from(s))}return{height:e.length,width:o,rows:e}}function ee(t,e){const n=t.createAndFill();return new g.Transform(n).replace(0,n.content.size,e).doc}function gt({width:t,height:e,rows:n},o,l){if(t!=o){const r=[],s=[];for(let i=0;i<n.length;i++){const c=n[i],a=[];for(let d=r[i]||0,u=0;d<o;u++){let f=c.child(u%c.childCount);d+f.attrs.colspan>o&&(f=f.type.createChecked(H(f.attrs,f.attrs.colspan,d+f.attrs.colspan-o),f.content)),a.push(f),d+=f.attrs.colspan;for(let h=1;h<f.attrs.rowspan;h++)r[i+h]=(r[i+h]||0)+f.attrs.colspan}s.push(g.Fragment.from(a))}n=s,t=o}if(e!=l){const r=[];for(let s=0,i=0;s<l;s++,i++){const c=[],a=n[i%e];for(let d=0;d<a.childCount;d++){let u=a.child(d);s+u.attrs.rowspan>l&&(u=u.type.create({...u.attrs,rowspan:Math.max(1,l-u.attrs.rowspan)},u.content)),c.push(u)}r.push(g.Fragment.from(c))}n=r,e=l}return{width:t,height:e,rows:n}}function bt(t,e,n,o,l,r,s){const i=t.doc.type.schema,c=S(i);let a,d;if(l>e.width)for(let u=0,f=0;u<e.height;u++){const h=n.child(u);f+=h.nodeSize;const p=[];let m;h.lastChild==null||h.lastChild.type==c.cell?m=a||(a=c.cell.createAndFill()):m=d||(d=c.header_cell.createAndFill());for(let b=e.width;b<l;b++)p.push(m);t.insert(t.mapping.slice(s).map(f-1+o),p)}if(r>e.height){const u=[];for(let p=0,m=(e.height-1)*e.width;p<Math.max(e.width,l);p++){const b=p>=e.width?!1:n.nodeAt(e.map[m+p]).type==c.header_cell;u.push(b?d||(d=c.header_cell.createAndFill()):a||(a=c.cell.createAndFill()))}const f=c.row.create(null,g.Fragment.from(u)),h=[];for(let p=e.height;p<r;p++)h.push(f);t.insert(t.mapping.slice(s).map(o+n.nodeSize-2),h)}return!!(a||d)}function ae(t,e,n,o,l,r,s,i){if(s==0||s==e.height)return!1;let c=!1;for(let a=l;a<r;a++){const d=s*e.width+a,u=e.map[d];if(e.map[d-e.width]==u){c=!0;const f=n.nodeAt(u),{top:h,left:p}=e.findCell(u);t.setNodeMarkup(t.mapping.slice(i).map(u+o),null,{...f.attrs,rowspan:s-h}),t.insert(t.mapping.slice(i).map(e.positionAt(s,p,n)),f.type.createAndFill({...f.attrs,rowspan:h+f.attrs.rowspan-s})),a+=f.attrs.colspan-1}}return c}function de(t,e,n,o,l,r,s,i){if(s==0||s==e.width)return!1;let c=!1;for(let a=l;a<r;a++){const d=a*e.width+s,u=e.map[d];if(e.map[d-1]==u){c=!0;const f=n.nodeAt(u),h=e.colCount(u),p=t.mapping.slice(i).map(u+o);t.setNodeMarkup(p,null,H(f.attrs,s-h,f.attrs.colspan-(s-h))),t.insert(p+f.nodeSize,f.type.createAndFill(H(f.attrs,0,s-h))),a+=f.attrs.rowspan-1}}return c}function ue(t,e,n,o,l){let r=n?t.doc.nodeAt(n-1):t.doc;if(!r)throw new Error("No table found");let s=y.get(r);const{top:i,left:c}=o,a=c+l.width,d=i+l.height,u=t.tr;let f=0;function h(){if(r=n?u.doc.nodeAt(n-1):u.doc,!r)throw new Error("No table found");s=y.get(r),f=u.mapping.maps.length}bt(u,s,r,n,a,d,f)&&h(),ae(u,s,r,n,c,a,i,f)&&h(),ae(u,s,r,n,c,a,d,f)&&h(),de(u,s,r,n,i,d,c,f)&&h(),de(u,s,r,n,i,d,a,f)&&h();for(let p=i;p<d;p++){const m=s.positionAt(p,c,r),b=s.positionAt(p,a,r);u.replace(u.mapping.slice(f).map(m+n),u.mapping.slice(f).map(b+n),new g.Slice(l.rows[p-i],0,0))}h(),u.setSelection(new C(u.doc.resolve(n+s.positionAt(i,c,r)),u.doc.resolve(n+s.positionAt(d-1,a-1,r)))),e(u)}const wt=D.keydownHandler({ArrowLeft:P("horiz",-1),ArrowRight:P("horiz",1),ArrowUp:P("vert",-1),ArrowDown:P("vert",1),"Shift-ArrowLeft":j("horiz",-1),"Shift-ArrowRight":j("horiz",1),"Shift-ArrowUp":j("vert",-1),"Shift-ArrowDown":j("vert",1),Backspace:F,"Mod-Backspace":F,Delete:F,"Mod-Delete":F});function G(t,e,n){return n.eq(t.selection)?!1:(e&&e(t.tr.setSelection(n).scrollIntoView()),!0)}function P(t,e){return(n,o,l)=>{if(!l)return!1;const r=n.selection;if(r instanceof C)return G(n,o,g.Selection.near(r.$headCell,e));if(t!="horiz"&&!r.empty)return!1;const s=Ee(l,t,e);if(s==null)return!1;if(t=="horiz")return G(n,o,g.Selection.near(n.doc.resolve(r.head+e),e));{const i=n.doc.resolve(s),c=Se(i,t,e);let a;return c?a=g.Selection.near(c,1):e<0?a=g.Selection.near(n.doc.resolve(i.before(-1)),-1):a=g.Selection.near(n.doc.resolve(i.after(-1)),1),G(n,o,a)}}}function j(t,e){return(n,o,l)=>{if(!l)return!1;const r=n.selection;let s;if(r instanceof C)s=r;else{const c=Ee(l,t,e);if(c==null)return!1;s=new C(n.doc.resolve(c))}const i=Se(s.$headCell,t,e);return i?G(n,o,new C(s.$anchorCell,i)):!1}}function Ct(t,e){const n=t.state.doc,o=_(n.resolve(e));return o?(t.dispatch(t.state.tr.setSelection(new C(o))),!0):!1}function yt(t,e,n){if(!E(t.state))return!1;let o=pt(n);const l=t.state.selection;if(l instanceof C){o||(o={width:1,height:1,rows:[g.Fragment.from(ee(S(t.state.schema).cell,n))]});const r=l.$anchorCell.node(-1),s=l.$anchorCell.start(-1),i=y.get(r).rectBetween(l.$anchorCell.pos-s,l.$headCell.pos-s);return o=gt(o,i.right-i.left,i.bottom-i.top),ue(t.state,t.dispatch,s,i,o),!0}else if(o){const r=q(t.state),s=r.start(-1);return ue(t.state,t.dispatch,s,y.get(r.node(-1)).findCell(r.pos-s),o),!0}else return!1}function St(t,e){var n;if(e.ctrlKey||e.metaKey)return;const o=fe(t,e.target);let l;if(e.shiftKey&&t.state.selection instanceof C)r(t.state.selection.$anchorCell,e),e.preventDefault();else if(e.shiftKey&&o&&(l=_(t.state.selection.$anchor))!=null&&((n=U(t,e))===null||n===void 0?void 0:n.pos)!=l.pos)r(l,e),e.preventDefault();else if(!o)return;function r(c,a){let d=U(t,a);const u=z.getState(t.state)==null;if(!d||!oe(c,d))if(u)d=c;else return;const f=new C(c,d);if(u||!t.state.selection.eq(f)){const h=t.state.tr.setSelection(f);u&&h.setMeta(z,c.pos),t.dispatch(h)}}function s(){t.root.removeEventListener("mouseup",s),t.root.removeEventListener("dragstart",s),t.root.removeEventListener("mousemove",i),z.getState(t.state)!=null&&t.dispatch(t.state.tr.setMeta(z,-1))}function i(c){const a=c,d=z.getState(t.state);let u;if(d!=null)u=t.state.doc.resolve(d);else if(fe(t,a.target)!=o&&(u=U(t,e),!u))return s();u&&r(u,a)}t.root.addEventListener("mouseup",s),t.root.addEventListener("dragstart",s),t.root.addEventListener("mousemove",i)}function Ee(t,e,n){if(!(t.state.selection instanceof g.TextSelection))return null;const{$head:o}=t.state.selection;for(let l=o.depth-1;l>=0;l--){const r=o.node(l);if((n<0?o.index(l):o.indexAfter(l))!=(n<0?0:r.childCount))return null;if(r.type.spec.tableRole=="cell"||r.type.spec.tableRole=="header_cell"){const s=o.before(l),i=e=="vert"?n>0?"down":"up":n>0?"right":"left";return t.endOfTextblock(i)?s:null}}return null}function fe(t,e){for(;e&&e!=t.dom;e=e.parentNode)if(e.nodeName=="TD"||e.nodeName=="TH")return e;return null}function U(t,e){const n=t.posAtCoords({left:e.clientX,top:e.clientY});if(!n)return null;const o=n.inside>=0?n.inside:n.pos;return _(t.state.doc.resolve(o))}var xt=class{constructor(e,n){this.node=e,this.defaultCellMinWidth=n,this.dom=document.createElement("div"),this.dom.className="tableWrapper",this.table=this.dom.appendChild(document.createElement("table")),this.table.style.setProperty("--default-cell-min-width",`${n}px`),this.colgroup=this.table.appendChild(document.createElement("colgroup")),te(e,this.colgroup,this.table,n),this.contentDOM=this.table.appendChild(document.createElement("tbody"))}update(e){return e.type!=this.node.type?!1:(this.node=e,te(e,this.colgroup,this.table,this.defaultCellMinWidth),!0)}ignoreMutation(e){return e.type=="attributes"&&(e.target==this.table||this.colgroup.contains(e.target))}};function te(t,e,n,o,l,r){let s=0,i=!0,c=e.firstChild;const a=t.firstChild;if(a){for(let u=0,f=0;u<a.childCount;u++){const{colspan:h,colwidth:p}=a.child(u).attrs;for(let m=0;m<h;m++,f++){const b=l==f?r:p&&p[m],w=b?b+"px":"";if(s+=b||o,b||(i=!1),c)c.style.width!=w&&(c.style.width=w),c=c.nextSibling;else{const x=document.createElement("col");x.style.width=w,e.appendChild(x)}}}for(;c;){var d;const u=c.nextSibling;(d=c.parentNode)===null||d===void 0||d.removeChild(c),c=u}i?(n.style.width=s+"px",n.style.minWidth=""):(n.style.width="",n.style.minWidth=s+"px")}}const T=new g.PluginKey("tableColumnResizing");function At({handleWidth:t=5,cellMinWidth:e=25,defaultCellMinWidth:n=100,View:o=xt,lastColumnResizable:l=!0}={}){const r=new g.Plugin({key:T,state:{init(s,i){var c;const a=(c=r.spec)===null||c===void 0||(c=c.props)===null||c===void 0?void 0:c.nodeViews,d=S(i.schema).table.name;return o&&a&&(a[d]=(u,f)=>new o(u,n,f)),new Tt(-1,!1)},apply(s,i){return i.apply(s)}},props:{attributes:s=>{const i=T.getState(s);return i&&i.activeHandle>-1?{class:"resize-cursor"}:{}},handleDOMEvents:{mousemove:(s,i)=>{Rt(s,i,t,l)},mouseleave:s=>{vt(s)},mousedown:(s,i)=>{Mt(s,i,e,n)}},decorations:s=>{const i=T.getState(s);if(i&&i.activeHandle>-1)return zt(s,i.activeHandle)},nodeViews:{}}});return r}var Tt=class V{constructor(e,n){this.activeHandle=e,this.dragging=n}apply(e){const n=this,o=e.getMeta(T);if(o&&o.setHandle!=null)return new V(o.setHandle,!1);if(o&&o.setDragging!==void 0)return new V(n.activeHandle,o.setDragging);if(n.activeHandle>-1&&e.docChanged){let l=e.mapping.map(n.activeHandle,-1);return Q(e.doc.resolve(l))||(l=-1),new V(l,n.dragging)}return n}};function Rt(t,e,n,o){if(!t.editable)return;const l=T.getState(t.state);if(l&&!l.dragging){const r=Nt(e.target);let s=-1;if(r){const{left:i,right:c}=r.getBoundingClientRect();e.clientX-i<=n?s=he(t,e,"left",n):c-e.clientX<=n&&(s=he(t,e,"right",n))}if(s!=l.activeHandle){if(!o&&s!==-1){const i=t.state.doc.resolve(s),c=i.node(-1),a=y.get(c),d=i.start(-1);if(a.colCount(i.pos-d)+i.nodeAfter.attrs.colspan-1==a.width-1)return}Ne(t,s)}}}function vt(t){if(!t.editable)return;const e=T.getState(t.state);e&&e.activeHandle>-1&&!e.dragging&&Ne(t,-1)}function Mt(t,e,n,o){var l;if(!t.editable)return!1;const r=(l=t.dom.ownerDocument.defaultView)!==null&&l!==void 0?l:window,s=T.getState(t.state);if(!s||s.activeHandle==-1||s.dragging)return!1;const i=t.state.doc.nodeAt(s.activeHandle),c=Et(t,s.activeHandle,i.attrs);t.dispatch(t.state.tr.setMeta(T,{setDragging:{startX:e.clientX,startWidth:c}}));function a(u){r.removeEventListener("mouseup",a),r.removeEventListener("mousemove",d);const f=T.getState(t.state);f!=null&&f.dragging&&(kt(t,f.activeHandle,pe(f.dragging,u,n)),t.dispatch(t.state.tr.setMeta(T,{setDragging:null})))}function d(u){if(!u.which)return a(u);const f=T.getState(t.state);if(f&&f.dragging){const h=pe(f.dragging,u,n);me(t,f.activeHandle,h,o)}}return me(t,s.activeHandle,c,o),r.addEventListener("mouseup",a),r.addEventListener("mousemove",d),e.preventDefault(),!0}function Et(t,e,{colspan:n,colwidth:o}){const l=o&&o[o.length-1];if(l)return l;const r=t.domAtPos(e);let s=r.node.childNodes[r.offset].offsetWidth,i=n;if(o)for(let c=0;c<n;c++)o[c]&&(s-=o[c],i--);return s/i}function Nt(t){for(;t&&t.nodeName!="TD"&&t.nodeName!="TH";)t=t.classList&&t.classList.contains("ProseMirror")?null:t.parentNode;return t}function he(t,e,n,o){const l=n=="right"?-o:o,r=t.posAtCoords({left:e.clientX+l,top:e.clientY});if(!r)return-1;const{pos:s}=r,i=_(t.state.doc.resolve(s));if(!i)return-1;if(n=="right")return i.pos;const c=y.get(i.node(-1)),a=i.start(-1),d=c.map.indexOf(i.pos-a);return d%c.width==0?-1:a+c.map[d-1]}function pe(t,e,n){const o=e.clientX-t.startX;return Math.max(n,t.startWidth+o)}function Ne(t,e){t.dispatch(t.state.tr.setMeta(T,{setHandle:e}))}function kt(t,e,n){const o=t.state.doc.resolve(e),l=o.node(-1),r=y.get(l),s=o.start(-1),i=r.colCount(o.pos-s)+o.nodeAfter.attrs.colspan-1,c=t.state.tr;for(let a=0;a<r.height;a++){const d=a*r.width+i;if(a&&r.map[d]==r.map[d-r.width])continue;const u=r.map[d],f=l.nodeAt(u).attrs,h=f.colspan==1?0:i-r.colCount(u);if(f.colwidth&&f.colwidth[h]==n)continue;const p=f.colwidth?f.colwidth.slice():Lt(f.colspan);p[h]=n,c.setNodeMarkup(s+u,null,{...f,colwidth:p})}c.docChanged&&t.dispatch(c)}function me(t,e,n,o){const l=t.state.doc.resolve(e),r=l.node(-1),s=l.start(-1),i=y.get(r).colCount(l.pos-s)+l.nodeAfter.attrs.colspan-1;let c=t.domAtPos(l.start(-1)).node;for(;c&&c.nodeName!="TABLE";)c=c.parentNode;c&&te(r,c.firstChild,c,o,i,n)}function Lt(t){return Array(t).fill(0)}function zt(t,e){const n=[],o=t.doc.resolve(e),l=o.node(-1);if(!l)return D.DecorationSet.empty;const r=y.get(l),s=o.start(-1),i=r.colCount(o.pos-s)+o.nodeAfter.attrs.colspan-1;for(let a=0;a<r.height;a++){const d=i+a*r.width;if((i==r.width-1||r.map[d]!=r.map[d+1])&&(a==0||r.map[d]!=r.map[d-r.width])){var c;const u=r.map[d],f=s+u+l.nodeAt(u).nodeSize-1,h=document.createElement("div");h.className="column-resize-handle",!((c=T.getState(t))===null||c===void 0)&&c.dragging&&n.push(D.Decoration.node(s+u,s+u+l.nodeAt(u).nodeSize,{class:"column-resize-dragging"})),n.push(D.Decoration.widget(f,h))}}return D.DecorationSet.create(t.doc,n)}function Dt({allowTableNodeSelection:t=!1}={}){return new g.Plugin({key:z,state:{init(){return null},apply(e,n){const o=e.getMeta(z);if(o!=null)return o==-1?null:o;if(n==null||!e.docChanged)return n;const{deleted:l,pos:r}=e.mapping.mapResult(n);return l?null:r}},props:{decorations:qe,handleDOMEvents:{mousedown:St},createSelectionBetween(e){return z.getState(e.state)!=null?e.state.selection:null},handleTripleClick:Ct,handleKeyDown:wt,handlePaste:yt},appendTransaction(e,n,o){return Ze(o,Re(o,n),t)}})}var ke=g.Node3.create({name:"tableCell",addOptions(){return{HTMLAttributes:{}}},content:"block+",addAttributes(){return{colspan:{default:1},rowspan:{default:1},colwidth:{default:null,parseHTML:t=>{var e,n;const o=t.getAttribute("colwidth"),l=o?o.split(",").map(r=>parseInt(r,10)):null;if(!l){const r=(e=t.closest("table"))==null?void 0:e.querySelectorAll("colgroup > col"),s=Array.from(((n=t.parentElement)==null?void 0:n.children)||[]).indexOf(t);if(s&&s>-1&&r&&r[s]){const i=r[s].getAttribute("width");return i?[parseInt(i,10)]:null}}return l}}}},tableRole:"cell",isolating:!0,parseHTML(){return[{tag:"td"}]},renderHTML({HTMLAttributes:t}){return["td",g.mergeAttributes(this.options.HTMLAttributes,t),0]}}),Le=g.Node3.create({name:"tableHeader",addOptions(){return{HTMLAttributes:{}}},content:"block+",addAttributes(){return{colspan:{default:1},rowspan:{default:1},colwidth:{default:null,parseHTML:t=>{const e=t.getAttribute("colwidth");return e?e.split(",").map(o=>parseInt(o,10)):null}}}},tableRole:"header_cell",isolating:!0,parseHTML(){return[{tag:"th"}]},renderHTML({HTMLAttributes:t}){return["th",g.mergeAttributes(this.options.HTMLAttributes,t),0]}}),ze=g.Node3.create({name:"tableRow",addOptions(){return{HTMLAttributes:{}}},content:"(tableCell | tableHeader)*",tableRole:"row",parseHTML(){return[{tag:"tr"}]},renderHTML({HTMLAttributes:t}){return["tr",g.mergeAttributes(this.options.HTMLAttributes,t),0]}});function ne(t,e){return e?["width",`${Math.max(e,t)}px`]:["min-width",`${t}px`]}function ge(t,e,n,o,l,r){var s;let i=0,c=!0,a=e.firstChild;const d=t.firstChild;if(d!==null)for(let f=0,h=0;f<d.childCount;f+=1){const{colspan:p,colwidth:m}=d.child(f).attrs;for(let b=0;b<p;b+=1,h+=1){const w=l===h?r:m&&m[b],x=w?`${w}px`:"";if(i+=w||o,w||(c=!1),a){if(a.style.width!==x){const[R,L]=ne(o,w);a.style.setProperty(R,L)}a=a.nextSibling}else{const R=document.createElement("col"),[L,M]=ne(o,w);R.style.setProperty(L,M),e.appendChild(R)}}}for(;a;){const f=a.nextSibling;(s=a.parentNode)==null||s.removeChild(a),a=f}const u=t.attrs.style&&typeof t.attrs.style=="string"&&/\bwidth\s*:/i.test(t.attrs.style);c&&!u?(n.style.width=`${i}px`,n.style.minWidth=""):(n.style.width="",n.style.minWidth=`${i}px`)}var Ht=class{constructor(t,e){this.node=t,this.cellMinWidth=e,this.dom=document.createElement("div"),this.dom.className="tableWrapper",this.table=this.dom.appendChild(document.createElement("table")),t.attrs.style&&(this.table.style.cssText=t.attrs.style),this.colgroup=this.table.appendChild(document.createElement("colgroup")),ge(t,this.colgroup,this.table,e),this.contentDOM=this.table.appendChild(document.createElement("tbody"))}update(t){return t.type!==this.node.type?!1:(this.node=t,ge(t,this.colgroup,this.table,this.cellMinWidth),!0)}ignoreMutation(t){const e=t.target,n=this.dom.contains(e),o=this.contentDOM.contains(e);return!!(n&&!o&&(t.type==="attributes"||t.type==="childList"||t.type==="characterData"))}};function _t(t,e,n,o){let l=0,r=!0;const s=[],i=t.firstChild;if(!i)return{};for(let u=0,f=0;u<i.childCount;u+=1){const{colspan:h,colwidth:p}=i.child(u).attrs;for(let m=0;m<h;m+=1,f+=1){const b=n===f?o:p&&p[m];l+=b||e,b||(r=!1);const[w,x]=ne(e,b);s.push(["col",{style:`${w}: ${x}`}])}}const c=r?`${l}px`:"",a=r?"":`${l}px`;return{colgroup:["colgroup",{},...s],tableWidth:c,tableMinWidth:a}}function be(t,e){return t.createAndFill()}function It(t){if(t.cached.tableNodeTypes)return t.cached.tableNodeTypes;const e={};return Object.keys(t.nodes).forEach(n=>{const o=t.nodes[n];o.spec.tableRole&&(e[o.spec.tableRole]=o)}),t.cached.tableNodeTypes=e,e}function Bt(t,e,n,o,l){const r=It(t),s=[],i=[];for(let a=0;a<n;a+=1){const d=be(r.cell);if(d&&i.push(d),o){const u=be(r.header_cell);u&&s.push(u)}}const c=[];for(let a=0;a<e;a+=1)c.push(r.row.createChecked(null,o&&a===0?s:i));return r.table.createChecked(null,c)}function $t(t){return t instanceof C}var O=({editor:t})=>{const{selection:e}=t.state;if(!$t(e))return!1;let n=0;const o=g.findParentNodeClosestToPos(e.ranges[0].$from,r=>r.type.name==="table");return o==null||o.node.descendants(r=>{if(r.type.name==="table")return!1;["tableCell","tableHeader"].includes(r.type.name)&&(n+=1)}),n===e.ranges.length?(t.commands.deleteTable(),!0):!1},Wt="";function Ft(t){return(t||"").replace(/\s+/g," ").trim()}function Pt(t,e,n={}){var o;const l=(o=n.cellLineSeparator)!=null?o:Wt;if(!t||!t.content||t.content.length===0)return"";const r=[];t.content.forEach(p=>{const m=[];p.content&&p.content.forEach(b=>{let w="";b.content&&Array.isArray(b.content)&&b.content.length>1?w=b.content.map(M=>e.renderChildren(M)).join(l):w=b.content?e.renderChildren(b.content):"";const x=Ft(w),R=b.type==="tableHeader";m.push({text:x,isHeader:R})}),r.push(m)});const s=r.reduce((p,m)=>Math.max(p,m.length),0);if(s===0)return"";const i=new Array(s).fill(0);r.forEach(p=>{var m;for(let b=0;b<s;b+=1){const x=(((m=p[b])==null?void 0:m.text)||"").length;x>i[b]&&(i[b]=x),i[b]<3&&(i[b]=3)}});const c=(p,m)=>p+" ".repeat(Math.max(0,m-p.length)),a=r[0],d=a.some(p=>p.isHeader);let u=`
|
|
2
2
|
`;const f=new Array(s).fill(0).map((p,m)=>d&&a[m]&&a[m].text||"");return u+=`| ${f.map((p,m)=>c(p,i[m])).join(" | ")} |
|
|
3
3
|
`,u+=`| ${i.map(p=>"-".repeat(Math.max(3,p))).join(" | ")} |
|
|
4
4
|
`,(d?r.slice(1):r).forEach(p=>{u+=`| ${new Array(s).fill(0).map((m,b)=>c(p[b]&&p[b].text||"",i[b])).join(" | ")} |
|
package/lib/Table.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./Table-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./Table-3VstSlg4.cjs");exports.RichTextTable=e.RichTextTable;exports.Table=e.Table;
|
package/lib/Table.js
CHANGED
package/lib/TaskList.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const c=require("./index-TMqmkmT6.cjs"),e=require("react/jsx-runtime"),m=require("./toggle-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const c=require("./index-TMqmkmT6.cjs"),e=require("react/jsx-runtime"),m=require("./toggle-DVCNvcqp.cjs");require("react");require("./index-CNzHZDls.cjs");const a=require("./useButtonProps-bei1vI37.cjs");function g(){const t=a.useButtonProps(u.name),{icon:s=void 0,tooltip:i=void 0,shortcutKeys:o=void 0,tooltipOptions:d={},action:n=void 0,isActive:l=void 0}=(t==null?void 0:t.componentProps)??{},{dataState:p,disabled:r,update:T}=a.useToggleActive(l),k=()=>{r||n&&(n(),T())};return t?e.jsx(m.ActionButton,{action:k,dataState:p,disabled:r,icon:s,shortcutKeys:o,tooltip:i,tooltipOptions:d}):e.jsx(e.Fragment,{})}const u=c.TaskList.extend({addOptions(){var t;return{...(t=this.parent)==null?void 0:t.call(this),HTMLAttributes:{class:"task-list"},taskItem:{HTMLAttributes:{class:"task-list-item"}},button:({editor:s,t:i,extension:o})=>({componentProps:{action:()=>s.commands.toggleTaskList(),isActive:()=>s.isActive("taskList"),disabled:!1,icon:"ListTodo",shortcutKeys:o.options.shortcutKeys??["shift","mod","9"],tooltip:i("editor.tasklist.tooltip")}})}},addExtensions(){return[c.TaskItem.configure(this.options.taskItem)]}});exports.RichTextTaskList=g;exports.TaskList=u;
|
package/lib/TaskList.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { T as u, a as l } from "./index-D-FhWysc.js";
|
|
2
2
|
import { jsx as a, Fragment as f } from "react/jsx-runtime";
|
|
3
|
-
import { A as k } from "./toggle-
|
|
3
|
+
import { A as k } from "./toggle-xchtz-Kf.js";
|
|
4
4
|
import "react";
|
|
5
5
|
import "./index-DuZCJJSp.js";
|
|
6
6
|
import { u as T, a as v } from "./useButtonProps-D0SrPzuG.js";
|
package/lib/TextAlign.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const K=require("./index-DLqogznp.cjs"),s=require("react/jsx-runtime"),m=require("react"),M=require("./toggle-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const K=require("./index-DLqogznp.cjs"),s=require("react/jsx-runtime"),m=require("react"),M=require("./toggle-DVCNvcqp.cjs");require("./index-CNzHZDls.cjs");const y=require("./useButtonProps-bei1vI37.cjs"),T=require("./popover-CZWSQZ0q.cjs"),S=require("./Icon-BjR_or8V.cjs"),j=require("./tooltip-DFjcKu9a.cjs");var q=K.Extension.create({name:"textAlign",addOptions(){return{types:[],alignments:["left","center","right","justify"],defaultAlignment:null}},addGlobalAttributes(){return[{types:this.options.types,attributes:{textAlign:{default:this.options.defaultAlignment,parseHTML:e=>{const t=e.style.textAlign;return this.options.alignments.includes(t)?t:this.options.defaultAlignment},renderHTML:e=>e.textAlign?{style:`text-align: ${e.textAlign}`}:{}}}}]},addCommands(){return{setTextAlign:e=>({commands:t})=>this.options.alignments.includes(e)?this.options.types.map(n=>t.updateAttributes(n,{textAlign:e})).some(n=>n):!1,unsetTextAlign:()=>({commands:e})=>this.options.types.map(t=>e.resetAttributes(t,"textAlign")).some(t=>t),toggleTextAlign:e=>({editor:t,commands:n})=>this.options.alignments.includes(e)?t.isActive({textAlign:e})?n.unsetTextAlign():n.setTextAlign(e):!1}},addKeyboardShortcuts(){return{"Mod-Shift-l":()=>this.editor.commands.setTextAlign("left"),"Mod-Shift-e":()=>this.editor.commands.setTextAlign("center"),"Mod-Shift-r":()=>this.editor.commands.setTextAlign("right"),"Mod-Shift-j":()=>this.editor.commands.setTextAlign("justify")}}}),P=q;function R(){const[e,t]=m.useState(!1),n=y.useButtonProps(C.name),{icon:g=void 0,tooltip:f=void 0,items:r=[],isActive:A=void 0}=(n==null?void 0:n.componentProps)??{},{disabled:l,dataState:c}=y.useActive(A),u=m.useMemo(()=>(c==null?void 0:c.title)||"",[c]),x=m.useMemo(()=>r==null?void 0:r.some(i=>i.title===u),[r,u]);return n?s.jsxs(T.Popover,{modal:!0,onOpenChange:t,open:e,children:[s.jsx(T.PopoverTrigger,{asChild:!0,className:"hover:richtext-bg-accent data-[state=on]:richtext-bg-accent","data-state":x?"on":"off",disabled:l,children:s.jsx(M.ActionButton,{customClass:"!richtext-w-12 richtext-h-12",disabled:l,icon:g,tooltip:f,children:s.jsx(S.IconComponent,{className:"richtext-ml-1 richtext-size-3 richtext-text-zinc-500",name:"MenuDown"})})}),s.jsx(T.PopoverContent,{align:"start",className:"richtext-flex richtext-w-full richtext-min-w-4 richtext-flex-row richtext-gap-1 !richtext-p-[4px]",side:"bottom",children:r==null?void 0:r.map((i,p)=>{var o,a;return s.jsxs(j.Tooltip,{children:[s.jsx(j.TooltipTrigger,{asChild:!0,children:s.jsx(M.Toggle,{className:"richtext-size-7 richtext-p-1","data-state":u===i.title?"on":"off",size:"sm",onClick:()=>{i==null||i.action(),t(!1)},children:(i==null?void 0:i.icon)&&s.jsx(S.IconComponent,{name:i.icon})})}),s.jsxs(j.TooltipContent,{className:"richtext-flex richtext-flex-col richtext-items-center",children:[s.jsx("span",{children:i.title}),!!((o=i.shortcutKeys)!=null&&o.length)&&s.jsx("span",{children:(a=i.shortcutKeys)==null?void 0:a.map(h=>y.getShortcutKey(h)).join(" ")})]})]},`text-align-${p}`)})})]}):s.jsx(s.Fragment,{})}const C=P.extend({addOptions(){var e;return{...(e=this.parent)==null?void 0:e.call(this),types:["heading","paragraph","list_item","title"],button({editor:t,extension:n,t:g}){var c,u,x,i,p;const f=((c=n.options)==null?void 0:c.alignments)||[],r={left:((u=n.options.shortcutKeys)==null?void 0:u[0])??["mod","Shift","L"],center:((x=n.options.shortcutKeys)==null?void 0:x[1])??["mod","Shift","E"],right:((i=n.options.shortcutKeys)==null?void 0:i[2])??["mod","Shift","R"],justify:((p=n.options.shortcutKeys)==null?void 0:p[3])??["mod","Shift","J"]},A={left:"AlignLeft",center:"AlignCenter",right:"AlignRight",justify:"AlignJustify"},l=f.map(o=>{var a,h,v;return{title:g(`editor.textalign.${o}.tooltip`),icon:A[o],shortcutKeys:r[o],isActive:()=>t.isActive({textAlign:o})||!1,action:()=>{var d,b;return(b=(d=t.commands)==null?void 0:d.setTextAlign)==null?void 0:b.call(d,o)},disabled:!((v=(h=(a=t==null?void 0:t.can)==null?void 0:a.call(t))==null?void 0:h.setTextAlign)!=null&&v.call(h,o))}});return{componentProps:{icon:"AlignJustify",tooltip:g("editor.textalign.tooltip"),items:l,isActive:()=>l==null?void 0:l.find(a=>a.isActive())}}}}}});exports.RichTextAlign=R;exports.TextAlign=C;
|
package/lib/TextAlign.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { E as C } from "./index-nFjllrEl.js";
|
|
2
2
|
import { jsx as o, Fragment as K, jsxs as A } from "react/jsx-runtime";
|
|
3
3
|
import M, { useMemo as v } from "react";
|
|
4
|
-
import { A as S, T as j } from "./toggle-
|
|
4
|
+
import { A as S, T as j } from "./toggle-xchtz-Kf.js";
|
|
5
5
|
import "./index-DuZCJJSp.js";
|
|
6
|
-
import { I as b } from "./Icon-C-qYUAS1.js";
|
|
7
6
|
import { u as P, b as w, h as N } from "./useButtonProps-D0SrPzuG.js";
|
|
8
7
|
import { P as z, a as L, b as O } from "./popover-CoepUobG.js";
|
|
8
|
+
import { I as b } from "./Icon-C-qYUAS1.js";
|
|
9
9
|
import { T as R, a as _, b as $ } from "./tooltip-BTFcHrd9.js";
|
|
10
10
|
var E = C.create({
|
|
11
11
|
name: "textAlign",
|
package/lib/TextDirection.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const C=require("./index-DLqogznp.cjs"),e=require("react/jsx-runtime"),j=require("react"),m=require("./toggle-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const C=require("./index-DLqogznp.cjs"),e=require("react/jsx-runtime"),j=require("react"),m=require("./toggle-DVCNvcqp.cjs");require("./index-CNzHZDls.cjs");const d=require("./useButtonProps-bei1vI37.cjs"),T=require("./popover-CZWSQZ0q.cjs"),D=require("./Icon-BjR_or8V.cjs"),g=require("./tooltip-DFjcKu9a.cjs");function b(){const i=d.useButtonProps(v.name),[c,x]=j.useState(!1),{icon:u=void 0,tooltip:h=void 0,items:s=[],isActive:p=void 0}=(i==null?void 0:i.componentProps)??{},{editorDisabled:l,dataState:o}=d.useActive(p),n=j.useMemo(()=>(o==null?void 0:o.dir)||"unset",[o]);return i?e.jsxs(T.Popover,{open:c,onOpenChange:x,modal:!0,children:[e.jsx(T.PopoverTrigger,{asChild:!0,disabled:l,children:e.jsx(m.ActionButton,{customClass:"!richtext-w-12 richtext-h-12",disabled:l,icon:u,tooltip:h,children:e.jsx(D.IconComponent,{className:"richtext-ml-1 richtext-size-3 richtext-text-zinc-500",name:"MenuDown"})})}),e.jsx(T.PopoverContent,{align:"start",className:"richtext-flex richtext-w-full richtext-min-w-4 richtext-flex-row richtext-gap-1 !richtext-p-[4px]",side:"bottom",hideWhenDetached:!0,children:s==null?void 0:s.map((t,r)=>{var a,f;return e.jsxs(g.Tooltip,{children:[e.jsx(g.TooltipTrigger,{"data-state":n===t.value?"on":"off",asChild:!0,children:e.jsx(m.Toggle,{className:"richtext-size-7 richtext-p-1",onClick:()=>{t==null||t.action(),x(!1)},size:"sm",children:(t==null?void 0:t.icon)&&e.jsx(D.IconComponent,{name:t.icon})})}),e.jsxs(g.TooltipContent,{className:"richtext-flex richtext-flex-col richtext-items-center",children:[e.jsx("span",{children:t.title}),!!((a=t.shortcutKeys)!=null&&a.length)&&e.jsx("span",{children:(f=t.shortcutKeys)==null?void 0:f.map(q=>d.getShortcutKey(q)).join(" ")})]})]},`text-direction-${r}`)})})]}):e.jsx(e.Fragment,{})}const v=C.Extension.create({name:"richTextTextDirection",addOptions(){var i;return{...(i=this.parent)==null?void 0:i.call(this),directions:["auto","ltr","rtl","unset"],defaultDirection:"auto",button({editor:c,extension:x,t:u}){var l;const h=((l=x.options)==null?void 0:l.directions)||[],s={auto:"TextDirection",ltr:"LeftToRight",rtl:"RightToLeft",unset:"X"},p=h.map(o=>({title:u(`editor.textDirection.${o}.tooltip`),value:o,icon:s[o],action:()=>{var n,t,r,a;if(o==="unset"){(t=(n=c.commands)==null?void 0:n.unsetTextDirection)==null||t.call(n);return}(a=(r=c.commands)==null?void 0:r.setTextDirection)==null||a.call(r,o)},disabled:!1}));return{componentProps:{icon:"TextDirection",tooltip:u("editor.textDirection.tooltip"),items:p,isActive:()=>c.getAttributes("paragraph")}}}}}});exports.RichTextTextDirection=b;exports.TextDirection=v;
|
package/lib/TextDirection.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { E as g } from "./index-nFjllrEl.js";
|
|
2
2
|
import { jsx as o, Fragment as D, jsxs as x } from "react/jsx-runtime";
|
|
3
3
|
import v, { useMemo as b } from "react";
|
|
4
|
-
import { A as C, T as A } from "./toggle-
|
|
4
|
+
import { A as C, T as A } from "./toggle-xchtz-Kf.js";
|
|
5
5
|
import "./index-DuZCJJSp.js";
|
|
6
|
-
import { I as f } from "./Icon-C-qYUAS1.js";
|
|
7
6
|
import { u as P, b as w, h as z } from "./useButtonProps-D0SrPzuG.js";
|
|
8
7
|
import { P as N, a as R, b as j } from "./popover-CoepUobG.js";
|
|
8
|
+
import { I as f } from "./Icon-C-qYUAS1.js";
|
|
9
9
|
import { T as y, a as K, b as M } from "./tooltip-BTFcHrd9.js";
|
|
10
10
|
function X() {
|
|
11
11
|
const i = P(O.name), [c, h] = v.useState(!1), {
|
package/lib/TextUnderline.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const u=require("./index-DLqogznp.cjs"),s=require("react/jsx-runtime"),h=require("./toggle-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const u=require("./index-DLqogznp.cjs"),s=require("react/jsx-runtime"),h=require("./toggle-DVCNvcqp.cjs");require("react");require("./index-CNzHZDls.cjs");const a=require("./useButtonProps-bei1vI37.cjs");var k=u.Mark.create({name:"underline",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"u"},{style:"text-decoration",consuming:!1,getAttrs:e=>e.includes("underline")?{}:!1}]},renderHTML({HTMLAttributes:e}){return["u",u.mergeAttributes(this.options.HTMLAttributes,e),0]},parseMarkdown(e,n){return n.applyMark(this.name||"underline",n.parseInline(e.tokens||[]))},renderMarkdown(e,n){return`++${n.renderChildren(e)}++`},markdownTokenizer:{name:"underline",level:"inline",start(e){return e.indexOf("++")},tokenize(e,n,t){const r=/^(\+\+)([\s\S]+?)(\+\+)/.exec(e);if(!r)return;const i=r[2].trim();return{type:"underline",raw:r[0],text:i,tokens:t.inlineTokens(i)}}},addCommands(){return{setUnderline:()=>({commands:e})=>e.setMark(this.name),toggleUnderline:()=>({commands:e})=>e.toggleMark(this.name),unsetUnderline:()=>({commands:e})=>e.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-u":()=>this.editor.commands.toggleUnderline(),"Mod-U":()=>this.editor.commands.toggleUnderline()}}}),v=k;function x(){const e=a.useButtonProps(l.name),{icon:n=void 0,tooltip:t=void 0,shortcutKeys:o=void 0,tooltipOptions:r={},action:i=void 0,isActive:c=void 0}=(e==null?void 0:e.componentProps)??{},{dataState:m,disabled:d,update:p}=a.useToggleActive(c),g=()=>{d||i&&(i(),p())};return e?s.jsx(h.ActionButton,{action:g,dataState:m,disabled:d,icon:n,shortcutKeys:o,tooltip:t,tooltipOptions:r}):s.jsx(s.Fragment,{})}const l=v.extend({addOptions(){var e;return{...(e=this.parent)==null?void 0:e.call(this),button({editor:n,t,extension:o}){return{componentProps:{action:()=>n.commands.toggleUnderline(),isActive:()=>n.isActive("underline")||!1,disabled:!1,icon:"Underline",shortcutKeys:o.options.shortcutKeys??["mod","U"],tooltip:t("editor.underline.tooltip")}}}}}});exports.RichTextUnderline=x;exports.TextUnderline=l;
|
package/lib/TextUnderline.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { M as m, m as p } from "./index-nFjllrEl.js";
|
|
2
2
|
import { jsx as d, Fragment as g } from "react/jsx-runtime";
|
|
3
|
-
import { A as f } from "./toggle-
|
|
3
|
+
import { A as f } from "./toggle-xchtz-Kf.js";
|
|
4
4
|
import "react";
|
|
5
5
|
import "./index-DuZCJJSp.js";
|
|
6
6
|
import { u as h, a as k } from "./useButtonProps-D0SrPzuG.js";
|