eddyter 1.4.18 → 1.4.19-beta.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/dist/AIChatPlugin-r4Q1CC4S.js +1042 -0
- package/dist/{CombinedAutocompletGrammarPlugin-BXOz6IRb.js → CombinedAutocompletGrammarPlugin-BuAfoCfe.js} +388 -337
- package/dist/{CommentBubblePlugin-kiMehQkL.js → CommentBubblePlugin-B8Q5ZxWY.js} +4 -4
- package/dist/CommentPlugin-BICzJnwy.js +197 -0
- package/dist/{NotePanelPlugin-FirMseLu.js → NotePanelPlugin-igN9zPi_.js} +3 -3
- package/dist/{TextEnhancePlugin-oXbL_F1i.js → TextEnhancePlugin-q9i0TKCN.js} +6 -6
- package/dist/assets/style.css +1 -1
- package/dist/components/AnimatedPlaceholderText.d.ts +2 -0
- package/dist/components/DividerPicker/DividerPicker.d.ts +17 -0
- package/dist/components/EditorialDivider/EditorialDividerView.d.ts +23 -0
- package/dist/components/EmojiPickerWidget/EmojiPickerWidget.d.ts +1 -1
- package/dist/components/LockedFeature/LockedFeature.d.ts +4 -0
- package/dist/components/Toolbar/styles.d.ts +19 -1
- package/dist/components/UnifiedColorPicker/UnifiedColorPicker.d.ts +1 -0
- package/dist/components/ui/button.d.ts +1 -1
- package/dist/components/ui/separator.d.ts +4 -1
- package/dist/constants.d.ts +12 -1
- package/dist/editorConfig.d.ts +7 -0
- package/dist/{generateDocxThumbnail-RE7yNAXP.js → generateDocxThumbnail-wh4lnFAw.js} +1 -1
- package/dist/{generatePdfThumbnail-CnldK2yE.js → generatePdfThumbnail-DQyYzjOS.js} +4 -4
- package/dist/{generateXlsxThumbnail-BpBB4ePK.js → generateXlsxThumbnail-DqvyM6q9.js} +1 -1
- package/dist/hooks/useEditorToolbar.d.ts +1 -1
- package/dist/{index-CKRp6axU.js → index-BWs0p6X8.js} +10 -10
- package/dist/{index-CL0adQ5R.js → index-Bzry1HiS.js} +13 -13
- package/dist/index-DEW_Wgag.js +1508 -0
- package/dist/{index-B4W_mfNI.js → index-DQah7JmS.js} +120 -123
- package/dist/{index-CXyZgoBl.js → index-jEC_qTLD.js} +18589 -15745
- package/dist/{index-C8ZUqYRj.js → index-m-NFtIUR.js} +27 -27
- package/dist/index-w_DzPr7S.js +796 -0
- package/dist/index.js +8 -8
- package/dist/nodes/AsterismNode.d.ts +22 -0
- package/dist/nodes/ButtonNode.d.ts +37 -0
- package/dist/nodes/ColumnNode.d.ts +44 -0
- package/dist/nodes/ColumnsNode.d.ts +45 -0
- package/dist/nodes/EditorialFieldNode.d.ts +32 -0
- package/dist/nodes/FaqNode.d.ts +28 -0
- package/dist/nodes/ImagePlaceholderNode.d.ts +15 -0
- package/dist/nodes/LabeledRuleNode.d.ts +33 -0
- package/dist/nodes/OrnamentDividerNode.d.ts +22 -0
- package/dist/nodes/PullQuoteRulesNode.d.ts +32 -0
- package/dist/nodes/SectionNumberHeadingNode.d.ts +42 -0
- package/dist/plugins/BlockLayoutPlugin.d.ts +29 -0
- package/dist/plugins/ColumnAddButtonPlugin.d.ts +12 -0
- package/dist/plugins/CommentPlugin.commands.d.ts +1 -0
- package/dist/plugins/CustomHorizontalRulePlugin/CustomHorizontalRuleNode.d.ts +12 -2
- package/dist/plugins/CustomHorizontalRulePlugin/HorizontalRuleCustomizationDialog.d.ts +2 -1
- package/dist/plugins/CustomHorizontalRulePlugin/styles.d.ts +38 -0
- package/dist/plugins/EditorialFloatingToolbarPlugin.d.ts +8 -0
- package/dist/plugins/EditorialTypographyPlugin.d.ts +18 -0
- package/dist/plugins/PatternsPlugin.d.ts +12 -0
- package/dist/{sparkles-CTAYmQOE.js → sparkles-N8q1Rg6P.js} +1 -1
- package/dist/types.d.ts +11 -0
- package/dist/ui/Icons.d.ts +21 -7
- package/dist/{useVoiceToText-U0yKgS5Q.js → useVoiceToText-BSB1QOIb.js} +13 -13
- package/package.json +1 -1
- package/dist/AIChatPlugin-DsUPycjT.js +0 -872
- package/dist/CommentPlugin-DIuM-Jao.js +0 -154
- package/dist/index-DZAvLKar.js +0 -1431
- package/dist/index-F2-F96Nx.js +0 -720
- package/dist/square-CupR-YWR.js +0 -7
|
@@ -1,19 +1,20 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { c as
|
|
3
|
-
import { $isCodeNode as
|
|
4
|
-
import { useLexicalComposerContext as
|
|
5
|
-
import { $getRoot as It, $getSelection as
|
|
1
|
+
import { jsx as v, jsxs as L, Fragment as Ee } from "react/jsx-runtime";
|
|
2
|
+
import { c as ve, a3 as Q, a4 as ye, a5 as be, a6 as ke, a7 as Se, a8 as Me, a0 as Ne, a9 as Vt, aa as Re } from "./index-jEC_qTLD.js";
|
|
3
|
+
import { $isCodeNode as Ie } from "@lexical/code";
|
|
4
|
+
import { useLexicalComposerContext as Oe } from "@lexical/react/LexicalComposerContext";
|
|
5
|
+
import { $getRoot as It, $getSelection as zt, $isRangeSelection as qt, $isTextNode as ut, $getNodeByKey as Gt, $createRangeSelection as Le, $setSelection as Ae, KEY_ARROW_DOWN_COMMAND as Be, COMMAND_PRIORITY_LOW as at, KEY_ARROW_UP_COMMAND as Pe, KEY_ESCAPE_COMMAND as De, KEY_TAB_COMMAND as _e, KEY_ENTER_COMMAND as Te, createCommand as He, $isElementNode as Fe } from "lexical";
|
|
6
6
|
import { g as We } from "./_commonjsHelpers-DaMA6jEr.js";
|
|
7
|
+
import * as st from "react";
|
|
7
8
|
import { useRef as B, useState as q, useEffect as T, useCallback as G } from "react";
|
|
8
|
-
import { createPortal as
|
|
9
|
-
import { S as
|
|
10
|
-
const
|
|
9
|
+
import { createPortal as Xt } from "react-dom";
|
|
10
|
+
import { S as $e } from "./sparkles-N8q1Rg6P.js";
|
|
11
|
+
const Yt = ve("BookOpen", [
|
|
11
12
|
["path", { d: "M2 3h6a4 4 0 0 1 4 4v14a3 3 0 0 0-3-3H2z", key: "vv98re" }],
|
|
12
13
|
["path", { d: "M22 3h-6a4 4 0 0 0-4 4v14a3 3 0 0 1 3-3h7z", key: "1cyq3y" }]
|
|
13
14
|
]);
|
|
14
|
-
var
|
|
15
|
-
function
|
|
16
|
-
return
|
|
15
|
+
var yt = { exports: {} }, bt = { exports: {} }, jt;
|
|
16
|
+
function Ke() {
|
|
17
|
+
return jt || (jt = 1, (function() {
|
|
17
18
|
var o = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/", t = {
|
|
18
19
|
// Bit-wise rotation left
|
|
19
20
|
rotl: function(e, n) {
|
|
@@ -76,13 +77,13 @@ function $e() {
|
|
|
76
77
|
return n;
|
|
77
78
|
}
|
|
78
79
|
};
|
|
79
|
-
|
|
80
|
-
})()),
|
|
80
|
+
bt.exports = t;
|
|
81
|
+
})()), bt.exports;
|
|
81
82
|
}
|
|
82
|
-
var
|
|
83
|
-
function
|
|
84
|
-
if (
|
|
85
|
-
|
|
83
|
+
var kt, Jt;
|
|
84
|
+
function Zt() {
|
|
85
|
+
if (Jt) return kt;
|
|
86
|
+
Jt = 1;
|
|
86
87
|
var o = {
|
|
87
88
|
// UTF-8 encoding
|
|
88
89
|
utf8: {
|
|
@@ -111,12 +112,12 @@ function jt() {
|
|
|
111
112
|
}
|
|
112
113
|
}
|
|
113
114
|
};
|
|
114
|
-
return
|
|
115
|
+
return kt = o, kt;
|
|
115
116
|
}
|
|
116
|
-
var
|
|
117
|
-
function
|
|
118
|
-
if (
|
|
119
|
-
|
|
117
|
+
var St, Qt;
|
|
118
|
+
function Ue() {
|
|
119
|
+
if (Qt) return St;
|
|
120
|
+
Qt = 1, St = function(e) {
|
|
120
121
|
return e != null && (o(e) || t(e) || !!e._isBuffer);
|
|
121
122
|
};
|
|
122
123
|
function o(e) {
|
|
@@ -125,19 +126,19 @@ function Ke() {
|
|
|
125
126
|
function t(e) {
|
|
126
127
|
return typeof e.readFloatLE == "function" && typeof e.slice == "function" && o(e.slice(0, 0));
|
|
127
128
|
}
|
|
128
|
-
return
|
|
129
|
+
return St;
|
|
129
130
|
}
|
|
130
|
-
var
|
|
131
|
-
function
|
|
132
|
-
return
|
|
133
|
-
var o =
|
|
131
|
+
var te;
|
|
132
|
+
function Ve() {
|
|
133
|
+
return te || (te = 1, (function() {
|
|
134
|
+
var o = Ke(), t = Zt().utf8, e = Ue(), n = Zt().bin, c = function(d, h) {
|
|
134
135
|
d.constructor == String ? h && h.encoding === "binary" ? d = n.stringToBytes(d) : d = t.stringToBytes(d) : e(d) ? d = Array.prototype.slice.call(d, 0) : !Array.isArray(d) && d.constructor !== Uint8Array && (d = d.toString());
|
|
135
136
|
for (var r = o.bytesToWords(d), w = d.length * 8, i = 1732584193, s = -271733879, l = -1732584194, a = 271733878, f = 0; f < r.length; f++)
|
|
136
137
|
r[f] = (r[f] << 8 | r[f] >>> 24) & 16711935 | (r[f] << 24 | r[f] >>> 8) & 4278255360;
|
|
137
138
|
r[w >>> 5] |= 128 << w % 32, r[(w + 64 >>> 9 << 4) + 14] = w;
|
|
138
|
-
for (var M = c._ff,
|
|
139
|
-
var J = i, P = s, H = l,
|
|
140
|
-
i = M(i, s, l, a, r[f + 0], 7, -680876936), a = M(a, i, s, l, r[f + 1], 12, -389564586), l = M(l, a, i, s, r[f + 2], 17, 606105819), s = M(s, l, a, i, r[f + 3], 22, -1044525330), i = M(i, s, l, a, r[f + 4], 7, -176418897), a = M(a, i, s, l, r[f + 5], 12, 1200080426), l = M(l, a, i, s, r[f + 6], 17, -1473231341), s = M(s, l, a, i, r[f + 7], 22, -45705983), i = M(i, s, l, a, r[f + 8], 7, 1770035416), a = M(a, i, s, l, r[f + 9], 12, -1958414417), l = M(l, a, i, s, r[f + 10], 17, -42063), s = M(s, l, a, i, r[f + 11], 22, -1990404162), i = M(i, s, l, a, r[f + 12], 7, 1804603682), a = M(a, i, s, l, r[f + 13], 12, -40341101), l = M(l, a, i, s, r[f + 14], 17, -1502002290), s = M(s, l, a, i, r[f + 15], 22, 1236535329), i =
|
|
139
|
+
for (var M = c._ff, k = c._gg, S = c._hh, N = c._ii, f = 0; f < r.length; f += 16) {
|
|
140
|
+
var J = i, P = s, H = l, X = a;
|
|
141
|
+
i = M(i, s, l, a, r[f + 0], 7, -680876936), a = M(a, i, s, l, r[f + 1], 12, -389564586), l = M(l, a, i, s, r[f + 2], 17, 606105819), s = M(s, l, a, i, r[f + 3], 22, -1044525330), i = M(i, s, l, a, r[f + 4], 7, -176418897), a = M(a, i, s, l, r[f + 5], 12, 1200080426), l = M(l, a, i, s, r[f + 6], 17, -1473231341), s = M(s, l, a, i, r[f + 7], 22, -45705983), i = M(i, s, l, a, r[f + 8], 7, 1770035416), a = M(a, i, s, l, r[f + 9], 12, -1958414417), l = M(l, a, i, s, r[f + 10], 17, -42063), s = M(s, l, a, i, r[f + 11], 22, -1990404162), i = M(i, s, l, a, r[f + 12], 7, 1804603682), a = M(a, i, s, l, r[f + 13], 12, -40341101), l = M(l, a, i, s, r[f + 14], 17, -1502002290), s = M(s, l, a, i, r[f + 15], 22, 1236535329), i = k(i, s, l, a, r[f + 1], 5, -165796510), a = k(a, i, s, l, r[f + 6], 9, -1069501632), l = k(l, a, i, s, r[f + 11], 14, 643717713), s = k(s, l, a, i, r[f + 0], 20, -373897302), i = k(i, s, l, a, r[f + 5], 5, -701558691), a = k(a, i, s, l, r[f + 10], 9, 38016083), l = k(l, a, i, s, r[f + 15], 14, -660478335), s = k(s, l, a, i, r[f + 4], 20, -405537848), i = k(i, s, l, a, r[f + 9], 5, 568446438), a = k(a, i, s, l, r[f + 14], 9, -1019803690), l = k(l, a, i, s, r[f + 3], 14, -187363961), s = k(s, l, a, i, r[f + 8], 20, 1163531501), i = k(i, s, l, a, r[f + 13], 5, -1444681467), a = k(a, i, s, l, r[f + 2], 9, -51403784), l = k(l, a, i, s, r[f + 7], 14, 1735328473), s = k(s, l, a, i, r[f + 12], 20, -1926607734), i = S(i, s, l, a, r[f + 5], 4, -378558), a = S(a, i, s, l, r[f + 8], 11, -2022574463), l = S(l, a, i, s, r[f + 11], 16, 1839030562), s = S(s, l, a, i, r[f + 14], 23, -35309556), i = S(i, s, l, a, r[f + 1], 4, -1530992060), a = S(a, i, s, l, r[f + 4], 11, 1272893353), l = S(l, a, i, s, r[f + 7], 16, -155497632), s = S(s, l, a, i, r[f + 10], 23, -1094730640), i = S(i, s, l, a, r[f + 13], 4, 681279174), a = S(a, i, s, l, r[f + 0], 11, -358537222), l = S(l, a, i, s, r[f + 3], 16, -722521979), s = S(s, l, a, i, r[f + 6], 23, 76029189), i = S(i, s, l, a, r[f + 9], 4, -640364487), a = S(a, i, s, l, r[f + 12], 11, -421815835), l = S(l, a, i, s, r[f + 15], 16, 530742520), s = S(s, l, a, i, r[f + 2], 23, -995338651), i = N(i, s, l, a, r[f + 0], 6, -198630844), a = N(a, i, s, l, r[f + 7], 10, 1126891415), l = N(l, a, i, s, r[f + 14], 15, -1416354905), s = N(s, l, a, i, r[f + 5], 21, -57434055), i = N(i, s, l, a, r[f + 12], 6, 1700485571), a = N(a, i, s, l, r[f + 3], 10, -1894986606), l = N(l, a, i, s, r[f + 10], 15, -1051523), s = N(s, l, a, i, r[f + 1], 21, -2054922799), i = N(i, s, l, a, r[f + 8], 6, 1873313359), a = N(a, i, s, l, r[f + 15], 10, -30611744), l = N(l, a, i, s, r[f + 6], 15, -1560198380), s = N(s, l, a, i, r[f + 13], 21, 1309151649), i = N(i, s, l, a, r[f + 4], 6, -145523070), a = N(a, i, s, l, r[f + 11], 10, -1120210379), l = N(l, a, i, s, r[f + 2], 15, 718787259), s = N(s, l, a, i, r[f + 9], 21, -343485551), i = i + J >>> 0, s = s + P >>> 0, l = l + H >>> 0, a = a + X >>> 0;
|
|
141
142
|
}
|
|
142
143
|
return o.endian([i, s, l, a]);
|
|
143
144
|
};
|
|
@@ -153,24 +154,24 @@ function Ue() {
|
|
|
153
154
|
}, c._ii = function(d, h, r, w, i, s, l) {
|
|
154
155
|
var a = d + (r ^ (h | ~w)) + (i >>> 0) + l;
|
|
155
156
|
return (a << s | a >>> 32 - s) + h;
|
|
156
|
-
}, c._blocksize = 16, c._digestsize = 16,
|
|
157
|
+
}, c._blocksize = 16, c._digestsize = 16, yt.exports = function(d, h) {
|
|
157
158
|
if (d == null)
|
|
158
159
|
throw new Error("Illegal argument " + d);
|
|
159
160
|
var r = o.wordsToBytes(c(d, h));
|
|
160
161
|
return h && h.asBytes ? r : h && h.asString ? n.bytesToString(r) : o.bytesToHex(r);
|
|
161
162
|
};
|
|
162
|
-
})()),
|
|
163
|
+
})()), yt.exports;
|
|
163
164
|
}
|
|
164
|
-
var
|
|
165
|
-
const
|
|
166
|
-
var
|
|
165
|
+
var ze = Ve();
|
|
166
|
+
const qe = /* @__PURE__ */ We(ze);
|
|
167
|
+
var ee;
|
|
167
168
|
(function(o) {
|
|
168
169
|
o.Document = "Document", o.DocumentExit = "Document:exit", o.Paragraph = "Paragraph", o.ParagraphExit = "Paragraph:exit", o.BlockQuote = "BlockQuote", o.BlockQuoteExit = "BlockQuote:exit", o.ListItem = "ListItem", o.ListItemExit = "ListItem:exit", o.List = "List", o.ListExit = "List:exit", o.Header = "Header", o.HeaderExit = "Header:exit", o.CodeBlock = "CodeBlock", o.CodeBlockExit = "CodeBlock:exit", o.HtmlBlock = "HtmlBlock", o.HtmlBlockExit = "HtmlBlock:exit", o.HorizontalRule = "HorizontalRule", o.HorizontalRuleExit = "HorizontalRule:exit", o.Comment = "Comment", o.CommentExit = "Comment:exit", o.ReferenceDef = "ReferenceDef", o.ReferenceDefExit = "ReferenceDef:exit", o.Str = "Str", o.StrExit = "Str:exit", o.Break = "Break", o.BreakExit = "Break:exit", o.Emphasis = "Emphasis", o.EmphasisExit = "Emphasis:exit", o.Strong = "Strong", o.StrongExit = "Strong:exit", o.Html = "Html", o.HtmlExit = "Html:exit", o.Link = "Link", o.LinkExit = "Link:exit", o.Image = "Image", o.ImageExit = "Image:exit", o.Code = "Code", o.CodeExit = "Code:exit", o.Delete = "Delete", o.DeleteExit = "Delete:exit", o.Table = "Table", o.TableExit = "Table:exit", o.TableRow = "TableRow", o.TableRowExit = "TableRow:exit", o.TableCell = "TableCell", o.TableCellExit = "TableCell:exit";
|
|
169
|
-
})(
|
|
170
|
-
var
|
|
171
|
-
function
|
|
172
|
-
if (
|
|
173
|
-
|
|
170
|
+
})(ee || (ee = {}));
|
|
171
|
+
var lt = {}, U = {}, re;
|
|
172
|
+
function Ge() {
|
|
173
|
+
if (re) return U;
|
|
174
|
+
re = 1, Object.defineProperty(U, "__esModule", { value: !0 }), U.binarySearch = U.upperBound = U.lowerBound = U.compare = void 0;
|
|
174
175
|
function o(c, d) {
|
|
175
176
|
return c < d;
|
|
176
177
|
}
|
|
@@ -199,11 +200,11 @@ function qe() {
|
|
|
199
200
|
}
|
|
200
201
|
return U.binarySearch = n, U;
|
|
201
202
|
}
|
|
202
|
-
var
|
|
203
|
-
function
|
|
204
|
-
if (
|
|
205
|
-
|
|
206
|
-
const o =
|
|
203
|
+
var ne;
|
|
204
|
+
function Xe() {
|
|
205
|
+
if (ne) return lt;
|
|
206
|
+
ne = 1, Object.defineProperty(lt, "__esModule", { value: !0 }), lt.StructuredSource = void 0;
|
|
207
|
+
const o = Ge();
|
|
207
208
|
class t {
|
|
208
209
|
/**
|
|
209
210
|
* @constructs StructuredSource
|
|
@@ -264,16 +265,16 @@ function Ge() {
|
|
|
264
265
|
};
|
|
265
266
|
}
|
|
266
267
|
}
|
|
267
|
-
return
|
|
268
|
+
return lt.StructuredSource = t, lt;
|
|
268
269
|
}
|
|
269
|
-
var
|
|
270
|
+
var oe = Xe();
|
|
270
271
|
const Ye = (o, t) => {
|
|
271
272
|
for (let e = o.length - 1; e >= 0; e--)
|
|
272
273
|
if (t(o[e], e, o))
|
|
273
274
|
return e;
|
|
274
275
|
return -1;
|
|
275
276
|
};
|
|
276
|
-
class
|
|
277
|
+
class je {
|
|
277
278
|
index = 0;
|
|
278
279
|
source;
|
|
279
280
|
textCharacters;
|
|
@@ -288,12 +289,12 @@ class Xe {
|
|
|
288
289
|
startOffset;
|
|
289
290
|
constructor(t) {
|
|
290
291
|
if (typeof t == "string")
|
|
291
|
-
this.textCharacters = t.split(""), this.source = new
|
|
292
|
+
this.textCharacters = t.split(""), this.source = new oe.StructuredSource(t), this.startOffset = 0, this.firstChildPadding = 0;
|
|
292
293
|
else {
|
|
293
294
|
this.sourceNode = t, this.startOffset = this.sourceNode.range[0], this.index = this.startOffset;
|
|
294
295
|
const e = Array.from(new Array(this.sourceNode.loc.start.line - 1)).fill(`
|
|
295
296
|
`), n = Array.from(new Array(this.startOffset - e.length)).fill("∯"), c = t.raw.split("");
|
|
296
|
-
this.textCharacters = [...e, ...n, ...c], this.source = new
|
|
297
|
+
this.textCharacters = [...e, ...n, ...c], this.source = new oe.StructuredSource(this.textCharacters.join("")), this.sourceNode.children[0] ? this.firstChildPadding = this.sourceNode.children[0].range[0] - this.startOffset : this.firstChildPadding = 0;
|
|
297
298
|
}
|
|
298
299
|
}
|
|
299
300
|
get length() {
|
|
@@ -410,7 +411,7 @@ class Xe {
|
|
|
410
411
|
return this.textCharacters.slice(t, e).join("");
|
|
411
412
|
}
|
|
412
413
|
}
|
|
413
|
-
class
|
|
414
|
+
class Je {
|
|
414
415
|
test(t) {
|
|
415
416
|
const e = t.read();
|
|
416
417
|
return e ? /[\r\n]/.test(e) : !1;
|
|
@@ -420,7 +421,7 @@ class je {
|
|
|
420
421
|
t.peek();
|
|
421
422
|
}
|
|
422
423
|
}
|
|
423
|
-
class
|
|
424
|
+
class Ze {
|
|
424
425
|
test(t) {
|
|
425
426
|
const e = t.read();
|
|
426
427
|
return e ? /[^\S\n\r]/.test(e) : !1;
|
|
@@ -430,7 +431,7 @@ class Je {
|
|
|
430
431
|
t.peek();
|
|
431
432
|
}
|
|
432
433
|
}
|
|
433
|
-
const
|
|
434
|
+
const Qe = {
|
|
434
435
|
separatorCharacters: [
|
|
435
436
|
".",
|
|
436
437
|
// period
|
|
@@ -448,11 +449,11 @@ const Ze = {
|
|
|
448
449
|
// (ja) zenkaku exclamation mark
|
|
449
450
|
]
|
|
450
451
|
};
|
|
451
|
-
class
|
|
452
|
+
class tr {
|
|
452
453
|
options;
|
|
453
454
|
separatorCharacters;
|
|
454
455
|
constructor(t) {
|
|
455
|
-
this.options = t, this.separatorCharacters = t && t.separatorCharacters ? t.separatorCharacters :
|
|
456
|
+
this.options = t, this.separatorCharacters = t && t.separatorCharacters ? t.separatorCharacters : Qe.separatorCharacters;
|
|
456
457
|
}
|
|
457
458
|
test(t) {
|
|
458
459
|
if (t.isInContext() || t.isInContextRange())
|
|
@@ -465,14 +466,14 @@ class Qe {
|
|
|
465
466
|
t.peek();
|
|
466
467
|
}
|
|
467
468
|
}
|
|
468
|
-
const
|
|
469
|
-
function
|
|
470
|
-
|
|
469
|
+
const ae = typeof process == "object" && process?.env?.DEBUG === "sentence-splitter";
|
|
470
|
+
function er(o, t) {
|
|
471
|
+
ae && console.log("sentence-splitter: " + o, t);
|
|
471
472
|
}
|
|
472
|
-
function
|
|
473
|
-
|
|
473
|
+
function ie(...o) {
|
|
474
|
+
ae && console.log("sentence-splitter: ", ...o.map((t) => typeof t == "string" ? t.replace(/\n/g, "\\n") : t));
|
|
474
475
|
}
|
|
475
|
-
class
|
|
476
|
+
class rr {
|
|
476
477
|
parsers;
|
|
477
478
|
markers;
|
|
478
479
|
/**
|
|
@@ -496,10 +497,10 @@ class er {
|
|
|
496
497
|
return e.range[0] <= c && c < e.range[1];
|
|
497
498
|
};
|
|
498
499
|
for (; n() && this.test(t); )
|
|
499
|
-
|
|
500
|
+
er(t.offset, t.read()), this.markers.forEach((c) => c.mark(t)), t.peek();
|
|
500
501
|
}
|
|
501
502
|
}
|
|
502
|
-
const
|
|
503
|
+
const nr = {
|
|
503
504
|
ABBREVIATIONS: [
|
|
504
505
|
"Adj.",
|
|
505
506
|
"Adm.",
|
|
@@ -741,14 +742,14 @@ const rr = {
|
|
|
741
742
|
"Y!J",
|
|
742
743
|
"Yum!"
|
|
743
744
|
]
|
|
744
|
-
},
|
|
745
|
-
language:
|
|
745
|
+
}, Mt = (o) => !o || o.length === 0 ? !1 : new RegExp("^\\p{Uppercase_Letter}", "u").test(o), Nt = (o, t) => o.toLowerCase() === t.toLowerCase(), or = {
|
|
746
|
+
language: nr
|
|
746
747
|
};
|
|
747
|
-
class
|
|
748
|
+
class ir {
|
|
748
749
|
options;
|
|
749
750
|
lang;
|
|
750
751
|
constructor(t) {
|
|
751
|
-
this.options = t, this.lang = t && t.language ? t.language :
|
|
752
|
+
this.options = t, this.lang = t && t.language ? t.language : or.language;
|
|
752
753
|
}
|
|
753
754
|
/**
|
|
754
755
|
* Get Word
|
|
@@ -783,16 +784,16 @@ class or {
|
|
|
783
784
|
return;
|
|
784
785
|
if (/^([a-zA-Z]\.){3,}$/.test(e))
|
|
785
786
|
return t.markContextRange([t.offset, t.offset + e.length]);
|
|
786
|
-
if (this.lang.EXCLAMATION_WORDS.some((i) =>
|
|
787
|
+
if (this.lang.EXCLAMATION_WORDS.some((i) => Nt(i, e)))
|
|
787
788
|
return t.markContextRange([t.offset, t.offset + e.length]);
|
|
788
|
-
const c = this.lang.PREPOSITIVE_ABBREVIATIONS.some((i) =>
|
|
789
|
+
const c = this.lang.PREPOSITIVE_ABBREVIATIONS.some((i) => Nt(i, e)), d = /^\d+\.$/.test(e);
|
|
789
790
|
if (c || d)
|
|
790
791
|
return t.markContextRange([t.offset, t.offset + e.length]);
|
|
791
|
-
const h = this.lang.ABBREVIATIONS.some((i) =>
|
|
792
|
-
|
|
792
|
+
const h = this.lang.ABBREVIATIONS.some((i) => Nt(i, e)), r = this.getPrevWord(t), w = this.getWord(t, e.length + 1);
|
|
793
|
+
Mt(r) && new RegExp("^\\p{Uppercase_Letter}\\.", "u").test(e) && Mt(w) ? t.markContextRange([t.offset, t.offset + e.length]) : h && !Mt(w) && t.markContextRange([t.offset, t.offset + e.length]);
|
|
793
794
|
}
|
|
794
795
|
}
|
|
795
|
-
const
|
|
796
|
+
const sr = [
|
|
796
797
|
{
|
|
797
798
|
key: "double quote",
|
|
798
799
|
start: '"',
|
|
@@ -854,8 +855,8 @@ const ir = [
|
|
|
854
855
|
end: "》"
|
|
855
856
|
}
|
|
856
857
|
];
|
|
857
|
-
class
|
|
858
|
-
PAIR_MARKS_KEY_Map = new Map(
|
|
858
|
+
class cr {
|
|
859
|
+
PAIR_MARKS_KEY_Map = new Map(sr.flatMap((t) => [
|
|
859
860
|
[t.start, t],
|
|
860
861
|
[t.end, t]
|
|
861
862
|
]));
|
|
@@ -864,21 +865,21 @@ class sr {
|
|
|
864
865
|
if (!e)
|
|
865
866
|
return;
|
|
866
867
|
const n = this.PAIR_MARKS_KEY_Map.get(e);
|
|
867
|
-
n && (t.isInContext(n) ? n.end === e && (
|
|
868
|
+
n && (t.isInContext(n) ? n.end === e && (ie(`PairMaker -> leaveContext: ${e} `), t.leaveContext(n)) : n.start === e && (ie(`PairMaker -> enterContext: ${e} `), t.enterContext(n)));
|
|
868
869
|
}
|
|
869
870
|
}
|
|
870
|
-
const
|
|
871
|
+
const mt = {
|
|
871
872
|
WhiteSpace: "WhiteSpace",
|
|
872
873
|
Punctuation: "Punctuation",
|
|
873
874
|
Sentence: "Sentence",
|
|
874
875
|
Str: "Str"
|
|
875
876
|
};
|
|
876
|
-
class
|
|
877
|
+
class ar {
|
|
877
878
|
sentenceNodeList = [];
|
|
878
879
|
results = [];
|
|
879
880
|
source;
|
|
880
881
|
constructor(t) {
|
|
881
|
-
this.source = new
|
|
882
|
+
this.source = new je(t);
|
|
882
883
|
}
|
|
883
884
|
get current() {
|
|
884
885
|
return this.sentenceNodeList[this.sentenceNodeList.length - 1];
|
|
@@ -896,20 +897,20 @@ class cr {
|
|
|
896
897
|
}
|
|
897
898
|
nextLine(t) {
|
|
898
899
|
const { value: e, startPosition: n, endPosition: c } = this.source.seekNext(t);
|
|
899
|
-
return this.pushNodeToCurrent(
|
|
900
|
+
return this.pushNodeToCurrent(se(e, n, c)), c;
|
|
900
901
|
}
|
|
901
902
|
nextSpace(t) {
|
|
902
903
|
const { value: e, startPosition: n, endPosition: c } = this.source.seekNext(t);
|
|
903
|
-
this.pushNodeToCurrent(
|
|
904
|
+
this.pushNodeToCurrent(se(e, n, c));
|
|
904
905
|
}
|
|
905
906
|
nextValue(t) {
|
|
906
907
|
const { value: e, startPosition: n, endPosition: c } = this.source.seekNext(t);
|
|
907
|
-
this.pushNodeToCurrent(
|
|
908
|
+
this.pushNodeToCurrent(fr(e, n, c));
|
|
908
909
|
}
|
|
909
910
|
// close current Node and remove it from list
|
|
910
911
|
close(t) {
|
|
911
912
|
const { value: e, startPosition: n, endPosition: c } = this.source.seekNext(t);
|
|
912
|
-
n.offset !== c.offset && !/^\s+$/.test(e) && this.pushNodeToCurrent(
|
|
913
|
+
n.offset !== c.offset && !/^\s+$/.test(e) && this.pushNodeToCurrent(ur(e, n, c));
|
|
913
914
|
const d = this.sentenceNodeList.pop();
|
|
914
915
|
if (!d || d.children.length === 0)
|
|
915
916
|
return;
|
|
@@ -937,8 +938,8 @@ class cr {
|
|
|
937
938
|
return this.results;
|
|
938
939
|
}
|
|
939
940
|
}
|
|
940
|
-
const
|
|
941
|
-
const t = new
|
|
941
|
+
const lr = (o = {}) => {
|
|
942
|
+
const t = new Je(), e = new Ze(), n = new tr(o.SeparatorParser), c = new ir(o.AbbrMarker), d = new cr(), h = new rr({
|
|
942
943
|
parsers: [t, n],
|
|
943
944
|
markers: [c, d]
|
|
944
945
|
});
|
|
@@ -950,15 +951,15 @@ const ar = (o = {}) => {
|
|
|
950
951
|
anyValueParser: h
|
|
951
952
|
};
|
|
952
953
|
};
|
|
953
|
-
function
|
|
954
|
-
const { newLine: e, space: n, separator: c, anyValueParser: d } =
|
|
954
|
+
function dr(o, t) {
|
|
955
|
+
const { newLine: e, space: n, separator: c, anyValueParser: d } = lr(t), h = new ar(o), r = h.source;
|
|
955
956
|
for (; !r.hasEnd; )
|
|
956
|
-
e.test(r) ? h.nextLine(e) : n.test(r) ? h.nextSpace(n) : c.test(r) ? h.close(c) : (h.isOpened() || h.open(
|
|
957
|
+
e.test(r) ? h.nextLine(e) : n.test(r) ? h.nextSpace(n) : c.test(r) ? h.close(c) : (h.isOpened() || h.open(hr()), h.nextValue(d));
|
|
957
958
|
return h.close(n), h.toList();
|
|
958
959
|
}
|
|
959
|
-
function
|
|
960
|
+
function se(o, t, e) {
|
|
960
961
|
return {
|
|
961
|
-
type:
|
|
962
|
+
type: mt.WhiteSpace,
|
|
962
963
|
raw: o,
|
|
963
964
|
value: o,
|
|
964
965
|
loc: {
|
|
@@ -974,9 +975,9 @@ function oe(o, t, e) {
|
|
|
974
975
|
range: [t.offset, e.offset]
|
|
975
976
|
};
|
|
976
977
|
}
|
|
977
|
-
function
|
|
978
|
+
function ur(o, t, e) {
|
|
978
979
|
return {
|
|
979
|
-
type:
|
|
980
|
+
type: mt.Punctuation,
|
|
980
981
|
raw: o,
|
|
981
982
|
value: o,
|
|
982
983
|
loc: {
|
|
@@ -992,9 +993,9 @@ function dr(o, t, e) {
|
|
|
992
993
|
range: [t.offset, e.offset]
|
|
993
994
|
};
|
|
994
995
|
}
|
|
995
|
-
function
|
|
996
|
+
function fr(o, t, e) {
|
|
996
997
|
return {
|
|
997
|
-
type:
|
|
998
|
+
type: mt.Str,
|
|
998
999
|
raw: o,
|
|
999
1000
|
value: o,
|
|
1000
1001
|
loc: {
|
|
@@ -1010,9 +1011,9 @@ function ur(o, t, e) {
|
|
|
1010
1011
|
range: [t.offset, e.offset]
|
|
1011
1012
|
};
|
|
1012
1013
|
}
|
|
1013
|
-
function
|
|
1014
|
+
function hr() {
|
|
1014
1015
|
return {
|
|
1015
|
-
type:
|
|
1016
|
+
type: mt.Sentence,
|
|
1016
1017
|
raw: "",
|
|
1017
1018
|
loc: {
|
|
1018
1019
|
start: { column: NaN, line: NaN },
|
|
@@ -1023,9 +1024,59 @@ function fr() {
|
|
|
1023
1024
|
contexts: []
|
|
1024
1025
|
};
|
|
1025
1026
|
}
|
|
1026
|
-
const
|
|
1027
|
+
const Ot = st.forwardRef(({ className: o, ...t }, e) => /* @__PURE__ */ v(
|
|
1028
|
+
"div",
|
|
1029
|
+
{
|
|
1030
|
+
ref: e,
|
|
1031
|
+
className: Q(
|
|
1032
|
+
"cteditor-rounded-xl cteditor-border cteditor-bg-card cteditor-text-card-foreground cteditor-shadow",
|
|
1033
|
+
o
|
|
1034
|
+
),
|
|
1035
|
+
...t
|
|
1036
|
+
}
|
|
1037
|
+
));
|
|
1038
|
+
Ot.displayName = "Card";
|
|
1039
|
+
const gr = st.forwardRef(({ className: o, ...t }, e) => /* @__PURE__ */ v(
|
|
1040
|
+
"div",
|
|
1041
|
+
{
|
|
1042
|
+
ref: e,
|
|
1043
|
+
className: Q("cteditor-flex cteditor-flex-col cteditor-space-y-1.5 cteditor-p-6", o),
|
|
1044
|
+
...t
|
|
1045
|
+
}
|
|
1046
|
+
));
|
|
1047
|
+
gr.displayName = "CardHeader";
|
|
1048
|
+
const pr = st.forwardRef(({ className: o, ...t }, e) => /* @__PURE__ */ v(
|
|
1049
|
+
"div",
|
|
1050
|
+
{
|
|
1051
|
+
ref: e,
|
|
1052
|
+
className: Q("cteditor-font-semibold cteditor-leading-none cteditor-tracking-tight", o),
|
|
1053
|
+
...t
|
|
1054
|
+
}
|
|
1055
|
+
));
|
|
1056
|
+
pr.displayName = "CardTitle";
|
|
1057
|
+
const mr = st.forwardRef(({ className: o, ...t }, e) => /* @__PURE__ */ v(
|
|
1058
|
+
"div",
|
|
1059
|
+
{
|
|
1060
|
+
ref: e,
|
|
1061
|
+
className: Q("cteditor-text-sm cteditor-text-muted-foreground", o),
|
|
1062
|
+
...t
|
|
1063
|
+
}
|
|
1064
|
+
));
|
|
1065
|
+
mr.displayName = "CardDescription";
|
|
1066
|
+
const Lt = st.forwardRef(({ className: o, ...t }, e) => /* @__PURE__ */ v("div", { ref: e, className: Q("cteditor-p-6 cteditor-pt-0", o), ...t }));
|
|
1067
|
+
Lt.displayName = "CardContent";
|
|
1068
|
+
const xr = st.forwardRef(({ className: o, ...t }, e) => /* @__PURE__ */ v(
|
|
1069
|
+
"div",
|
|
1070
|
+
{
|
|
1071
|
+
ref: e,
|
|
1072
|
+
className: Q("cteditor-flex cteditor-items-center cteditor-p-6 cteditor-pt-0", o),
|
|
1073
|
+
...t
|
|
1074
|
+
}
|
|
1075
|
+
));
|
|
1076
|
+
xr.displayName = "CardFooter";
|
|
1077
|
+
const Wr = He(
|
|
1027
1078
|
"AUTOCOMPLETE_COMMAND"
|
|
1028
|
-
),
|
|
1079
|
+
), le = "grammarDictionary", wr = [
|
|
1029
1080
|
"javascript",
|
|
1030
1081
|
"typescript",
|
|
1031
1082
|
"lexical",
|
|
@@ -1036,49 +1087,49 @@ const Dr = Te(
|
|
|
1036
1087
|
"navigation",
|
|
1037
1088
|
"development",
|
|
1038
1089
|
"programming"
|
|
1039
|
-
],
|
|
1090
|
+
], Cr = 300 * 1e3, Er = 200, vr = 3e4, yr = { padding: 8 }, dt = {
|
|
1040
1091
|
width: 340,
|
|
1041
1092
|
maxHeight: 280,
|
|
1042
1093
|
padding: 16,
|
|
1043
1094
|
offsetX: 10,
|
|
1044
1095
|
offsetY: 20
|
|
1045
|
-
},
|
|
1096
|
+
}, br = 400, de = () => {
|
|
1046
1097
|
try {
|
|
1047
|
-
const o = localStorage.getItem(
|
|
1098
|
+
const o = localStorage.getItem(le);
|
|
1048
1099
|
return o ? new Set(JSON.parse(o)) : /* @__PURE__ */ new Set();
|
|
1049
1100
|
} catch (o) {
|
|
1050
1101
|
return console.error("Error reading dictionary from localStorage", o), /* @__PURE__ */ new Set();
|
|
1051
1102
|
}
|
|
1052
|
-
},
|
|
1103
|
+
}, kr = (o) => {
|
|
1053
1104
|
try {
|
|
1054
|
-
const t =
|
|
1105
|
+
const t = de();
|
|
1055
1106
|
return t.add(o.toLowerCase()), localStorage.setItem(
|
|
1056
|
-
|
|
1107
|
+
le,
|
|
1057
1108
|
JSON.stringify(Array.from(t))
|
|
1058
1109
|
), t;
|
|
1059
1110
|
} catch (t) {
|
|
1060
1111
|
return console.error("Error saving to dictionary", t), /* @__PURE__ */ new Set();
|
|
1061
1112
|
}
|
|
1062
|
-
},
|
|
1063
|
-
function
|
|
1064
|
-
return
|
|
1113
|
+
}, Rt = (o) => qe(o.trim().toLowerCase());
|
|
1114
|
+
function Sr(o) {
|
|
1115
|
+
return dr(o).filter((e) => e.type === "Sentence").map((e, n) => ({
|
|
1065
1116
|
id: `${n}`,
|
|
1066
1117
|
text: e.raw,
|
|
1067
1118
|
index: n
|
|
1068
1119
|
})).filter((e) => e.text.trim().length > 0);
|
|
1069
1120
|
}
|
|
1070
|
-
const
|
|
1121
|
+
const Mr = (o, t, e, n, c, d, h) => {
|
|
1071
1122
|
const r = window.innerWidth, w = window.innerHeight;
|
|
1072
1123
|
let i = o + c, s = t + d;
|
|
1073
1124
|
return i + e > r - h && (i = o - e - c), i < h && (i = h), s + n > w - h && (s = t - n - d), s < h && (s = h), { left: i, top: s };
|
|
1074
|
-
},
|
|
1125
|
+
}, ce = (o) => {
|
|
1075
1126
|
let t = "";
|
|
1076
1127
|
const e = [];
|
|
1077
1128
|
try {
|
|
1078
1129
|
o.read(() => {
|
|
1079
1130
|
const n = It(), c = (d) => {
|
|
1080
|
-
if (!
|
|
1081
|
-
if (
|
|
1131
|
+
if (!Ie(d)) {
|
|
1132
|
+
if (ut(d)) {
|
|
1082
1133
|
const h = d.getTextContent(), r = t.length;
|
|
1083
1134
|
t += h, e.push({
|
|
1084
1135
|
start: r,
|
|
@@ -1086,7 +1137,7 @@ const vr = (o, t, e, n, c, d, h) => {
|
|
|
1086
1137
|
key: d.getKey(),
|
|
1087
1138
|
text: h
|
|
1088
1139
|
});
|
|
1089
|
-
} else if (
|
|
1140
|
+
} else if (Fe(d)) {
|
|
1090
1141
|
const h = d.getChildren();
|
|
1091
1142
|
for (const r of h)
|
|
1092
1143
|
c(r);
|
|
@@ -1102,19 +1153,19 @@ const vr = (o, t, e, n, c, d, h) => {
|
|
|
1102
1153
|
}
|
|
1103
1154
|
return { fullText: t, nodeMap: e };
|
|
1104
1155
|
};
|
|
1105
|
-
class
|
|
1156
|
+
class Nr {
|
|
1106
1157
|
apiEndpoint;
|
|
1107
|
-
requestTimeout =
|
|
1158
|
+
requestTimeout = vr;
|
|
1108
1159
|
sentenceCache = /* @__PURE__ */ new Map();
|
|
1109
1160
|
constructor(t = "/api/ai/process") {
|
|
1110
|
-
this.apiEndpoint =
|
|
1161
|
+
this.apiEndpoint = Re + t;
|
|
1111
1162
|
}
|
|
1112
1163
|
isSentenceCached(t) {
|
|
1113
|
-
const e =
|
|
1114
|
-
return n && Date.now() - n.checkedAt <
|
|
1164
|
+
const e = Rt(t), n = this.sentenceCache.get(e);
|
|
1165
|
+
return n && Date.now() - n.checkedAt < Cr ? n : (n && this.sentenceCache.delete(e), null);
|
|
1115
1166
|
}
|
|
1116
1167
|
cacheSentence(t, e, n) {
|
|
1117
|
-
const c =
|
|
1168
|
+
const c = Rt(t.text);
|
|
1118
1169
|
if (this.sentenceCache.set(c, {
|
|
1119
1170
|
id: t.id,
|
|
1120
1171
|
text: t.text,
|
|
@@ -1122,7 +1173,7 @@ class yr {
|
|
|
1122
1173
|
isClean: n,
|
|
1123
1174
|
errors: e,
|
|
1124
1175
|
checkedAt: Date.now()
|
|
1125
|
-
}), this.sentenceCache.size >
|
|
1176
|
+
}), this.sentenceCache.size > Er) {
|
|
1126
1177
|
const d = this.sentenceCache.keys().next().value;
|
|
1127
1178
|
d && this.sentenceCache.delete(d);
|
|
1128
1179
|
}
|
|
@@ -1161,36 +1212,36 @@ class yr {
|
|
|
1161
1212
|
if (clearTimeout(i), !s.ok) throw new Error(`Status ${s.status}`);
|
|
1162
1213
|
const a = (await s.json()).data;
|
|
1163
1214
|
a?.results && a.results.forEach((f, M) => {
|
|
1164
|
-
const
|
|
1165
|
-
if (!
|
|
1166
|
-
const S = [],
|
|
1167
|
-
Array.isArray(H) && H.forEach((A,
|
|
1168
|
-
const Z = Number(A.startOffset ?? -1),
|
|
1169
|
-
|
|
1170
|
-
type:
|
|
1215
|
+
const k = r[M];
|
|
1216
|
+
if (!k) return;
|
|
1217
|
+
const S = [], N = f.correctedSentence || k.text, J = (H, X) => {
|
|
1218
|
+
Array.isArray(H) && H.forEach((A, ct) => {
|
|
1219
|
+
const Z = Number(A.startOffset ?? -1), F = Number(A.endOffset ?? Z);
|
|
1220
|
+
X === "spelling" && F <= Z || A.original && S.push({
|
|
1221
|
+
type: X,
|
|
1171
1222
|
original: A.original,
|
|
1172
1223
|
suggestions: A.suggestions || (A.suggestion ? [A.suggestion] : []),
|
|
1173
|
-
index:
|
|
1224
|
+
index: X === "grammar" ? 1e3 + ct : ct,
|
|
1174
1225
|
issue: A.issue,
|
|
1175
1226
|
severity: A.severity,
|
|
1176
|
-
sentenceId:
|
|
1177
|
-
sentenceIndex:
|
|
1178
|
-
originalSentence:
|
|
1179
|
-
correctedSentence:
|
|
1227
|
+
sentenceId: k.id,
|
|
1228
|
+
sentenceIndex: k.index,
|
|
1229
|
+
originalSentence: k.text,
|
|
1230
|
+
correctedSentence: N,
|
|
1180
1231
|
wordPosition: A.wordPosition ?? 0
|
|
1181
1232
|
});
|
|
1182
1233
|
});
|
|
1183
1234
|
};
|
|
1184
1235
|
J(f.errors?.spelling, "spelling"), J(f.errors?.grammar, "grammar");
|
|
1185
1236
|
const P = {
|
|
1186
|
-
id:
|
|
1187
|
-
text:
|
|
1188
|
-
hash:
|
|
1237
|
+
id: k.id,
|
|
1238
|
+
text: k.text,
|
|
1239
|
+
hash: Rt(k.text),
|
|
1189
1240
|
isClean: S.length === 0,
|
|
1190
1241
|
errors: S,
|
|
1191
1242
|
checkedAt: Date.now()
|
|
1192
1243
|
};
|
|
1193
|
-
this.cacheSentence(
|
|
1244
|
+
this.cacheSentence(k, S, S.length === 0), n?.(P), d.push(P), c?.(h + M + 1, t.length);
|
|
1194
1245
|
});
|
|
1195
1246
|
} catch {
|
|
1196
1247
|
}
|
|
@@ -1204,7 +1255,7 @@ class yr {
|
|
|
1204
1255
|
};
|
|
1205
1256
|
}
|
|
1206
1257
|
}
|
|
1207
|
-
function
|
|
1258
|
+
function $r({
|
|
1208
1259
|
onQueryChange: o,
|
|
1209
1260
|
onSelectOption: t,
|
|
1210
1261
|
minMatchLength: e = 2,
|
|
@@ -1213,28 +1264,28 @@ function _r({
|
|
|
1213
1264
|
enableAI: d = !0,
|
|
1214
1265
|
debounceDelay: h = 800
|
|
1215
1266
|
}) {
|
|
1216
|
-
const [r] =
|
|
1217
|
-
}), A = B(0),
|
|
1218
|
-
}), Z = B(/* @__PURE__ */ new Set()), [
|
|
1267
|
+
const [r] = Oe(), { toolbarState: w, updateToolbarState: i } = ye(), { isHtmlView: s } = be(), l = B([]), a = B(new Nr(c)), f = B(), M = B(""), k = B(null), S = B(null), N = B(null), J = B(!1), P = B(null), H = B(null), X = B(() => {
|
|
1268
|
+
}), A = B(0), ct = B(async () => {
|
|
1269
|
+
}), Z = B(/* @__PURE__ */ new Set()), [F, tt] = q(null), [W, et] = q([]), [ft, rt] = q(0), [At, ue] = q(
|
|
1219
1270
|
null
|
|
1220
|
-
), [
|
|
1271
|
+
), [xt, V] = q([]), [Rr, z] = q(/* @__PURE__ */ new Map()), [Ir, nt] = q(
|
|
1221
1272
|
/* @__PURE__ */ new Set()
|
|
1222
|
-
), [
|
|
1273
|
+
), [Bt, fe] = q(/* @__PURE__ */ new Set()), [Or, he] = q(
|
|
1223
1274
|
/* @__PURE__ */ new Set()
|
|
1224
|
-
), [
|
|
1275
|
+
), [wt, $] = q(null), ot = ke() ?? null;
|
|
1225
1276
|
T(() => {
|
|
1226
|
-
Z.current =
|
|
1277
|
+
Z.current = de();
|
|
1227
1278
|
}, []);
|
|
1228
|
-
const
|
|
1229
|
-
const u = new Set(
|
|
1279
|
+
const Pt = G(() => {
|
|
1280
|
+
const u = new Set(wr);
|
|
1230
1281
|
return r.getEditorState().read(() => {
|
|
1231
1282
|
const E = It().getTextContent().match(/\b[a-zA-Z][a-zA-Z0-9_]*\b/g);
|
|
1232
1283
|
E && E.forEach((x) => {
|
|
1233
1284
|
x.length >= e && u.add(x);
|
|
1234
1285
|
});
|
|
1235
1286
|
}), Array.from(u);
|
|
1236
|
-
}, [r, e]),
|
|
1237
|
-
(u) => !u || u.length < e ? [] :
|
|
1287
|
+
}, [r, e]), Dt = G(
|
|
1288
|
+
(u) => !u || u.length < e ? [] : Pt().filter(
|
|
1238
1289
|
(m) => m.toLowerCase().startsWith(u.toLowerCase()) && m.toLowerCase() !== u.toLowerCase()
|
|
1239
1290
|
).slice(0, n).map((m) => ({
|
|
1240
1291
|
displayText: m,
|
|
@@ -1244,28 +1295,28 @@ function _r({
|
|
|
1244
1295
|
type: "suggestion",
|
|
1245
1296
|
confidence: "low"
|
|
1246
1297
|
})),
|
|
1247
|
-
[
|
|
1248
|
-
),
|
|
1249
|
-
|
|
1250
|
-
}, []),
|
|
1298
|
+
[Pt, e, n]
|
|
1299
|
+
), _t = G(() => {
|
|
1300
|
+
tt(null);
|
|
1301
|
+
}, []), ht = G(async () => {
|
|
1251
1302
|
if (!w.isAutocompleteEnabled || !d) {
|
|
1252
|
-
V([]), z(/* @__PURE__ */ new Map()),
|
|
1303
|
+
V([]), z(/* @__PURE__ */ new Map()), nt(/* @__PURE__ */ new Set());
|
|
1253
1304
|
return;
|
|
1254
1305
|
}
|
|
1255
|
-
const { fullText: u, nodeMap: m } =
|
|
1306
|
+
const { fullText: u, nodeMap: m } = ce(r.getEditorState());
|
|
1256
1307
|
if (!u) return;
|
|
1257
1308
|
if (l.current = m, u.trim().length < 3) {
|
|
1258
|
-
V([]), z(/* @__PURE__ */ new Map()),
|
|
1309
|
+
V([]), z(/* @__PURE__ */ new Map()), nt(/* @__PURE__ */ new Set());
|
|
1259
1310
|
return;
|
|
1260
1311
|
}
|
|
1261
1312
|
M.current = u;
|
|
1262
|
-
const E =
|
|
1313
|
+
const E = Sr(u);
|
|
1263
1314
|
if (E.length === 0) return;
|
|
1264
1315
|
const x = ++A.current, p = new Set(E.map((g) => g.id));
|
|
1265
|
-
|
|
1316
|
+
nt(new Set(E.map((g) => g.id))), z((g) => {
|
|
1266
1317
|
const C = /* @__PURE__ */ new Map();
|
|
1267
|
-
return g.forEach((
|
|
1268
|
-
p.has(
|
|
1318
|
+
return g.forEach((y, b) => {
|
|
1319
|
+
p.has(b) && C.set(b, y);
|
|
1269
1320
|
}), C;
|
|
1270
1321
|
});
|
|
1271
1322
|
try {
|
|
@@ -1274,73 +1325,73 @@ function _r({
|
|
|
1274
1325
|
n,
|
|
1275
1326
|
(g) => {
|
|
1276
1327
|
if (A.current !== x) return;
|
|
1277
|
-
|
|
1278
|
-
const
|
|
1279
|
-
return
|
|
1328
|
+
nt((y) => {
|
|
1329
|
+
const b = new Set(y);
|
|
1330
|
+
return b.delete(g.id), b;
|
|
1280
1331
|
});
|
|
1281
|
-
const C = g.errors.filter((
|
|
1282
|
-
const
|
|
1283
|
-
|
|
1332
|
+
const C = g.errors.filter((y) => {
|
|
1333
|
+
const b = `${y.sentenceId}-${y.original.toLowerCase()}`, I = Bt.has(b), K = Z.current.has(
|
|
1334
|
+
y.original.toLowerCase()
|
|
1284
1335
|
);
|
|
1285
|
-
return !
|
|
1336
|
+
return !I && !K;
|
|
1286
1337
|
});
|
|
1287
|
-
z((
|
|
1288
|
-
const
|
|
1289
|
-
return C.length > 0 ?
|
|
1290
|
-
}), V((
|
|
1291
|
-
(
|
|
1338
|
+
z((y) => {
|
|
1339
|
+
const b = new Map(y);
|
|
1340
|
+
return C.length > 0 ? b.set(g.id, C) : b.delete(g.id), b;
|
|
1341
|
+
}), V((y) => [...y.filter(
|
|
1342
|
+
(I) => I.sentenceId !== g.id
|
|
1292
1343
|
), ...C]);
|
|
1293
1344
|
}
|
|
1294
1345
|
);
|
|
1295
1346
|
} catch {
|
|
1296
|
-
A.current === x && (V([]), z(/* @__PURE__ */ new Map()),
|
|
1347
|
+
A.current === x && (V([]), z(/* @__PURE__ */ new Map()), nt(/* @__PURE__ */ new Set()));
|
|
1297
1348
|
}
|
|
1298
|
-
}, [r, w, d, n,
|
|
1349
|
+
}, [r, w, d, n, Bt]);
|
|
1299
1350
|
T(() => {
|
|
1300
|
-
|
|
1351
|
+
ct.current = ht;
|
|
1301
1352
|
});
|
|
1302
|
-
const
|
|
1353
|
+
const gt = G(
|
|
1303
1354
|
(u) => {
|
|
1304
|
-
|
|
1305
|
-
const m =
|
|
1306
|
-
if (!
|
|
1355
|
+
et((m) => m.filter((E) => E.key !== u.key)), rt(0), J.current = !0, r.update(() => {
|
|
1356
|
+
const m = zt();
|
|
1357
|
+
if (!qt(m)) return;
|
|
1307
1358
|
const E = m.anchor, x = E.getNode(), p = x.getTextContent(), g = E.offset;
|
|
1308
1359
|
let C = g;
|
|
1309
1360
|
for (; C > 0 && /[a-zA-Z0-9_']/.test(p[C - 1]); )
|
|
1310
1361
|
C--;
|
|
1311
|
-
if (
|
|
1312
|
-
const
|
|
1313
|
-
x.setTextContent(
|
|
1314
|
-
const
|
|
1315
|
-
m.anchor.set(x.getKey(),
|
|
1362
|
+
if (ut(x)) {
|
|
1363
|
+
const y = p.slice(0, C) + u.displayText + p.slice(g);
|
|
1364
|
+
x.setTextContent(y);
|
|
1365
|
+
const b = C + u.displayText.length;
|
|
1366
|
+
m.anchor.set(x.getKey(), b, "text"), m.focus.set(x.getKey(), b, "text");
|
|
1316
1367
|
}
|
|
1317
|
-
}), M.current = "",
|
|
1368
|
+
}), M.current = "", tt(null), et([]), t?.(u, null, () => tt(null)), setTimeout(ht, 500);
|
|
1318
1369
|
},
|
|
1319
|
-
[r, t,
|
|
1320
|
-
),
|
|
1370
|
+
[r, t, ht]
|
|
1371
|
+
), ge = G(
|
|
1321
1372
|
(u, m) => {
|
|
1322
1373
|
const E = m.sentenceId || "";
|
|
1323
1374
|
z((x) => {
|
|
1324
|
-
const p = new Map(x), C = (p.get(E) || []).filter((
|
|
1375
|
+
const p = new Map(x), C = (p.get(E) || []).filter((y) => y !== m);
|
|
1325
1376
|
return C.length > 0 ? p.set(E, C) : p.delete(E), p;
|
|
1326
1377
|
}), V((x) => x.filter((p) => p !== m)), $(null), r.update(() => {
|
|
1327
|
-
const { fullText: x, nodeMap: p } =
|
|
1378
|
+
const { fullText: x, nodeMap: p } = ce(
|
|
1328
1379
|
r.getEditorState()
|
|
1329
1380
|
);
|
|
1330
1381
|
let g = x.indexOf(m.originalSentence || "");
|
|
1331
1382
|
if (g === -1 && (g = x.indexOf(m.original)), g === -1) return;
|
|
1332
1383
|
const C = x.substring(g).indexOf(m.original);
|
|
1333
1384
|
if (C === -1) return;
|
|
1334
|
-
const
|
|
1335
|
-
(O) =>
|
|
1385
|
+
const y = g + C, b = y + m.original.length, I = p.find(
|
|
1386
|
+
(O) => y >= O.start && y < O.end
|
|
1336
1387
|
), K = p.find(
|
|
1337
|
-
(O) =>
|
|
1388
|
+
(O) => b > O.start && b <= O.end
|
|
1338
1389
|
);
|
|
1339
|
-
if (
|
|
1340
|
-
const O =
|
|
1341
|
-
if (
|
|
1342
|
-
const D =
|
|
1343
|
-
D.anchor.set(O.getKey(),
|
|
1390
|
+
if (I && K) {
|
|
1391
|
+
const O = Gt(I.key), Y = Gt(K.key);
|
|
1392
|
+
if (ut(O) && ut(Y)) {
|
|
1393
|
+
const D = Le(), it = y - I.start, Wt = b - K.start;
|
|
1394
|
+
D.anchor.set(O.getKey(), it, "text"), D.focus.set(Y.getKey(), Wt, "text"), Ae(D), D.insertText(u);
|
|
1344
1395
|
}
|
|
1345
1396
|
}
|
|
1346
1397
|
}), V(
|
|
@@ -1354,9 +1405,9 @@ function _r({
|
|
|
1354
1405
|
), window.dispatchEvent(new Event("customUpdateHighlights"));
|
|
1355
1406
|
},
|
|
1356
1407
|
[r]
|
|
1357
|
-
),
|
|
1408
|
+
), pe = G(
|
|
1358
1409
|
(u, m, E) => {
|
|
1359
|
-
|
|
1410
|
+
he((x) => new Set(x).add(E)), z((x) => {
|
|
1360
1411
|
const p = new Map(x);
|
|
1361
1412
|
return p.delete(E), p;
|
|
1362
1413
|
}), V((x) => x.filter((p) => p.sentenceId !== E)), $(null), r.update(() => {
|
|
@@ -1364,37 +1415,37 @@ function _r({
|
|
|
1364
1415
|
let p = !1;
|
|
1365
1416
|
const g = (C) => {
|
|
1366
1417
|
if (p) return !0;
|
|
1367
|
-
if (
|
|
1368
|
-
const
|
|
1369
|
-
if (
|
|
1370
|
-
const K =
|
|
1418
|
+
if (ut(C)) {
|
|
1419
|
+
const b = C.getTextContent(), I = b.toLowerCase().indexOf(m.toLowerCase());
|
|
1420
|
+
if (I !== -1) {
|
|
1421
|
+
const K = b.substring(0, I) + u + b.substring(I + m.length);
|
|
1371
1422
|
return C.setTextContent(K), p = !0, !0;
|
|
1372
1423
|
}
|
|
1373
1424
|
}
|
|
1374
|
-
const
|
|
1375
|
-
for (const
|
|
1376
|
-
if (g(
|
|
1425
|
+
const y = C.getChildren ? C.getChildren() : [];
|
|
1426
|
+
for (const b of y)
|
|
1427
|
+
if (g(b)) return !0;
|
|
1377
1428
|
return !1;
|
|
1378
1429
|
};
|
|
1379
1430
|
g(x);
|
|
1380
1431
|
});
|
|
1381
1432
|
},
|
|
1382
1433
|
[r]
|
|
1383
|
-
),
|
|
1434
|
+
), Tt = G((u) => {
|
|
1384
1435
|
const m = `${u.sentenceId}-${u.original.toLowerCase()}`, E = u.sentenceId || "";
|
|
1385
|
-
|
|
1436
|
+
fe((x) => new Set(x).add(m)), z((x) => {
|
|
1386
1437
|
const p = new Map(x), C = (p.get(E) || []).filter(
|
|
1387
|
-
(
|
|
1438
|
+
(y) => y.original !== u.original
|
|
1388
1439
|
);
|
|
1389
1440
|
return C.length > 0 ? p.set(E, C) : p.delete(E), p;
|
|
1390
1441
|
}), V((x) => x.filter((p) => p.original !== u.original)), $(null);
|
|
1391
|
-
}, []),
|
|
1392
|
-
const m =
|
|
1442
|
+
}, []), Ht = G((u) => {
|
|
1443
|
+
const m = kr(u.original);
|
|
1393
1444
|
Z.current = m;
|
|
1394
1445
|
const E = u.sentenceId || "";
|
|
1395
1446
|
z((x) => {
|
|
1396
1447
|
const p = new Map(x), C = (p.get(E) || []).filter(
|
|
1397
|
-
(
|
|
1448
|
+
(y) => y.original.toLowerCase() !== u.original.toLowerCase()
|
|
1398
1449
|
);
|
|
1399
1450
|
return C.length > 0 ? p.set(E, C) : p.delete(E), p;
|
|
1400
1451
|
}), V(
|
|
@@ -1402,67 +1453,67 @@ function _r({
|
|
|
1402
1453
|
(p) => p.original.toLowerCase() !== u.original.toLowerCase()
|
|
1403
1454
|
)
|
|
1404
1455
|
), $(null), window.dispatchEvent(new Event("customUpdateHighlights"));
|
|
1405
|
-
}, []),
|
|
1456
|
+
}, []), Ft = G(() => {
|
|
1406
1457
|
S.current && r.getEditorState().read(() => {
|
|
1407
|
-
const u =
|
|
1408
|
-
if (!
|
|
1458
|
+
const u = zt();
|
|
1459
|
+
if (!qt(u)) return;
|
|
1409
1460
|
const m = window.getSelection()?.getRangeAt(0);
|
|
1410
1461
|
if (!m) return;
|
|
1411
1462
|
const E = m.getBoundingClientRect(), x = S.current;
|
|
1412
1463
|
if (!x) return;
|
|
1413
|
-
const p = E.bottom + window.scrollY +
|
|
1464
|
+
const p = E.bottom + window.scrollY + yr.padding, g = E.left + window.scrollX;
|
|
1414
1465
|
x.style.top = `${p}px`, x.style.left = `${g}px`;
|
|
1415
1466
|
});
|
|
1416
1467
|
}, [r]);
|
|
1417
1468
|
T(() => {
|
|
1418
1469
|
M.current = "";
|
|
1419
1470
|
}, []), T(() => {
|
|
1420
|
-
w.isAutocompleteEnabled ?
|
|
1421
|
-
}, [w.isAutocompleteEnabled]), T(() => (
|
|
1422
|
-
|
|
1423
|
-
}, h) : (
|
|
1424
|
-
|
|
1425
|
-
}), [
|
|
1426
|
-
if (!
|
|
1471
|
+
w.isAutocompleteEnabled ? ht() : (tt(null), et([]), V([]), z(/* @__PURE__ */ new Map()), nt(/* @__PURE__ */ new Set()));
|
|
1472
|
+
}, [w.isAutocompleteEnabled]), T(() => (N.current && clearTimeout(N.current), F && !J.current ? N.current = window.setTimeout(() => {
|
|
1473
|
+
et(Dt(F)), rt(0), o?.(F);
|
|
1474
|
+
}, h) : (et([]), rt(0), o?.(null)), () => {
|
|
1475
|
+
N.current && clearTimeout(N.current);
|
|
1476
|
+
}), [F, Dt, o, h]), T(() => {
|
|
1477
|
+
if (!F || W.length === 0) return;
|
|
1427
1478
|
const u = r.registerCommand(
|
|
1428
|
-
Ae,
|
|
1429
|
-
(g) => (g?.preventDefault(), et((C) => (C + 1) % F.length), !0),
|
|
1430
|
-
st
|
|
1431
|
-
), m = r.registerCommand(
|
|
1432
1479
|
Be,
|
|
1433
|
-
(g) => (g?.preventDefault(),
|
|
1434
|
-
|
|
1480
|
+
(g) => (g?.preventDefault(), rt((C) => (C + 1) % W.length), !0),
|
|
1481
|
+
at
|
|
1482
|
+
), m = r.registerCommand(
|
|
1483
|
+
Pe,
|
|
1484
|
+
(g) => (g?.preventDefault(), rt(
|
|
1485
|
+
(C) => (C - 1 + W.length) % W.length
|
|
1435
1486
|
), !0),
|
|
1436
|
-
|
|
1487
|
+
at
|
|
1437
1488
|
), E = r.registerCommand(
|
|
1438
|
-
Pe,
|
|
1439
|
-
(g) => (g?.preventDefault(), Q(null), !0),
|
|
1440
|
-
st
|
|
1441
|
-
), x = r.registerCommand(
|
|
1442
1489
|
De,
|
|
1443
|
-
(g) => (g?.preventDefault(),
|
|
1444
|
-
|
|
1445
|
-
),
|
|
1490
|
+
(g) => (g?.preventDefault(), tt(null), !0),
|
|
1491
|
+
at
|
|
1492
|
+
), x = r.registerCommand(
|
|
1446
1493
|
_e,
|
|
1447
|
-
(g) => (g?.preventDefault(),
|
|
1448
|
-
|
|
1494
|
+
(g) => (g?.preventDefault(), gt(W[ft]), !0),
|
|
1495
|
+
at
|
|
1496
|
+
), p = r.registerCommand(
|
|
1497
|
+
Te,
|
|
1498
|
+
(g) => (g?.preventDefault(), gt(W[ft]), !0),
|
|
1499
|
+
at
|
|
1449
1500
|
);
|
|
1450
1501
|
return () => {
|
|
1451
1502
|
u(), m(), E(), x(), p();
|
|
1452
1503
|
};
|
|
1453
|
-
}, [r,
|
|
1454
|
-
u.read(() => setTimeout(
|
|
1455
|
-
}), [r,
|
|
1456
|
-
|
|
1457
|
-
}, [
|
|
1504
|
+
}, [r, F, W, ft, gt]), T(() => r.registerUpdateListener(({ editorState: u }) => {
|
|
1505
|
+
u.read(() => setTimeout(_t, 0));
|
|
1506
|
+
}), [r, _t]), T(() => {
|
|
1507
|
+
F && W.length > 0 && Ft();
|
|
1508
|
+
}, [F, W, Ft]), T(() => {
|
|
1458
1509
|
const u = document.createElement("div");
|
|
1459
|
-
return u.style.position = "absolute", u.style.zIndex = "1000", document.body.appendChild(u), S.current = u,
|
|
1510
|
+
return u.style.position = "absolute", u.style.zIndex = "1000", document.body.appendChild(u), S.current = u, ue(u), () => {
|
|
1460
1511
|
S.current && document.body.removeChild(S.current);
|
|
1461
1512
|
};
|
|
1462
1513
|
}, []), T(() => {
|
|
1463
1514
|
if (!w.isAutocompleteEnabled) return;
|
|
1464
1515
|
const u = r.registerUpdateListener(() => {
|
|
1465
|
-
clearTimeout(f.current), f.current = window.setTimeout(() =>
|
|
1516
|
+
clearTimeout(f.current), f.current = window.setTimeout(() => ct.current(), 1e3);
|
|
1466
1517
|
});
|
|
1467
1518
|
return () => {
|
|
1468
1519
|
u(), clearTimeout(f.current);
|
|
@@ -1480,41 +1531,41 @@ function _r({
|
|
|
1480
1531
|
document.querySelectorAll(".grammar-error-highlight").forEach((g) => g.remove());
|
|
1481
1532
|
return;
|
|
1482
1533
|
}
|
|
1483
|
-
if (document.querySelectorAll(".grammar-error-highlight").forEach((g) => g.remove()),
|
|
1534
|
+
if (document.querySelectorAll(".grammar-error-highlight").forEach((g) => g.remove()), xt.length === 0) return;
|
|
1484
1535
|
const x = l.current, p = M.current;
|
|
1485
|
-
|
|
1536
|
+
xt.forEach((g) => {
|
|
1486
1537
|
if (Z.current.has(g.original.toLowerCase()))
|
|
1487
1538
|
return;
|
|
1488
1539
|
let C = p.indexOf(g.originalSentence || "");
|
|
1489
1540
|
if (C === -1 && (C = p.indexOf(g.original)), C === -1) return;
|
|
1490
|
-
const
|
|
1541
|
+
const y = p.substring(C), b = g.original.replace(
|
|
1491
1542
|
/[.*+?^${}()|[\]\\]/g,
|
|
1492
1543
|
"\\$&"
|
|
1493
|
-
),
|
|
1494
|
-
if (!
|
|
1544
|
+
), I = new RegExp(`\\b${b}\\b`, "g");
|
|
1545
|
+
if (!I.test(p))
|
|
1495
1546
|
return;
|
|
1496
|
-
|
|
1497
|
-
const K = new RegExp(`\\b${
|
|
1498
|
-
if (
|
|
1499
|
-
const D = C +
|
|
1547
|
+
I.lastIndex = 0;
|
|
1548
|
+
const K = new RegExp(`\\b${b}\\b`), O = y.match(K), Y = O ? O.index : -1;
|
|
1549
|
+
if (Y === void 0 || Y === -1) return;
|
|
1550
|
+
const D = C + Y, it = D + g.original.length;
|
|
1500
1551
|
x.filter(
|
|
1501
|
-
(_) => _.start <= D && _.end > D || _.start <
|
|
1552
|
+
(_) => _.start <= D && _.end > D || _.start < it && _.end >= it || _.start >= D && _.end <= it
|
|
1502
1553
|
).forEach((_) => {
|
|
1503
|
-
const
|
|
1504
|
-
if (
|
|
1505
|
-
const
|
|
1506
|
-
if (!
|
|
1507
|
-
const
|
|
1508
|
-
if (!
|
|
1509
|
-
const
|
|
1554
|
+
const we = Math.max(_.start, D), Ce = Math.min(_.end, it), $t = we - _.start, Kt = Ce - _.start;
|
|
1555
|
+
if (Kt <= $t) return;
|
|
1556
|
+
const Ut = r.getElementByKey(_.key);
|
|
1557
|
+
if (!Ut) return;
|
|
1558
|
+
const pt = Ut.firstChild;
|
|
1559
|
+
if (!pt || pt.nodeType !== Node.TEXT_NODE) return;
|
|
1560
|
+
const Ct = document.createRange();
|
|
1510
1561
|
try {
|
|
1511
|
-
|
|
1512
|
-
const
|
|
1513
|
-
for (let
|
|
1514
|
-
const j =
|
|
1562
|
+
Ct.setStart(pt, $t), Ct.setEnd(pt, Kt);
|
|
1563
|
+
const Et = Ct.getClientRects();
|
|
1564
|
+
for (let vt = 0; vt < Et.length; vt++) {
|
|
1565
|
+
const j = Et[vt];
|
|
1515
1566
|
if (j.width === 0 || j.height === 0) continue;
|
|
1516
|
-
const
|
|
1517
|
-
|
|
1567
|
+
const R = document.createElement("div");
|
|
1568
|
+
R.className = "grammar-error-highlight", R.style.position = "absolute", R.style.left = `${j.left + window.scrollX}px`, R.style.top = `${j.bottom + window.scrollY - 8}px`, R.style.width = `${j.width}px`, R.style.height = "2px", R.style.paddingTop = "3px", R.style.paddingBottom = "3px", R.style.zIndex = "10", R.style.cursor = "pointer", R.style.pointerEvents = "auto", R.style.boxSizing = "content-box", g.type === "grammar" ? (R.style.backgroundColor = "rgba(59, 130, 246, 0.1)", R.style.borderBottom = "2.5px solid #3b82f6") : (R.style.backgroundColor = "rgba(239, 68, 68, 0.1)", R.style.borderBottom = "2.5px solid #ef4444"), R.onmouseenter = () => {
|
|
1518
1569
|
P.current && (clearTimeout(P.current), P.current = null), H.current && clearTimeout(H.current), H.current = window.setTimeout(() => {
|
|
1519
1570
|
$({
|
|
1520
1571
|
error: g,
|
|
@@ -1524,48 +1575,48 @@ function _r({
|
|
|
1524
1575
|
isLocked: !1
|
|
1525
1576
|
});
|
|
1526
1577
|
}, 200);
|
|
1527
|
-
},
|
|
1578
|
+
}, R.onmouseleave = () => {
|
|
1528
1579
|
H.current && (clearTimeout(H.current), H.current = null), P.current = window.setTimeout(() => {
|
|
1529
1580
|
$(null);
|
|
1530
1581
|
}, 400);
|
|
1531
|
-
}, document.body.appendChild(
|
|
1582
|
+
}, document.body.appendChild(R);
|
|
1532
1583
|
}
|
|
1533
1584
|
} catch {
|
|
1534
1585
|
}
|
|
1535
1586
|
});
|
|
1536
1587
|
});
|
|
1537
1588
|
};
|
|
1538
|
-
return
|
|
1539
|
-
window.removeEventListener("scroll", u, !0), window.removeEventListener("resize", u), window.removeEventListener("customUpdateHighlights", u), document.querySelectorAll(".grammar-error-highlight").forEach((m) => m.remove()),
|
|
1589
|
+
return X.current = u, window.addEventListener("scroll", u, !0), window.addEventListener("resize", u), window.addEventListener("customUpdateHighlights", u), requestAnimationFrame(u), () => {
|
|
1590
|
+
window.removeEventListener("scroll", u, !0), window.removeEventListener("resize", u), window.removeEventListener("customUpdateHighlights", u), document.querySelectorAll(".grammar-error-highlight").forEach((m) => m.remove()), X.current = () => {
|
|
1540
1591
|
};
|
|
1541
1592
|
};
|
|
1542
|
-
}, [
|
|
1593
|
+
}, [xt, r, s]), T(() => {
|
|
1543
1594
|
const u = (m) => {
|
|
1544
1595
|
const E = m.target;
|
|
1545
|
-
|
|
1596
|
+
k.current?.contains(E) || document.querySelector(".grammar-tooltip-card")?.contains(E) || (tt(null), et([]), $(null));
|
|
1546
1597
|
};
|
|
1547
1598
|
return document.addEventListener("mousedown", u), () => document.removeEventListener("mousedown", u);
|
|
1548
1599
|
}, []);
|
|
1549
|
-
const
|
|
1550
|
-
if (!
|
|
1551
|
-
const { error: u, x: m, y: E } =
|
|
1600
|
+
const me = () => {
|
|
1601
|
+
if (!wt || !wt.isVisible) return null;
|
|
1602
|
+
const { error: u, x: m, y: E } = wt, x = !!ot, p = ot?.getBoundingClientRect(), { left: g, top: C } = Mr(
|
|
1552
1603
|
m,
|
|
1553
1604
|
E,
|
|
1554
|
-
|
|
1555
|
-
|
|
1556
|
-
|
|
1557
|
-
|
|
1558
|
-
|
|
1605
|
+
dt.width,
|
|
1606
|
+
dt.maxHeight,
|
|
1607
|
+
dt.offsetX,
|
|
1608
|
+
dt.offsetY,
|
|
1609
|
+
dt.padding
|
|
1559
1610
|
);
|
|
1560
|
-
let
|
|
1561
|
-
x && p &&
|
|
1562
|
-
const K = /* @__PURE__ */
|
|
1611
|
+
let y, b, I;
|
|
1612
|
+
x && p && ot ? (I = "absolute", y = g - p.left + ot.scrollLeft, b = C - p.top + ot.scrollTop) : (I = "fixed", y = g, b = C);
|
|
1613
|
+
const K = /* @__PURE__ */ v(
|
|
1563
1614
|
"div",
|
|
1564
1615
|
{
|
|
1565
|
-
className:
|
|
1616
|
+
className: I === "fixed" ? "cteditor-fixed cteditor-z-[10001]" : "cteditor-absolute cteditor-z-[10001]",
|
|
1566
1617
|
style: {
|
|
1567
|
-
top: `${
|
|
1568
|
-
left: `${
|
|
1618
|
+
top: `${b}px`,
|
|
1619
|
+
left: `${y}px`,
|
|
1569
1620
|
animation: "fadeIn 0.2s ease-out",
|
|
1570
1621
|
pointerEvents: "auto",
|
|
1571
1622
|
paddingTop: "10px"
|
|
@@ -1576,17 +1627,17 @@ function _r({
|
|
|
1576
1627
|
onMouseLeave: () => {
|
|
1577
1628
|
P.current = window.setTimeout(() => {
|
|
1578
1629
|
$(null);
|
|
1579
|
-
},
|
|
1630
|
+
}, br);
|
|
1580
1631
|
},
|
|
1581
|
-
children: /* @__PURE__ */
|
|
1632
|
+
children: /* @__PURE__ */ v(Ot, { className: "cteditor-w-[340px] cteditor-max-w-[calc(100vw-32px)] cteditor-shadow-2xl cteditor-border cteditor-border-foreground/15 cteditor-bg-grammar-tooltip-bg grammar-tooltip-card cteditor-overflow-hidden cteditor-relative", children: /* @__PURE__ */ L(Lt, { className: "!cteditor-p-4 sm:!cteditor-p-5 cteditor-space-y-3 cteditor-font-geist", children: [
|
|
1582
1633
|
/* @__PURE__ */ L("div", { className: "cteditor-flex cteditor-items-start cteditor-justify-between cteditor-gap-2 ", children: [
|
|
1583
1634
|
/* @__PURE__ */ L("div", { className: "cteditor-flex cteditor-items-center cteditor-gap-2 cteditor-min-w-0 cteditor-flex-1", children: [
|
|
1584
|
-
/* @__PURE__ */
|
|
1635
|
+
/* @__PURE__ */ v(
|
|
1585
1636
|
"div",
|
|
1586
1637
|
{
|
|
1587
1638
|
className: `cteditor-w-6 cteditor-h-6 cteditor-rounded-full cteditor-flex cteditor-items-center cteditor-justify-center cteditor-flex-shrink-0 ${u.type === "spelling" ? "cteditor-bg-red-100 dark:cteditor-bg-red-900/30" : "cteditor-bg-blue-100 dark:cteditor-bg-blue-900/30"}`,
|
|
1588
|
-
children: /* @__PURE__ */
|
|
1589
|
-
|
|
1639
|
+
children: /* @__PURE__ */ v(
|
|
1640
|
+
Se,
|
|
1590
1641
|
{
|
|
1591
1642
|
className: `cteditor-w-4 cteditor-h-4 ${u.type === "spelling" ? "cteditor-text-red-600 dark:cteditor-text-red-400" : "cteditor-text-blue-600 dark:cteditor-text-blue-400"}`
|
|
1592
1643
|
}
|
|
@@ -1594,51 +1645,51 @@ function _r({
|
|
|
1594
1645
|
}
|
|
1595
1646
|
),
|
|
1596
1647
|
/* @__PURE__ */ L("div", { className: "cteditor-min-w-0 cteditor-flex-1", children: [
|
|
1597
|
-
/* @__PURE__ */
|
|
1598
|
-
|
|
1648
|
+
/* @__PURE__ */ v(
|
|
1649
|
+
Me,
|
|
1599
1650
|
{
|
|
1600
1651
|
variant: u.type === "spelling" ? "destructive" : "default",
|
|
1601
1652
|
className: "cteditor-text-xs cteditor-font-bold",
|
|
1602
1653
|
children: u.type === "spelling" ? "Spelling" : "Grammar"
|
|
1603
1654
|
}
|
|
1604
1655
|
),
|
|
1605
|
-
u.issue && /* @__PURE__ */
|
|
1656
|
+
u.issue && /* @__PURE__ */ v("p", { className: "cteditor-text-xs cteditor-text-foreground/50 cteditor-mt-1 cteditor-break-words", children: u.issue })
|
|
1606
1657
|
] })
|
|
1607
1658
|
] }),
|
|
1608
|
-
/* @__PURE__ */
|
|
1659
|
+
/* @__PURE__ */ v(
|
|
1609
1660
|
"button",
|
|
1610
1661
|
{
|
|
1611
1662
|
type: "button",
|
|
1612
1663
|
onClick: () => $(null),
|
|
1613
1664
|
className: "cteditor-text-gray-400 hover:cteditor-text-gray-600 cteditor-flex-shrink-0 cteditor-p-1 cteditor-absolute cteditor-top-1 cteditor-right-1",
|
|
1614
|
-
children: /* @__PURE__ */
|
|
1665
|
+
children: /* @__PURE__ */ v(Ne, { className: "cteditor-w-4 cteditor-h-4" })
|
|
1615
1666
|
}
|
|
1616
1667
|
)
|
|
1617
1668
|
] }),
|
|
1618
|
-
/* @__PURE__ */
|
|
1669
|
+
/* @__PURE__ */ v("div", { className: "cteditor-p-3 cteditor-bg-incorrect-word-bg cteditor-rounded-lg cteditor-border cteditor-border-incorrect-word-border cteditor-overflow-hidden", children: /* @__PURE__ */ v("p", { className: "cteditor-text-sm cteditor-line-through cteditor-text-incorrect-word-text cteditor-font-semibold cteditor-break-all", children: u.original }) }),
|
|
1619
1670
|
u.suggestions.length > 0 ? /* @__PURE__ */ L("div", { className: "cteditor-space-y-3", children: [
|
|
1620
|
-
/* @__PURE__ */
|
|
1621
|
-
/* @__PURE__ */
|
|
1671
|
+
/* @__PURE__ */ v("p", { className: "cteditor-text-xs cteditor-font-bold cteditor-text-main-foreground cteditor-uppercase cteditor-tracking-wider", children: "Suggestions:" }),
|
|
1672
|
+
/* @__PURE__ */ v("div", { className: "cteditor-space-y-2 cteditor-max-h-[120px] cteditor-overflow-y-auto cteditor-pr-1", children: u.suggestions.map((O, Y) => /* @__PURE__ */ L(
|
|
1622
1673
|
"button",
|
|
1623
1674
|
{
|
|
1624
1675
|
type: "button",
|
|
1625
1676
|
onClick: (D) => {
|
|
1626
|
-
D.preventDefault(), D.stopPropagation(),
|
|
1677
|
+
D.preventDefault(), D.stopPropagation(), ge(O, u);
|
|
1627
1678
|
},
|
|
1628
1679
|
className: "cteditor-w-full cteditor-flex cteditor-items-center cteditor-gap-2 cteditor-px-3 cteditor-py-2 cteditor-bg-suggestion-bg cteditor-border cteditor-border-suggestion-border cteditor-rounded-lg cteditor-transition-all",
|
|
1629
1680
|
children: [
|
|
1630
|
-
/* @__PURE__ */
|
|
1631
|
-
/* @__PURE__ */
|
|
1681
|
+
/* @__PURE__ */ v(Vt, { className: "cteditor-w-4 cteditor-h-4 cteditor-flex-shrink-0 cteditor-text-suggestion-text " }),
|
|
1682
|
+
/* @__PURE__ */ v("span", { className: "cteditor-text-sm cteditor-font-semibold cteditor-text-suggestion-text cteditor-break-all cteditor-text-left", children: O })
|
|
1632
1683
|
]
|
|
1633
1684
|
},
|
|
1634
|
-
|
|
1685
|
+
Y
|
|
1635
1686
|
)) }),
|
|
1636
|
-
u.type === "grammar" && u.correctedSentence && /* @__PURE__ */
|
|
1687
|
+
u.type === "grammar" && u.correctedSentence && /* @__PURE__ */ v(
|
|
1637
1688
|
"button",
|
|
1638
1689
|
{
|
|
1639
1690
|
type: "button",
|
|
1640
1691
|
onClick: (O) => {
|
|
1641
|
-
O.preventDefault(),
|
|
1692
|
+
O.preventDefault(), pe(
|
|
1642
1693
|
u.correctedSentence,
|
|
1643
1694
|
u.originalSentence,
|
|
1644
1695
|
u.sentenceId
|
|
@@ -1646,20 +1697,20 @@ function _r({
|
|
|
1646
1697
|
},
|
|
1647
1698
|
className: "cteditor-w-full cteditor-px-3 cteditor-py-2 cteditor-bg-explanation-bg cteditor-border-2 cteditor-border-explanation-border cteditor-rounded-lg cteditor-text-left",
|
|
1648
1699
|
children: /* @__PURE__ */ L("div", { className: "cteditor-flex cteditor-items-start cteditor-gap-2", children: [
|
|
1649
|
-
/* @__PURE__ */
|
|
1700
|
+
/* @__PURE__ */ v(Vt, { className: "cteditor-w-4 cteditor-h-4 cteditor-text-blue-600 cteditor-mt-0.5 cteditor-flex-shrink-0" }),
|
|
1650
1701
|
/* @__PURE__ */ L("div", { className: "cteditor-min-w-0 cteditor-flex-1", children: [
|
|
1651
|
-
/* @__PURE__ */
|
|
1652
|
-
/* @__PURE__ */
|
|
1702
|
+
/* @__PURE__ */ v("p", { className: "cteditor-text-xs cteditor-font-semibold cteditor-text-blue-700", children: "Fix entire sentence" }),
|
|
1703
|
+
/* @__PURE__ */ v("p", { className: "cteditor-text-xs cteditor-text-blue-600 cteditor-break-words cteditor-line-clamp-2", children: u.correctedSentence })
|
|
1653
1704
|
] })
|
|
1654
1705
|
] })
|
|
1655
1706
|
}
|
|
1656
1707
|
),
|
|
1657
1708
|
/* @__PURE__ */ L("div", { className: "cteditor-flex cteditor-flex-col cteditor-gap-3 cteditor-mt-3 cteditor-pt-3 ", children: [
|
|
1658
|
-
/* @__PURE__ */
|
|
1709
|
+
/* @__PURE__ */ v(
|
|
1659
1710
|
"button",
|
|
1660
1711
|
{
|
|
1661
1712
|
type: "button",
|
|
1662
|
-
onClick: () =>
|
|
1713
|
+
onClick: () => Tt(u),
|
|
1663
1714
|
className: "cteditor-w-full cteditor-px-4 cteditor-py-2.5 cteditor-text-sm cteditor-font-medium cteditor-rounded-lg cteditor-border cteditor-border-foreground/20 hover:cteditor-bg-foreground/10 cteditor-transition-colors",
|
|
1664
1715
|
title: "Ignore this suggestion",
|
|
1665
1716
|
children: "Dismiss"
|
|
@@ -1670,16 +1721,16 @@ function _r({
|
|
|
1670
1721
|
"button",
|
|
1671
1722
|
{
|
|
1672
1723
|
type: "button",
|
|
1673
|
-
onClick: () =>
|
|
1724
|
+
onClick: () => Ht(u),
|
|
1674
1725
|
className: "cteditor-flex cteditor-items-center cteditor-justify-center cteditor-gap-1.5 cteditor-text-xs cteditor-transition-colors cteditor-font-medium hover:cteditor-opacity-90",
|
|
1675
1726
|
title: "Add word to your personal dictionary ",
|
|
1676
1727
|
children: [
|
|
1677
|
-
/* @__PURE__ */
|
|
1728
|
+
/* @__PURE__ */ v(Yt, { className: "cteditor-w-3.5 cteditor-h-3.5" }),
|
|
1678
1729
|
"Add to Dictionary"
|
|
1679
1730
|
]
|
|
1680
1731
|
}
|
|
1681
1732
|
),
|
|
1682
|
-
/* @__PURE__ */
|
|
1733
|
+
/* @__PURE__ */ v(
|
|
1683
1734
|
"button",
|
|
1684
1735
|
{
|
|
1685
1736
|
type: "button",
|
|
@@ -1696,11 +1747,11 @@ function _r({
|
|
|
1696
1747
|
] }) : (
|
|
1697
1748
|
/* No suggestions - action buttons only */
|
|
1698
1749
|
/* @__PURE__ */ L("div", { className: "cteditor-flex cteditor-flex-col cteditor-gap-3 cteditor-mt-3 cteditor-pt-3 ", children: [
|
|
1699
|
-
/* @__PURE__ */
|
|
1750
|
+
/* @__PURE__ */ v(
|
|
1700
1751
|
"button",
|
|
1701
1752
|
{
|
|
1702
1753
|
type: "button",
|
|
1703
|
-
onClick: () =>
|
|
1754
|
+
onClick: () => Tt(u),
|
|
1704
1755
|
className: "cteditor-flex-1 cteditor-px-3 cteditor-py-2 cteditor-flex cteditor-items-center cteditor-justify-center cteditor-gap-1.5 cteditor-text-xs cteditor-rounded-md cteditor-border cteditor-border-foreground/50 hover:cteditor-bg-foreground/10 cteditor-transition-colors",
|
|
1705
1756
|
title: "Ignore this suggestion",
|
|
1706
1757
|
children: "Dismiss"
|
|
@@ -1711,16 +1762,16 @@ function _r({
|
|
|
1711
1762
|
"button",
|
|
1712
1763
|
{
|
|
1713
1764
|
type: "button",
|
|
1714
|
-
onClick: () =>
|
|
1765
|
+
onClick: () => Ht(u),
|
|
1715
1766
|
className: "cteditor-flex cteditor-items-center cteditor-justify-center cteditor-gap-1.5 cteditor-text-xs cteditor-rounded-md cteditor-transition-colors cteditor-font-medium hover:cteditor-opacity-90 ",
|
|
1716
1767
|
title: "Add word to your personal dictionary",
|
|
1717
1768
|
children: [
|
|
1718
|
-
/* @__PURE__ */
|
|
1769
|
+
/* @__PURE__ */ v(Yt, { className: "cteditor-w-3.5 cteditor-h-3.5" }),
|
|
1719
1770
|
"Add to Dictionary"
|
|
1720
1771
|
]
|
|
1721
1772
|
}
|
|
1722
1773
|
),
|
|
1723
|
-
/* @__PURE__ */
|
|
1774
|
+
/* @__PURE__ */ v(
|
|
1724
1775
|
"button",
|
|
1725
1776
|
{
|
|
1726
1777
|
type: "button",
|
|
@@ -1738,41 +1789,41 @@ function _r({
|
|
|
1738
1789
|
] }) })
|
|
1739
1790
|
}
|
|
1740
1791
|
);
|
|
1741
|
-
return
|
|
1742
|
-
},
|
|
1743
|
-
/* @__PURE__ */
|
|
1744
|
-
|
|
1792
|
+
return Xt(K, ot || document.body);
|
|
1793
|
+
}, xe = () => !At || !F || W.length === 0 ? null : Xt(
|
|
1794
|
+
/* @__PURE__ */ v(
|
|
1795
|
+
Ot,
|
|
1745
1796
|
{
|
|
1746
|
-
ref:
|
|
1797
|
+
ref: k,
|
|
1747
1798
|
className: "cteditor-w-80 cteditor-max-h-64 cteditor-overflow-hidden cteditor-shadow-xl cteditor-border-2 cteditor-bg-white dark:cteditor-bg-gray-900 autocomplete-menu",
|
|
1748
|
-
children: /* @__PURE__ */
|
|
1799
|
+
children: /* @__PURE__ */ v(Lt, { className: "!cteditor-p-2", children: /* @__PURE__ */ v("div", { className: "cteditor-max-h-56 cteditor-overflow-y-auto cteditor-space-y-1", children: W.map((u, m) => /* @__PURE__ */ L(
|
|
1749
1800
|
"button",
|
|
1750
1801
|
{
|
|
1751
1802
|
type: "button",
|
|
1752
|
-
className:
|
|
1803
|
+
className: Q(
|
|
1753
1804
|
"cteditor-w-full cteditor-flex cteditor-items-center cteditor-gap-3 cteditor-px-3 cteditor-py-2.5 cteditor-rounded-md cteditor-text-left",
|
|
1754
|
-
m ===
|
|
1805
|
+
m === ft ? "cteditor-bg-blue-100" : "hover:cteditor-bg-gray-100"
|
|
1755
1806
|
),
|
|
1756
|
-
onClick: () =>
|
|
1757
|
-
onMouseEnter: () =>
|
|
1807
|
+
onClick: () => gt(u),
|
|
1808
|
+
onMouseEnter: () => rt(m),
|
|
1758
1809
|
children: [
|
|
1759
|
-
/* @__PURE__ */
|
|
1760
|
-
/* @__PURE__ */
|
|
1810
|
+
/* @__PURE__ */ v($e, { className: "cteditor-w-4 cteditor-h-4" }),
|
|
1811
|
+
/* @__PURE__ */ v("span", { className: "cteditor-text-sm cteditor-font-medium", children: u.displayText })
|
|
1761
1812
|
]
|
|
1762
1813
|
},
|
|
1763
1814
|
u.key
|
|
1764
1815
|
)) }) })
|
|
1765
1816
|
}
|
|
1766
1817
|
),
|
|
1767
|
-
|
|
1818
|
+
At
|
|
1768
1819
|
);
|
|
1769
|
-
return /* @__PURE__ */ L(
|
|
1770
|
-
|
|
1771
|
-
|
|
1820
|
+
return /* @__PURE__ */ L(Ee, { children: [
|
|
1821
|
+
me(),
|
|
1822
|
+
xe()
|
|
1772
1823
|
] });
|
|
1773
1824
|
}
|
|
1774
1825
|
export {
|
|
1775
|
-
|
|
1776
|
-
|
|
1777
|
-
|
|
1826
|
+
Wr as AUTOCOMPLETE_COMMAND,
|
|
1827
|
+
$r as default,
|
|
1828
|
+
Sr as splitIntoSentences
|
|
1778
1829
|
};
|