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