quoin-editor 1.6.0 → 1.8.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 +16 -0
- package/README.md +27 -11
- package/dist/ai-labels-BXX32H9a.d.cts +53 -0
- package/dist/ai-labels-BXX32H9a.d.ts +53 -0
- package/dist/ai.cjs +84 -86
- package/dist/ai.d.cts +4 -53
- package/dist/ai.d.ts +4 -53
- package/dist/ai.js +8 -10
- package/dist/ai.js.map +1 -1
- package/dist/catalogue.cjs +27 -24
- package/dist/catalogue.d.cts +12 -1
- package/dist/catalogue.d.ts +12 -1
- package/dist/catalogue.js +19 -16
- package/dist/catalogue.js.map +1 -1
- package/dist/{chunk-QR2NIDUK.cjs → chunk-4MCYQHFL.cjs} +2 -2
- package/dist/{chunk-XFR7QGSN.cjs → chunk-53CNYRVQ.cjs} +92 -94
- package/dist/{chunk-T7O3BROK.cjs → chunk-53FJFYBR.cjs} +115 -117
- package/dist/{chunk-KFYJW7W5.js → chunk-5OZX2LV4.js} +10 -12
- package/dist/chunk-5OZX2LV4.js.map +1 -0
- package/dist/{chunk-OS2O6IKX.js → chunk-5RBMZGKV.js} +4 -4
- package/dist/{chunk-OS2O6IKX.js.map → chunk-5RBMZGKV.js.map} +1 -1
- package/dist/{chunk-4T4TJ2QS.cjs → chunk-7E43TURF.cjs} +7 -7
- package/dist/{chunk-L6RB43YM.cjs → chunk-7X3T7VXV.cjs} +32 -34
- package/dist/{chunk-BJTOLCRR.js → chunk-7Y4B7NHO.js} +2 -2
- package/dist/chunk-7Y4B7NHO.js.map +1 -0
- package/dist/{chunk-LOP66FVU.cjs → chunk-B3OBM6I4.cjs} +25 -27
- package/dist/{chunk-UUSZGUXJ.cjs → chunk-BA5WXBGE.cjs} +291 -293
- package/dist/{chunk-CSKKSXCE.js → chunk-CSPCDVCT.js} +3 -3
- package/dist/{chunk-CSKKSXCE.js.map → chunk-CSPCDVCT.js.map} +1 -1
- package/dist/{chunk-R7MYG522.js → chunk-D4L5FINK.js} +3 -3
- package/dist/{chunk-R7MYG522.js.map → chunk-D4L5FINK.js.map} +1 -1
- package/dist/{chunk-GHNQKJMD.js → chunk-DBOZFNWU.js} +3 -3
- package/dist/{chunk-GHNQKJMD.js.map → chunk-DBOZFNWU.js.map} +1 -1
- package/dist/{chunk-BM2GRZNM.cjs → chunk-DJU25PFC.cjs} +11 -11
- package/dist/chunk-DLQCTGC3.js +10 -0
- package/dist/chunk-DLQCTGC3.js.map +1 -0
- package/dist/{chunk-B5OMWOVI.js → chunk-DXUDBPG5.js} +9 -11
- package/dist/chunk-DXUDBPG5.js.map +1 -0
- package/dist/{chunk-TKCPXUPP.cjs → chunk-EZWJRBQT.cjs} +51 -53
- package/dist/{chunk-N2SCDXTI.js → chunk-EZX37R5D.js} +8 -10
- package/dist/chunk-EZX37R5D.js.map +1 -0
- package/dist/{chunk-VZZPCYA3.cjs → chunk-FK7EBZPX.cjs} +226 -226
- package/dist/{chunk-BXSWZEA5.js → chunk-GPTJYWGS.js} +3 -3
- package/dist/{chunk-BXSWZEA5.js.map → chunk-GPTJYWGS.js.map} +1 -1
- package/dist/{chunk-H3C3MJW5.cjs → chunk-LM3DHROX.cjs} +2 -2
- package/dist/{chunk-AD3NY7NA.js → chunk-LSI4RMTY.js} +3 -3
- package/dist/{chunk-AD3NY7NA.js.map → chunk-LSI4RMTY.js.map} +1 -1
- package/dist/chunk-MMS4D4MK.cjs +87 -0
- package/dist/{chunk-HT7OF52E.js → chunk-MRHDPXQ7.js} +8 -10
- package/dist/chunk-MRHDPXQ7.js.map +1 -0
- package/dist/{chunk-XFEDJEJF.js → chunk-MSWA5ZZM.js} +4 -4
- package/dist/{chunk-XFEDJEJF.js.map → chunk-MSWA5ZZM.js.map} +1 -1
- package/dist/chunk-NCDMQCZR.js +85 -0
- package/dist/chunk-NCDMQCZR.js.map +1 -0
- package/dist/{chunk-QJ34MOFV.cjs → chunk-P6HC7RUN.cjs} +120 -120
- package/dist/{chunk-O7XZFXPE.js → chunk-PHQMHXNG.js} +9 -11
- package/dist/chunk-PHQMHXNG.js.map +1 -0
- package/dist/{chunk-WN7BZDNH.cjs → chunk-PURYVDC3.cjs} +13 -13
- package/dist/{chunk-46JH34SR.cjs → chunk-PVFSJXYQ.cjs} +28 -30
- package/dist/{chunk-QOIVLYMW.js → chunk-SP4F5F6V.js} +5 -5
- package/dist/{chunk-QOIVLYMW.js.map → chunk-SP4F5F6V.js.map} +1 -1
- package/dist/{chunk-JVSYEENH.cjs → chunk-TQHFGSTT.cjs} +57 -59
- package/dist/{chunk-G25FMFEZ.js → chunk-UDBLZILE.js} +4 -4
- package/dist/{chunk-G25FMFEZ.js.map → chunk-UDBLZILE.js.map} +1 -1
- package/dist/{chunk-2AVGGPLT.js → chunk-VM567D6O.js} +8 -10
- package/dist/chunk-VM567D6O.js.map +1 -0
- package/dist/{chunk-KF3KKN4N.js → chunk-VWYPO6SX.js} +8 -10
- package/dist/chunk-VWYPO6SX.js.map +1 -0
- package/dist/{chunk-IJKGF6SC.js → chunk-WOGCD7JN.js} +8 -10
- package/dist/chunk-WOGCD7JN.js.map +1 -0
- package/dist/{chunk-AZF7B2AE.cjs → chunk-XKYNINUX.cjs} +11 -11
- package/dist/{chunk-32OZ2WM2.js → chunk-Y4EJ6UBV.js} +8 -11
- package/dist/chunk-Y4EJ6UBV.js.map +1 -0
- package/dist/{chunk-XZ4NC3Q7.cjs → chunk-YEDPBYO5.cjs} +4 -4
- package/dist/{chunk-STKGRXSA.cjs → chunk-YVPZDTVZ.cjs} +15 -17
- package/dist/chunk-ZWTIRGY5.cjs +10 -0
- package/dist/comments-labels-DWqsSz8G.d.cts +30 -0
- package/dist/comments-labels-DWqsSz8G.d.ts +30 -0
- package/dist/comments.cjs +63 -65
- package/dist/comments.d.cts +4 -30
- package/dist/comments.d.ts +4 -30
- package/dist/comments.js +9 -11
- package/dist/comments.js.map +1 -1
- package/dist/diagram-extension-22x_njXB.d.ts +30 -0
- package/dist/diagram-extension-C_FSkoj9.d.cts +30 -0
- package/dist/diagram-labels-Bi_jEZ8_.d.cts +11 -0
- package/dist/diagram-labels-Bi_jEZ8_.d.ts +11 -0
- package/dist/diagram.cjs +26 -0
- package/dist/diagram.d.cts +9 -0
- package/dist/diagram.d.ts +9 -0
- package/dist/diagram.js +11 -0
- package/dist/diagram.js.map +1 -0
- package/dist/diff-labels-DWwg7N0n.d.cts +27 -0
- package/dist/diff-labels-DWwg7N0n.d.ts +27 -0
- package/dist/diff.cjs +27 -29
- package/dist/diff.d.cts +4 -27
- package/dist/diff.d.ts +4 -27
- package/dist/diff.js +5 -7
- package/dist/diff.js.map +1 -1
- package/dist/docx.cjs +30 -30
- package/dist/docx.js +3 -3
- package/dist/embed-labels-BiVa9HYl.d.cts +23 -0
- package/dist/embed-labels-BiVa9HYl.d.ts +23 -0
- package/dist/embed.cjs +10 -9
- package/dist/embed.d.cts +4 -23
- package/dist/embed.d.ts +4 -23
- package/dist/embed.js +8 -7
- package/dist/emoji-extension-C832oGeT.d.ts +16 -0
- package/dist/emoji-extension-Dk5IQLZf.d.cts +16 -0
- package/dist/{emoji-extension-gRKnbW8G.d.ts → emoji-labels-YwOms7ZJ.d.cts} +2 -15
- package/dist/{emoji-extension-C3o_Y5uC.d.cts → emoji-labels-YwOms7ZJ.d.ts} +2 -15
- package/dist/emoji.cjs +10 -9
- package/dist/emoji.d.cts +4 -3
- package/dist/emoji.d.ts +4 -3
- package/dist/emoji.js +7 -6
- package/dist/engine.cjs +58 -58
- package/dist/engine.d.cts +8 -7
- package/dist/engine.d.ts +8 -7
- package/dist/engine.js +3 -3
- package/dist/find-extension-BfruAPLi.d.cts +15 -0
- package/dist/find-extension-DmK9_N81.d.ts +15 -0
- package/dist/{find-extension-B_Ctrs6T.d.ts → find-labels-C4vs8Qe9.d.cts} +2 -14
- package/dist/{find-extension-BGGsJMu4.d.cts → find-labels-C4vs8Qe9.d.ts} +2 -14
- package/dist/find.cjs +11 -10
- package/dist/find.d.cts +2 -1
- package/dist/find.d.ts +2 -1
- package/dist/find.js +7 -6
- package/dist/headless.cjs +74 -74
- package/dist/headless.d.cts +38 -8
- package/dist/headless.d.ts +38 -8
- package/dist/headless.js +4 -4
- package/dist/highlight.cjs +7 -6
- package/dist/highlight.js +6 -5
- package/dist/highlight.js.map +1 -1
- package/dist/{index-CsG7OQoq.d.cts → index-3fYvwqUZ.d.cts} +1 -1
- package/dist/{index-h1llgZM-.d.ts → index-CgxnzCO5.d.ts} +1 -1
- package/dist/index.cjs +87 -86
- package/dist/index.d.cts +18 -185
- package/dist/index.d.ts +18 -185
- package/dist/index.js +6 -5
- package/dist/labels-BhRJYo46.d.ts +176 -0
- package/dist/labels-CiCxj2jP.d.cts +176 -0
- package/dist/locale-ar.cjs +565 -0
- package/dist/locale-ar.d.cts +63 -0
- package/dist/locale-ar.d.ts +63 -0
- package/dist/locale-ar.js +551 -0
- package/dist/locale-ar.js.map +1 -0
- package/dist/locale-de.cjs +510 -0
- package/dist/locale-de.d.cts +63 -0
- package/dist/locale-de.d.ts +63 -0
- package/dist/locale-de.js +496 -0
- package/dist/locale-de.js.map +1 -0
- package/dist/locale-es.cjs +510 -0
- package/dist/locale-es.d.cts +63 -0
- package/dist/locale-es.d.ts +63 -0
- package/dist/locale-es.js +496 -0
- package/dist/locale-es.js.map +1 -0
- package/dist/locale-fr.cjs +510 -0
- package/dist/locale-fr.d.cts +63 -0
- package/dist/locale-fr.d.ts +63 -0
- package/dist/locale-fr.js +496 -0
- package/dist/locale-fr.js.map +1 -0
- package/dist/locale-ja.cjs +505 -0
- package/dist/locale-ja.d.cts +63 -0
- package/dist/locale-ja.d.ts +63 -0
- package/dist/locale-ja.js +491 -0
- package/dist/locale-ja.js.map +1 -0
- package/dist/locale-pt.cjs +511 -0
- package/dist/locale-pt.d.cts +63 -0
- package/dist/locale-pt.d.ts +63 -0
- package/dist/locale-pt.js +497 -0
- package/dist/locale-pt.js.map +1 -0
- package/dist/locale-zh.cjs +505 -0
- package/dist/locale-zh.d.cts +63 -0
- package/dist/locale-zh.d.ts +63 -0
- package/dist/locale-zh.js +491 -0
- package/dist/locale-zh.js.map +1 -0
- package/dist/math-labels-DOf5KFxp.d.cts +24 -0
- package/dist/math-labels-DOf5KFxp.d.ts +24 -0
- package/dist/math.cjs +11 -10
- package/dist/math.d.cts +4 -24
- package/dist/math.d.ts +4 -24
- package/dist/math.js +9 -8
- package/dist/mention-labels-DIQy8LRT.d.cts +15 -0
- package/dist/mention-labels-DIQy8LRT.d.ts +15 -0
- package/dist/mention.cjs +11 -10
- package/dist/mention.d.cts +4 -15
- package/dist/mention.d.ts +4 -15
- package/dist/mention.js +9 -8
- package/dist/{view-controller-p-2x3J7Y.d.ts → node-reveal-BnFcnHhz.d.ts} +14 -14
- package/dist/{view-controller-BfVSNZYZ.d.cts → node-reveal-DY6bimv3.d.cts} +14 -14
- package/dist/palette-BrX-hEd-.d.cts +4 -0
- package/dist/palette-BrX-hEd-.d.ts +4 -0
- package/dist/presence-labels-DXVJLifl.d.cts +15 -0
- package/dist/presence-labels-DXVJLifl.d.ts +15 -0
- package/dist/presence.cjs +40 -42
- package/dist/presence.d.cts +4 -15
- package/dist/presence.d.ts +4 -15
- package/dist/presence.js +9 -11
- package/dist/presence.js.map +1 -1
- package/dist/source-labels-CeQDXsYZ.d.cts +9 -0
- package/dist/source-labels-CeQDXsYZ.d.ts +9 -0
- package/dist/source.cjs +11 -14
- package/dist/source.d.cts +5 -10
- package/dist/source.d.ts +5 -10
- package/dist/source.js +7 -10
- package/dist/source.js.map +1 -1
- package/dist/{stats-extension-oD6D1cYy.d.ts → stats-extension-D5HySF0a.d.cts} +4 -16
- package/dist/{stats-extension-XqOTvRaq.d.cts → stats-extension-Dmw0Ujxe.d.ts} +4 -16
- package/dist/stats-labels-W8gep51s.d.cts +15 -0
- package/dist/stats-labels-W8gep51s.d.ts +15 -0
- package/dist/stats.cjs +11 -10
- package/dist/stats.d.cts +3 -2
- package/dist/stats.d.ts +3 -2
- package/dist/stats.js +8 -7
- package/dist/styles.css +1 -1
- package/dist/table-extension-7LkLNK6Q.d.cts +15 -0
- package/dist/table-extension-DEpV0DnP.d.ts +15 -0
- package/dist/{table-extension-v6VB59bF.d.ts → table-labels-Dc-MzU3j.d.cts} +2 -14
- package/dist/{table-extension-BP47hHoz.d.cts → table-labels-Dc-MzU3j.d.ts} +2 -14
- package/dist/table.cjs +26 -25
- package/dist/table.d.cts +2 -1
- package/dist/table.d.ts +2 -1
- package/dist/table.js +7 -6
- package/dist/{to-html-1oD-CDle.d.cts → to-html-C19PbIzh.d.cts} +1 -0
- package/dist/{to-html-CLRBCX0I.d.ts → to-html-CogwrQer.d.ts} +1 -0
- package/dist/{to-markdown-CFPMbbiX.d.cts → to-markdown-C2w7Dzg8.d.cts} +1 -0
- package/dist/{to-markdown-BVOzhgVM.d.ts → to-markdown-DC1EUye5.d.ts} +1 -0
- package/dist/toc-extension-Dvh37bWQ.d.cts +15 -0
- package/dist/toc-extension-SVckrFmb.d.ts +15 -0
- package/dist/toc-labels-B2apPfXG.d.cts +14 -0
- package/dist/toc-labels-B2apPfXG.d.ts +14 -0
- package/dist/toc.cjs +10 -9
- package/dist/toc.d.cts +3 -2
- package/dist/toc.d.ts +3 -2
- package/dist/toc.js +7 -6
- package/dist/{types-DXF9p4qV.d.cts → types-Bzhq5AXj.d.cts} +1 -0
- package/dist/{types-BjLcmV00.d.ts → types-DMuuDBVh.d.ts} +1 -0
- package/dist/view.cjs +4 -4
- package/dist/view.js +2 -2
- package/dist/yjs.cjs +121 -121
- package/dist/yjs.d.cts +2 -2
- package/dist/yjs.d.ts +2 -2
- package/dist/yjs.js +5 -5
- package/package.json +81 -1
- package/dist/chunk-2AVGGPLT.js.map +0 -1
- package/dist/chunk-32OZ2WM2.js.map +0 -1
- package/dist/chunk-B5OMWOVI.js.map +0 -1
- package/dist/chunk-BJTOLCRR.js.map +0 -1
- package/dist/chunk-HT7OF52E.js.map +0 -1
- package/dist/chunk-IJKGF6SC.js.map +0 -1
- package/dist/chunk-KF3KKN4N.js.map +0 -1
- package/dist/chunk-KFYJW7W5.js.map +0 -1
- package/dist/chunk-N2SCDXTI.js.map +0 -1
- package/dist/chunk-O7XZFXPE.js.map +0 -1
- package/dist/toc-extension-CI6jNOYl.d.cts +0 -26
- package/dist/toc-extension-CTHWjNJC.d.ts +0 -26
- /package/dist/{chunk-WZA5S5EJ.cjs → chunk-I7X7B3WD.cjs} +0 -0
package/dist/ai.cjs
CHANGED
|
@@ -2,13 +2,14 @@
|
|
|
2
2
|
'use strict';
|
|
3
3
|
|
|
4
4
|
var chunkLE5XMIFJ_cjs = require('./chunk-LE5XMIFJ.cjs');
|
|
5
|
-
var
|
|
6
|
-
var
|
|
7
|
-
var
|
|
5
|
+
var chunk4MCYQHFL_cjs = require('./chunk-4MCYQHFL.cjs');
|
|
6
|
+
var chunkBA5WXBGE_cjs = require('./chunk-BA5WXBGE.cjs');
|
|
7
|
+
var chunkP6HC7RUN_cjs = require('./chunk-P6HC7RUN.cjs');
|
|
8
|
+
var chunkZWTIRGY5_cjs = require('./chunk-ZWTIRGY5.cjs');
|
|
8
9
|
require('./chunk-A6PGQVTR.cjs');
|
|
9
|
-
var
|
|
10
|
-
require('./chunk-
|
|
11
|
-
var
|
|
10
|
+
var chunkFK7EBZPX_cjs = require('./chunk-FK7EBZPX.cjs');
|
|
11
|
+
require('./chunk-DJU25PFC.cjs');
|
|
12
|
+
var chunkI7X7B3WD_cjs = require('./chunk-I7X7B3WD.cjs');
|
|
12
13
|
var react = require('react');
|
|
13
14
|
var jsxRuntime = require('react/jsx-runtime');
|
|
14
15
|
|
|
@@ -109,30 +110,30 @@ function closeStreaming(markdown) {
|
|
|
109
110
|
// src/extensions/ai/ai-target.ts
|
|
110
111
|
function targetOfBlocks(state, ids) {
|
|
111
112
|
const { doc, schema } = state;
|
|
112
|
-
const first =
|
|
113
|
-
const last =
|
|
113
|
+
const first = chunkI7X7B3WD_cjs.blockById(doc, ids[0]);
|
|
114
|
+
const last = chunkI7X7B3WD_cjs.blockById(doc, ids[ids.length - 1]);
|
|
114
115
|
if (first === void 0 || last === void 0) return null;
|
|
115
|
-
const start =
|
|
116
|
-
const end =
|
|
116
|
+
const start = chunkFK7EBZPX_cjs.primaryRegion(schema, first);
|
|
117
|
+
const end = chunkFK7EBZPX_cjs.primaryRegion(schema, last);
|
|
117
118
|
if (start === null || end === null) return null;
|
|
118
119
|
const from = { block: first.id, region: start, offset: 0 };
|
|
119
|
-
return { from, to: { block: last.id, region: end, offset:
|
|
120
|
+
return { from, to: { block: last.id, region: end, offset: chunkFK7EBZPX_cjs.regionLength(last, end) }, selected: ids.length > 1 };
|
|
120
121
|
}
|
|
121
122
|
function targetOfSelection(state) {
|
|
122
123
|
const { doc, selection } = state;
|
|
123
124
|
if (selection === null) return null;
|
|
124
|
-
if (selection.kind !== "text") return targetOfBlocks(state,
|
|
125
|
-
const { from, to } =
|
|
126
|
-
if (
|
|
125
|
+
if (selection.kind !== "text") return targetOfBlocks(state, chunkFK7EBZPX_cjs.selectedBlockIds(doc, selection));
|
|
126
|
+
const { from, to } = chunkFK7EBZPX_cjs.orderedRange(doc, selection.anchor, selection.head);
|
|
127
|
+
if (chunkFK7EBZPX_cjs.comparePos(doc, from, to) !== 0) return { from, to, selected: true };
|
|
127
128
|
const block = doc.blocks[doc.index.get(from.block)];
|
|
128
129
|
const whole = { block: from.block, region: from.region };
|
|
129
|
-
return { from: { ...whole, offset: 0 }, to: { ...whole, offset:
|
|
130
|
+
return { from: { ...whole, offset: 0 }, to: { ...whole, offset: chunkFK7EBZPX_cjs.regionLength(block, from.region) }, selected: false };
|
|
130
131
|
}
|
|
131
132
|
function nearestKept(tr, target) {
|
|
132
133
|
const { doc } = tr.before;
|
|
133
134
|
const first = doc.index.get(target.from.block) ?? 0;
|
|
134
135
|
const last = doc.index.get(target.to.block) ?? first;
|
|
135
|
-
const kept = (block) => block &&
|
|
136
|
+
const kept = (block) => block && chunkI7X7B3WD_cjs.blockById(tr.doc, block.id);
|
|
136
137
|
for (let step = 1; first - step >= 0 || last + step < doc.blocks.length; step++) {
|
|
137
138
|
const found = kept(doc.blocks[first - step]) ?? kept(doc.blocks[last + step]);
|
|
138
139
|
if (found) return found;
|
|
@@ -141,10 +142,10 @@ function nearestKept(tr, target) {
|
|
|
141
142
|
}
|
|
142
143
|
function edgeOf(tr, target) {
|
|
143
144
|
const point = tr.mapPos(target.from, -1);
|
|
144
|
-
const block =
|
|
145
|
+
const block = chunkI7X7B3WD_cjs.blockById(tr.doc, point.block) ?? nearestKept(tr, target);
|
|
145
146
|
if (block === void 0) return null;
|
|
146
|
-
const region =
|
|
147
|
-
const length = region === "" ? 0 :
|
|
147
|
+
const region = chunkFK7EBZPX_cjs.primaryRegion(tr.before.schema, block) ?? "";
|
|
148
|
+
const length = region === "" ? 0 : chunkFK7EBZPX_cjs.regionLength(block, region);
|
|
148
149
|
const offset = block.id === point.block ? Math.min(point.offset, length) : length;
|
|
149
150
|
const after = offset > 0 || length === 0;
|
|
150
151
|
const at = { block: block.id, region, offset: after ? length : 0 };
|
|
@@ -156,29 +157,29 @@ function mapTarget(tr, target) {
|
|
|
156
157
|
const from = tr.mapPos(target.from, inside);
|
|
157
158
|
const mapped2 = tr.mapPos(target.to, -inside);
|
|
158
159
|
if (!tr.doc.index.has(from.block) || !tr.doc.index.has(mapped2.block)) return edgeOf(tr, target);
|
|
159
|
-
const to =
|
|
160
|
+
const to = chunkFK7EBZPX_cjs.comparePos(tr.doc, from, mapped2) > 0 ? from : mapped2;
|
|
160
161
|
return from === target.from && to === target.to ? target : { ...target, from, to };
|
|
161
162
|
}
|
|
162
|
-
var targetGone = (doc, target) => target.lost !== void 0 || target.selected &&
|
|
163
|
+
var targetGone = (doc, target) => target.lost !== void 0 || target.selected && chunkFK7EBZPX_cjs.comparePos(doc, target.from, target.to) === 0;
|
|
163
164
|
function targetRanges(state, { from, to }) {
|
|
164
165
|
const { doc, schema } = state;
|
|
165
166
|
const start = doc.index.get(from.block);
|
|
166
167
|
const end = doc.index.get(to.block);
|
|
167
168
|
return doc.blocks.slice(start, end + 1).flatMap((block, i) => {
|
|
168
|
-
const region = i === 0 ? from.region : block.id === to.block ? to.region :
|
|
169
|
+
const region = i === 0 ? from.region : block.id === to.block ? to.region : chunkFK7EBZPX_cjs.primaryRegion(schema, block);
|
|
169
170
|
if (region === null || !Object.hasOwn(block.regions, region)) return [];
|
|
170
171
|
const left = i === 0 ? from.offset : 0;
|
|
171
|
-
const right = block.id === to.block ? to.offset :
|
|
172
|
+
const right = block.id === to.block ? to.offset : chunkFK7EBZPX_cjs.regionLength(block, region);
|
|
172
173
|
return right > left ? [{ block: block.id, region, from: left, to: right }] : [];
|
|
173
174
|
});
|
|
174
175
|
}
|
|
175
176
|
|
|
176
177
|
// src/extensions/ai/ai-plugin.ts
|
|
177
|
-
var aiKey =
|
|
178
|
+
var aiKey = chunkFK7EBZPX_cjs.createPluginKey("ai");
|
|
178
179
|
var AI = "ai";
|
|
179
180
|
var IDLE = { target: null, menu: null, ghost: null, held: [] };
|
|
180
|
-
var aiState = (state) =>
|
|
181
|
-
var aiTransaction = (state, act2) => new
|
|
181
|
+
var aiState = (state) => chunkFK7EBZPX_cjs.getPluginState(state, aiKey);
|
|
182
|
+
var aiTransaction = (state, act2) => new chunkFK7EBZPX_cjs.Transaction(state).setMeta(AI, act2).setMeta("addToHistory", false);
|
|
182
183
|
function written(ghost, key, phase, output) {
|
|
183
184
|
return ghost.key !== key ? ghost : { ...ghost, phase, output, shown: closeStreaming(output) };
|
|
184
185
|
}
|
|
@@ -210,8 +211,8 @@ function caretBlock(state) {
|
|
|
210
211
|
return selection?.kind === "text" ? selection.head.block : null;
|
|
211
212
|
}
|
|
212
213
|
function hasText(state, id) {
|
|
213
|
-
const block =
|
|
214
|
-
return block !== void 0 && Object.keys(block.regions).some((region) =>
|
|
214
|
+
const block = chunkI7X7B3WD_cjs.blockById(state.doc, id);
|
|
215
|
+
return block !== void 0 && Object.keys(block.regions).some((region) => chunkFK7EBZPX_cjs.regionLength(block, region) > 0);
|
|
215
216
|
}
|
|
216
217
|
function heldText(tr, value, before, after) {
|
|
217
218
|
if (!tr.docChanged) return value.held;
|
|
@@ -309,13 +310,13 @@ function aroundSelection(text, start, end, limit = CONTEXT_LIMIT) {
|
|
|
309
310
|
}
|
|
310
311
|
var WHITESPACE_ENTITY = /(?<!\\)&#(32|9);/g;
|
|
311
312
|
var plain = (markdown) => markdown.replace(WHITESPACE_ENTITY, (_, code) => code === "32" ? " " : " ");
|
|
312
|
-
var markdownOf = (state, blocks) =>
|
|
313
|
+
var markdownOf = (state, blocks) => chunkFK7EBZPX_cjs.toMarkdown(blocks, { schema: state.schema, comments: false });
|
|
313
314
|
function rangeMarkdown(state, from, to) {
|
|
314
|
-
const slice =
|
|
315
|
+
const slice = chunkFK7EBZPX_cjs.sliceFromSelection({ ...state, selection: chunkFK7EBZPX_cjs.textSelection(from, to) }, chunkI7X7B3WD_cjs.createBlockCodec(state.schema));
|
|
315
316
|
return slice === null ? "" : markdownOf(state, slice.blocks).replace(/\n$/, "");
|
|
316
317
|
}
|
|
317
318
|
function documentContext(state, target, selection) {
|
|
318
|
-
const blocks =
|
|
319
|
+
const blocks = chunkI7X7B3WD_cjs.createBlockCodec(state.schema).blocksFromDoc(state.doc);
|
|
319
320
|
const full = plain(markdownOf(state, blocks));
|
|
320
321
|
if (full.length <= CONTEXT_LIMIT) return full;
|
|
321
322
|
const index = state.doc.index.get(target.from.block) ?? 0;
|
|
@@ -376,7 +377,7 @@ async function read(editor, link, run, stream, request) {
|
|
|
376
377
|
} catch (error) {
|
|
377
378
|
if (!live()) return;
|
|
378
379
|
end("error");
|
|
379
|
-
link.report(
|
|
380
|
+
link.report(chunkBA5WXBGE_cjs.toError(error));
|
|
380
381
|
}
|
|
381
382
|
}
|
|
382
383
|
function startStream(editor, link, stream, request, replace) {
|
|
@@ -473,7 +474,7 @@ function aiSlashItems(labels, stream) {
|
|
|
473
474
|
title: labels.askAi,
|
|
474
475
|
description: labels.askAiDescription,
|
|
475
476
|
group: "ai",
|
|
476
|
-
icon:
|
|
477
|
+
icon: chunkBA5WXBGE_cjs.Sparkles,
|
|
477
478
|
keywords: KEYWORDS,
|
|
478
479
|
run: ({ controller }) => void openFor(controller)
|
|
479
480
|
},
|
|
@@ -481,7 +482,7 @@ function aiSlashItems(labels, stream) {
|
|
|
481
482
|
id: "ai-continue",
|
|
482
483
|
title: labels.actions.continue,
|
|
483
484
|
group: "ai",
|
|
484
|
-
icon:
|
|
485
|
+
icon: chunkBA5WXBGE_cjs.PenLine,
|
|
485
486
|
keywords: [...KEYWORDS, "continue"],
|
|
486
487
|
run: ({ controller }) => {
|
|
487
488
|
if (openFor(controller)) askFrom({ controller, stream}, "continue");
|
|
@@ -492,14 +493,14 @@ function aiSlashItems(labels, stream) {
|
|
|
492
493
|
var aiBubbleItem = (labels) => ({
|
|
493
494
|
id: "ai",
|
|
494
495
|
title: labels.askAi,
|
|
495
|
-
icon:
|
|
496
|
+
icon: chunkBA5WXBGE_cjs.Sparkles,
|
|
496
497
|
available: (state) => aiState(state).ghost === null,
|
|
497
498
|
run: (controller) => void openFor(controller)
|
|
498
499
|
});
|
|
499
500
|
var aiBlockMenuItem = (labels) => ({
|
|
500
501
|
id: "ai",
|
|
501
502
|
label: labels.askAi,
|
|
502
|
-
icon:
|
|
503
|
+
icon: chunkBA5WXBGE_cjs.Sparkles,
|
|
503
504
|
available: (state, blockIds) => targetOfBlocks(state, blockIds) !== null,
|
|
504
505
|
run: (controller, blockIds) => {
|
|
505
506
|
const target = targetOfBlocks(controller.editor.state, blockIds);
|
|
@@ -542,34 +543,31 @@ var englishAiLabels = {
|
|
|
542
543
|
halted: (text) => `Stopped. AI response so far: ${text}`,
|
|
543
544
|
targetGone: "The text this was for was removed, so Accept inserts it where that text was"
|
|
544
545
|
};
|
|
545
|
-
|
|
546
|
-
const given = Object.entries(overrides ?? {}).filter(([, value]) => value !== void 0);
|
|
547
|
-
return given.length === 0 ? englishAiLabels : { ...englishAiLabels, ...Object.fromEntries(given) };
|
|
548
|
-
}
|
|
546
|
+
var resolveAiLabels = (overrides) => chunkZWTIRGY5_cjs.mergeLabels(englishAiLabels, overrides);
|
|
549
547
|
|
|
550
548
|
// src/extensions/ai/ai-space.ts
|
|
551
549
|
var openOnSpace = (state, dispatch) => {
|
|
552
550
|
const { selection, doc } = state;
|
|
553
551
|
const ai = aiState(state);
|
|
554
|
-
if (selection?.kind !== "text" || !
|
|
552
|
+
if (selection?.kind !== "text" || !chunkFK7EBZPX_cjs.isCollapsed(selection) || ai.menu !== null || ai.ghost !== null) return false;
|
|
555
553
|
const { head } = selection;
|
|
556
554
|
const block = doc.blocks[doc.index.get(head.block)];
|
|
557
555
|
const paragraph = block.type === "MARKDOWN" && block.attrs.kind === "paragraph";
|
|
558
|
-
if (!paragraph ||
|
|
556
|
+
if (!paragraph || chunkFK7EBZPX_cjs.regionLength(block, head.region) > 0 || ai.held.includes(block.id)) return false;
|
|
559
557
|
dispatch?.(aiTransaction(state, { type: "open", target: { from: head, to: head, selected: false }, fromSpace: true }));
|
|
560
558
|
return true;
|
|
561
559
|
};
|
|
562
560
|
|
|
563
561
|
// src/extensions/ai/ai-accept.ts
|
|
564
|
-
var isParagraph = (block) => block?.type === "MARKDOWN" &&
|
|
562
|
+
var isParagraph = (block) => block?.type === "MARKDOWN" && chunkI7X7B3WD_cjs.parseLine(String(block.data.markdown ?? "")).kind === "paragraph";
|
|
565
563
|
var DISCARD = { type: "discard" };
|
|
566
564
|
function insertBeside(tr, schema, target, pieces, makeId) {
|
|
567
565
|
const index = tr.doc.index.get(target.to.block);
|
|
568
|
-
const at = target.lost?.after ?
|
|
569
|
-
const fresh =
|
|
570
|
-
tr.step(
|
|
571
|
-
|
|
572
|
-
tr.setSelection(
|
|
566
|
+
const at = target.lost?.after ? chunkFK7EBZPX_cjs.descendantsEnd(tr.doc, index) : index;
|
|
567
|
+
const fresh = chunkFK7EBZPX_cjs.freshBlocks(pieces, tr.doc.blocks[index].indent, makeId);
|
|
568
|
+
tr.step(chunkFK7EBZPX_cjs.insertBlocksStep(at, fresh));
|
|
569
|
+
chunkFK7EBZPX_cjs.capIndents(tr, at, at + fresh.length);
|
|
570
|
+
tr.setSelection(chunkFK7EBZPX_cjs.endOf(tr.doc, schema, fresh[fresh.length - 1].id));
|
|
573
571
|
}
|
|
574
572
|
function acceptAnswer(editor) {
|
|
575
573
|
const { state } = editor;
|
|
@@ -577,7 +575,7 @@ function acceptAnswer(editor) {
|
|
|
577
575
|
if (target === null || ghost === null || ghost.phase === "streaming" || ghost.phase === "error") return null;
|
|
578
576
|
const { codec } = editor;
|
|
579
577
|
const makeId = codec.context.newId;
|
|
580
|
-
const blocks =
|
|
578
|
+
const blocks = chunkI7X7B3WD_cjs.fromMarkdown(ghost.output, { newId: makeId });
|
|
581
579
|
const pieces = blocks.flatMap((block) => codec.toEngineBlocks(block));
|
|
582
580
|
const tr = editor.createTransaction().setOrigin("ai").setMeta(AI, DISCARD);
|
|
583
581
|
const gone = targetGone(state.doc, target);
|
|
@@ -587,12 +585,12 @@ function acceptAnswer(editor) {
|
|
|
587
585
|
const { schema } = state;
|
|
588
586
|
const open = { openStart: isParagraph(blocks[0]), openEnd: isParagraph(blocks[blocks.length - 1]) };
|
|
589
587
|
if (ghost.replace || gone) {
|
|
590
|
-
const caret = ghost.replace && !gone ?
|
|
591
|
-
|
|
588
|
+
const caret = ghost.replace && !gone ? chunkFK7EBZPX_cjs.deleteRange(tr, schema, target.from, target.to, makeId) : target.to;
|
|
589
|
+
chunkFK7EBZPX_cjs.pasteAtCaret(tr, schema, caret, open, pieces, makeId);
|
|
592
590
|
} else {
|
|
593
591
|
const block = tr.doc.blocks[tr.doc.index.get(target.to.block)];
|
|
594
|
-
const end = { ...target.to, offset:
|
|
595
|
-
|
|
592
|
+
const end = { ...target.to, offset: chunkFK7EBZPX_cjs.regionLength(block, target.to.region) };
|
|
593
|
+
chunkFK7EBZPX_cjs.pasteAtCaret(tr, schema, end, { openStart: false, openEnd: false }, pieces, makeId);
|
|
596
594
|
}
|
|
597
595
|
}
|
|
598
596
|
editor.dispatch(tr);
|
|
@@ -607,12 +605,12 @@ function AiBar({ env, ghost, gone, barId }) {
|
|
|
607
605
|
const [next, setNext] = react.useState("");
|
|
608
606
|
const { phase } = ghost;
|
|
609
607
|
const focusPrimary = () => content.current?.querySelector(`[${PRIMARY}]`)?.focus();
|
|
610
|
-
|
|
608
|
+
chunkP6HC7RUN_cjs.useIsomorphicLayoutEffect(() => {
|
|
611
609
|
const active = content.current?.ownerDocument.activeElement;
|
|
612
610
|
inside.current = active == null || active === active.ownerDocument.body;
|
|
613
611
|
if (inside.current) focusPrimary();
|
|
614
612
|
}, []);
|
|
615
|
-
|
|
613
|
+
chunkP6HC7RUN_cjs.useIsomorphicLayoutEffect(() => {
|
|
616
614
|
const active = content.current?.ownerDocument.activeElement;
|
|
617
615
|
if (inside.current && !content.current?.contains(active ?? null)) focusPrimary();
|
|
618
616
|
}, [phase, ghost.key]);
|
|
@@ -660,21 +658,21 @@ function AiBar({ env, ghost, gone, barId }) {
|
|
|
660
658
|
children: [
|
|
661
659
|
phase === "streaming" && /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
662
660
|
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-sm text-muted-foreground", children: labels.writing }),
|
|
663
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
661
|
+
/* @__PURE__ */ jsxRuntime.jsx(chunkBA5WXBGE_cjs.Button, { ...primary, size: "sm", variant: "outline", onClick: () => stop(editor), children: labels.stop })
|
|
664
662
|
] }),
|
|
665
663
|
phase === "error" && /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
666
664
|
/* @__PURE__ */ jsxRuntime.jsx("p", { role: "alert", className: "text-sm text-destructive", children: labels.failed }),
|
|
667
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
668
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
665
|
+
/* @__PURE__ */ jsxRuntime.jsx(chunkBA5WXBGE_cjs.Button, { ...primary, size: "sm", onClick: () => retry(editor, stream), children: labels.retry }),
|
|
666
|
+
/* @__PURE__ */ jsxRuntime.jsx(chunkBA5WXBGE_cjs.Button, { size: "sm", variant: "ghost", onClick: onDiscard, children: labels.discard })
|
|
669
667
|
] }),
|
|
670
668
|
(phase === "done" || phase === "stopped") && /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
671
669
|
phase === "stopped" && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-sm text-muted-foreground", children: labels.stopped }),
|
|
672
670
|
gone && /* @__PURE__ */ jsxRuntime.jsx("p", { className: "w-full text-xs text-muted-foreground", children: labels.targetGone }),
|
|
673
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
674
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
675
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
671
|
+
/* @__PURE__ */ jsxRuntime.jsx(chunkBA5WXBGE_cjs.Button, { ...primary, size: "sm", onClick: onAccept, children: labels.accept }),
|
|
672
|
+
/* @__PURE__ */ jsxRuntime.jsx(chunkBA5WXBGE_cjs.Button, { size: "sm", variant: "ghost", onClick: onDiscard, children: labels.discard }),
|
|
673
|
+
/* @__PURE__ */ jsxRuntime.jsx(chunkBA5WXBGE_cjs.Button, { size: "sm", variant: "ghost", onClick: () => retry(editor, stream), children: labels.retry }),
|
|
676
674
|
/* @__PURE__ */ jsxRuntime.jsx("form", { className: "w-full", onSubmit: onFollowUp, children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
677
|
-
|
|
675
|
+
chunkBA5WXBGE_cjs.Input,
|
|
678
676
|
{
|
|
679
677
|
"aria-label": labels.followUp,
|
|
680
678
|
placeholder: labels.followUp,
|
|
@@ -695,8 +693,8 @@ function AiBar({ env, ghost, gone, barId }) {
|
|
|
695
693
|
var reader = null;
|
|
696
694
|
function readerOf() {
|
|
697
695
|
if (reader === null) {
|
|
698
|
-
const schema =
|
|
699
|
-
reader = { schema, codec:
|
|
696
|
+
const schema = chunkI7X7B3WD_cjs.createSchema();
|
|
697
|
+
reader = { schema, codec: chunkI7X7B3WD_cjs.createBlockCodec(schema) };
|
|
700
698
|
}
|
|
701
699
|
return reader;
|
|
702
700
|
}
|
|
@@ -704,16 +702,16 @@ function fillGhost(ghost, markdown) {
|
|
|
704
702
|
const doc = ghost.ownerDocument;
|
|
705
703
|
const { schema, codec } = readerOf();
|
|
706
704
|
const drawn2 = [];
|
|
707
|
-
for (const block of
|
|
705
|
+
for (const block of chunkI7X7B3WD_cjs.fromMarkdown(markdown)) {
|
|
708
706
|
for (const piece of codec.toEngineBlocks(block)) {
|
|
709
707
|
const element = doc.createElement("div");
|
|
710
708
|
element.className = "quoin-ai-ghost-block";
|
|
711
709
|
element.dataset.kind = String(piece.attrs.kind ?? piece.type.toLowerCase());
|
|
712
710
|
if (piece.attrs.level !== void 0) element.dataset.level = String(piece.attrs.level);
|
|
713
711
|
if (piece.indent > 0) element.style.setProperty("--quoin-ai-indent", String(piece.indent));
|
|
714
|
-
const region =
|
|
715
|
-
if (region === null) element.textContent =
|
|
716
|
-
else
|
|
712
|
+
const region = chunkFK7EBZPX_cjs.primaryRegion(schema, piece);
|
|
713
|
+
if (region === null) element.textContent = chunkFK7EBZPX_cjs.toPlainText([codec.toQuoin(piece)], { schema });
|
|
714
|
+
else chunkP6HC7RUN_cjs.renderInline(element, piece.regions[region], []);
|
|
717
715
|
drawn2.push(element);
|
|
718
716
|
}
|
|
719
717
|
}
|
|
@@ -790,7 +788,7 @@ function clipAside(layer, text, areas, scale) {
|
|
|
790
788
|
function useGhostPlace(controller, layer, block, region) {
|
|
791
789
|
const placeNow = react.useRef(() => {
|
|
792
790
|
});
|
|
793
|
-
|
|
791
|
+
chunkP6HC7RUN_cjs.useIsomorphicLayoutEffect(() => {
|
|
794
792
|
const root = controller.root;
|
|
795
793
|
const element = layer.current;
|
|
796
794
|
const view = root?.ownerDocument.defaultView;
|
|
@@ -829,7 +827,7 @@ function AiGhost({ env, ghost, target, gone, barId }) {
|
|
|
829
827
|
const layer = react.useRef(null);
|
|
830
828
|
const drawn2 = react.useRef(null);
|
|
831
829
|
const place2 = useGhostPlace(env.controller, layer, target.to.block, target.to.region);
|
|
832
|
-
|
|
830
|
+
chunkP6HC7RUN_cjs.useIsomorphicLayoutEffect(() => {
|
|
833
831
|
const element = drawn2.current;
|
|
834
832
|
if (element === null) return;
|
|
835
833
|
element.setAttribute("inert", "");
|
|
@@ -843,7 +841,7 @@ function AiGhost({ env, ghost, target, gone, barId }) {
|
|
|
843
841
|
}
|
|
844
842
|
function useTargetAnchor(controller, target) {
|
|
845
843
|
const latest = react.useRef(target);
|
|
846
|
-
|
|
844
|
+
chunkP6HC7RUN_cjs.useIsomorphicLayoutEffect(() => {
|
|
847
845
|
latest.current = target;
|
|
848
846
|
});
|
|
849
847
|
return react.useMemo(() => {
|
|
@@ -852,8 +850,8 @@ function useTargetAnchor(controller, target) {
|
|
|
852
850
|
return { block: to.block, region: to.region, from: to.offset, to: to.offset };
|
|
853
851
|
};
|
|
854
852
|
return {
|
|
855
|
-
current:
|
|
856
|
-
() =>
|
|
853
|
+
current: chunkBA5WXBGE_cjs.virtualAnchor(
|
|
854
|
+
() => chunkBA5WXBGE_cjs.rangeRect(controller, end()),
|
|
857
855
|
() => controller.registry.get(end().block, end().region)
|
|
858
856
|
)
|
|
859
857
|
};
|
|
@@ -907,7 +905,7 @@ function AiMenu({ env, target, fromSpace }) {
|
|
|
907
905
|
};
|
|
908
906
|
const fieldLabel = asking === "tone" ? labels.tonePrompt : asking === "translate" ? labels.translatePrompt : labels.prompt;
|
|
909
907
|
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
910
|
-
|
|
908
|
+
chunkBA5WXBGE_cjs.Popover,
|
|
911
909
|
{
|
|
912
910
|
open: true,
|
|
913
911
|
modal: false,
|
|
@@ -915,9 +913,9 @@ function AiMenu({ env, target, fromSpace }) {
|
|
|
915
913
|
if (!next) closeMenu(controller.editor);
|
|
916
914
|
},
|
|
917
915
|
children: [
|
|
918
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
916
|
+
/* @__PURE__ */ jsxRuntime.jsx(chunkBA5WXBGE_cjs.PopoverAnchor, { virtualRef: anchor }),
|
|
919
917
|
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
920
|
-
|
|
918
|
+
chunkBA5WXBGE_cjs.PopoverContent,
|
|
921
919
|
{
|
|
922
920
|
"aria-label": labels.askAi,
|
|
923
921
|
side: "bottom",
|
|
@@ -934,7 +932,7 @@ function AiMenu({ env, target, fromSpace }) {
|
|
|
934
932
|
},
|
|
935
933
|
children: [
|
|
936
934
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
937
|
-
|
|
935
|
+
chunkBA5WXBGE_cjs.Input,
|
|
938
936
|
{
|
|
939
937
|
ref: field,
|
|
940
938
|
role: "combobox",
|
|
@@ -958,7 +956,7 @@ function AiMenu({ env, target, fromSpace }) {
|
|
|
958
956
|
id: optionId(index),
|
|
959
957
|
role: "option",
|
|
960
958
|
"aria-selected": index === current,
|
|
961
|
-
className:
|
|
959
|
+
className: chunkBA5WXBGE_cjs.cn(chunkBA5WXBGE_cjs.MENU_ITEM, index === current && "bg-accent text-accent-foreground"),
|
|
962
960
|
onMouseDown: (event) => event.preventDefault(),
|
|
963
961
|
onClick: () => choose(choice),
|
|
964
962
|
children: choice.label
|
|
@@ -976,17 +974,17 @@ var goneOf = (state) => {
|
|
|
976
974
|
const { target, ghost } = aiState(state);
|
|
977
975
|
return target !== null && ghost !== null && targetGone(state.doc, target);
|
|
978
976
|
};
|
|
979
|
-
var plainText = (markdown) =>
|
|
977
|
+
var plainText = (markdown) => chunkFK7EBZPX_cjs.toPlainText(chunkI7X7B3WD_cjs.fromMarkdown(markdown));
|
|
980
978
|
function AiOverlay({ controller, stream, labels }) {
|
|
981
|
-
const { onError } =
|
|
979
|
+
const { onError } = chunkBA5WXBGE_cjs.useQuoin();
|
|
982
980
|
const link = linkOf(controller.editor);
|
|
983
|
-
|
|
981
|
+
chunkP6HC7RUN_cjs.useIsomorphicLayoutEffect(() => {
|
|
984
982
|
link.report = onError;
|
|
985
983
|
link.ended = (phase, output) => controller.announce((phase === "done" ? labels.written : labels.halted)(plainText(output)));
|
|
986
984
|
}, [link, onError, controller, labels]);
|
|
987
|
-
const value =
|
|
988
|
-
const gone =
|
|
989
|
-
const readOnly =
|
|
985
|
+
const value = chunkP6HC7RUN_cjs.useEditorState(controller, aiState);
|
|
986
|
+
const gone = chunkP6HC7RUN_cjs.useEditorState(controller, goneOf);
|
|
987
|
+
const readOnly = chunkP6HC7RUN_cjs.useReadOnly(controller);
|
|
990
988
|
const env = react.useMemo(() => ({ controller, stream, labels }), [controller, stream, labels]);
|
|
991
989
|
const barId = react.useId();
|
|
992
990
|
const showing = value.ghost !== null;
|
|
@@ -1005,7 +1003,7 @@ function AiOverlay({ controller, stream, labels }) {
|
|
|
1005
1003
|
const root = controller.root;
|
|
1006
1004
|
if (!root) return;
|
|
1007
1005
|
let away = true;
|
|
1008
|
-
return
|
|
1006
|
+
return chunk4MCYQHFL_cjs.watchCanvasFocus(controller, root.ownerDocument, (inside, node) => {
|
|
1009
1007
|
if (!inside) away = true;
|
|
1010
1008
|
else if (root.contains(node)) {
|
|
1011
1009
|
if (away) noteFocus(controller.editor);
|
|
@@ -1041,7 +1039,7 @@ function aiExtension(options) {
|
|
|
1041
1039
|
blockMenuItems: [aiBlockMenuItem(labels)],
|
|
1042
1040
|
overlays: [Overlay]
|
|
1043
1041
|
};
|
|
1044
|
-
return
|
|
1042
|
+
return chunkFK7EBZPX_cjs.defineExtension({
|
|
1045
1043
|
name: "ai",
|
|
1046
1044
|
plugins: [aiPlugin],
|
|
1047
1045
|
decorations: aiDecorations,
|
package/dist/ai.d.cts
CHANGED
|
@@ -1,57 +1,8 @@
|
|
|
1
1
|
import { Extension } from './engine.cjs';
|
|
2
|
+
import { A as AiStream, a as AiLabels } from './ai-labels-BXX32H9a.cjs';
|
|
3
|
+
export { b as AiAction, c as AiRequest, e as englishAiLabels } from './ai-labels-BXX32H9a.cjs';
|
|
2
4
|
import './types-CQ8Vw_7N.cjs';
|
|
3
5
|
|
|
4
|
-
type AiAction = 'continue' | 'improve' | 'fix' | 'shorten' | 'lengthen' | 'simplify' | 'tone' | 'translate' | 'summarize' | 'explain' | 'custom';
|
|
5
|
-
/** What the host is asked: `selection` and `context` are markdown, `language` the canvas's `lang` when it has one. */
|
|
6
|
-
type AiRequest = {
|
|
7
|
-
action: AiAction;
|
|
8
|
-
prompt?: string;
|
|
9
|
-
selection: string;
|
|
10
|
-
context: string;
|
|
11
|
-
language?: string;
|
|
12
|
-
};
|
|
13
|
-
/** The host's model, answering a request as markdown in chunks, and stopping when `signal` aborts. */
|
|
14
|
-
type AiStream = (request: AiRequest, signal: AbortSignal) => AsyncIterable<string>;
|
|
15
|
-
|
|
16
|
-
/** Every string AI actions show or speak. */
|
|
17
|
-
type AiLabels = {
|
|
18
|
-
/** The toolbar button, block menu item and slash command that open the AI menu. */
|
|
19
|
-
askAi: string;
|
|
20
|
-
/** What the slash command for the AI menu does. */
|
|
21
|
-
askAiDescription: string;
|
|
22
|
-
/** The name of each action in the AI menu; `custom` names the slash command group's own entry. */
|
|
23
|
-
actions: Record<AiAction, string>;
|
|
24
|
-
/** The name of the list of actions. */
|
|
25
|
-
menu: string;
|
|
26
|
-
/** The field the writer types a request in. */
|
|
27
|
-
prompt: string;
|
|
28
|
-
/** The field once Change tone is chosen. */
|
|
29
|
-
tonePrompt: string;
|
|
30
|
-
/** The field once Translate is chosen. */
|
|
31
|
-
translatePrompt: string;
|
|
32
|
-
/** The choice that sends what was typed as a request of its own. */
|
|
33
|
-
ask(prompt: string): string;
|
|
34
|
-
/** The name of the bar under the answer. */
|
|
35
|
-
response: string;
|
|
36
|
-
writing: string;
|
|
37
|
-
stopped: string;
|
|
38
|
-
stop: string;
|
|
39
|
-
accept: string;
|
|
40
|
-
discard: string;
|
|
41
|
-
retry: string;
|
|
42
|
-
/** The field for a further request about the answer. */
|
|
43
|
-
followUp: string;
|
|
44
|
-
/** Shown when the host's answer failed. */
|
|
45
|
-
failed: string;
|
|
46
|
-
/** Said once an answer is complete, given its text. */
|
|
47
|
-
written(text: string): string;
|
|
48
|
-
/** Said once an answer is stopped, given what it wrote. */
|
|
49
|
-
halted(text: string): string;
|
|
50
|
-
/** Shown when the text the answer was for was deleted meanwhile. */
|
|
51
|
-
targetGone: string;
|
|
52
|
-
};
|
|
53
|
-
declare const englishAiLabels: AiLabels;
|
|
54
|
-
|
|
55
6
|
type AiOptions = {
|
|
56
7
|
/** The host's model: answers each request as markdown chunks, and stops when the signal aborts. */
|
|
57
8
|
stream: AiStream;
|
|
@@ -65,5 +16,5 @@ type AiOptions = {
|
|
|
65
16
|
*/
|
|
66
17
|
declare function aiExtension(options: AiOptions): Extension;
|
|
67
18
|
|
|
68
|
-
export {
|
|
69
|
-
export type {
|
|
19
|
+
export { AiLabels, AiStream, aiExtension };
|
|
20
|
+
export type { AiOptions };
|
package/dist/ai.d.ts
CHANGED
|
@@ -1,57 +1,8 @@
|
|
|
1
1
|
import { Extension } from './engine.js';
|
|
2
|
+
import { A as AiStream, a as AiLabels } from './ai-labels-BXX32H9a.js';
|
|
3
|
+
export { b as AiAction, c as AiRequest, e as englishAiLabels } from './ai-labels-BXX32H9a.js';
|
|
2
4
|
import './types-CQ8Vw_7N.js';
|
|
3
5
|
|
|
4
|
-
type AiAction = 'continue' | 'improve' | 'fix' | 'shorten' | 'lengthen' | 'simplify' | 'tone' | 'translate' | 'summarize' | 'explain' | 'custom';
|
|
5
|
-
/** What the host is asked: `selection` and `context` are markdown, `language` the canvas's `lang` when it has one. */
|
|
6
|
-
type AiRequest = {
|
|
7
|
-
action: AiAction;
|
|
8
|
-
prompt?: string;
|
|
9
|
-
selection: string;
|
|
10
|
-
context: string;
|
|
11
|
-
language?: string;
|
|
12
|
-
};
|
|
13
|
-
/** The host's model, answering a request as markdown in chunks, and stopping when `signal` aborts. */
|
|
14
|
-
type AiStream = (request: AiRequest, signal: AbortSignal) => AsyncIterable<string>;
|
|
15
|
-
|
|
16
|
-
/** Every string AI actions show or speak. */
|
|
17
|
-
type AiLabels = {
|
|
18
|
-
/** The toolbar button, block menu item and slash command that open the AI menu. */
|
|
19
|
-
askAi: string;
|
|
20
|
-
/** What the slash command for the AI menu does. */
|
|
21
|
-
askAiDescription: string;
|
|
22
|
-
/** The name of each action in the AI menu; `custom` names the slash command group's own entry. */
|
|
23
|
-
actions: Record<AiAction, string>;
|
|
24
|
-
/** The name of the list of actions. */
|
|
25
|
-
menu: string;
|
|
26
|
-
/** The field the writer types a request in. */
|
|
27
|
-
prompt: string;
|
|
28
|
-
/** The field once Change tone is chosen. */
|
|
29
|
-
tonePrompt: string;
|
|
30
|
-
/** The field once Translate is chosen. */
|
|
31
|
-
translatePrompt: string;
|
|
32
|
-
/** The choice that sends what was typed as a request of its own. */
|
|
33
|
-
ask(prompt: string): string;
|
|
34
|
-
/** The name of the bar under the answer. */
|
|
35
|
-
response: string;
|
|
36
|
-
writing: string;
|
|
37
|
-
stopped: string;
|
|
38
|
-
stop: string;
|
|
39
|
-
accept: string;
|
|
40
|
-
discard: string;
|
|
41
|
-
retry: string;
|
|
42
|
-
/** The field for a further request about the answer. */
|
|
43
|
-
followUp: string;
|
|
44
|
-
/** Shown when the host's answer failed. */
|
|
45
|
-
failed: string;
|
|
46
|
-
/** Said once an answer is complete, given its text. */
|
|
47
|
-
written(text: string): string;
|
|
48
|
-
/** Said once an answer is stopped, given what it wrote. */
|
|
49
|
-
halted(text: string): string;
|
|
50
|
-
/** Shown when the text the answer was for was deleted meanwhile. */
|
|
51
|
-
targetGone: string;
|
|
52
|
-
};
|
|
53
|
-
declare const englishAiLabels: AiLabels;
|
|
54
|
-
|
|
55
6
|
type AiOptions = {
|
|
56
7
|
/** The host's model: answers each request as markdown chunks, and stops when the signal aborts. */
|
|
57
8
|
stream: AiStream;
|
|
@@ -65,5 +16,5 @@ type AiOptions = {
|
|
|
65
16
|
*/
|
|
66
17
|
declare function aiExtension(options: AiOptions): Extension;
|
|
67
18
|
|
|
68
|
-
export {
|
|
69
|
-
export type {
|
|
19
|
+
export { AiLabels, AiStream, aiExtension };
|
|
20
|
+
export type { AiOptions };
|
package/dist/ai.js
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
import { clipBoxes } from './chunk-MQUCCSWG.js';
|
|
3
|
-
import { watchCanvasFocus } from './chunk-
|
|
4
|
-
import { Sparkles, PenLine, useQuoin, Popover, PopoverAnchor, PopoverContent, Input, cn, MENU_ITEM, virtualAnchor, rangeRect, Button, toError } from './chunk-
|
|
5
|
-
import { useIsomorphicLayoutEffect, useEditorState, useReadOnly, renderInline } from './chunk-
|
|
3
|
+
import { watchCanvasFocus } from './chunk-D4L5FINK.js';
|
|
4
|
+
import { Sparkles, PenLine, useQuoin, Popover, PopoverAnchor, PopoverContent, Input, cn, MENU_ITEM, virtualAnchor, rangeRect, Button, toError } from './chunk-Y4EJ6UBV.js';
|
|
5
|
+
import { useIsomorphicLayoutEffect, useEditorState, useReadOnly, renderInline } from './chunk-MSWA5ZZM.js';
|
|
6
|
+
import { mergeLabels } from './chunk-DLQCTGC3.js';
|
|
6
7
|
import './chunk-HDJ653LM.js';
|
|
7
|
-
import { createPluginKey, defineExtension, isCollapsed, regionLength, primaryRegion, getPluginState, Transaction, toPlainText, selectedBlockIds, orderedRange, comparePos, sliceFromSelection, textSelection, deleteRange, pasteAtCaret, toMarkdown, descendantsEnd, freshBlocks, insertBlocksStep, capIndents, endOf } from './chunk-
|
|
8
|
-
import './chunk-
|
|
9
|
-
import { blockById, fromMarkdown, createSchema, createBlockCodec, parseLine } from './chunk-
|
|
8
|
+
import { createPluginKey, defineExtension, isCollapsed, regionLength, primaryRegion, getPluginState, Transaction, toPlainText, selectedBlockIds, orderedRange, comparePos, sliceFromSelection, textSelection, deleteRange, pasteAtCaret, toMarkdown, descendantsEnd, freshBlocks, insertBlocksStep, capIndents, endOf } from './chunk-5RBMZGKV.js';
|
|
9
|
+
import './chunk-CSPCDVCT.js';
|
|
10
|
+
import { blockById, fromMarkdown, createSchema, createBlockCodec, parseLine } from './chunk-7Y4B7NHO.js';
|
|
10
11
|
import { useMemo, useId, useEffect, useState, useRef, useCallback } from 'react';
|
|
11
12
|
import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
12
13
|
|
|
@@ -540,10 +541,7 @@ var englishAiLabels = {
|
|
|
540
541
|
halted: (text) => `Stopped. AI response so far: ${text}`,
|
|
541
542
|
targetGone: "The text this was for was removed, so Accept inserts it where that text was"
|
|
542
543
|
};
|
|
543
|
-
|
|
544
|
-
const given = Object.entries(overrides ?? {}).filter(([, value]) => value !== void 0);
|
|
545
|
-
return given.length === 0 ? englishAiLabels : { ...englishAiLabels, ...Object.fromEntries(given) };
|
|
546
|
-
}
|
|
544
|
+
var resolveAiLabels = (overrides) => mergeLabels(englishAiLabels, overrides);
|
|
547
545
|
|
|
548
546
|
// src/extensions/ai/ai-space.ts
|
|
549
547
|
var openOnSpace = (state, dispatch) => {
|