@kungal/editor-nuxt 0.37.0 → 0.38.1

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 CHANGED
@@ -1,5 +1,65 @@
1
1
  # @kungal/editor-nuxt
2
2
 
3
+ ## 0.38.1
4
+
5
+ ### Patch Changes
6
+
7
+ - f078b5b: KunUI 工具栏的链接面板不再抢着聚焦,页面不会被弹到顶部
8
+
9
+ 下游报的两个 bug:① 滚到页面中部点「链接」,整页跳回顶部;② 编辑器放进 `KunModal` /
10
+ `KunDrawer` 时,链接面板里的输入框一个字都打不进去。
11
+
12
+ 两个都属实,但根因都在 KunUI 侧,且 `@kungal/ui-vue` **2.26.0 已经全部修好**(库里每一处
13
+ 主动 `focus()` 都带 `preventScroll`;浮层面板会登记进开它的那个弹窗的焦点陷阱)。
14
+
15
+ 这里只做一件事:**把工具栏链接面板上那个多余的 `:autofocus="true"` 删掉。**
16
+ `KunPopover` 打开时本来就会带着 `preventScroll` 聚焦面板里第一个可聚焦元素 ——
17
+ 输入框自己的挂载聚焦比它早一拍,发生在 floating-ui 量出位置**之前**,此时 teleport 到
18
+ `<body>` 的面板还停在文档原点(实测 `getBoundingClientRect().top === -1440`),
19
+ 浏览器「滚动到该元素」就把整页拉回了顶部。这个 prop 从来没做过 popover 没做对的事,
20
+ 删掉之后即使宿主的 KunUI 还没升到 2.26.0,也不会再跳顶。
21
+
22
+ 第二个问题(弹窗里的焦点陷阱)编辑器这一侧无解 —— 面板是 KunUI teleport 的,陷阱也是
23
+ KunUI 建的。**编辑器放进 `KunModal` / `KunDrawer`,请把 `@kungal/ui-vue` 升到 2.26.0 及以上**,
24
+ 这一点已写进 `@kungal/editor-nuxt` 的 README 与文档的「Nuxt 接入」页(那页还加了一个
25
+ 「弹窗里的编辑器」实测 demo)。
26
+
27
+ 无破坏性变更:面板照样自动聚焦,行为不变。
28
+
29
+ - Updated dependencies [f078b5b]
30
+ - @kungal/editor-core@0.38.1
31
+ - @kungal/editor-vue@0.38.1
32
+
33
+ ## 0.38.0
34
+
35
+ ### Minor Changes
36
+
37
+ - 0f3ceab: 隐藏文本:编辑时看得出被隐藏,光标锚点不再进入存库的 markdown
38
+
39
+ - **剧透块的底色不再依赖宿主 token。** 原来是 `background: var(--color-default-500)`,
40
+ 没有 fallback —— 宿主没定义这个调色板变量时整条声明作废,实测算出来是
41
+ `rgba(0, 0, 0, 0)`:编辑时剧透块和正文长得一模一样。而「零 CSS 的 headless 编辑器」
42
+ 正是这样的宿主。现在自带一份不依赖任何设计 token 的默认底色(由 `currentColor`
43
+ 混出,明暗主题都成立),并留出 `--kun-spoiler-bg` 这个换肤钩子 —— 内联样式压得过
44
+ 任何选择器,但压不过自定义属性,所以这是宿主唯一能用纯 CSS 改它的入口。
45
+ `@kungal/editor-nuxt/editor.css` 把它映射成 `--color-default-200`,KunUI 宿主观感不变。
46
+ - **光标锚点(`U+200B`)只留在编辑器文档里,不再写进 markdown。** 锚点是编辑器的
47
+ 内部装置(光标必须落在某个 text 节点上),但它一直跟着正文一起被序列化出去,存库的
48
+ 文本会变成 `鲲 ||Galgame||<U+200B> 论坛` —— 数据库、diff、以及每一个不认识本编辑器的
49
+ 下游都得吃下这个看不见的字符。现在在 **serializer** 这一层统一剥掉:`getMarkdown()`、
50
+ `v-model`、源码视图、宿主自己的 action 都读同一个 slice,所以一处收口全部干净;
51
+ 从旧内容或粘贴带进来的锚点也一并清掉 —— **旧帖打开再保存一次就自愈**。
52
+ 解析时反过来给每个 `||…||` 补回锚点,所以「点在段尾的剧透块后面接着打字,字落在
53
+ 块外面」这件事和以前一样成立。
54
+
55
+ 对下游没有破坏性改动:markdown 少了一个不可见字符,DOM 结构与命令行为不变。
56
+
57
+ ### Patch Changes
58
+
59
+ - Updated dependencies [0f3ceab]
60
+ - @kungal/editor-core@0.38.0
61
+ - @kungal/editor-vue@0.38.0
62
+
3
63
  ## 0.37.0
4
64
 
5
65
  ### Minor Changes
package/README.md CHANGED
@@ -30,6 +30,12 @@ Then, anywhere in a template:
30
30
  `@kungal/ui-tokens` + `@kungal/ui-vue` setup. This layer intentionally owns no
31
31
  Tailwind entry — the `@source` scan path is node_modules-layout-specific, so
32
32
  only the app can write it correctly.
33
+ - **Rendering the editor inside a `KunModal` / `KunDrawer` needs
34
+ `@kungal/ui-vue` >= 2.26.0.** The toolbar's link and sticker panels are
35
+ `KunPopover`s, which teleport to `<body>`; before 2.26.0 an overlay's focus
36
+ trap did not know about them and pulled focus straight back to the trigger, so
37
+ those panels could not be typed into. 2.26.0 registers a popover with the
38
+ overlay that opened it. Nothing to configure on the editor side.
33
39
 
34
40
  ## Status
35
41
 
package/editor.css CHANGED
@@ -105,6 +105,17 @@
105
105
  word-wrap: break-word;
106
106
  }
107
107
 
108
+ /* The spoiler chip while you EDIT it (`||hidden||`). @kungal/editor-core paints
109
+ * a `currentColor`-derived tint on its own — it must look hidden in a host with
110
+ * no design tokens at all — and reads `--kun-spoiler-bg` first, which is this
111
+ * hook: KunUI's muted surface, so the chip matches the rest of the chrome.
112
+ * Setting a custom property works from here even though the chip's `background`
113
+ * is an inline style (specificity applies per property, and this sets a
114
+ * different one). */
115
+ .kun-editor__wysiwyg .kun-spoiler {
116
+ --kun-spoiler-bg: var(--color-default-200);
117
+ }
118
+
108
119
  /* Placeholder: the editor sets a `data-placeholder` attr + this class on the
109
120
  * empty block (a decoration, not real content). Render the text via ::before so
110
121
  * it never affects the doc / caret. */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kungal/editor-nuxt",
3
- "version": "0.37.0",
3
+ "version": "0.38.1",
4
4
  "description": "KunEditor Nuxt Layer — wraps @kungal/editor-vue and auto-imports <KunEditor> so an existing Nuxt app keeps its exact DX (no import needed).",
5
5
  "type": "module",
6
6
  "keywords": [
@@ -32,8 +32,8 @@
32
32
  "nuxt.config.ts"
33
33
  ],
34
34
  "dependencies": {
35
- "@kungal/editor-core": "0.37.0",
36
- "@kungal/editor-vue": "0.37.0"
35
+ "@kungal/editor-core": "0.38.1",
36
+ "@kungal/editor-vue": "0.38.1"
37
37
  },
38
38
  "peerDependencies": {
39
39
  "@kungal/ui-vue": "^2.7.0",
@@ -42,6 +42,7 @@
42
42
  "vue": "^3.5.0"
43
43
  },
44
44
  "devDependencies": {
45
+ "@kungal/ui-vue": "^2.26.0",
45
46
  "@nuxt/kit": "^4.4.7"
46
47
  },
47
48
  "scripts": {
@@ -321,7 +321,16 @@ const insertSticker = (src: string, name: string) =>
321
321
  </template>
322
322
  <!-- `type="text"` + `inputmode="url"`, never `type="url"`: this IS a
323
323
  form, so native URL validation would block submit on a schemeless
324
- `www.a.com/x` — the very input insertLinkCommand normalizes. -->
324
+ `www.a.com/x` — the very input insertLinkCommand normalizes.
325
+
326
+ NO `autofocus`: KunPopover already focuses the first focusable
327
+ element in its panel when it opens, and does it with
328
+ `preventScroll`. The input's own mount-time focus ran a tick
329
+ EARLIER — while the panel, teleported to <body>, was still sitting
330
+ at the document origin because floating-ui had not measured yet —
331
+ so "scroll the focused element into view" yanked the whole page to
332
+ the top. KunUI ≥ 2.26.0 passes preventScroll there too, but this
333
+ prop was doing nothing the popover wasn't already doing right. -->
325
334
  <form class="flex items-center gap-1" @submit.prevent="applyLink">
326
335
  <KunInput
327
336
  v-model="linkUrl"
@@ -329,7 +338,6 @@ const insertSticker = (src: string, name: string) =>
329
338
  inputmode="url"
330
339
  size="sm"
331
340
  :placeholder="t.linkPlaceholder"
332
- :autofocus="true"
333
341
  class="flex-1"
334
342
  />
335
343
  <KunButton type="submit" variant="flat" color="primary" size="sm">