yh-codemirror 1.0.7 → 1.0.8
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/CHANGELOG.md +4 -0
- package/CodeMirror.vue +13 -2
- package/README.md +2 -0
- package/ai-history.js +0 -3
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,10 @@
|
|
|
2
2
|
|
|
3
3
|
## 1.0.7
|
|
4
4
|
|
|
5
|
+
- 2026-10-08 15:06 feature: 新增 `aiWindowId` 入参与 `ai-activate` 事件
|
|
6
|
+
- AI 面板打开时把 `aiWindowId` 通过 `ai-activate` 抛给宿主,宿主可趁用户还没打字时预取上下文
|
|
7
|
+
- 组件本身不认识任何业务接口(保持零依赖),窗口配置怎么取、怎么缓存完全由宿主决定
|
|
8
|
+
- `aiWindowId` 为空时不触发事件
|
|
5
9
|
- 2026-09-30 18:54 feature: 新增 `aiPanelSize` 尺寸档位(`'normal' | 'large'`)
|
|
6
10
|
- 放大场景(window-form 的「放大」抽屉)传 `large`:面板内边距 6/8 → 10/12、字号 12 → 14px、
|
|
7
11
|
输入框 2 行 → 4 行、历史面板 max-height 62% → 72%(代码区 170px → 300px)
|
package/CodeMirror.vue
CHANGED
|
@@ -218,10 +218,16 @@ const props = withDefaults(
|
|
|
218
218
|
/** 编辑器主题:dark(默认)或 light */
|
|
219
219
|
theme?: 'dark' | 'light';
|
|
220
220
|
/**
|
|
221
|
-
* AI
|
|
221
|
+
* AI 面板尺寸档位。编辑区被放大时(如 window-form 的「放大」抽屉)传 'large',
|
|
222
222
|
* 否则 12px 字号 + 2 行输入框在大面板里会显得很局促。
|
|
223
223
|
*/
|
|
224
224
|
aiPanelSize?: 'normal' | 'large';
|
|
225
|
+
/**
|
|
226
|
+
* AI 上下文用的「所属窗口 ID」(SLW 为 formConfig.params.parentData.SYS_WINDOW_ID)。
|
|
227
|
+
* 组件本身不知道怎么取窗口配置,只在 AI 被激活时通过 `ai-activate` 事件把它抛给宿主,
|
|
228
|
+
* 由宿主去拉配置;不传就不触发该事件。
|
|
229
|
+
*/
|
|
230
|
+
aiWindowId?: string | number;
|
|
225
231
|
}>(),
|
|
226
232
|
{
|
|
227
233
|
modelValue: '',
|
|
@@ -232,6 +238,7 @@ const props = withDefaults(
|
|
|
232
238
|
aiScope: 'document',
|
|
233
239
|
theme: 'dark',
|
|
234
240
|
aiPanelSize: 'normal',
|
|
241
|
+
aiWindowId: '',
|
|
235
242
|
}
|
|
236
243
|
);
|
|
237
244
|
|
|
@@ -316,7 +323,7 @@ watch(
|
|
|
316
323
|
}
|
|
317
324
|
);
|
|
318
325
|
|
|
319
|
-
const emits = defineEmits(['update:modelValue', 'ai-apply', 'ai-error']);
|
|
326
|
+
const emits = defineEmits(['update:modelValue', 'ai-apply', 'ai-error', 'ai-activate']);
|
|
320
327
|
|
|
321
328
|
/* ------------------------------ AI 提示编辑 ------------------------------ */
|
|
322
329
|
const aiEnabled = computed(() => typeof props.aiRequest === 'function');
|
|
@@ -376,6 +383,10 @@ const openAi = (presetPrompt?: string) => {
|
|
|
376
383
|
aiError.value = '';
|
|
377
384
|
aiLoading.value = false;
|
|
378
385
|
aiVisible.value = true;
|
|
386
|
+
// AI 被激活:把窗口 ID 抛给宿主,让它提前把窗口配置拉好(组件本身不认识任何业务接口)
|
|
387
|
+
if (props.aiWindowId !== '' && props.aiWindowId !== null && props.aiWindowId !== undefined) {
|
|
388
|
+
emits('ai-activate', props.aiWindowId);
|
|
389
|
+
}
|
|
379
390
|
nextTick(() => {
|
|
380
391
|
aiInputRef.value && aiInputRef.value.focus();
|
|
381
392
|
});
|
package/README.md
CHANGED
|
@@ -39,12 +39,14 @@ Vue3 的 CodeMirror6 封装,在全屏 / 美化 / 全选 / 复制 / 清空 等
|
|
|
39
39
|
| `aiPlaceholder` | `string` | 见源码 | 输入框占位提示 |
|
|
40
40
|
| `aiScope` | `'document' \| 'cursor'` | `'document'` | 无选区时的作用范围 |
|
|
41
41
|
| `aiPanelSize` | `'normal' \| 'large'` | `'normal'` | AI 输入框 / 历史面板的尺寸档位。编辑区被放大时(如 window-form 的「放大」抽屉)传 `large` |
|
|
42
|
+
| `aiWindowId` | `string \| number` | `''` | AI 上下文用的「所属窗口 ID」。组件不认识任何业务接口,只在 AI 被唤起时通过 `ai-activate` 把它抛给宿主,由宿主去取窗口配置 |
|
|
42
43
|
|
|
43
44
|
### Events
|
|
44
45
|
|
|
45
46
|
| 事件 | 参数 | 说明 |
|
|
46
47
|
| ---------------- | ----------------------------- | ------------------------ |
|
|
47
48
|
| `update:modelValue` | `string` | 代码变更(原有) |
|
|
49
|
+
| `ai-activate` | `string \| number` | AI 面板刚打开(携带 `aiWindowId`),宿主可趁此时预取上下文;`aiWindowId` 为空时不触发 |
|
|
48
50
|
| `ai-apply` | `{prompt, text}` | AI 结果已写入编辑器 |
|
|
49
51
|
| `ai-error` | `Error` | AI 请求失败 |
|
|
50
52
|
|
package/ai-history.js
CHANGED