@cgboiler/biz-basic 1.0.51 → 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 CHANGED
@@ -5,6 +5,6 @@ declare namespace _default {
5
5
  }
6
6
  export default _default;
7
7
  export function install(app: any): void;
8
- export const version: "1.0.50";
8
+ export const version: "1.0.52";
9
9
  import RichTextEditor from './rich-text-editor';
10
10
  export { RichTextEditor };
package/es/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import RichTextEditor from "./rich-text-editor";
2
- const version = "1.0.50";
2
+ const version = "1.0.52";
3
3
  function install(app) {
4
4
  const components = [
5
5
  RichTextEditor
@@ -95,7 +95,8 @@ var stdin_default = defineComponent({
95
95
  type: "hashTag",
96
96
  attrs: {
97
97
  id: data.hashTagId,
98
- label: data.name
98
+ label: data.name,
99
+ type: data.type
99
100
  }
100
101
  });
101
102
  };
@@ -172,11 +173,13 @@ var stdin_default = defineComponent({
172
173
  if (tagEl) {
173
174
  const id = tagEl.getAttribute("data-id") || "";
174
175
  const label = tagEl.getAttribute("data-label") || tagEl.textContent || "";
175
- const hashTag = tagEl.getAttribute("data-hash-tag") || "#";
176
+ const trigger = tagEl.getAttribute("data-hash-tag") || "#";
177
+ const tagType = tagEl.getAttribute("data-tag-type") || "";
176
178
  emit("hashTag-clicked", {
177
179
  hashTagId: id,
178
180
  name: label,
179
- type: hashTag
181
+ trigger,
182
+ type: tagType
180
183
  });
181
184
  event.stopPropagation();
182
185
  event.preventDefault();
@@ -25,6 +25,7 @@ export interface MentionData {
25
25
  export interface HashTagData {
26
26
  hashTagId: string;
27
27
  name: string;
28
+ type?: string;
28
29
  }
29
30
  /**
30
31
  * CustomContentData
@@ -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,
@@ -59,10 +61,42 @@ function useExtensions({ props, emit }) {
59
61
  parseHTML() {
60
62
  return [{ tag: 'span[data-type="hashTag"]' }];
61
63
  },
64
+ addAttributes() {
65
+ return {
66
+ id: {
67
+ default: null,
68
+ parseHTML: (element) => element.getAttribute("data-id"),
69
+ renderHTML: (attributes) => {
70
+ if (!attributes.id)
71
+ return {};
72
+ return { "data-id": attributes.id };
73
+ }
74
+ },
75
+ label: {
76
+ default: null,
77
+ parseHTML: (element) => element.getAttribute("data-label"),
78
+ renderHTML: (attributes) => {
79
+ if (!attributes.label)
80
+ return {};
81
+ return { "data-label": attributes.label };
82
+ }
83
+ },
84
+ type: {
85
+ default: null,
86
+ parseHTML: (element) => element.getAttribute("data-tag-type"),
87
+ renderHTML: (attributes) => {
88
+ if (!attributes.type)
89
+ return {};
90
+ return { "data-tag-type": attributes.type };
91
+ }
92
+ }
93
+ };
94
+ },
62
95
  renderHTML({ node }) {
63
- var _a, _b, _c, _d;
96
+ var _a, _b, _c, _d, _e, _f;
64
97
  const id = (_b = (_a = node == null ? void 0 : node.attrs) == null ? void 0 : _a.id) != null ? _b : "";
65
98
  const label = (_d = (_c = node == null ? void 0 : node.attrs) == null ? void 0 : _c.label) != null ? _d : "";
99
+ const type = (_f = (_e = node == null ? void 0 : node.attrs) == null ? void 0 : _e.type) != null ? _f : "";
66
100
  return [
67
101
  "span",
68
102
  {
@@ -70,6 +104,7 @@ function useExtensions({ props, emit }) {
70
104
  "data-type": "hashTag",
71
105
  "data-id": id,
72
106
  "data-label": label,
107
+ "data-tag-type": type,
73
108
  "data-hash-tag": "#",
74
109
  contenteditable: "false"
75
110
  },
@@ -86,8 +121,11 @@ function useExtensions({ props, emit }) {
86
121
  * allow
87
122
  * - 功能:判断是否允许触发建议态。
88
123
  * - 若该字符带有 consumedTrigger 标记,说明此前已触发过或用户选择忽略,则不再触发建议。
124
+ * - 若当前处于 IME composition 状态,也不触发建议(防止中文输入法误触发)。
89
125
  */
90
126
  allow: ({ state, range }) => {
127
+ if (isComposing)
128
+ return true;
91
129
  return !checkConsumed(state, range);
92
130
  },
93
131
  render() {
@@ -102,10 +140,10 @@ function useExtensions({ props, emit }) {
102
140
  try {
103
141
  (activeEditor || editor).chain().focus().deleteRange(activeRange || range).insertContentAt((activeRange || range).from, {
104
142
  type: "hashTag",
105
- attrs: { id: data.hashTagId, label: data.name }
143
+ attrs: { id: data.hashTagId, label: data.name, type: data.type }
106
144
  }).setTextSelection((activeRange || range).from + 1).insertContent(" ").run();
107
145
  } catch (e) {
108
- command({ id: data.hashTagId, label: data.name });
146
+ command({ id: data.hashTagId, label: data.name, type: data.type });
109
147
  (activeEditor || editor).chain().focus().insertContent(" ").run();
110
148
  }
111
149
  });
@@ -126,6 +164,9 @@ function useExtensions({ props, emit }) {
126
164
  },
127
165
  onExit({ editor, range }) {
128
166
  var _a, _b, _c, _d, _e;
167
+ if (isComposing) {
168
+ return;
169
+ }
129
170
  try {
130
171
  const sel = (_a = editor.state) == null ? void 0 : _a.selection;
131
172
  const from = (_b = sel == null ? void 0 : sel.from) != null ? _b : 0;
@@ -248,6 +289,30 @@ function useExtensions({ props, emit }) {
248
289
  StarterKit,
249
290
  HtmlBlock,
250
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
+ }),
251
316
  // Video input rule extension
252
317
  Extension.create({
253
318
  name: "videoInputRule",
@@ -354,6 +419,8 @@ function useExtensions({ props, emit }) {
354
419
  allowedPrefixes: null,
355
420
  allowSpaces: false,
356
421
  allow: ({ state, range }) => {
422
+ if (isComposing)
423
+ return true;
357
424
  if (checkConsumed(state, range))
358
425
  return false;
359
426
  const doc = state.doc;
@@ -384,6 +451,9 @@ function useExtensions({ props, emit }) {
384
451
  emit("mention-input", query != null ? query : "");
385
452
  },
386
453
  onExit({ editor, range }) {
454
+ if (isComposing) {
455
+ return;
456
+ }
387
457
  markAsConsumed(editor, range, "@");
388
458
  emit("mention-exit");
389
459
  }
package/lib/index.d.ts CHANGED
@@ -5,6 +5,6 @@ declare namespace _default {
5
5
  }
6
6
  export default _default;
7
7
  export function install(app: any): void;
8
- export const version: "1.0.50";
8
+ export const version: "1.0.52";
9
9
  import RichTextEditor from './rich-text-editor';
10
10
  export { RichTextEditor };
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.50";
39
+ const version = "1.0.52";
40
40
  function install(app) {
41
41
  const components = [
42
42
  import_rich_text_editor.default
@@ -127,7 +127,8 @@ var stdin_default = (0, import_vue2.defineComponent)({
127
127
  type: "hashTag",
128
128
  attrs: {
129
129
  id: data.hashTagId,
130
- label: data.name
130
+ label: data.name,
131
+ type: data.type
131
132
  }
132
133
  });
133
134
  };
@@ -204,11 +205,13 @@ var stdin_default = (0, import_vue2.defineComponent)({
204
205
  if (tagEl) {
205
206
  const id = tagEl.getAttribute("data-id") || "";
206
207
  const label = tagEl.getAttribute("data-label") || tagEl.textContent || "";
207
- const hashTag = tagEl.getAttribute("data-hash-tag") || "#";
208
+ const trigger = tagEl.getAttribute("data-hash-tag") || "#";
209
+ const tagType = tagEl.getAttribute("data-tag-type") || "";
208
210
  emit("hashTag-clicked", {
209
211
  hashTagId: id,
210
212
  name: label,
211
- type: hashTag
213
+ trigger,
214
+ type: tagType
212
215
  });
213
216
  event.stopPropagation();
214
217
  event.preventDefault();
@@ -25,6 +25,7 @@ export interface MentionData {
25
25
  export interface HashTagData {
26
26
  hashTagId: string;
27
27
  name: string;
28
+ type?: string;
28
29
  }
29
30
  /**
30
31
  * CustomContentData
@@ -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,
@@ -91,10 +93,42 @@ function useExtensions({ props, emit }) {
91
93
  parseHTML() {
92
94
  return [{ tag: 'span[data-type="hashTag"]' }];
93
95
  },
96
+ addAttributes() {
97
+ return {
98
+ id: {
99
+ default: null,
100
+ parseHTML: (element) => element.getAttribute("data-id"),
101
+ renderHTML: (attributes) => {
102
+ if (!attributes.id)
103
+ return {};
104
+ return { "data-id": attributes.id };
105
+ }
106
+ },
107
+ label: {
108
+ default: null,
109
+ parseHTML: (element) => element.getAttribute("data-label"),
110
+ renderHTML: (attributes) => {
111
+ if (!attributes.label)
112
+ return {};
113
+ return { "data-label": attributes.label };
114
+ }
115
+ },
116
+ type: {
117
+ default: null,
118
+ parseHTML: (element) => element.getAttribute("data-tag-type"),
119
+ renderHTML: (attributes) => {
120
+ if (!attributes.type)
121
+ return {};
122
+ return { "data-tag-type": attributes.type };
123
+ }
124
+ }
125
+ };
126
+ },
94
127
  renderHTML({ node }) {
95
- var _a, _b, _c, _d;
128
+ var _a, _b, _c, _d, _e, _f;
96
129
  const id = (_b = (_a = node == null ? void 0 : node.attrs) == null ? void 0 : _a.id) != null ? _b : "";
97
130
  const label = (_d = (_c = node == null ? void 0 : node.attrs) == null ? void 0 : _c.label) != null ? _d : "";
131
+ const type = (_f = (_e = node == null ? void 0 : node.attrs) == null ? void 0 : _e.type) != null ? _f : "";
98
132
  return [
99
133
  "span",
100
134
  {
@@ -102,6 +136,7 @@ function useExtensions({ props, emit }) {
102
136
  "data-type": "hashTag",
103
137
  "data-id": id,
104
138
  "data-label": label,
139
+ "data-tag-type": type,
105
140
  "data-hash-tag": "#",
106
141
  contenteditable: "false"
107
142
  },
@@ -118,8 +153,11 @@ function useExtensions({ props, emit }) {
118
153
  * allow
119
154
  * - 功能:判断是否允许触发建议态。
120
155
  * - 若该字符带有 consumedTrigger 标记,说明此前已触发过或用户选择忽略,则不再触发建议。
156
+ * - 若当前处于 IME composition 状态,也不触发建议(防止中文输入法误触发)。
121
157
  */
122
158
  allow: ({ state, range }) => {
159
+ if (isComposing)
160
+ return true;
123
161
  return !checkConsumed(state, range);
124
162
  },
125
163
  render() {
@@ -134,10 +172,10 @@ function useExtensions({ props, emit }) {
134
172
  try {
135
173
  (activeEditor || editor).chain().focus().deleteRange(activeRange || range).insertContentAt((activeRange || range).from, {
136
174
  type: "hashTag",
137
- attrs: { id: data.hashTagId, label: data.name }
175
+ attrs: { id: data.hashTagId, label: data.name, type: data.type }
138
176
  }).setTextSelection((activeRange || range).from + 1).insertContent(" ").run();
139
177
  } catch (e) {
140
- command({ id: data.hashTagId, label: data.name });
178
+ command({ id: data.hashTagId, label: data.name, type: data.type });
141
179
  (activeEditor || editor).chain().focus().insertContent(" ").run();
142
180
  }
143
181
  });
@@ -158,6 +196,9 @@ function useExtensions({ props, emit }) {
158
196
  },
159
197
  onExit({ editor, range }) {
160
198
  var _a, _b, _c, _d, _e;
199
+ if (isComposing) {
200
+ return;
201
+ }
161
202
  try {
162
203
  const sel = (_a = editor.state) == null ? void 0 : _a.selection;
163
204
  const from = (_b = sel == null ? void 0 : sel.from) != null ? _b : 0;
@@ -280,6 +321,30 @@ function useExtensions({ props, emit }) {
280
321
  import_starter_kit.default,
281
322
  import_HtmlBlock.default,
282
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
+ }),
283
348
  // Video input rule extension
284
349
  import_core.Extension.create({
285
350
  name: "videoInputRule",
@@ -386,6 +451,8 @@ function useExtensions({ props, emit }) {
386
451
  allowedPrefixes: null,
387
452
  allowSpaces: false,
388
453
  allow: ({ state, range }) => {
454
+ if (isComposing)
455
+ return true;
389
456
  if (checkConsumed(state, range))
390
457
  return false;
391
458
  const doc = state.doc;
@@ -416,6 +483,9 @@ function useExtensions({ props, emit }) {
416
483
  emit("mention-input", query != null ? query : "");
417
484
  },
418
485
  onExit({ editor, range }) {
486
+ if (isComposing) {
487
+ return;
488
+ }
419
489
  markAsConsumed(editor, range, "@");
420
490
  emit("mention-exit");
421
491
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cgboiler/biz-basic",
3
- "version": "1.0.51",
3
+ "version": "1.0.53",
4
4
  "description": "",
5
5
  "main": "lib/index.js",
6
6
  "module": "es/index.js",