@kungal/editor-nuxt 0.38.1 → 0.38.3
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 +84 -0
- package/editor.css +24 -2
- package/package.json +4 -4
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,89 @@
|
|
|
1
1
|
# @kungal/editor-nuxt
|
|
2
2
|
|
|
3
|
+
## 0.38.3
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- cac6a81: 一次输入整段插进来的网址会自动变成链接,和粘贴一样
|
|
8
|
+
|
|
9
|
+
下游报的问题:手机上复制链接再插进编辑器,不会自动变成超链接。
|
|
10
|
+
|
|
11
|
+
真正的粘贴(长按「粘贴」、Ctrl+V)一直会变:Milkdown 的剪贴板插件把文本当 markdown 读,GFM 的裸链接识别把它变成链接。但安卓输入法的**剪贴板栏**(Gboard、搜狗、百度……)根本不触发 paste,它像打出一个词一样把整段文字提交进来,所以网址一直是纯文本。这不只是「编辑时不是蓝的」:序列化器会把纯文本网址转义成 `https\://…`(正是为了它以后不被读成链接),发出去的帖子上它也点不了。
|
|
12
|
+
|
|
13
|
+
新增(在 `createLinkPlugin()` 里,预设默认启用,纯逻辑):**一次输入插进来的文本,如果整段恰好是一个链接**(由粘贴所用的同一个 markdown 解析器判定,所以 `www.…`、邮箱都和粘贴时一样),就给它加上链接,保存为 `<https://…>`。三种情况不转:
|
|
14
|
+
|
|
15
|
+
- 在代码块或行内代码里;
|
|
16
|
+
- 已经在链接里(剧透里也不转 —— 剧透只装纯文本);
|
|
17
|
+
- 逐字打出来的网址:每次按键都是单独一次输入,几个字符永远不是一整个链接,打到一半不会变蓝。
|
|
18
|
+
|
|
19
|
+
输入法在前后带的空格不算进链接;链接后面接着打的字不会跟进链接。输入法组字过程中不动它,等 `compositionend` 再加(和输入规则一样 —— 组字中改样式会把组字打断);加链接这一步和那次输入在同一个撤销步骤里,撤销一次全部撤掉。
|
|
20
|
+
|
|
21
|
+
无破坏性变更。
|
|
22
|
+
|
|
23
|
+
- 8c798e2: 剧透里的网址不再在第二次打开时把收尾的 `||` 吞进链接
|
|
24
|
+
|
|
25
|
+
下游报的问题:引用块里放一个链接再隐藏,第一次编辑正常,第二次打开就把右边的 `||` 当成了链接的一部分;再保存,帖子里就成了一条坏链接。
|
|
26
|
+
|
|
27
|
+
根因:GFM 的裸链接识别(micromark 的 autolink literal)不会在 `|` 处停下,所以 `||https://a.com||` 在剧透的 remark 转换运行**之前**,收尾的 `||` 就被吞进了链接 —— mdast 里是文字 `||` 加一个指向 `https://a.com||` 的链接,没有哪个文字节点装着完整的一对 `||`,剧透就没了。再保存会写出 `||<https://a.com||>`,任何渲染器读出来都是一条以 `||` 结尾的坏链接。服务端的 linkify 遇到 `|` 会停,所以第一次保存看起来没问题。
|
|
28
|
+
|
|
29
|
+
修法(`remarkSpoilerPlugin`):落在**未闭合的 `||` 里**、且收尾的 `||` 在它里面或后面的**裸链接**(GFM 字面链接或 `<…>`,也就是文字就是网址本身的链接),先还原成文字、和前后文字合并,再按原来的规则配对。这一步不丢任何东西 —— 剧透本来就只装纯文本(`marks: ''`),装不下链接。
|
|
30
|
+
|
|
31
|
+
- `||https://…||`、`||www.…||`、`||me@a.com||`、`||看 https://… 这个||` 都会得到同一个剧透,打开、保存多少次都一样。剧透里的网址存成 `https\://…`(序列化器对纯文本网址的既有转义,防止它被再读成链接)。
|
|
32
|
+
- 已经坏成 `||<https://…||>` 的旧内容,**打开再保存一次即可自愈**。
|
|
33
|
+
- 不在剧透里的裸链接不受影响;`[文字](链接)` 这种带自己文字的链接不会被拆(拆了会丢网址),原样保留。
|
|
34
|
+
|
|
35
|
+
无破坏性变更。
|
|
36
|
+
|
|
37
|
+
- Updated dependencies [cac6a81]
|
|
38
|
+
- Updated dependencies [8c798e2]
|
|
39
|
+
- @kungal/editor-core@0.38.3
|
|
40
|
+
- @kungal/editor-vue@0.38.3
|
|
41
|
+
|
|
42
|
+
## 0.38.2
|
|
43
|
+
|
|
44
|
+
### Patch Changes
|
|
45
|
+
|
|
46
|
+
- 4dbe38b: 删 @提及 / #楼层 引用块时光标不再跳行,手机键盘不再收起又弹出
|
|
47
|
+
|
|
48
|
+
下游报的问题:回复里 `@anjila #3 ` 这样的引用标记,按退格时光标先掉到下一行、再回来,
|
|
49
|
+
删两个块要抖两次;手机端每抖一次,键盘就收起再弹出一次。原因此前一直没查明。
|
|
50
|
+
|
|
51
|
+
根因有两层,都在「段落以一个不可编辑的行内原子节点结尾」这一刻:
|
|
52
|
+
|
|
53
|
+
1. **视觉跳行(桌面 + 手机都有)。** 尾随空格删掉后,段落最后一个节点是
|
|
54
|
+
`contenteditable="false"` 的芯片。ProseMirror 为了让 Chrome / Safari 能在芯片后面画光标,
|
|
55
|
+
会补一个 `<img class="ProseMirror-separator">` 和一个尾随 `<br>`。这个 img 本该是 0×0 的
|
|
56
|
+
行内空元素,但宿主的通用 `img` 规则(Tailwind preflight 让所有 img `display:block`,
|
|
57
|
+
论坛的 `.milkdown img` 又加了 `my-8` 外边距和边框)把它变成了块级盒子 —— `<br>` 连同光标
|
|
58
|
+
被挤到下一行,段落高度翻倍(实测 24px → 48px),下一次退格删掉芯片后又缩回去,这就是抖动。
|
|
59
|
+
ProseMirror 自己的样式表里有一条 "Protect against generic img rules" 的守卫,Milkdown
|
|
60
|
+
不带那份样式表,`editor.css` 也一直没补 —— 现在补上了,`!important`,压过宿主的 prose 层。
|
|
61
|
+
2. **键盘闪烁(Android)。** 光标紧挨芯片时,基础 keymap 的退格命令全都不适用,ProseMirror 交给
|
|
62
|
+
浏览器原生删;桌面上真实的 keydown 会触发 prosemirror-view 自己的兜底(`captureKeyDown`)
|
|
63
|
+
用事务删掉节点,但虚拟键盘发的是 keyCode 229,兜底不会跑,浏览器原生删不可编辑元素
|
|
64
|
+
「有时会失败」(prosemirror-view 原话),它对这种情况的回退是 **`view.dom.blur(); view.focus()`**
|
|
65
|
+
再粗暴删一格 —— 那一对 blur/focus 就是键盘收起又弹出。
|
|
66
|
+
|
|
67
|
+
修法:
|
|
68
|
+
|
|
69
|
+
- `@kungal/editor-nuxt/editor.css` 新增结构性规则 `.kun-editor__wysiwyg img.ProseMirror-separator`
|
|
70
|
+
(display:inline、0×0、无外边距无边框)。写自己样式表的宿主请把它一并带上 —— 文档「样式」页
|
|
71
|
+
的结构性规则清单已加入。
|
|
72
|
+
- `@kungal/editor-core` 新增 `createInlineAtomPlugin()`(预设默认启用,纯逻辑):在 `beforeinput`
|
|
73
|
+
的 `deleteContentBackward` / `deleteContentForward` 上,只要光标紧挨(或选中的就是)一个行内原子
|
|
74
|
+
节点,就 `preventDefault` 并用**一个事务**删掉它 —— 硬件键盘、IME、虚拟键盘、右键菜单删除走的
|
|
75
|
+
都是这一个事件,浏览器再也碰不到那个 `contenteditable=false` 元素,prosemirror-view 的
|
|
76
|
+
blur/focus 回退没有机会触发。任何 `atom: true` 的行内节点(提及、引用、行内公式、以后的自定义
|
|
77
|
+
芯片)自动享有;块级原子节点仍交给基础 keymap 的 `selectNodeBackward`。输入规则刚触发时的退格
|
|
78
|
+
照旧先撤销规则(与基础 keymap 的顺序一致);IME 组合中不介入。
|
|
79
|
+
|
|
80
|
+
行为:`@anjila #3 ` 仍是 4 次退格(空格、芯片、空格、芯片 —— 空格是真实字符,与 Slack / Notion /
|
|
81
|
+
Google Docs 一致),但每一次都精确删一个单位,光标全程留在同一行。无破坏性变更。
|
|
82
|
+
|
|
83
|
+
- Updated dependencies [4dbe38b]
|
|
84
|
+
- @kungal/editor-core@0.38.2
|
|
85
|
+
- @kungal/editor-vue@0.38.2
|
|
86
|
+
|
|
3
87
|
## 0.38.1
|
|
4
88
|
|
|
5
89
|
### Patch Changes
|
package/editor.css
CHANGED
|
@@ -11,8 +11,9 @@
|
|
|
11
11
|
* Import it (fixes then arrive with a version bump) or copy it into your app and
|
|
12
12
|
* edit freely — it's plain CSS with no build step.
|
|
13
13
|
*
|
|
14
|
-
* It also carries the
|
|
15
|
-
*
|
|
14
|
+
* It also carries the structural rules the editor genuinely needs to function:
|
|
15
|
+
* ProseMirror's `white-space`, the guard on ProseMirror's caret hack nodes, and
|
|
16
|
+
* the popover positioning / show-hide.
|
|
16
17
|
*/
|
|
17
18
|
|
|
18
19
|
/* The surface every floating panel sits on (selection bubble, @mention dropdown,
|
|
@@ -105,6 +106,27 @@
|
|
|
105
106
|
word-wrap: break-word;
|
|
106
107
|
}
|
|
107
108
|
|
|
109
|
+
/* ProseMirror's caret hack node. When a textblock ENDS in a `contenteditable=false`
|
|
110
|
+
* node — an @mention or #floor chip, inline math, any inline atom — prosemirror-view
|
|
111
|
+
* appends `<img class="ProseMirror-separator">` + `<br class="ProseMirror-trailingBreak">`
|
|
112
|
+
* so Chrome / Safari can draw a caret after it. The img is meant to be a 0×0
|
|
113
|
+
* inline nothing, but a host's generic `img` rule (Tailwind's preflight makes
|
|
114
|
+
* every img display:block; the forum adds my-8 margins and a border) turns it
|
|
115
|
+
* into a block box: the trailing <br>, and the caret with it, drop onto a new
|
|
116
|
+
* line, the paragraph doubles in height, and every Backspace past a chip looks
|
|
117
|
+
* like a jump. prosemirror-view's own stylesheet ships this guard ("Protect
|
|
118
|
+
* against generic img rules"); Milkdown doesn't include that sheet, so it lives
|
|
119
|
+
* here. `!important` on purpose — it has to beat whatever the host's prose
|
|
120
|
+
* layer says about images. */
|
|
121
|
+
.kun-editor__wysiwyg img.ProseMirror-separator {
|
|
122
|
+
display: inline !important;
|
|
123
|
+
width: 0 !important;
|
|
124
|
+
height: 0 !important;
|
|
125
|
+
margin: 0 !important;
|
|
126
|
+
padding: 0 !important;
|
|
127
|
+
border: none !important;
|
|
128
|
+
}
|
|
129
|
+
|
|
108
130
|
/* The spoiler chip while you EDIT it (`||hidden||`). @kungal/editor-core paints
|
|
109
131
|
* a `currentColor`-derived tint on its own — it must look hidden in a host with
|
|
110
132
|
* no design tokens at all — and reads `--kun-spoiler-bg` first, which is this
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kungal/editor-nuxt",
|
|
3
|
-
"version": "0.38.
|
|
3
|
+
"version": "0.38.3",
|
|
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.38.
|
|
36
|
-
"@kungal/editor-vue": "0.38.
|
|
35
|
+
"@kungal/editor-core": "0.38.3",
|
|
36
|
+
"@kungal/editor-vue": "0.38.3"
|
|
37
37
|
},
|
|
38
38
|
"peerDependencies": {
|
|
39
39
|
"@kungal/ui-vue": "^2.7.0",
|
|
@@ -42,7 +42,7 @@
|
|
|
42
42
|
"vue": "^3.5.0"
|
|
43
43
|
},
|
|
44
44
|
"devDependencies": {
|
|
45
|
-
"@kungal/ui-vue": "^2.
|
|
45
|
+
"@kungal/ui-vue": "^2.32.0",
|
|
46
46
|
"@nuxt/kit": "^4.4.7"
|
|
47
47
|
},
|
|
48
48
|
"scripts": {
|