quoin-editor 1.0.2 → 1.1.1
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/CHANGELOG.md +32 -0
- package/dist/ai.cjs +169 -249
- package/dist/ai.cjs.map +1 -1
- package/dist/ai.js +38 -121
- package/dist/ai.js.map +1 -1
- package/dist/catalogue.cjs +29 -43
- package/dist/catalogue.cjs.map +1 -1
- package/dist/catalogue.js +21 -37
- package/dist/catalogue.js.map +1 -1
- package/dist/{chunk-DUE3HCZD.js → chunk-2EQ6FKSK.js} +19 -28
- package/dist/chunk-2EQ6FKSK.js.map +1 -0
- package/dist/{chunk-RJRX34BZ.js → chunk-3BXUGX5F.js} +4 -18
- package/dist/chunk-3BXUGX5F.js.map +1 -0
- package/dist/chunk-3QRVAI53.cjs +27 -0
- package/dist/chunk-3QRVAI53.cjs.map +1 -0
- package/dist/{chunk-U3LOLYAU.js → chunk-7FAVFJAS.js} +4 -10
- package/dist/chunk-7FAVFJAS.js.map +1 -0
- package/dist/{chunk-FDRUAL3Z.cjs → chunk-7NAONESM.cjs} +90 -153
- package/dist/chunk-7NAONESM.cjs.map +1 -0
- package/dist/{chunk-6V6GGBDK.cjs → chunk-7SVKLWDT.cjs} +24 -31
- package/dist/chunk-7SVKLWDT.cjs.map +1 -0
- package/dist/{chunk-CW3AFJBR.cjs → chunk-7XQGOCUG.cjs} +1332 -1772
- package/dist/chunk-7XQGOCUG.cjs.map +1 -0
- package/dist/{chunk-EH5KXQXY.cjs → chunk-A6PGQVTR.cjs} +36 -20
- package/dist/chunk-A6PGQVTR.cjs.map +1 -0
- package/dist/{chunk-4SLJNZSM.cjs → chunk-AIS37SL2.cjs} +201 -198
- package/dist/chunk-AIS37SL2.cjs.map +1 -0
- package/dist/{chunk-IQBMAE3F.js → chunk-CKHKCPGL.js} +34 -92
- package/dist/chunk-CKHKCPGL.js.map +1 -0
- package/dist/{chunk-T43RZTUT.js → chunk-DYWU4SQ2.js} +723 -1246
- package/dist/chunk-DYWU4SQ2.js.map +1 -0
- package/dist/chunk-EFRQMYZ6.cjs +33 -0
- package/dist/chunk-EFRQMYZ6.cjs.map +1 -0
- package/dist/{chunk-O4Z2WMFF.js → chunk-HDJ653LM.js} +25 -18
- package/dist/chunk-HDJ653LM.js.map +1 -0
- package/dist/chunk-HQ43EIYO.cjs +94 -0
- package/dist/chunk-HQ43EIYO.cjs.map +1 -0
- package/dist/{chunk-6NULZPVC.js → chunk-HTLWPSMU.js} +8 -61
- package/dist/chunk-HTLWPSMU.js.map +1 -0
- package/dist/{chunk-EPARJI4V.js → chunk-IEP7BPFN.js} +122 -267
- package/dist/chunk-IEP7BPFN.js.map +1 -0
- package/dist/{chunk-P6KYXFZC.cjs → chunk-IGZRZIAF.cjs} +440 -538
- package/dist/chunk-IGZRZIAF.cjs.map +1 -0
- package/dist/chunk-JCEFSTVG.cjs +483 -0
- package/dist/chunk-JCEFSTVG.cjs.map +1 -0
- package/dist/chunk-KXRGY5LK.cjs +612 -0
- package/dist/chunk-KXRGY5LK.cjs.map +1 -0
- package/dist/{chunk-JHQUHFLX.js → chunk-KZ6ZFCGO.js} +38 -120
- package/dist/chunk-KZ6ZFCGO.js.map +1 -0
- package/dist/{chunk-ADSJ42DO.js → chunk-L2QA2UTY.js} +17 -69
- package/dist/chunk-L2QA2UTY.js.map +1 -0
- package/dist/{chunk-OBMBSU2S.js → chunk-L4D23LM2.js} +5 -184
- package/dist/chunk-L4D23LM2.js.map +1 -0
- package/dist/{chunk-4XFXB37X.js → chunk-L6OW2FL3.js} +7 -90
- package/dist/chunk-L6OW2FL3.js.map +1 -0
- package/dist/chunk-LE5XMIFJ.cjs +4 -3
- package/dist/chunk-LE5XMIFJ.cjs.map +1 -1
- package/dist/chunk-MQUCCSWG.js +2 -3
- package/dist/chunk-MQUCCSWG.js.map +1 -1
- package/dist/{chunk-C23RQVRK.js → chunk-MUIPM26J.js} +66 -216
- package/dist/chunk-MUIPM26J.js.map +1 -0
- package/dist/{chunk-AUOEM3SF.cjs → chunk-OKWER2RV.cjs} +102 -155
- package/dist/chunk-OKWER2RV.cjs.map +1 -0
- package/dist/{chunk-TLGX43P6.cjs → chunk-OM7E43ZN.cjs} +89 -86
- package/dist/chunk-OM7E43ZN.cjs.map +1 -0
- package/dist/{chunk-NEZJ7ZP5.js → chunk-QSXPKZ2F.js} +4 -8
- package/dist/chunk-QSXPKZ2F.js.map +1 -0
- package/dist/{chunk-VCLL5C7J.js → chunk-RFLFRIPV.js} +14 -57
- package/dist/chunk-RFLFRIPV.js.map +1 -0
- package/dist/chunk-RIIXJWBR.cjs +24 -0
- package/dist/chunk-RIIXJWBR.cjs.map +1 -0
- package/dist/{chunk-VRS6WCEK.js → chunk-SFMORPWB.js} +60 -167
- package/dist/chunk-SFMORPWB.js.map +1 -0
- package/dist/{chunk-YBMUEEM5.js → chunk-TYZSB7JT.js} +4 -8
- package/dist/chunk-TYZSB7JT.js.map +1 -0
- package/dist/{chunk-BQANU5BH.cjs → chunk-U5BSCAMP.cjs} +34 -44
- package/dist/chunk-U5BSCAMP.cjs.map +1 -0
- package/dist/{chunk-OSHZQR3W.js → chunk-UEVR4B5S.js} +13 -45
- package/dist/chunk-UEVR4B5S.js.map +1 -0
- package/dist/{chunk-N4FGA3H4.js → chunk-VBJY2CSK.js} +38 -105
- package/dist/chunk-VBJY2CSK.js.map +1 -0
- package/dist/{chunk-ZKVOS57Q.cjs → chunk-VFSVN5IQ.cjs} +495 -551
- package/dist/chunk-VFSVN5IQ.cjs.map +1 -0
- package/dist/{chunk-X4HDKFW5.cjs → chunk-VNRI5DAL.cjs} +56 -105
- package/dist/chunk-VNRI5DAL.cjs.map +1 -0
- package/dist/chunk-W7B4WQ3L.cjs +200 -0
- package/dist/chunk-W7B4WQ3L.cjs.map +1 -0
- package/dist/{chunk-623AOJM2.js → chunk-WAGBELKA.js} +7 -25
- package/dist/chunk-WAGBELKA.js.map +1 -0
- package/dist/{chunk-WEYDDIBQ.cjs → chunk-WH56EW3H.cjs} +36 -64
- package/dist/chunk-WH56EW3H.cjs.map +1 -0
- package/dist/{chunk-5MAYUGTE.cjs → chunk-XAS7LANM.cjs} +233 -363
- package/dist/chunk-XAS7LANM.cjs.map +1 -0
- package/dist/comments.cjs +210 -290
- package/dist/comments.cjs.map +1 -1
- package/dist/comments.js +82 -186
- package/dist/comments.js.map +1 -1
- package/dist/diff.cjs +48 -65
- package/dist/diff.cjs.map +1 -1
- package/dist/diff.d.cts +2 -2
- package/dist/diff.d.ts +2 -2
- package/dist/diff.js +8 -32
- package/dist/diff.js.map +1 -1
- package/dist/docx.cjs +50 -63
- package/dist/docx.cjs.map +1 -1
- package/dist/docx.js +7 -22
- package/dist/docx.js.map +1 -1
- package/dist/embed.cjs +19 -12
- package/dist/embed.cjs.map +1 -1
- package/dist/embed.js +10 -16
- package/dist/embed.js.map +1 -1
- package/dist/emoji-data.cjs +7 -5
- package/dist/emoji-data.cjs.map +1 -1
- package/dist/emoji-data.js +3 -5
- package/dist/emoji-data.js.map +1 -1
- package/dist/emoji.cjs +26 -17
- package/dist/emoji.cjs.map +1 -1
- package/dist/emoji.js +9 -17
- package/dist/emoji.js.map +1 -1
- package/dist/engine.cjs +229 -118
- package/dist/engine.cjs.map +1 -1
- package/dist/engine.js +4 -118
- package/dist/engine.js.map +1 -1
- package/dist/find.cjs +30 -19
- package/dist/find.cjs.map +1 -1
- package/dist/find.js +9 -19
- package/dist/find.js.map +1 -1
- package/dist/headless.cjs +291 -151
- package/dist/headless.cjs.map +1 -1
- package/dist/headless.d.cts +5 -1
- package/dist/headless.d.ts +5 -1
- package/dist/headless.js +6 -151
- package/dist/headless.js.map +1 -1
- package/dist/index.cjs +349 -183
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +17 -4
- package/dist/index.d.ts +17 -4
- package/dist/index.js +8 -183
- package/dist/index.js.map +1 -1
- package/dist/math.cjs +20 -13
- package/dist/math.cjs.map +1 -1
- package/dist/math.js +11 -17
- package/dist/math.js.map +1 -1
- package/dist/mention.cjs +20 -13
- package/dist/mention.cjs.map +1 -1
- package/dist/mention.js +11 -17
- package/dist/mention.js.map +1 -1
- package/dist/presence.cjs +99 -132
- package/dist/presence.cjs.map +1 -1
- package/dist/presence.js +22 -78
- package/dist/presence.js.map +1 -1
- package/dist/{registry-CWBOSAHm.d.ts → registry-CXegaw5k.d.cts} +25 -2
- package/dist/{registry-CWBOSAHm.d.cts → registry-CXegaw5k.d.ts} +25 -2
- package/dist/stats.cjs +27 -18
- package/dist/stats.cjs.map +1 -1
- package/dist/stats.js +10 -18
- package/dist/stats.js.map +1 -1
- package/dist/styles.css +1 -1
- package/dist/table.cjs +90 -49
- package/dist/table.cjs.map +1 -1
- package/dist/table.js +9 -49
- package/dist/table.js.map +1 -1
- package/dist/toc.cjs +26 -17
- package/dist/toc.cjs.map +1 -1
- package/dist/toc.js +9 -17
- package/dist/toc.js.map +1 -1
- package/dist/view.cjs +13 -16
- package/dist/view.cjs.map +1 -1
- package/dist/view.d.cts +2 -2
- package/dist/view.d.ts +2 -2
- package/dist/view.js +7 -16
- package/dist/view.js.map +1 -1
- package/dist/yjs.cjs +186 -228
- package/dist/yjs.cjs.map +1 -1
- package/dist/yjs.js +12 -80
- package/dist/yjs.js.map +1 -1
- package/package.json +2 -1
- package/dist/chunk-4SLJNZSM.cjs.map +0 -1
- package/dist/chunk-4XFXB37X.js.map +0 -1
- package/dist/chunk-5MAYUGTE.cjs.map +0 -1
- package/dist/chunk-623AOJM2.js.map +0 -1
- package/dist/chunk-6NULZPVC.js.map +0 -1
- package/dist/chunk-6V6GGBDK.cjs.map +0 -1
- package/dist/chunk-73653CJ4.cjs +0 -34
- package/dist/chunk-73653CJ4.cjs.map +0 -1
- package/dist/chunk-ADSJ42DO.js.map +0 -1
- package/dist/chunk-AUOEM3SF.cjs.map +0 -1
- package/dist/chunk-BQANU5BH.cjs.map +0 -1
- package/dist/chunk-C23RQVRK.js.map +0 -1
- package/dist/chunk-CW3AFJBR.cjs.map +0 -1
- package/dist/chunk-DUE3HCZD.js.map +0 -1
- package/dist/chunk-EH5KXQXY.cjs.map +0 -1
- package/dist/chunk-EPARJI4V.js.map +0 -1
- package/dist/chunk-FDRUAL3Z.cjs.map +0 -1
- package/dist/chunk-IQBMAE3F.js.map +0 -1
- package/dist/chunk-JHQUHFLX.js.map +0 -1
- package/dist/chunk-KUYZMSMF.cjs +0 -100
- package/dist/chunk-KUYZMSMF.cjs.map +0 -1
- package/dist/chunk-LLTEGXWZ.cjs +0 -562
- package/dist/chunk-LLTEGXWZ.cjs.map +0 -1
- package/dist/chunk-N4FGA3H4.js.map +0 -1
- package/dist/chunk-NEZJ7ZP5.js.map +0 -1
- package/dist/chunk-O4Z2WMFF.js.map +0 -1
- package/dist/chunk-OBMBSU2S.js.map +0 -1
- package/dist/chunk-OSHZQR3W.js.map +0 -1
- package/dist/chunk-P6KYXFZC.cjs.map +0 -1
- package/dist/chunk-R2BLBV43.cjs +0 -239
- package/dist/chunk-R2BLBV43.cjs.map +0 -1
- package/dist/chunk-RJRX34BZ.js.map +0 -1
- package/dist/chunk-T43RZTUT.js.map +0 -1
- package/dist/chunk-TLGX43P6.cjs.map +0 -1
- package/dist/chunk-U3LOLYAU.js.map +0 -1
- package/dist/chunk-UEKXVCKC.cjs +0 -716
- package/dist/chunk-UEKXVCKC.cjs.map +0 -1
- package/dist/chunk-VCLL5C7J.js.map +0 -1
- package/dist/chunk-VRS6WCEK.js.map +0 -1
- package/dist/chunk-WEYDDIBQ.cjs.map +0 -1
- package/dist/chunk-X4HDKFW5.cjs.map +0 -1
- package/dist/chunk-X4P4TQXH.cjs +0 -30
- package/dist/chunk-X4P4TQXH.cjs.map +0 -1
- package/dist/chunk-XA3UEJIW.cjs +0 -25
- package/dist/chunk-XA3UEJIW.cjs.map +0 -1
- package/dist/chunk-YBMUEEM5.js.map +0 -1
- package/dist/chunk-ZKVOS57Q.cjs.map +0 -1
package/dist/comments.cjs
CHANGED
|
@@ -1,64 +1,50 @@
|
|
|
1
|
-
'use client';
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
var
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
var
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
var
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
var _chunkZKVOS57Qcjs = require('./chunk-ZKVOS57Q.cjs');
|
|
39
|
-
require('./chunk-6V6GGBDK.cjs');
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
var _chunk4SLJNZSMcjs = require('./chunk-4SLJNZSM.cjs');
|
|
1
|
+
'use client';
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
var chunkRIIXJWBR_cjs = require('./chunk-RIIXJWBR.cjs');
|
|
5
|
+
var chunkEFRQMYZ6_cjs = require('./chunk-EFRQMYZ6.cjs');
|
|
6
|
+
var chunk7XQGOCUG_cjs = require('./chunk-7XQGOCUG.cjs');
|
|
7
|
+
var chunkIGZRZIAF_cjs = require('./chunk-IGZRZIAF.cjs');
|
|
8
|
+
require('./chunk-A6PGQVTR.cjs');
|
|
9
|
+
var chunkVFSVN5IQ_cjs = require('./chunk-VFSVN5IQ.cjs');
|
|
10
|
+
require('./chunk-7SVKLWDT.cjs');
|
|
11
|
+
var chunkAIS37SL2_cjs = require('./chunk-AIS37SL2.cjs');
|
|
12
|
+
var lucideReact = require('lucide-react');
|
|
13
|
+
var react = require('react');
|
|
14
|
+
var jsxRuntime = require('react/jsx-runtime');
|
|
15
|
+
var DialogPrimitive = require('@radix-ui/react-dialog');
|
|
16
|
+
|
|
17
|
+
function _interopNamespace(e) {
|
|
18
|
+
if (e && e.__esModule) return e;
|
|
19
|
+
var n = Object.create(null);
|
|
20
|
+
if (e) {
|
|
21
|
+
Object.keys(e).forEach(function (k) {
|
|
22
|
+
if (k !== 'default') {
|
|
23
|
+
var d = Object.getOwnPropertyDescriptor(e, k);
|
|
24
|
+
Object.defineProperty(n, k, d.get ? d : {
|
|
25
|
+
enumerable: true,
|
|
26
|
+
get: function () { return e[k]; }
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
n.default = e;
|
|
32
|
+
return Object.freeze(n);
|
|
33
|
+
}
|
|
47
34
|
|
|
48
|
-
|
|
49
|
-
var _lucidereact = require('lucide-react');
|
|
35
|
+
var DialogPrimitive__namespace = /*#__PURE__*/_interopNamespace(DialogPrimitive);
|
|
50
36
|
|
|
51
37
|
// src/extensions/comments/comment-anchors.ts
|
|
52
|
-
var idsOf = (node) =>
|
|
38
|
+
var idsOf = (node) => node?.marks.flatMap((mark) => mark.type === "comment" && mark.attrs?.id ? [mark.attrs.id] : []) ?? [];
|
|
53
39
|
function addRegion(anchors, block, region, inline2) {
|
|
54
40
|
let position = 0;
|
|
55
41
|
for (const node of inline2) {
|
|
56
42
|
const from = position;
|
|
57
|
-
position +=
|
|
43
|
+
position += chunkAIS37SL2_cjs.nodeLength(node);
|
|
58
44
|
for (const id of idsOf(node)) {
|
|
59
|
-
const ranges =
|
|
45
|
+
const ranges = anchors.get(id) ?? [];
|
|
60
46
|
const last = ranges[ranges.length - 1];
|
|
61
|
-
const continues =
|
|
47
|
+
const continues = last?.block === block && last.region === region && last.to === from;
|
|
62
48
|
if (continues) ranges[ranges.length - 1] = { ...last, to: position };
|
|
63
49
|
else ranges.push({ block, region, from, to: position });
|
|
64
50
|
anchors.set(id, ranges);
|
|
@@ -78,28 +64,28 @@ function commentAnchors(doc) {
|
|
|
78
64
|
}
|
|
79
65
|
return anchors;
|
|
80
66
|
}
|
|
81
|
-
var atomLabel = (node) => node.kind === "atom" ?
|
|
67
|
+
var atomLabel = (node) => node.kind === "atom" ? node.attrs.label ?? "" : "";
|
|
82
68
|
function anchorText(doc, ranges) {
|
|
83
69
|
return ranges.map(({ block, region, from, to }) => {
|
|
84
|
-
const inline2 =
|
|
85
|
-
return
|
|
70
|
+
const inline2 = chunkAIS37SL2_cjs.blockById(doc, block)?.regions[region] ?? [];
|
|
71
|
+
return chunkAIS37SL2_cjs.inlineText(chunkAIS37SL2_cjs.sliceInline(inline2, from, to), atomLabel);
|
|
86
72
|
}).join(" ");
|
|
87
73
|
}
|
|
88
74
|
function commentIdsAt(doc, { block, region, offset }) {
|
|
89
|
-
const inline2 =
|
|
75
|
+
const inline2 = chunkAIS37SL2_cjs.blockById(doc, block)?.regions[region] ?? [];
|
|
90
76
|
const ids = /* @__PURE__ */ new Set();
|
|
91
77
|
let position = 0;
|
|
92
78
|
for (const node of inline2) {
|
|
93
|
-
const end = position +
|
|
79
|
+
const end = position + chunkAIS37SL2_cjs.nodeLength(node);
|
|
94
80
|
if (position <= offset && offset <= end && end > position) idsOf(node).forEach((id) => ids.add(id));
|
|
95
81
|
position = end;
|
|
96
82
|
}
|
|
97
83
|
return [...ids].sort();
|
|
98
84
|
}
|
|
99
85
|
function threadRemoval(state, id) {
|
|
100
|
-
const tr = new
|
|
101
|
-
for (const { block, region, from, to } of
|
|
102
|
-
tr.step(
|
|
86
|
+
const tr = new chunkVFSVN5IQ_cjs.Transaction(state).setOrigin("command");
|
|
87
|
+
for (const { block, region, from, to } of commentAnchors(state.doc).get(id) ?? []) {
|
|
88
|
+
tr.step(chunkVFSVN5IQ_cjs.removeMarkStep(block, region, from, to, { type: "comment", attrs: { id } }));
|
|
103
89
|
}
|
|
104
90
|
return tr;
|
|
105
91
|
}
|
|
@@ -110,14 +96,14 @@ function mapPendingRanges(tr, ranges, state) {
|
|
|
110
96
|
const from = tr.mapPos({ block: range.block, region: range.region, offset: range.from }, 1);
|
|
111
97
|
const to = tr.mapPos({ block: range.block, region: range.region, offset: range.to }, -1);
|
|
112
98
|
const { index } = state.doc;
|
|
113
|
-
if (!index.has(from.block) || !index.has(to.block) ||
|
|
114
|
-
return
|
|
99
|
+
if (!index.has(from.block) || !index.has(to.block) || chunkVFSVN5IQ_cjs.comparePos(state.doc, from, to) >= 0) return [];
|
|
100
|
+
return chunkVFSVN5IQ_cjs.markRanges({ ...state, selection: chunkVFSVN5IQ_cjs.textSelection(from, to) });
|
|
115
101
|
});
|
|
116
102
|
}
|
|
117
103
|
|
|
118
104
|
// src/extensions/comments/comments-plugin.ts
|
|
119
|
-
var isEnded = (ended, id, current) => ended.some((thread) => thread.id === id &&
|
|
120
|
-
var commentsKey =
|
|
105
|
+
var isEnded = (ended, id, current) => ended.some((thread) => thread.id === id && thread.seen?.resolved === current?.resolved);
|
|
106
|
+
var commentsKey = chunkVFSVN5IQ_cjs.createPluginKey("comments");
|
|
121
107
|
var COMMENTS = "comments";
|
|
122
108
|
var IDLE = { pending: [], active: null, open: null, ended: [] };
|
|
123
109
|
function act(value, action) {
|
|
@@ -127,7 +113,7 @@ function act(value, action) {
|
|
|
127
113
|
case "settled": {
|
|
128
114
|
const pending = value.pending.filter(({ key }) => key !== action.key);
|
|
129
115
|
if (action.open === void 0) return { ...value, pending };
|
|
130
|
-
return { ...value, pending, active:
|
|
116
|
+
return { ...value, pending, active: action.open.ids[0] ?? null, open: action.open };
|
|
131
117
|
}
|
|
132
118
|
case "activate":
|
|
133
119
|
return value.active === action.id ? value : { ...value, active: action.id };
|
|
@@ -137,7 +123,7 @@ function act(value, action) {
|
|
|
137
123
|
return value.open === null ? value : { ...value, active: null, open: null };
|
|
138
124
|
case "forget": {
|
|
139
125
|
const active = value.active === action.id ? null : value.active;
|
|
140
|
-
const open =
|
|
126
|
+
const open = value.open?.ids.includes(action.id) ? null : value.open;
|
|
141
127
|
const ended = [...value.ended.filter(({ id }) => id !== action.id), { id: action.id, seen: action.seen }];
|
|
142
128
|
return { ...value, active, open, ended };
|
|
143
129
|
}
|
|
@@ -155,7 +141,7 @@ function afterMove(tr, value, state) {
|
|
|
155
141
|
const { open } = value;
|
|
156
142
|
if (open === null || open.focus || !tr.selectionSet || !WRITER_MOVES.includes(tr.origin)) return value;
|
|
157
143
|
const { selection } = state;
|
|
158
|
-
const here =
|
|
144
|
+
const here = selection?.kind === "text" ? commentIdsAt(state.doc, selection.head) : [];
|
|
159
145
|
return open.ids.some((id) => here.includes(id)) ? value : { ...value, active: null, open: null };
|
|
160
146
|
}
|
|
161
147
|
var commentsPlugin = {
|
|
@@ -170,26 +156,26 @@ var commentsPlugin = {
|
|
|
170
156
|
|
|
171
157
|
// src/extensions/comments/comment-create.ts
|
|
172
158
|
var nextKey = 0;
|
|
173
|
-
var hasCommentableText = (state) =>
|
|
159
|
+
var hasCommentableText = (state) => state.selection?.kind === "text" && chunkVFSVN5IQ_cjs.markRanges(state).length > 0;
|
|
174
160
|
var requestComment = (state, dispatch) => {
|
|
175
161
|
const { selection } = state;
|
|
176
|
-
if (
|
|
177
|
-
const ranges =
|
|
162
|
+
if (selection?.kind !== "text" || chunkVFSVN5IQ_cjs.getPluginState(state, commentsKey).pending.length > 0) return false;
|
|
163
|
+
const ranges = chunkVFSVN5IQ_cjs.markRanges(state);
|
|
178
164
|
if (ranges.length === 0) return false;
|
|
179
165
|
if (dispatch === void 0) return true;
|
|
180
166
|
const pending = { key: ++nextKey, ranges, selection };
|
|
181
167
|
const action = { type: "pending", pending };
|
|
182
|
-
dispatch(new
|
|
168
|
+
dispatch(new chunkVFSVN5IQ_cjs.Transaction(state).setMeta(COMMENTS, action).setMeta("addToHistory", false));
|
|
183
169
|
return true;
|
|
184
170
|
};
|
|
185
171
|
function settledTransaction(editor, key, id) {
|
|
186
|
-
const pending =
|
|
172
|
+
const pending = chunkVFSVN5IQ_cjs.getPluginState(editor.state, commentsKey).pending.find((anchor) => anchor.key === key);
|
|
187
173
|
const tr = editor.createTransaction().setOrigin("command");
|
|
188
|
-
const ranges = id === null ? [] :
|
|
174
|
+
const ranges = id === null ? [] : pending?.ranges ?? [];
|
|
189
175
|
for (const { block, region, from, to } of ranges) {
|
|
190
|
-
tr.step(
|
|
176
|
+
tr.step(chunkVFSVN5IQ_cjs.addMarkStep(block, region, from, to, { type: "comment", attrs: { id } }));
|
|
191
177
|
}
|
|
192
|
-
const untouched = pending !== void 0 &&
|
|
178
|
+
const untouched = pending !== void 0 && chunkVFSVN5IQ_cjs.sameSelection(editor.state.selection, pending.selection);
|
|
193
179
|
const open = id !== null && ranges.length > 0 && untouched ? { ids: [id], focus: true } : void 0;
|
|
194
180
|
const action = { type: "settled", key, open };
|
|
195
181
|
return tr.setMeta(COMMENTS, action);
|
|
@@ -200,7 +186,7 @@ function create(editor, pending, onCreate, link) {
|
|
|
200
186
|
if (link.mounts === 0) return;
|
|
201
187
|
const tr = settledTransaction(editor, pending.key, id);
|
|
202
188
|
editor.dispatch(tr);
|
|
203
|
-
if (id === null) link.report(
|
|
189
|
+
if (id === null) link.report(chunk7XQGOCUG_cjs.toError(error));
|
|
204
190
|
else if (!tr.docChanged) link.report(new Error(`Comment thread ${id} has no text: it was deleted meanwhile`));
|
|
205
191
|
};
|
|
206
192
|
new Promise((resolve) => resolve(onCreate(input))).then(
|
|
@@ -210,30 +196,30 @@ function create(editor, pending, onCreate, link) {
|
|
|
210
196
|
}
|
|
211
197
|
function watchCreates(editor, onCreate, link) {
|
|
212
198
|
return editor.subscribe((_, tr) => {
|
|
213
|
-
const action =
|
|
214
|
-
if (
|
|
199
|
+
const action = tr?.getMeta(COMMENTS);
|
|
200
|
+
if (action?.type === "pending") create(editor, action.pending, onCreate, link);
|
|
215
201
|
});
|
|
216
202
|
}
|
|
217
203
|
|
|
218
204
|
// src/extensions/comments/comment-open.ts
|
|
219
205
|
function openIds(state, threads, ids) {
|
|
220
|
-
const { ended } =
|
|
206
|
+
const { ended } = chunkVFSVN5IQ_cjs.getPluginState(state, commentsKey);
|
|
221
207
|
return ids.filter((id) => {
|
|
222
208
|
const thread = threads.find(id);
|
|
223
|
-
return
|
|
209
|
+
return thread?.resolved === false && !isEnded(ended, id, thread);
|
|
224
210
|
});
|
|
225
211
|
}
|
|
226
212
|
function commentsTransaction(state, action) {
|
|
227
|
-
return new
|
|
213
|
+
return new chunkVFSVN5IQ_cjs.Transaction(state).setMeta(COMMENTS, action).setMeta("addToHistory", false);
|
|
228
214
|
}
|
|
229
215
|
function commentCommand(threads) {
|
|
230
216
|
return (state, dispatch) => {
|
|
231
217
|
if (requestComment(state, dispatch)) return true;
|
|
232
218
|
const { selection } = state;
|
|
233
|
-
if (
|
|
219
|
+
if (selection?.kind !== "text" || !chunkVFSVN5IQ_cjs.isCollapsed(selection)) return false;
|
|
234
220
|
const ids = openIds(state, threads, commentIdsAt(state.doc, selection.head));
|
|
235
221
|
if (ids.length === 0) return false;
|
|
236
|
-
|
|
222
|
+
dispatch?.(commentsTransaction(state, { type: "open", open: { ids, focus: true } }));
|
|
237
223
|
return true;
|
|
238
224
|
};
|
|
239
225
|
}
|
|
@@ -261,7 +247,7 @@ var englishCommentsLabels = {
|
|
|
261
247
|
postedAt: englishDate
|
|
262
248
|
};
|
|
263
249
|
function resolveCommentsLabels(overrides) {
|
|
264
|
-
const given = Object.entries(
|
|
250
|
+
const given = Object.entries(overrides ?? {}).filter(([, value]) => value !== void 0);
|
|
265
251
|
return given.length === 0 ? englishCommentsLabels : { ...englishCommentsLabels, ...Object.fromEntries(given) };
|
|
266
252
|
}
|
|
267
253
|
|
|
@@ -276,17 +262,11 @@ function linkOf(editor) {
|
|
|
276
262
|
return link;
|
|
277
263
|
}
|
|
278
264
|
|
|
279
|
-
// src/extensions/comments/CommentsOverlay.tsx
|
|
280
|
-
var _react = require('react');
|
|
281
|
-
|
|
282
|
-
// src/extensions/comments/CommentMarkers.tsx
|
|
283
|
-
|
|
284
|
-
|
|
285
265
|
// src/extensions/comments/rail-layout.ts
|
|
286
266
|
function stackTops(items, gap) {
|
|
287
267
|
let next = 0;
|
|
288
268
|
return items.map(({ top, height }) => {
|
|
289
|
-
const placed = Math.max(
|
|
269
|
+
const placed = Math.max(top ?? next, next);
|
|
290
270
|
next = placed + height + gap;
|
|
291
271
|
return placed;
|
|
292
272
|
});
|
|
@@ -304,7 +284,7 @@ function place(controller, box, gap) {
|
|
|
304
284
|
if (root === null) return;
|
|
305
285
|
const items = Array.from(box.querySelectorAll("[data-rail-item]"));
|
|
306
286
|
const tops = stackTops(
|
|
307
|
-
items.map((item) => ({ top: topOf(controller, root,
|
|
287
|
+
items.map((item) => ({ top: topOf(controller, root, item.dataset.block ?? ""), height: item.offsetHeight })),
|
|
308
288
|
gap
|
|
309
289
|
);
|
|
310
290
|
items.forEach((item, i) => item.style.transform = `translateY(${tops[i]}px)`);
|
|
@@ -312,9 +292,9 @@ function place(controller, box, gap) {
|
|
|
312
292
|
root.style.setProperty(HEIGHT, `${bottom}px`);
|
|
313
293
|
}
|
|
314
294
|
function useBlockAligned(controller, box, gap, key) {
|
|
315
|
-
|
|
295
|
+
chunkIGZRZIAF_cjs.useIsomorphicLayoutEffect(() => {
|
|
316
296
|
const element = box.current;
|
|
317
|
-
const view =
|
|
297
|
+
const view = element?.ownerDocument.defaultView;
|
|
318
298
|
if (!element || !view) return void 0;
|
|
319
299
|
const update = () => place(controller, element, gap);
|
|
320
300
|
update();
|
|
@@ -331,19 +311,16 @@ function useBlockAligned(controller, box, gap, key) {
|
|
|
331
311
|
view.cancelAnimationFrame(frame);
|
|
332
312
|
unsubscribe();
|
|
333
313
|
observer.disconnect();
|
|
334
|
-
|
|
314
|
+
element.parentElement?.style.removeProperty(HEIGHT);
|
|
335
315
|
};
|
|
336
316
|
}, [controller, box, gap, key]);
|
|
337
317
|
}
|
|
338
|
-
|
|
339
|
-
// src/extensions/comments/CommentMarkers.tsx
|
|
340
|
-
var _jsxruntime = require('react/jsx-runtime');
|
|
341
318
|
var GAP = 4;
|
|
342
319
|
function groupsOf(entries) {
|
|
343
320
|
const groups = /* @__PURE__ */ new Map();
|
|
344
321
|
for (const { thread, ranges } of entries) {
|
|
345
|
-
const block =
|
|
346
|
-
groups.set(block, [...
|
|
322
|
+
const block = ranges[0]?.block ?? "";
|
|
323
|
+
groups.set(block, [...groups.get(block) ?? [], thread.id]);
|
|
347
324
|
}
|
|
348
325
|
const removed = groups.get("");
|
|
349
326
|
groups.delete("");
|
|
@@ -352,17 +329,17 @@ function groupsOf(entries) {
|
|
|
352
329
|
function CommentMarkers({ env, box, entries, onOpen }) {
|
|
353
330
|
const groups = groupsOf(entries);
|
|
354
331
|
useBlockAligned(env.controller, box, GAP, groups.map(({ block, ids }) => `${block}:${ids}`).join(" "));
|
|
355
|
-
return /* @__PURE__ */
|
|
332
|
+
return /* @__PURE__ */ jsxRuntime.jsx("div", { ref: box, className: "quoin-comments-markers", children: groups.map(({ block, ids }) => /* @__PURE__ */ jsxRuntime.jsxs(
|
|
356
333
|
"button",
|
|
357
334
|
{
|
|
358
335
|
type: "button",
|
|
359
336
|
"data-rail-item": "",
|
|
360
337
|
"data-block": block,
|
|
361
338
|
"aria-label": env.labels.showComments(ids.length),
|
|
362
|
-
className:
|
|
339
|
+
className: chunk7XQGOCUG_cjs.cn("quoin-comments-marker", chunk7XQGOCUG_cjs.FOCUS_RING),
|
|
363
340
|
onClick: (event) => onOpen(ids[0], event.currentTarget),
|
|
364
341
|
children: [
|
|
365
|
-
/* @__PURE__ */
|
|
342
|
+
/* @__PURE__ */ jsxRuntime.jsx(lucideReact.MessageSquare, { "aria-hidden": "true" }),
|
|
366
343
|
ids.length
|
|
367
344
|
]
|
|
368
345
|
},
|
|
@@ -370,41 +347,31 @@ function CommentMarkers({ env, box, entries, onOpen }) {
|
|
|
370
347
|
)) });
|
|
371
348
|
}
|
|
372
349
|
|
|
373
|
-
// src/extensions/comments/ThreadCard.tsx
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
// src/extensions/comments/ThreadView.tsx
|
|
377
|
-
|
|
378
|
-
|
|
379
350
|
// src/extensions/comments/comment-actions.ts
|
|
380
351
|
async function called(link, call) {
|
|
381
352
|
try {
|
|
382
353
|
await call();
|
|
383
354
|
return true;
|
|
384
355
|
} catch (error) {
|
|
385
|
-
link.report(
|
|
356
|
+
link.report(chunk7XQGOCUG_cjs.toError(error));
|
|
386
357
|
return false;
|
|
387
358
|
}
|
|
388
359
|
}
|
|
389
360
|
async function endThread(editor, link, call, id, threads) {
|
|
390
361
|
if (!await called(link, () => call(id)) || link.mounts === 0) return false;
|
|
391
|
-
const action = { type: "forget", id, seen:
|
|
362
|
+
const action = { type: "forget", id, seen: threads?.find(id) };
|
|
392
363
|
editor.dispatch(threadRemoval(editor.state, id).setMeta(COMMENTS, action));
|
|
393
364
|
return true;
|
|
394
365
|
}
|
|
395
366
|
function sendReply(link, call, id, body) {
|
|
396
367
|
return called(link, () => call(id, body));
|
|
397
368
|
}
|
|
398
|
-
|
|
399
|
-
// src/extensions/comments/CommentAvatar.tsx
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
var initials = (name) => name.trim().split(/\s+/).slice(0, 2).map((word) => _nullishCoalesce(_optionalChain([Array, 'access', _40 => _40.from, 'call', _41 => _41(word), 'access', _42 => _42[0], 'optionalAccess', _43 => _43.toUpperCase, 'call', _44 => _44()]), () => ( ""))).join("");
|
|
369
|
+
var initials = (name) => name.trim().split(/\s+/).slice(0, 2).map((word) => Array.from(word)[0]?.toUpperCase() ?? "").join("");
|
|
403
370
|
function CommentAvatar({ author }) {
|
|
404
|
-
const picture =
|
|
405
|
-
const [failed, setFailed] =
|
|
371
|
+
const picture = chunkRIIXJWBR_cjs.webAddress(author.avatarUrl);
|
|
372
|
+
const [failed, setFailed] = react.useState(null);
|
|
406
373
|
if (picture !== null && picture !== failed) {
|
|
407
|
-
return /* @__PURE__ */
|
|
374
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
408
375
|
"img",
|
|
409
376
|
{
|
|
410
377
|
src: picture,
|
|
@@ -417,35 +384,27 @@ function CommentAvatar({ author }) {
|
|
|
417
384
|
}
|
|
418
385
|
);
|
|
419
386
|
}
|
|
420
|
-
return /* @__PURE__ */
|
|
387
|
+
return /* @__PURE__ */ jsxRuntime.jsx("span", { "aria-hidden": "true", className: "quoin-comments-initials", children: initials(author.name) });
|
|
421
388
|
}
|
|
422
|
-
|
|
423
|
-
// src/extensions/comments/CommentItem.tsx
|
|
424
|
-
|
|
425
389
|
function CommentItem({ comment, labels }) {
|
|
426
|
-
return /* @__PURE__ */
|
|
427
|
-
/* @__PURE__ */
|
|
428
|
-
/* @__PURE__ */
|
|
429
|
-
/* @__PURE__ */
|
|
430
|
-
/* @__PURE__ */
|
|
431
|
-
/* @__PURE__ */
|
|
390
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("li", { className: "flex gap-2", children: [
|
|
391
|
+
/* @__PURE__ */ jsxRuntime.jsx(CommentAvatar, { author: comment.author }),
|
|
392
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "min-w-0 flex-1", children: [
|
|
393
|
+
/* @__PURE__ */ jsxRuntime.jsxs("p", { className: "flex flex-wrap items-baseline gap-x-2 text-sm", children: [
|
|
394
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "font-medium", children: comment.author.name }),
|
|
395
|
+
/* @__PURE__ */ jsxRuntime.jsx("time", { dateTime: comment.createdAt, className: "text-xs text-muted-foreground", children: labels.postedAt(comment.createdAt) })
|
|
432
396
|
] }),
|
|
433
|
-
/* @__PURE__ */
|
|
397
|
+
/* @__PURE__ */ jsxRuntime.jsx("p", { className: "quoin-comments-body text-sm", children: comment.body })
|
|
434
398
|
] })
|
|
435
399
|
] });
|
|
436
400
|
}
|
|
437
|
-
|
|
438
|
-
// src/extensions/comments/ReplyBox.tsx
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
401
|
var REPLY_FIELD = "data-comments-field";
|
|
443
402
|
function ReplyBox({ env, threadId, first }) {
|
|
444
403
|
const { controller, host, labels, link } = env;
|
|
445
|
-
const [body, setBody] =
|
|
446
|
-
const [sending, setSending] =
|
|
447
|
-
const alive =
|
|
448
|
-
|
|
404
|
+
const [body, setBody] = react.useState("");
|
|
405
|
+
const [sending, setSending] = react.useState(false);
|
|
406
|
+
const alive = react.useRef(true);
|
|
407
|
+
react.useEffect(() => {
|
|
449
408
|
alive.current = true;
|
|
450
409
|
return () => {
|
|
451
410
|
alive.current = false;
|
|
@@ -471,9 +430,9 @@ function ReplyBox({ env, threadId, first }) {
|
|
|
471
430
|
event.preventDefault();
|
|
472
431
|
void send();
|
|
473
432
|
};
|
|
474
|
-
return /* @__PURE__ */
|
|
475
|
-
/* @__PURE__ */
|
|
476
|
-
/* @__PURE__ */
|
|
433
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("form", { className: "flex items-start gap-2", onSubmit, children: [
|
|
434
|
+
/* @__PURE__ */ jsxRuntime.jsx(CommentAvatar, { author: host.currentUser }),
|
|
435
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
477
436
|
"textarea",
|
|
478
437
|
{
|
|
479
438
|
...{ [REPLY_FIELD]: "" },
|
|
@@ -486,50 +445,47 @@ function ReplyBox({ env, threadId, first }) {
|
|
|
486
445
|
className: "quoin-comments-field"
|
|
487
446
|
}
|
|
488
447
|
),
|
|
489
|
-
/* @__PURE__ */
|
|
490
|
-
|
|
448
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
449
|
+
chunk7XQGOCUG_cjs.Button,
|
|
491
450
|
{
|
|
492
451
|
type: "submit",
|
|
493
452
|
variant: "ghost",
|
|
494
453
|
size: "icon-sm",
|
|
495
454
|
"aria-label": labels.send,
|
|
496
455
|
"aria-disabled": text === "" || sending || void 0,
|
|
497
|
-
children: /* @__PURE__ */
|
|
456
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.SendHorizontal, {})
|
|
498
457
|
}
|
|
499
458
|
)
|
|
500
459
|
] });
|
|
501
460
|
}
|
|
502
|
-
|
|
503
|
-
// src/extensions/comments/ThreadView.tsx
|
|
504
|
-
|
|
505
461
|
function ThreadView({ env, id, thread, onEnded }) {
|
|
506
462
|
const { controller, host, labels, link } = env;
|
|
507
|
-
const readOnly =
|
|
508
|
-
const [busy, setBusy] =
|
|
509
|
-
const alive =
|
|
510
|
-
const root =
|
|
511
|
-
|
|
463
|
+
const readOnly = chunkIGZRZIAF_cjs.useReadOnly(controller);
|
|
464
|
+
const [busy, setBusy] = react.useState(false);
|
|
465
|
+
const alive = react.useRef(true);
|
|
466
|
+
const root = react.useRef(null);
|
|
467
|
+
react.useEffect(() => {
|
|
512
468
|
alive.current = true;
|
|
513
469
|
return () => {
|
|
514
470
|
alive.current = false;
|
|
515
471
|
};
|
|
516
472
|
}, []);
|
|
517
|
-
const comments =
|
|
473
|
+
const comments = thread?.comments ?? [];
|
|
518
474
|
const end = async (call) => {
|
|
519
475
|
if (busy) return;
|
|
520
476
|
setBusy(true);
|
|
521
477
|
const ended = await endThread(controller.editor, link, call, id, host.threads);
|
|
522
478
|
if (alive.current) setBusy(false);
|
|
523
479
|
const active = document.activeElement;
|
|
524
|
-
const stayed = active === null || active === document.body ||
|
|
480
|
+
const stayed = active === null || active === document.body || root.current?.contains(active) === true;
|
|
525
481
|
if (ended && stayed) onEnded();
|
|
526
482
|
};
|
|
527
|
-
return /* @__PURE__ */
|
|
528
|
-
comments.length > 0 && /* @__PURE__ */
|
|
529
|
-
/* @__PURE__ */
|
|
530
|
-
!readOnly && /* @__PURE__ */
|
|
531
|
-
/* @__PURE__ */
|
|
532
|
-
|
|
483
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("div", { ref: root, className: "flex flex-col gap-3", children: [
|
|
484
|
+
comments.length > 0 && /* @__PURE__ */ jsxRuntime.jsx("ol", { className: "flex flex-col gap-3", children: comments.map((comment) => /* @__PURE__ */ jsxRuntime.jsx(CommentItem, { comment, labels }, comment.id)) }),
|
|
485
|
+
/* @__PURE__ */ jsxRuntime.jsx(ReplyBox, { env, threadId: id, first: comments.length === 0 }),
|
|
486
|
+
!readOnly && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex justify-end gap-1", children: [
|
|
487
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
488
|
+
chunk7XQGOCUG_cjs.Button,
|
|
533
489
|
{
|
|
534
490
|
type: "button",
|
|
535
491
|
variant: "ghost",
|
|
@@ -539,8 +495,8 @@ function ThreadView({ env, id, thread, onEnded }) {
|
|
|
539
495
|
children: labels.resolve
|
|
540
496
|
}
|
|
541
497
|
),
|
|
542
|
-
/* @__PURE__ */
|
|
543
|
-
|
|
498
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
499
|
+
chunk7XQGOCUG_cjs.Button,
|
|
544
500
|
{
|
|
545
501
|
type: "button",
|
|
546
502
|
variant: "ghost",
|
|
@@ -553,17 +509,14 @@ function ThreadView({ env, id, thread, onEnded }) {
|
|
|
553
509
|
] })
|
|
554
510
|
] });
|
|
555
511
|
}
|
|
556
|
-
|
|
557
|
-
// src/extensions/comments/ThreadCard.tsx
|
|
558
|
-
|
|
559
512
|
function ThreadCard({ env, entry, active, expanded, onToggle }) {
|
|
560
513
|
const { labels, controller } = env;
|
|
561
514
|
const { thread, anchorText: anchorText2, ranges } = entry;
|
|
562
|
-
const header =
|
|
515
|
+
const header = react.useRef(null);
|
|
563
516
|
const [first] = thread.comments;
|
|
564
517
|
const removed = ranges.length === 0;
|
|
565
518
|
const backToHeader = () => {
|
|
566
|
-
if (
|
|
519
|
+
if (header.current?.isConnected) header.current.focus();
|
|
567
520
|
else controller.focus();
|
|
568
521
|
};
|
|
569
522
|
const onKeyDown = (event) => {
|
|
@@ -571,39 +524,36 @@ function ThreadCard({ env, entry, active, expanded, onToggle }) {
|
|
|
571
524
|
event.preventDefault();
|
|
572
525
|
event.stopPropagation();
|
|
573
526
|
onToggle(null);
|
|
574
|
-
|
|
527
|
+
header.current?.focus();
|
|
575
528
|
};
|
|
576
|
-
return /* @__PURE__ */
|
|
577
|
-
/* @__PURE__ */
|
|
529
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "quoin-comments-card", "data-active": active || void 0, onKeyDown, children: [
|
|
530
|
+
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
578
531
|
"button",
|
|
579
532
|
{
|
|
580
533
|
ref: header,
|
|
581
534
|
type: "button",
|
|
582
535
|
"aria-expanded": expanded,
|
|
583
|
-
className:
|
|
536
|
+
className: chunk7XQGOCUG_cjs.cn("flex w-full flex-col items-start gap-1 rounded-sm text-start", chunk7XQGOCUG_cjs.FOCUS_RING),
|
|
584
537
|
onClick: () => onToggle(expanded ? null : thread.id),
|
|
585
538
|
children: [
|
|
586
|
-
/* @__PURE__ */
|
|
587
|
-
first !== void 0 && /* @__PURE__ */
|
|
588
|
-
/* @__PURE__ */
|
|
539
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: removed ? "text-xs text-muted-foreground italic" : "quoin-comments-quote", children: removed ? labels.textRemoved : anchorText2 }),
|
|
540
|
+
first !== void 0 && /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "line-clamp-2 text-sm", children: [
|
|
541
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "font-medium", children: first.author.name }),
|
|
589
542
|
" ",
|
|
590
543
|
first.body
|
|
591
544
|
] }),
|
|
592
|
-
/* @__PURE__ */
|
|
545
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-xs text-muted-foreground", children: labels.commentCount(thread.comments.length) })
|
|
593
546
|
]
|
|
594
547
|
}
|
|
595
548
|
),
|
|
596
|
-
expanded && /* @__PURE__ */
|
|
549
|
+
expanded && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "mt-3", role: "group", "aria-label": removed ? labels.textRemoved : labels.thread(anchorText2), children: /* @__PURE__ */ jsxRuntime.jsx(ThreadView, { env, id: thread.id, thread, onEnded: backToHeader }) })
|
|
597
550
|
] });
|
|
598
551
|
}
|
|
599
|
-
|
|
600
|
-
// src/extensions/comments/CommentsRail.tsx
|
|
601
|
-
|
|
602
552
|
var GAP2 = 8;
|
|
603
|
-
var layoutKey = (entries, value) => `${value.active} ${value.open !== null} ${entries.map(({ thread, ranges }) => `${thread.id}:${
|
|
553
|
+
var layoutKey = (entries, value) => `${value.active} ${value.open !== null} ${entries.map(({ thread, ranges }) => `${thread.id}:${ranges[0]?.block}`)}`;
|
|
604
554
|
function CommentsRail({ env, box, entries, value, onToggle }) {
|
|
605
555
|
useBlockAligned(env.controller, box, GAP2, layoutKey(entries, value));
|
|
606
|
-
return /* @__PURE__ */
|
|
556
|
+
return /* @__PURE__ */ jsxRuntime.jsx("div", { ref: box, className: "quoin-comments-rail", children: /* @__PURE__ */ jsxRuntime.jsx("ul", { "aria-label": env.labels.comments, children: entries.map((entry) => /* @__PURE__ */ jsxRuntime.jsx("li", { "data-rail-item": "", "data-block": entry.ranges[0]?.block ?? "", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
607
557
|
ThreadCard,
|
|
608
558
|
{
|
|
609
559
|
env,
|
|
@@ -614,32 +564,26 @@ function CommentsRail({ env, box, entries, value, onToggle }) {
|
|
|
614
564
|
}
|
|
615
565
|
) }, entry.thread.id)) }) });
|
|
616
566
|
}
|
|
617
|
-
|
|
618
|
-
// src/extensions/comments/CommentsSheet.tsx
|
|
619
|
-
var _reactdialog = require('@radix-ui/react-dialog'); var DialogPrimitive = _interopRequireWildcard(_reactdialog);
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
567
|
function CommentsSheet({ env, entries, value, onToggle, onClose, returnFocus }) {
|
|
624
568
|
const { labels } = env;
|
|
625
|
-
const content =
|
|
626
|
-
const outside =
|
|
569
|
+
const content = react.useRef(null);
|
|
570
|
+
const outside = react.useRef(false);
|
|
627
571
|
const focusOpened = (event) => {
|
|
628
|
-
const opened =
|
|
572
|
+
const opened = content.current?.querySelector('[aria-expanded="true"]');
|
|
629
573
|
if (!opened) return;
|
|
630
574
|
event.preventDefault();
|
|
631
575
|
opened.focus();
|
|
632
576
|
};
|
|
633
|
-
return /* @__PURE__ */
|
|
634
|
-
|
|
577
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
578
|
+
DialogPrimitive__namespace.Root,
|
|
635
579
|
{
|
|
636
580
|
open: true,
|
|
637
581
|
modal: false,
|
|
638
582
|
onOpenChange: (open) => {
|
|
639
583
|
if (!open) onClose();
|
|
640
584
|
},
|
|
641
|
-
children: /* @__PURE__ */
|
|
642
|
-
|
|
585
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(DialogPrimitive__namespace.Portal, { children: /* @__PURE__ */ jsxRuntime.jsxs(
|
|
586
|
+
DialogPrimitive__namespace.Content,
|
|
643
587
|
{
|
|
644
588
|
ref: content,
|
|
645
589
|
"aria-describedby": void 0,
|
|
@@ -653,11 +597,11 @@ function CommentsSheet({ env, entries, value, onToggle, onClose, returnFocus })
|
|
|
653
597
|
if (!outside.current) returnFocus();
|
|
654
598
|
},
|
|
655
599
|
children: [
|
|
656
|
-
/* @__PURE__ */
|
|
657
|
-
/* @__PURE__ */
|
|
658
|
-
/* @__PURE__ */
|
|
600
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center justify-between gap-2", children: [
|
|
601
|
+
/* @__PURE__ */ jsxRuntime.jsx(DialogPrimitive__namespace.Title, { className: "text-sm font-semibold", children: labels.comments }),
|
|
602
|
+
/* @__PURE__ */ jsxRuntime.jsx(DialogPrimitive__namespace.Close, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(chunk7XQGOCUG_cjs.Button, { type: "button", variant: "ghost", size: "icon-sm", "aria-label": labels.close, children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.XIcon, {}) }) })
|
|
659
603
|
] }),
|
|
660
|
-
/* @__PURE__ */
|
|
604
|
+
/* @__PURE__ */ jsxRuntime.jsx("ul", { "aria-label": labels.comments, className: "flex flex-col gap-2", children: entries.map((entry) => /* @__PURE__ */ jsxRuntime.jsx("li", { children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
661
605
|
ThreadCard,
|
|
662
606
|
{
|
|
663
607
|
env,
|
|
@@ -679,71 +623,62 @@ var NONE = [];
|
|
|
679
623
|
function railEntries(doc, threads, ended = []) {
|
|
680
624
|
const anchors = commentAnchors(doc);
|
|
681
625
|
const entries = threads.filter((thread) => !thread.resolved && !isEnded(ended, thread.id, thread)).map((thread) => {
|
|
682
|
-
const ranges =
|
|
626
|
+
const ranges = anchors.get(thread.id) ?? NONE;
|
|
683
627
|
return { thread, ranges, anchorText: anchorText(doc, ranges) };
|
|
684
628
|
});
|
|
685
|
-
const place2 = ({ ranges: [first] }) => first === void 0 ? [Infinity, 0] : [
|
|
629
|
+
const place2 = ({ ranges: [first] }) => first === void 0 ? [Infinity, 0] : [chunkAIS37SL2_cjs.indexOfBlock(doc, first.block), first.from];
|
|
686
630
|
return entries.map((entry, order) => ({ entry, order, at: place2(entry) })).sort((a, b) => a.at[0] - b.at[0] || a.at[1] - b.at[1] || a.order - b.order).map(({ entry }) => entry);
|
|
687
631
|
}
|
|
688
|
-
|
|
689
|
-
// src/extensions/comments/ThreadPopover.tsx
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
// src/extensions/comments/ThreadChooser.tsx
|
|
693
|
-
|
|
694
632
|
function ThreadChooser({ env, choices, onChoose }) {
|
|
695
|
-
return /* @__PURE__ */
|
|
633
|
+
return /* @__PURE__ */ jsxRuntime.jsx("ul", { "aria-label": env.labels.threadsHere, className: "flex flex-col gap-1", children: choices.map(({ id, anchorText: anchorText2, preview }) => /* @__PURE__ */ jsxRuntime.jsx("li", { children: /* @__PURE__ */ jsxRuntime.jsxs(
|
|
696
634
|
"button",
|
|
697
635
|
{
|
|
698
636
|
type: "button",
|
|
699
637
|
className: "quoin-comments-choice",
|
|
700
638
|
onClick: () => onChoose(id),
|
|
701
639
|
children: [
|
|
702
|
-
/* @__PURE__ */
|
|
703
|
-
preview && /* @__PURE__ */
|
|
640
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "quoin-comments-quote", children: anchorText2 }),
|
|
641
|
+
preview && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "line-clamp-1 text-sm", children: preview })
|
|
704
642
|
]
|
|
705
643
|
}
|
|
706
644
|
) }, id)) });
|
|
707
645
|
}
|
|
708
|
-
|
|
709
|
-
// src/extensions/comments/ThreadPopover.tsx
|
|
710
|
-
|
|
711
646
|
var docOf = (state) => state.doc;
|
|
712
647
|
function focusIsOurs(controller, content) {
|
|
713
|
-
const active =
|
|
714
|
-
return active === null || active === active.ownerDocument.body ||
|
|
648
|
+
const active = content?.ownerDocument.activeElement ?? null;
|
|
649
|
+
return active === null || active === active.ownerDocument.body || chunkEFRQMYZ6_cjs.ownsNode(controller, active);
|
|
715
650
|
}
|
|
716
651
|
function ThreadPopover({ env, open, threads, onChoose, onClose }) {
|
|
717
652
|
const { controller, labels } = env;
|
|
718
|
-
const doc =
|
|
653
|
+
const doc = chunkIGZRZIAF_cjs.useEditorState(controller, docOf);
|
|
719
654
|
const anchors = commentAnchors(doc);
|
|
720
655
|
const { ids } = open;
|
|
721
|
-
const first = ids.map((id) =>
|
|
722
|
-
const latest =
|
|
723
|
-
|
|
656
|
+
const first = ids.map((id) => anchors.get(id)?.[0]).find(Boolean);
|
|
657
|
+
const latest = react.useRef(first);
|
|
658
|
+
chunkIGZRZIAF_cjs.useIsomorphicLayoutEffect(() => {
|
|
724
659
|
if (first) latest.current = first;
|
|
725
660
|
});
|
|
726
|
-
const anchor =
|
|
661
|
+
const anchor = react.useMemo(
|
|
727
662
|
() => ({
|
|
728
|
-
current:
|
|
729
|
-
() => latest.current ?
|
|
663
|
+
current: chunk7XQGOCUG_cjs.virtualAnchor(
|
|
664
|
+
() => latest.current ? chunk7XQGOCUG_cjs.rangeRect(controller, latest.current) : null,
|
|
730
665
|
() => latest.current && controller.registry.get(latest.current.block, latest.current.region)
|
|
731
666
|
)
|
|
732
667
|
}),
|
|
733
668
|
[controller]
|
|
734
669
|
);
|
|
735
|
-
const content =
|
|
670
|
+
const content = react.useRef(null);
|
|
736
671
|
const focusField = () => {
|
|
737
|
-
const target =
|
|
738
|
-
if (focusIsOurs(controller, content.current) && !
|
|
739
|
-
|
|
672
|
+
const target = content.current?.querySelector(`[${REPLY_FIELD}], button`);
|
|
673
|
+
if (focusIsOurs(controller, content.current) && !content.current?.contains(content.current.ownerDocument.activeElement)) {
|
|
674
|
+
target?.focus();
|
|
740
675
|
}
|
|
741
676
|
};
|
|
742
|
-
|
|
677
|
+
chunkIGZRZIAF_cjs.useIsomorphicLayoutEffect(() => {
|
|
743
678
|
if (open.focus) focusField();
|
|
744
679
|
}, [open]);
|
|
745
680
|
if (first === void 0 && latest.current === void 0) return null;
|
|
746
|
-
const textOf = (id) => anchorText(doc,
|
|
681
|
+
const textOf = (id) => anchorText(doc, anchors.get(id) ?? []) || labels.textRemoved;
|
|
747
682
|
const single = ids.length === 1;
|
|
748
683
|
const gone = single && !anchors.has(ids[0]);
|
|
749
684
|
const backToText = () => controller.focus();
|
|
@@ -754,13 +689,13 @@ function ThreadPopover({ env, open, threads, onChoose, onClose }) {
|
|
|
754
689
|
const onEscape = (event) => {
|
|
755
690
|
event.preventDefault();
|
|
756
691
|
event.stopPropagation();
|
|
757
|
-
const inside =
|
|
692
|
+
const inside = content.current?.contains(content.current.ownerDocument.activeElement) ?? false;
|
|
758
693
|
onClose();
|
|
759
694
|
if (inside) backToText();
|
|
760
695
|
};
|
|
761
|
-
const choices = ids.map((id) => ({ id, anchorText: textOf(id), preview:
|
|
762
|
-
return /* @__PURE__ */
|
|
763
|
-
|
|
696
|
+
const choices = ids.map((id) => ({ id, anchorText: textOf(id), preview: threads.find(id)?.comments[0]?.body ?? "" }));
|
|
697
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
698
|
+
chunk7XQGOCUG_cjs.Popover,
|
|
764
699
|
{
|
|
765
700
|
open: true,
|
|
766
701
|
modal: false,
|
|
@@ -768,9 +703,9 @@ function ThreadPopover({ env, open, threads, onChoose, onClose }) {
|
|
|
768
703
|
if (!next) onClose();
|
|
769
704
|
},
|
|
770
705
|
children: [
|
|
771
|
-
/* @__PURE__ */
|
|
772
|
-
/* @__PURE__ */
|
|
773
|
-
|
|
706
|
+
/* @__PURE__ */ jsxRuntime.jsx(chunk7XQGOCUG_cjs.PopoverAnchor, { virtualRef: anchor }),
|
|
707
|
+
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
708
|
+
chunk7XQGOCUG_cjs.PopoverContent,
|
|
774
709
|
{
|
|
775
710
|
ref: content,
|
|
776
711
|
"aria-label": gone ? labels.textRemoved : single ? labels.thread(textOf(ids[0])) : labels.threadsHere,
|
|
@@ -781,8 +716,8 @@ function ThreadPopover({ env, open, threads, onChoose, onClose }) {
|
|
|
781
716
|
onCloseAutoFocus: (event) => event.preventDefault(),
|
|
782
717
|
onEscapeKeyDown: onEscape,
|
|
783
718
|
children: [
|
|
784
|
-
gone && /* @__PURE__ */
|
|
785
|
-
single ? /* @__PURE__ */
|
|
719
|
+
gone && /* @__PURE__ */ jsxRuntime.jsx("p", { className: "mb-2 text-xs text-muted-foreground italic", children: labels.textRemoved }),
|
|
720
|
+
single ? /* @__PURE__ */ jsxRuntime.jsx(ThreadView, { env, id: ids[0], thread: threads.find(ids[0]), onEnded: backToText }) : /* @__PURE__ */ jsxRuntime.jsx(ThreadChooser, { env, choices, onChoose })
|
|
786
721
|
]
|
|
787
722
|
},
|
|
788
723
|
ids.join(" ")
|
|
@@ -791,24 +726,21 @@ function ThreadPopover({ env, open, threads, onChoose, onClose }) {
|
|
|
791
726
|
}
|
|
792
727
|
);
|
|
793
728
|
}
|
|
794
|
-
|
|
795
|
-
// src/extensions/comments/use-anchor-clicks.ts
|
|
796
|
-
|
|
797
729
|
function idsUnder(root, target) {
|
|
798
730
|
const ids = [];
|
|
799
731
|
let element = target instanceof Element ? target.closest("[data-comment]") : null;
|
|
800
732
|
while (element !== null && root.contains(element)) {
|
|
801
733
|
const id = element.getAttribute("data-comment");
|
|
802
734
|
if (id) ids.push(id);
|
|
803
|
-
element =
|
|
735
|
+
element = element.parentElement?.closest("[data-comment]") ?? null;
|
|
804
736
|
}
|
|
805
737
|
return ids;
|
|
806
738
|
}
|
|
807
739
|
function useAnchorClicks(controller, threads) {
|
|
808
|
-
|
|
740
|
+
react.useEffect(() => {
|
|
809
741
|
const onClick = (event) => {
|
|
810
742
|
const root = controller.root;
|
|
811
|
-
if (root === null || event.defaultPrevented || !
|
|
743
|
+
if (root === null || event.defaultPrevented || !root.ownerDocument.getSelection()?.isCollapsed) return;
|
|
812
744
|
const { editor } = controller;
|
|
813
745
|
const ids = openIds(editor.state, threads, idsUnder(root, event.target));
|
|
814
746
|
if (ids.length === 0) return;
|
|
@@ -818,14 +750,11 @@ function useAnchorClicks(controller, threads) {
|
|
|
818
750
|
return () => document.removeEventListener("click", onClick);
|
|
819
751
|
}, [controller, threads]);
|
|
820
752
|
}
|
|
821
|
-
|
|
822
|
-
// src/extensions/comments/use-canvas-wide.ts
|
|
823
|
-
|
|
824
753
|
var WIDE_CANVAS = 800;
|
|
825
754
|
function useCanvasWide(box, initial) {
|
|
826
|
-
const [wide, setWide] =
|
|
827
|
-
|
|
828
|
-
const canvas =
|
|
755
|
+
const [wide, setWide] = react.useState(initial);
|
|
756
|
+
chunkIGZRZIAF_cjs.useIsomorphicLayoutEffect(() => {
|
|
757
|
+
const canvas = box.current?.parentElement;
|
|
829
758
|
if (!canvas) return void 0;
|
|
830
759
|
const measure = () => setWide(canvas.offsetWidth >= WIDE_CANVAS);
|
|
831
760
|
measure();
|
|
@@ -835,57 +764,51 @@ function useCanvasWide(box, initial) {
|
|
|
835
764
|
}, [box]);
|
|
836
765
|
return wide;
|
|
837
766
|
}
|
|
838
|
-
|
|
839
|
-
// src/extensions/comments/use-threads.ts
|
|
840
|
-
|
|
841
767
|
function useThreads(threads) {
|
|
842
|
-
return
|
|
768
|
+
return react.useSyncExternalStore(threads.subscribe, threads.get, threads.get);
|
|
843
769
|
}
|
|
844
|
-
|
|
845
|
-
// src/extensions/comments/CommentsOverlay.tsx
|
|
846
|
-
|
|
847
|
-
var commentsOf = (state) => _chunkZKVOS57Qcjs.getPluginState.call(void 0, state, commentsKey);
|
|
770
|
+
var commentsOf = (state) => chunkVFSVN5IQ_cjs.getPluginState(state, commentsKey);
|
|
848
771
|
var docOf2 = (state) => state.doc;
|
|
849
772
|
function CommentsOverlay({ controller, host, labels }) {
|
|
850
|
-
const { onError } =
|
|
773
|
+
const { onError } = chunk7XQGOCUG_cjs.useQuoin();
|
|
851
774
|
const link = linkOf(controller.editor);
|
|
852
|
-
|
|
775
|
+
chunkIGZRZIAF_cjs.useIsomorphicLayoutEffect(() => {
|
|
853
776
|
link.report = onError;
|
|
854
777
|
}, [link, onError]);
|
|
855
778
|
useAnchorClicks(controller, host.threads);
|
|
856
779
|
const threads = useThreads(host.threads);
|
|
857
|
-
const value =
|
|
858
|
-
const doc =
|
|
859
|
-
const entries =
|
|
860
|
-
const box =
|
|
780
|
+
const value = chunkIGZRZIAF_cjs.useEditorState(controller, commentsOf);
|
|
781
|
+
const doc = chunkIGZRZIAF_cjs.useEditorState(controller, docOf2);
|
|
782
|
+
const entries = react.useMemo(() => railEntries(doc, threads, value.ended), [doc, threads, value.ended]);
|
|
783
|
+
const box = react.useRef(null);
|
|
861
784
|
const wide = useCanvasWide(box, host.initialLayout === "wide");
|
|
862
|
-
const [sheet, setSheet] =
|
|
863
|
-
const opener =
|
|
864
|
-
|
|
785
|
+
const [sheet, setSheet] = react.useState(false);
|
|
786
|
+
const opener = react.useRef(null);
|
|
787
|
+
react.useEffect(() => {
|
|
865
788
|
if (wide) setSheet(false);
|
|
866
789
|
}, [wide]);
|
|
867
|
-
const env =
|
|
868
|
-
const act2 =
|
|
790
|
+
const env = react.useMemo(() => ({ controller, host, labels, link }), [controller, host, labels, link]);
|
|
791
|
+
const act2 = react.useCallback(
|
|
869
792
|
(action) => controller.editor.dispatch(commentsTransaction(controller.editor.state, action)),
|
|
870
793
|
[controller]
|
|
871
794
|
);
|
|
872
|
-
const toggle =
|
|
795
|
+
const toggle = react.useCallback((id) => act2({ type: "activate", id }), [act2]);
|
|
873
796
|
const openSheet = (id, marker) => {
|
|
874
797
|
opener.current = marker;
|
|
875
798
|
toggle(id);
|
|
876
799
|
setSheet(true);
|
|
877
800
|
};
|
|
878
801
|
const returnFocus = () => {
|
|
879
|
-
if (
|
|
802
|
+
if (opener.current?.isConnected) opener.current.focus();
|
|
880
803
|
else controller.focus();
|
|
881
804
|
};
|
|
882
805
|
const closeSheet = () => {
|
|
883
806
|
setSheet(false);
|
|
884
807
|
toggle(null);
|
|
885
808
|
};
|
|
886
|
-
return /* @__PURE__ */
|
|
887
|
-
wide ? /* @__PURE__ */
|
|
888
|
-
!wide && sheet && /* @__PURE__ */
|
|
809
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
810
|
+
wide ? /* @__PURE__ */ jsxRuntime.jsx(CommentsRail, { env, box, entries, value, onToggle: toggle }) : /* @__PURE__ */ jsxRuntime.jsx(CommentMarkers, { env, box, entries, onOpen: openSheet }),
|
|
811
|
+
!wide && sheet && /* @__PURE__ */ jsxRuntime.jsx(
|
|
889
812
|
CommentsSheet,
|
|
890
813
|
{
|
|
891
814
|
env,
|
|
@@ -896,7 +819,7 @@ function CommentsOverlay({ controller, host, labels }) {
|
|
|
896
819
|
returnFocus
|
|
897
820
|
}
|
|
898
821
|
),
|
|
899
|
-
value.open && /* @__PURE__ */
|
|
822
|
+
value.open && /* @__PURE__ */ jsxRuntime.jsx(
|
|
900
823
|
ThreadPopover,
|
|
901
824
|
{
|
|
902
825
|
env,
|
|
@@ -915,10 +838,10 @@ var ACTIVE = { class: "quoin-comment-active" };
|
|
|
915
838
|
var inline = (ranges, attrs) => ranges.map((range) => ({ kind: "inline", ...range, attrs }));
|
|
916
839
|
var drawn = /* @__PURE__ */ new WeakMap();
|
|
917
840
|
function commentsDecorations(state) {
|
|
918
|
-
const value =
|
|
841
|
+
const value = chunkVFSVN5IQ_cjs.getPluginState(state, commentsKey);
|
|
919
842
|
const last = drawn.get(value);
|
|
920
|
-
if (
|
|
921
|
-
const active = value.active === null ? [] :
|
|
843
|
+
if (last?.doc === state.doc) return last.decorations;
|
|
844
|
+
const active = value.active === null ? [] : commentAnchors(state.doc).get(value.active) ?? [];
|
|
922
845
|
const decorations = [...value.pending.flatMap(({ ranges }) => inline(ranges, PENDING)), ...inline(active, ACTIVE)];
|
|
923
846
|
drawn.set(value, { doc: state.doc, decorations });
|
|
924
847
|
return decorations;
|
|
@@ -927,20 +850,17 @@ function commentsDecorations(state) {
|
|
|
927
850
|
// src/extensions/comments/watch-ended.ts
|
|
928
851
|
function watchEnded(editor, threads) {
|
|
929
852
|
return threads.subscribe(() => {
|
|
930
|
-
const { ended } =
|
|
853
|
+
const { ended } = chunkVFSVN5IQ_cjs.getPluginState(editor.state, commentsKey);
|
|
931
854
|
const kept = ended.filter(({ id }) => isEnded(ended, id, threads.find(id)));
|
|
932
855
|
if (kept.length < ended.length) editor.dispatch(commentsTransaction(editor.state, { type: "caught", kept }));
|
|
933
856
|
});
|
|
934
857
|
}
|
|
935
|
-
|
|
936
|
-
// src/extensions/comments/comments-extension.tsx
|
|
937
|
-
|
|
938
858
|
var commentItem = (labels) => ({
|
|
939
859
|
id: "comment",
|
|
940
860
|
title: labels.comment,
|
|
941
|
-
icon:
|
|
861
|
+
icon: lucideReact.MessageSquarePlus,
|
|
942
862
|
shortcut: "Mod-Alt-m",
|
|
943
|
-
available: (state) => hasCommentableText(state) &&
|
|
863
|
+
available: (state) => hasCommentableText(state) && chunkVFSVN5IQ_cjs.getPluginState(state, commentsKey).pending.length === 0,
|
|
944
864
|
// Focus goes back to the text first: the button leaves the toolbar while the thread is being asked for.
|
|
945
865
|
run: (controller) => {
|
|
946
866
|
controller.focus();
|
|
@@ -951,10 +871,10 @@ function commentsExtension(options) {
|
|
|
951
871
|
const { labels: overrides, ...host } = options;
|
|
952
872
|
const labels = resolveCommentsLabels(overrides);
|
|
953
873
|
function Overlay({ controller }) {
|
|
954
|
-
return /* @__PURE__ */
|
|
874
|
+
return /* @__PURE__ */ jsxRuntime.jsx(CommentsOverlay, { controller, host, labels });
|
|
955
875
|
}
|
|
956
876
|
const ui = { bubbleItems: [commentItem(labels)], overlays: [Overlay] };
|
|
957
|
-
return
|
|
877
|
+
return chunkVFSVN5IQ_cjs.defineExtension({
|
|
958
878
|
name: "comments",
|
|
959
879
|
plugins: [commentsPlugin],
|
|
960
880
|
decorations: commentsDecorations,
|
|
@@ -968,7 +888,7 @@ function commentsExtension(options) {
|
|
|
968
888
|
}
|
|
969
889
|
return () => {
|
|
970
890
|
if (--link.mounts > 0) return;
|
|
971
|
-
|
|
891
|
+
link.stopWatching?.();
|
|
972
892
|
link.stopWatching = null;
|
|
973
893
|
};
|
|
974
894
|
},
|
|
@@ -1001,8 +921,8 @@ function createCommentThreads(initial = NO_THREADS) {
|
|
|
1001
921
|
};
|
|
1002
922
|
}
|
|
1003
923
|
|
|
1004
|
-
|
|
1005
|
-
|
|
1006
|
-
|
|
1007
|
-
|
|
924
|
+
exports.commentsExtension = commentsExtension;
|
|
925
|
+
exports.createCommentThreads = createCommentThreads;
|
|
926
|
+
exports.englishCommentsLabels = englishCommentsLabels;
|
|
927
|
+
//# sourceMappingURL=comments.cjs.map
|
|
1008
928
|
//# sourceMappingURL=comments.cjs.map
|