@cgboiler/biz-basic 1.0.52 → 1.0.53
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/es/index.d.ts +1 -1
- package/es/index.js +1 -1
- package/es/rich-text-editor/useExtensions.js +37 -0
- package/lib/index.d.ts +1 -1
- package/lib/index.js +1 -1
- package/lib/rich-text-editor/useExtensions.js +37 -0
- package/package.json +1 -1
package/es/index.d.ts
CHANGED
package/es/index.js
CHANGED
|
@@ -7,10 +7,12 @@ import { TextStyle } from "@tiptap/extension-text-style";
|
|
|
7
7
|
import { Color } from "@tiptap/extension-color";
|
|
8
8
|
import { Markdown } from "tiptap-markdown";
|
|
9
9
|
import { Extension, InputRule, Mark, mergeAttributes } from "@tiptap/core";
|
|
10
|
+
import { Plugin } from "@tiptap/pm/state";
|
|
10
11
|
import HtmlBlock from "./extensions/HtmlBlock";
|
|
11
12
|
import { Placeholder } from "@tiptap/extensions";
|
|
12
13
|
function useExtensions({ props, emit }) {
|
|
13
14
|
let activeEditor = null;
|
|
15
|
+
let isComposing = false;
|
|
14
16
|
const ConsumedTrigger = Mark.create({
|
|
15
17
|
name: "consumedTrigger",
|
|
16
18
|
keepOnSplit: false,
|
|
@@ -119,8 +121,11 @@ function useExtensions({ props, emit }) {
|
|
|
119
121
|
* allow
|
|
120
122
|
* - 功能:判断是否允许触发建议态。
|
|
121
123
|
* - 若该字符带有 consumedTrigger 标记,说明此前已触发过或用户选择忽略,则不再触发建议。
|
|
124
|
+
* - 若当前处于 IME composition 状态,也不触发建议(防止中文输入法误触发)。
|
|
122
125
|
*/
|
|
123
126
|
allow: ({ state, range }) => {
|
|
127
|
+
if (isComposing)
|
|
128
|
+
return true;
|
|
124
129
|
return !checkConsumed(state, range);
|
|
125
130
|
},
|
|
126
131
|
render() {
|
|
@@ -159,6 +164,9 @@ function useExtensions({ props, emit }) {
|
|
|
159
164
|
},
|
|
160
165
|
onExit({ editor, range }) {
|
|
161
166
|
var _a, _b, _c, _d, _e;
|
|
167
|
+
if (isComposing) {
|
|
168
|
+
return;
|
|
169
|
+
}
|
|
162
170
|
try {
|
|
163
171
|
const sel = (_a = editor.state) == null ? void 0 : _a.selection;
|
|
164
172
|
const from = (_b = sel == null ? void 0 : sel.from) != null ? _b : 0;
|
|
@@ -281,6 +289,30 @@ function useExtensions({ props, emit }) {
|
|
|
281
289
|
StarterKit,
|
|
282
290
|
HtmlBlock,
|
|
283
291
|
ConsumedTrigger,
|
|
292
|
+
// IME Composition 事件监听扩展
|
|
293
|
+
Extension.create({
|
|
294
|
+
name: "imeCompositionTracker",
|
|
295
|
+
addProseMirrorPlugins() {
|
|
296
|
+
return [
|
|
297
|
+
new Plugin({
|
|
298
|
+
props: {
|
|
299
|
+
handleDOMEvents: {
|
|
300
|
+
compositionstart: () => {
|
|
301
|
+
isComposing = true;
|
|
302
|
+
return false;
|
|
303
|
+
},
|
|
304
|
+
compositionend: () => {
|
|
305
|
+
setTimeout(() => {
|
|
306
|
+
isComposing = false;
|
|
307
|
+
}, 10);
|
|
308
|
+
return false;
|
|
309
|
+
}
|
|
310
|
+
}
|
|
311
|
+
}
|
|
312
|
+
})
|
|
313
|
+
];
|
|
314
|
+
}
|
|
315
|
+
}),
|
|
284
316
|
// Video input rule extension
|
|
285
317
|
Extension.create({
|
|
286
318
|
name: "videoInputRule",
|
|
@@ -387,6 +419,8 @@ function useExtensions({ props, emit }) {
|
|
|
387
419
|
allowedPrefixes: null,
|
|
388
420
|
allowSpaces: false,
|
|
389
421
|
allow: ({ state, range }) => {
|
|
422
|
+
if (isComposing)
|
|
423
|
+
return true;
|
|
390
424
|
if (checkConsumed(state, range))
|
|
391
425
|
return false;
|
|
392
426
|
const doc = state.doc;
|
|
@@ -417,6 +451,9 @@ function useExtensions({ props, emit }) {
|
|
|
417
451
|
emit("mention-input", query != null ? query : "");
|
|
418
452
|
},
|
|
419
453
|
onExit({ editor, range }) {
|
|
454
|
+
if (isComposing) {
|
|
455
|
+
return;
|
|
456
|
+
}
|
|
420
457
|
markAsConsumed(editor, range, "@");
|
|
421
458
|
emit("mention-exit");
|
|
422
459
|
}
|
package/lib/index.d.ts
CHANGED
package/lib/index.js
CHANGED
|
@@ -36,7 +36,7 @@ __export(stdin_exports, {
|
|
|
36
36
|
module.exports = __toCommonJS(stdin_exports);
|
|
37
37
|
var import_rich_text_editor = __toESM(require("./rich-text-editor"));
|
|
38
38
|
__reExport(stdin_exports, require("./rich-text-editor"), module.exports);
|
|
39
|
-
const version = "1.0.
|
|
39
|
+
const version = "1.0.52";
|
|
40
40
|
function install(app) {
|
|
41
41
|
const components = [
|
|
42
42
|
import_rich_text_editor.default
|
|
@@ -39,10 +39,12 @@ var import_extension_text_style = require("@tiptap/extension-text-style");
|
|
|
39
39
|
var import_extension_color = require("@tiptap/extension-color");
|
|
40
40
|
var import_tiptap_markdown = require("tiptap-markdown");
|
|
41
41
|
var import_core = require("@tiptap/core");
|
|
42
|
+
var import_state = require("@tiptap/pm/state");
|
|
42
43
|
var import_HtmlBlock = __toESM(require("./extensions/HtmlBlock"));
|
|
43
44
|
var import_extensions = require("@tiptap/extensions");
|
|
44
45
|
function useExtensions({ props, emit }) {
|
|
45
46
|
let activeEditor = null;
|
|
47
|
+
let isComposing = false;
|
|
46
48
|
const ConsumedTrigger = import_core.Mark.create({
|
|
47
49
|
name: "consumedTrigger",
|
|
48
50
|
keepOnSplit: false,
|
|
@@ -151,8 +153,11 @@ function useExtensions({ props, emit }) {
|
|
|
151
153
|
* allow
|
|
152
154
|
* - 功能:判断是否允许触发建议态。
|
|
153
155
|
* - 若该字符带有 consumedTrigger 标记,说明此前已触发过或用户选择忽略,则不再触发建议。
|
|
156
|
+
* - 若当前处于 IME composition 状态,也不触发建议(防止中文输入法误触发)。
|
|
154
157
|
*/
|
|
155
158
|
allow: ({ state, range }) => {
|
|
159
|
+
if (isComposing)
|
|
160
|
+
return true;
|
|
156
161
|
return !checkConsumed(state, range);
|
|
157
162
|
},
|
|
158
163
|
render() {
|
|
@@ -191,6 +196,9 @@ function useExtensions({ props, emit }) {
|
|
|
191
196
|
},
|
|
192
197
|
onExit({ editor, range }) {
|
|
193
198
|
var _a, _b, _c, _d, _e;
|
|
199
|
+
if (isComposing) {
|
|
200
|
+
return;
|
|
201
|
+
}
|
|
194
202
|
try {
|
|
195
203
|
const sel = (_a = editor.state) == null ? void 0 : _a.selection;
|
|
196
204
|
const from = (_b = sel == null ? void 0 : sel.from) != null ? _b : 0;
|
|
@@ -313,6 +321,30 @@ function useExtensions({ props, emit }) {
|
|
|
313
321
|
import_starter_kit.default,
|
|
314
322
|
import_HtmlBlock.default,
|
|
315
323
|
ConsumedTrigger,
|
|
324
|
+
// IME Composition 事件监听扩展
|
|
325
|
+
import_core.Extension.create({
|
|
326
|
+
name: "imeCompositionTracker",
|
|
327
|
+
addProseMirrorPlugins() {
|
|
328
|
+
return [
|
|
329
|
+
new import_state.Plugin({
|
|
330
|
+
props: {
|
|
331
|
+
handleDOMEvents: {
|
|
332
|
+
compositionstart: () => {
|
|
333
|
+
isComposing = true;
|
|
334
|
+
return false;
|
|
335
|
+
},
|
|
336
|
+
compositionend: () => {
|
|
337
|
+
setTimeout(() => {
|
|
338
|
+
isComposing = false;
|
|
339
|
+
}, 10);
|
|
340
|
+
return false;
|
|
341
|
+
}
|
|
342
|
+
}
|
|
343
|
+
}
|
|
344
|
+
})
|
|
345
|
+
];
|
|
346
|
+
}
|
|
347
|
+
}),
|
|
316
348
|
// Video input rule extension
|
|
317
349
|
import_core.Extension.create({
|
|
318
350
|
name: "videoInputRule",
|
|
@@ -419,6 +451,8 @@ function useExtensions({ props, emit }) {
|
|
|
419
451
|
allowedPrefixes: null,
|
|
420
452
|
allowSpaces: false,
|
|
421
453
|
allow: ({ state, range }) => {
|
|
454
|
+
if (isComposing)
|
|
455
|
+
return true;
|
|
422
456
|
if (checkConsumed(state, range))
|
|
423
457
|
return false;
|
|
424
458
|
const doc = state.doc;
|
|
@@ -449,6 +483,9 @@ function useExtensions({ props, emit }) {
|
|
|
449
483
|
emit("mention-input", query != null ? query : "");
|
|
450
484
|
},
|
|
451
485
|
onExit({ editor, range }) {
|
|
486
|
+
if (isComposing) {
|
|
487
|
+
return;
|
|
488
|
+
}
|
|
452
489
|
markAsConsumed(editor, range, "@");
|
|
453
490
|
emit("mention-exit");
|
|
454
491
|
}
|