@cgboiler/biz-basic 1.0.44 → 1.0.46

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.43";
8
+ export const version: "1.0.45";
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.43";
2
+ const version = "1.0.45";
3
3
  function install(app) {
4
4
  const components = [
5
5
  RichTextEditor
@@ -16,7 +16,7 @@ declare const _default: import("vue").DefineComponent<import("vue").ExtractPropT
16
16
  type: BooleanConstructor;
17
17
  default: boolean;
18
18
  };
19
- }>, () => import("vue/jsx-runtime").JSX.Element, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, ("blur" | "focus" | "hashTag-triggered" | "hashTag-input" | "hashTag-exit" | "mention-triggered" | "update:modelValue" | "mention-clicked" | "hashTag-clicked")[], "blur" | "focus" | "hashTag-triggered" | "hashTag-input" | "hashTag-exit" | "mention-triggered" | "update:modelValue" | "mention-clicked" | "hashTag-clicked", import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
19
+ }>, () => import("vue/jsx-runtime").JSX.Element, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, ("blur" | "focus" | "hashTag-triggered" | "hashTag-input" | "hashTag-exit" | "mention-triggered" | "mention-input" | "mention-exit" | "update:modelValue" | "mention-clicked" | "hashTag-clicked")[], "blur" | "focus" | "hashTag-triggered" | "hashTag-input" | "hashTag-exit" | "mention-triggered" | "mention-input" | "mention-exit" | "update:modelValue" | "mention-clicked" | "hashTag-clicked", import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
20
20
  modelValue: {
21
21
  type: StringConstructor;
22
22
  default: string;
@@ -39,6 +39,8 @@ declare const _default: import("vue").DefineComponent<import("vue").ExtractPropT
39
39
  "onHashTag-input"?: ((...args: any[]) => any) | undefined;
40
40
  "onHashTag-exit"?: ((...args: any[]) => any) | undefined;
41
41
  "onMention-triggered"?: ((...args: any[]) => any) | undefined;
42
+ "onMention-input"?: ((...args: any[]) => any) | undefined;
43
+ "onMention-exit"?: ((...args: any[]) => any) | undefined;
42
44
  "onUpdate:modelValue"?: ((...args: any[]) => any) | undefined;
43
45
  "onMention-clicked"?: ((...args: any[]) => any) | undefined;
44
46
  "onHashTag-clicked"?: ((...args: any[]) => any) | undefined;
@@ -31,7 +31,7 @@ import "./index.css";
31
31
  var stdin_default = defineComponent({
32
32
  name: "RichTextEditor",
33
33
  props: richTextEditorProps,
34
- emits: ["update:modelValue", "mention-triggered", "mention-clicked", "hashTag-triggered", "hashTag-input", "hashTag-exit", "hashTag-clicked", "blur", "focus"],
34
+ emits: ["update:modelValue", "mention-triggered", "mention-input", "mention-exit", "mention-clicked", "hashTag-triggered", "hashTag-input", "hashTag-exit", "hashTag-clicked", "blur", "focus"],
35
35
  setup(props, {
36
36
  emit,
37
37
  expose
@@ -8,4 +8,4 @@ import { Extension } from '@tiptap/core';
8
8
  * - 返回值:Extension[] 扩展数组,用于初始化 TipTap 编辑器。
9
9
  * - 异常:无显式抛出;若内部命令执行失败(例如插入内容时)可能由 TipTap 抛出异常,应在上层统一处理。
10
10
  */
11
- export declare function useExtensions({ props, emit }: any): (import("@tiptap/core").Node<any, any> | import("@tiptap/core").Node<import("@tiptap/extension-mention").MentionOptions<any, import("@tiptap/extension-mention").MentionNodeAttrs>, any> | Extension<import("@tiptap/starter-kit").StarterKitOptions, any> | Extension<any, any> | import("@tiptap/core").Mark<import("@tiptap/extension-text-style").TextStyleOptions, any> | Extension<import("@tiptap/extension-text-style").ColorOptions, any> | Extension<import("tiptap-markdown").MarkdownOptions, import("tiptap-markdown").MarkdownStorage> | import("@tiptap/core").Node<import("@tiptap/extension-image").ImageOptions, any> | Extension<import("@tiptap/extension-table").TableKitOptions, any> | Extension<import("@tiptap/extensions").PlaceholderOptions, any> | Extension<import("@tiptap/extension-list").ListKitOptions, any>)[];
11
+ export declare function useExtensions({ props, emit }: any): (import("@tiptap/core").Node<any, any> | import("@tiptap/core").Node<import("@tiptap/extension-mention").MentionOptions<any, import("@tiptap/extension-mention").MentionNodeAttrs>, any> | Extension<any, any> | Extension<import("@tiptap/starter-kit").StarterKitOptions, any> | import("@tiptap/core").Mark<import("@tiptap/extension-text-style").TextStyleOptions, any> | Extension<import("@tiptap/extension-text-style").ColorOptions, any> | Extension<import("tiptap-markdown").MarkdownOptions, import("tiptap-markdown").MarkdownStorage> | import("@tiptap/core").Node<import("@tiptap/extension-image").ImageOptions, any> | Extension<import("@tiptap/extension-table").TableKitOptions, any> | Extension<import("@tiptap/extensions").PlaceholderOptions, any> | Extension<import("@tiptap/extension-list").ListKitOptions, any>)[];
@@ -36,7 +36,6 @@ function useExtensions({ props, emit }) {
36
36
  allowedPrefixes: null,
37
37
  render() {
38
38
  let activeRange = null;
39
- let activeEditor = null;
40
39
  let exitCause = "unknown";
41
40
  return {
42
41
  onStart({ editor, range, command, query }) {
@@ -114,6 +113,27 @@ function useExtensions({ props, emit }) {
114
113
  }
115
114
  }
116
115
  });
116
+ let spentMentionPositions = [];
117
+ let activeEditor = null;
118
+ const MentionTracker = Extension.create({
119
+ name: "mentionTracker",
120
+ onTransaction({ transaction }) {
121
+ if (spentMentionPositions.length === 0)
122
+ return;
123
+ spentMentionPositions = spentMentionPositions.map((pos) => transaction.mapping.map(pos, -1));
124
+ spentMentionPositions = spentMentionPositions.filter((pos) => {
125
+ try {
126
+ if (pos < 0 || pos >= transaction.doc.content.size)
127
+ return false;
128
+ const char = transaction.doc.textBetween(pos, pos + 1);
129
+ return char === "@";
130
+ } catch (e) {
131
+ return false;
132
+ }
133
+ });
134
+ spentMentionPositions = Array.from(new Set(spentMentionPositions));
135
+ }
136
+ });
117
137
  const extensions = [
118
138
  StarterKit,
119
139
  HtmlBlock,
@@ -244,21 +264,60 @@ function useExtensions({ props, emit }) {
244
264
  suggestion: {
245
265
  char: "@",
246
266
  allowedPrefixes: null,
247
- // 允许任何前缀
267
+ allowSpaces: false,
268
+ /**
269
+ * allow
270
+ * - 功能:判断是否允许触发建议态。
271
+ * - 1. 当@ 前面一个字符是数字/英文时,不触发,防止用户是想要输入邮箱。
272
+ * - 2. 触发以后如果包含数字,则收起(通过返回 false 销毁建议态)。
273
+ */
274
+ allow: ({ state, range }) => {
275
+ if (spentMentionPositions.includes(range.from)) {
276
+ return false;
277
+ }
278
+ const doc = state.doc;
279
+ const $from = doc.resolve(range.from);
280
+ const isAtStart = range.from === $from.start();
281
+ const prevChar = isAtStart ? "" : doc.textBetween(range.from - 1, range.from);
282
+ if (/[a-zA-Z0-9]/.test(prevChar)) {
283
+ return false;
284
+ }
285
+ const query = doc.textBetween(range.from + 1, range.to);
286
+ if (/[0-9]/.test(query)) {
287
+ return false;
288
+ }
289
+ return true;
290
+ },
248
291
  render() {
249
292
  return {
250
- onStart({ command }) {
293
+ onStart({ editor, range, command, query }) {
294
+ activeEditor = editor;
251
295
  emit("mention-triggered", (data) => {
252
296
  command({
253
297
  id: data.userId,
254
298
  label: data.name
255
299
  });
256
300
  });
301
+ emit("mention-input", query != null ? query : "");
302
+ },
303
+ onUpdate({ query, editor }) {
304
+ activeEditor = editor;
305
+ emit("mention-input", query != null ? query : "");
306
+ },
307
+ onExit({ range }) {
308
+ if (range.from !== void 0) {
309
+ spentMentionPositions.push(range.from);
310
+ }
311
+ emit("mention-exit");
257
312
  }
258
313
  };
259
314
  }
260
315
  }
261
316
  }),
317
+ /**
318
+ * 辅助扩展:追踪记录已失活的 Mention 触发点
319
+ */
320
+ MentionTracker,
262
321
  // HashTag 扩展:支持 # 触发、实时输入同步、完成后插入为 “#+文字”
263
322
  HashTag
264
323
  ];
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.43";
8
+ export const version: "1.0.45";
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.43";
39
+ const version = "1.0.45";
40
40
  function install(app) {
41
41
  const components = [
42
42
  import_rich_text_editor.default
@@ -16,7 +16,7 @@ declare const _default: import("vue").DefineComponent<import("vue").ExtractPropT
16
16
  type: BooleanConstructor;
17
17
  default: boolean;
18
18
  };
19
- }>, () => import("vue/jsx-runtime").JSX.Element, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, ("blur" | "focus" | "hashTag-triggered" | "hashTag-input" | "hashTag-exit" | "mention-triggered" | "update:modelValue" | "mention-clicked" | "hashTag-clicked")[], "blur" | "focus" | "hashTag-triggered" | "hashTag-input" | "hashTag-exit" | "mention-triggered" | "update:modelValue" | "mention-clicked" | "hashTag-clicked", import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
19
+ }>, () => import("vue/jsx-runtime").JSX.Element, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, ("blur" | "focus" | "hashTag-triggered" | "hashTag-input" | "hashTag-exit" | "mention-triggered" | "mention-input" | "mention-exit" | "update:modelValue" | "mention-clicked" | "hashTag-clicked")[], "blur" | "focus" | "hashTag-triggered" | "hashTag-input" | "hashTag-exit" | "mention-triggered" | "mention-input" | "mention-exit" | "update:modelValue" | "mention-clicked" | "hashTag-clicked", import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
20
20
  modelValue: {
21
21
  type: StringConstructor;
22
22
  default: string;
@@ -39,6 +39,8 @@ declare const _default: import("vue").DefineComponent<import("vue").ExtractPropT
39
39
  "onHashTag-input"?: ((...args: any[]) => any) | undefined;
40
40
  "onHashTag-exit"?: ((...args: any[]) => any) | undefined;
41
41
  "onMention-triggered"?: ((...args: any[]) => any) | undefined;
42
+ "onMention-input"?: ((...args: any[]) => any) | undefined;
43
+ "onMention-exit"?: ((...args: any[]) => any) | undefined;
42
44
  "onUpdate:modelValue"?: ((...args: any[]) => any) | undefined;
43
45
  "onMention-clicked"?: ((...args: any[]) => any) | undefined;
44
46
  "onHashTag-clicked"?: ((...args: any[]) => any) | undefined;
@@ -63,7 +63,7 @@ var import_index = require("./index.css");
63
63
  var stdin_default = (0, import_vue2.defineComponent)({
64
64
  name: "RichTextEditor",
65
65
  props: import_types.richTextEditorProps,
66
- emits: ["update:modelValue", "mention-triggered", "mention-clicked", "hashTag-triggered", "hashTag-input", "hashTag-exit", "hashTag-clicked", "blur", "focus"],
66
+ emits: ["update:modelValue", "mention-triggered", "mention-input", "mention-exit", "mention-clicked", "hashTag-triggered", "hashTag-input", "hashTag-exit", "hashTag-clicked", "blur", "focus"],
67
67
  setup(props, {
68
68
  emit,
69
69
  expose
@@ -8,4 +8,4 @@ import { Extension } from '@tiptap/core';
8
8
  * - 返回值:Extension[] 扩展数组,用于初始化 TipTap 编辑器。
9
9
  * - 异常:无显式抛出;若内部命令执行失败(例如插入内容时)可能由 TipTap 抛出异常,应在上层统一处理。
10
10
  */
11
- export declare function useExtensions({ props, emit }: any): (import("@tiptap/core").Node<any, any> | import("@tiptap/core").Node<import("@tiptap/extension-mention").MentionOptions<any, import("@tiptap/extension-mention").MentionNodeAttrs>, any> | Extension<import("@tiptap/starter-kit").StarterKitOptions, any> | Extension<any, any> | import("@tiptap/core").Mark<import("@tiptap/extension-text-style").TextStyleOptions, any> | Extension<import("@tiptap/extension-text-style").ColorOptions, any> | Extension<import("tiptap-markdown").MarkdownOptions, import("tiptap-markdown").MarkdownStorage> | import("@tiptap/core").Node<import("@tiptap/extension-image").ImageOptions, any> | Extension<import("@tiptap/extension-table").TableKitOptions, any> | Extension<import("@tiptap/extensions").PlaceholderOptions, any> | Extension<import("@tiptap/extension-list").ListKitOptions, any>)[];
11
+ export declare function useExtensions({ props, emit }: any): (import("@tiptap/core").Node<any, any> | import("@tiptap/core").Node<import("@tiptap/extension-mention").MentionOptions<any, import("@tiptap/extension-mention").MentionNodeAttrs>, any> | Extension<any, any> | Extension<import("@tiptap/starter-kit").StarterKitOptions, any> | import("@tiptap/core").Mark<import("@tiptap/extension-text-style").TextStyleOptions, any> | Extension<import("@tiptap/extension-text-style").ColorOptions, any> | Extension<import("tiptap-markdown").MarkdownOptions, import("tiptap-markdown").MarkdownStorage> | import("@tiptap/core").Node<import("@tiptap/extension-image").ImageOptions, any> | Extension<import("@tiptap/extension-table").TableKitOptions, any> | Extension<import("@tiptap/extensions").PlaceholderOptions, any> | Extension<import("@tiptap/extension-list").ListKitOptions, any>)[];
@@ -68,7 +68,6 @@ function useExtensions({ props, emit }) {
68
68
  allowedPrefixes: null,
69
69
  render() {
70
70
  let activeRange = null;
71
- let activeEditor = null;
72
71
  let exitCause = "unknown";
73
72
  return {
74
73
  onStart({ editor, range, command, query }) {
@@ -146,6 +145,27 @@ function useExtensions({ props, emit }) {
146
145
  }
147
146
  }
148
147
  });
148
+ let spentMentionPositions = [];
149
+ let activeEditor = null;
150
+ const MentionTracker = import_core.Extension.create({
151
+ name: "mentionTracker",
152
+ onTransaction({ transaction }) {
153
+ if (spentMentionPositions.length === 0)
154
+ return;
155
+ spentMentionPositions = spentMentionPositions.map((pos) => transaction.mapping.map(pos, -1));
156
+ spentMentionPositions = spentMentionPositions.filter((pos) => {
157
+ try {
158
+ if (pos < 0 || pos >= transaction.doc.content.size)
159
+ return false;
160
+ const char = transaction.doc.textBetween(pos, pos + 1);
161
+ return char === "@";
162
+ } catch (e) {
163
+ return false;
164
+ }
165
+ });
166
+ spentMentionPositions = Array.from(new Set(spentMentionPositions));
167
+ }
168
+ });
149
169
  const extensions = [
150
170
  import_starter_kit.default,
151
171
  import_HtmlBlock.default,
@@ -276,21 +296,60 @@ function useExtensions({ props, emit }) {
276
296
  suggestion: {
277
297
  char: "@",
278
298
  allowedPrefixes: null,
279
- // 允许任何前缀
299
+ allowSpaces: false,
300
+ /**
301
+ * allow
302
+ * - 功能:判断是否允许触发建议态。
303
+ * - 1. 当@ 前面一个字符是数字/英文时,不触发,防止用户是想要输入邮箱。
304
+ * - 2. 触发以后如果包含数字,则收起(通过返回 false 销毁建议态)。
305
+ */
306
+ allow: ({ state, range }) => {
307
+ if (spentMentionPositions.includes(range.from)) {
308
+ return false;
309
+ }
310
+ const doc = state.doc;
311
+ const $from = doc.resolve(range.from);
312
+ const isAtStart = range.from === $from.start();
313
+ const prevChar = isAtStart ? "" : doc.textBetween(range.from - 1, range.from);
314
+ if (/[a-zA-Z0-9]/.test(prevChar)) {
315
+ return false;
316
+ }
317
+ const query = doc.textBetween(range.from + 1, range.to);
318
+ if (/[0-9]/.test(query)) {
319
+ return false;
320
+ }
321
+ return true;
322
+ },
280
323
  render() {
281
324
  return {
282
- onStart({ command }) {
325
+ onStart({ editor, range, command, query }) {
326
+ activeEditor = editor;
283
327
  emit("mention-triggered", (data) => {
284
328
  command({
285
329
  id: data.userId,
286
330
  label: data.name
287
331
  });
288
332
  });
333
+ emit("mention-input", query != null ? query : "");
334
+ },
335
+ onUpdate({ query, editor }) {
336
+ activeEditor = editor;
337
+ emit("mention-input", query != null ? query : "");
338
+ },
339
+ onExit({ range }) {
340
+ if (range.from !== void 0) {
341
+ spentMentionPositions.push(range.from);
342
+ }
343
+ emit("mention-exit");
289
344
  }
290
345
  };
291
346
  }
292
347
  }
293
348
  }),
349
+ /**
350
+ * 辅助扩展:追踪记录已失活的 Mention 触发点
351
+ */
352
+ MentionTracker,
294
353
  // HashTag 扩展:支持 # 触发、实时输入同步、完成后插入为 “#+文字”
295
354
  HashTag
296
355
  ];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cgboiler/biz-basic",
3
- "version": "1.0.44",
3
+ "version": "1.0.46",
4
4
  "description": "",
5
5
  "main": "lib/index.js",
6
6
  "module": "es/index.js",