@cgboiler/biz-basic 1.0.46 → 1.0.47

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.45";
8
+ export const version: "1.0.46";
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.45";
2
+ const version = "1.0.46";
3
3
  function install(app) {
4
4
  const components = [
5
5
  RichTextEditor
@@ -10,6 +10,9 @@ import { Extension, InputRule } from "@tiptap/core";
10
10
  import HtmlBlock from "./extensions/HtmlBlock";
11
11
  import { Placeholder } from "@tiptap/extensions";
12
12
  function useExtensions({ props, emit }) {
13
+ let spentHashTagPositions = [];
14
+ let spentMentionPositions = [];
15
+ let activeEditor = null;
13
16
  const HashTag = Mention.extend({
14
17
  name: "hashTag",
15
18
  renderHTML({ node, HTMLAttributes }) {
@@ -34,6 +37,18 @@ function useExtensions({ props, emit }) {
34
37
  suggestion: {
35
38
  char: "#",
36
39
  allowedPrefixes: null,
40
+ allowSpaces: false,
41
+ /**
42
+ * allow
43
+ * - 功能:判断是否允许触发建议态。
44
+ * - 1. 若该位置的 # 已经触发过且未被删除,则不再重复触发(满足“单次触发制/光标静默”)。
45
+ */
46
+ allow: ({ state, range }) => {
47
+ if (spentHashTagPositions.includes(range.from)) {
48
+ return false;
49
+ }
50
+ return true;
51
+ },
37
52
  render() {
38
53
  let activeRange = null;
39
54
  let exitCause = "unknown";
@@ -87,7 +102,7 @@ function useExtensions({ props, emit }) {
87
102
  * - 返回值:无(通过 emit 派发事件)。
88
103
  * - 异常:内部读取选择/文档时若发生异常,捕获后保持原有退出原因,不影响外部流程。
89
104
  */
90
- onExit() {
105
+ onExit({ range }) {
91
106
  var _a, _b, _c, _d, _e;
92
107
  try {
93
108
  const editorRef = activeEditor;
@@ -101,6 +116,9 @@ function useExtensions({ props, emit }) {
101
116
  }
102
117
  } catch (e) {
103
118
  }
119
+ if ((range == null ? void 0 : range.from) !== void 0) {
120
+ spentHashTagPositions.push(range.from);
121
+ }
104
122
  activeRange = null;
105
123
  activeEditor = null;
106
124
  const payload = {
@@ -113,8 +131,25 @@ function useExtensions({ props, emit }) {
113
131
  }
114
132
  }
115
133
  });
116
- let spentMentionPositions = [];
117
- let activeEditor = null;
134
+ const HashTagTracker = Extension.create({
135
+ name: "hashTagTracker",
136
+ onTransaction({ transaction }) {
137
+ if (spentHashTagPositions.length === 0)
138
+ return;
139
+ spentHashTagPositions = spentHashTagPositions.map((pos) => transaction.mapping.map(pos, -1));
140
+ spentHashTagPositions = spentHashTagPositions.filter((pos) => {
141
+ try {
142
+ if (pos < 0 || pos >= transaction.doc.content.size)
143
+ return false;
144
+ const char = transaction.doc.textBetween(pos, pos + 1);
145
+ return char === "#";
146
+ } catch (e) {
147
+ return false;
148
+ }
149
+ });
150
+ spentHashTagPositions = Array.from(new Set(spentHashTagPositions));
151
+ }
152
+ });
118
153
  const MentionTracker = Extension.create({
119
154
  name: "mentionTracker",
120
155
  onTransaction({ transaction }) {
@@ -315,9 +350,10 @@ function useExtensions({ props, emit }) {
315
350
  }
316
351
  }),
317
352
  /**
318
- * 辅助扩展:追踪记录已失活的 Mention 触发点
353
+ * 辅助扩展:追踪记录已失活的触发点
319
354
  */
320
355
  MentionTracker,
356
+ HashTagTracker,
321
357
  // HashTag 扩展:支持 # 触发、实时输入同步、完成后插入为 “#+文字”
322
358
  HashTag
323
359
  ];
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.45";
8
+ export const version: "1.0.46";
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.45";
39
+ const version = "1.0.46";
40
40
  function install(app) {
41
41
  const components = [
42
42
  import_rich_text_editor.default
@@ -42,6 +42,9 @@ var import_core = require("@tiptap/core");
42
42
  var import_HtmlBlock = __toESM(require("./extensions/HtmlBlock"));
43
43
  var import_extensions = require("@tiptap/extensions");
44
44
  function useExtensions({ props, emit }) {
45
+ let spentHashTagPositions = [];
46
+ let spentMentionPositions = [];
47
+ let activeEditor = null;
45
48
  const HashTag = import_extension_mention.default.extend({
46
49
  name: "hashTag",
47
50
  renderHTML({ node, HTMLAttributes }) {
@@ -66,6 +69,18 @@ function useExtensions({ props, emit }) {
66
69
  suggestion: {
67
70
  char: "#",
68
71
  allowedPrefixes: null,
72
+ allowSpaces: false,
73
+ /**
74
+ * allow
75
+ * - 功能:判断是否允许触发建议态。
76
+ * - 1. 若该位置的 # 已经触发过且未被删除,则不再重复触发(满足“单次触发制/光标静默”)。
77
+ */
78
+ allow: ({ state, range }) => {
79
+ if (spentHashTagPositions.includes(range.from)) {
80
+ return false;
81
+ }
82
+ return true;
83
+ },
69
84
  render() {
70
85
  let activeRange = null;
71
86
  let exitCause = "unknown";
@@ -119,7 +134,7 @@ function useExtensions({ props, emit }) {
119
134
  * - 返回值:无(通过 emit 派发事件)。
120
135
  * - 异常:内部读取选择/文档时若发生异常,捕获后保持原有退出原因,不影响外部流程。
121
136
  */
122
- onExit() {
137
+ onExit({ range }) {
123
138
  var _a, _b, _c, _d, _e;
124
139
  try {
125
140
  const editorRef = activeEditor;
@@ -133,6 +148,9 @@ function useExtensions({ props, emit }) {
133
148
  }
134
149
  } catch (e) {
135
150
  }
151
+ if ((range == null ? void 0 : range.from) !== void 0) {
152
+ spentHashTagPositions.push(range.from);
153
+ }
136
154
  activeRange = null;
137
155
  activeEditor = null;
138
156
  const payload = {
@@ -145,8 +163,25 @@ function useExtensions({ props, emit }) {
145
163
  }
146
164
  }
147
165
  });
148
- let spentMentionPositions = [];
149
- let activeEditor = null;
166
+ const HashTagTracker = import_core.Extension.create({
167
+ name: "hashTagTracker",
168
+ onTransaction({ transaction }) {
169
+ if (spentHashTagPositions.length === 0)
170
+ return;
171
+ spentHashTagPositions = spentHashTagPositions.map((pos) => transaction.mapping.map(pos, -1));
172
+ spentHashTagPositions = spentHashTagPositions.filter((pos) => {
173
+ try {
174
+ if (pos < 0 || pos >= transaction.doc.content.size)
175
+ return false;
176
+ const char = transaction.doc.textBetween(pos, pos + 1);
177
+ return char === "#";
178
+ } catch (e) {
179
+ return false;
180
+ }
181
+ });
182
+ spentHashTagPositions = Array.from(new Set(spentHashTagPositions));
183
+ }
184
+ });
150
185
  const MentionTracker = import_core.Extension.create({
151
186
  name: "mentionTracker",
152
187
  onTransaction({ transaction }) {
@@ -347,9 +382,10 @@ function useExtensions({ props, emit }) {
347
382
  }
348
383
  }),
349
384
  /**
350
- * 辅助扩展:追踪记录已失活的 Mention 触发点
385
+ * 辅助扩展:追踪记录已失活的触发点
351
386
  */
352
387
  MentionTracker,
388
+ HashTagTracker,
353
389
  // HashTag 扩展:支持 # 触发、实时输入同步、完成后插入为 “#+文字”
354
390
  HashTag
355
391
  ];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cgboiler/biz-basic",
3
- "version": "1.0.46",
3
+ "version": "1.0.47",
4
4
  "description": "",
5
5
  "main": "lib/index.js",
6
6
  "module": "es/index.js",