@kungal/editor-nuxt 0.34.0 → 0.36.0

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,88 @@
1
1
  # @kungal/editor-nuxt
2
2
 
3
+ ## 0.36.0
4
+
5
+ ### Minor Changes
6
+
7
+ - f7c65c2: fix(editor): the spoiler toolbar button hides the selection instead of deleting it
8
+
9
+ `insertKunSpoilerCommand` built an EMPTY `kun-spoiler` node and dropped it over
10
+ the selection with `replaceSelectionWith`, so clicking 隐藏文本 with text selected
11
+ deleted the text and left a bare `||||` — and the next thing typed landed
12
+ outside the node, so nothing was hidden either. The JSDoc said "wraps the
13
+ current selection"; the code never wrapped anything.
14
+
15
+ The command now covers the three cases the `||…||` syntax does:
16
+
17
+ - **a selection** → its text moves inside the node. The schema is `marks: ''`
18
+ (inline formatting cannot round-trip through `||…||`), so bold is what's
19
+ dropped, never the words. Selections spanning paragraphs collapse into one
20
+ spoiler; select-all (an `AllSelection`) works too.
21
+ - **an empty selection** → a new spoiler with the caret INSIDE it: type and it
22
+ is hidden. It holds a zero-width caret anchor, because a caret cannot sit in
23
+ an inline node with no text node in it — the serializer strips anchors, and a
24
+ spoiler holding nothing else serializes to nothing, so a stray click cannot
25
+ leave `||||` behind.
26
+ - **the caret already inside a spoiler** → reveal it, leaving the text selected.
27
+ Nesting would have produced `||||text||||`, which reads back as nothing.
28
+
29
+ The button is therefore a toggle, and both toolbars (the headless one and the
30
+ KunUI one in `@kungal/editor-nuxt`) now show it pressed while the caret is
31
+ inside a spoiler — `KunToggleMark` gains a `'spoiler'` member for that, so
32
+ `activeMarks` carries one more key.
33
+
34
+ It returns `false` — no document change — inside a code block and with a node
35
+ selected (an image is not text; replacing it would delete it).
36
+
37
+ ### Patch Changes
38
+
39
+ - Updated dependencies [f7c65c2]
40
+ - @kungal/editor-core@0.36.0
41
+ - @kungal/editor-vue@0.36.0
42
+
43
+ ## 0.35.0
44
+
45
+ ### Minor Changes
46
+
47
+ - c90e1b9: fix(link): give a typed URL the scheme it needs, in ONE place
48
+
49
+ Typing `www.kungal.com/topic/1` into any link input produced a **relative**
50
+ href: with no scheme the browser resolves it against the current page, so the
51
+ link went to `<origin>/<current/path>/www.kungal.com/topic/1` — dead, and dead
52
+ in a way the author can't see while writing.
53
+
54
+ `insertLinkCommand` now normalizes its `href`, and since every link entry point
55
+ (the selection bubble's input, the headless toolbar's URL panel, the KunUI
56
+ toolbar's popover, and a host's own `linkPrompt` adapter) dispatches that one
57
+ command, all of them are fixed at once — a host must not re-implement this.
58
+
59
+ - `www.kungal.com/topic/1` → `https://www.kungal.com/topic/1` (https, not http:
60
+ an http-only site redirects, an https-only site doesn't). Ports, queries,
61
+ fragments and bare IPv4 hosts included.
62
+ - `me@kungal.com` → `mailto:me@kungal.com` (`https://` would read the address as
63
+ userinfo and go nowhere).
64
+ - Untouched: anything with a scheme — `kungal-user:` / `kungal-reply:` included
65
+ — and anything explicitly relative (`/x`, `./x`, `../x`, `#x`, `?x`, `//host`).
66
+ - The one ambiguous input is a lone dotted word: `readme.md` looks exactly like
67
+ a hostname (`.md` is a TLD), so it gets `https://`. Write `./readme.md` when a
68
+ relative file is what you mean.
69
+
70
+ The rule is also exported as `normalizeLinkHref(input)` from the light,
71
+ zero-dependency `@kungal/editor-core` entry, so a server can normalize legacy
72
+ content with the exact same logic.
73
+
74
+ Along with it, the three URL inputs move from `type="url"` to `type="text"` +
75
+ `inputmode="url"`. Native URL validation rejects exactly the schemeless input
76
+ this change exists to accept — in the KunUI toolbar's popover, which submits a
77
+ real `<form>`, pressing Enter on `www.kungal.com/topic/1` did nothing at all.
78
+ The mobile keyboard hint is kept.
79
+
80
+ ### Patch Changes
81
+
82
+ - Updated dependencies [c90e1b9]
83
+ - @kungal/editor-core@0.35.0
84
+ - @kungal/editor-vue@0.35.0
85
+
3
86
  ## 0.34.0
4
87
 
5
88
  ### Minor Changes
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kungal/editor-nuxt",
3
- "version": "0.34.0",
3
+ "version": "0.36.0",
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.34.0",
36
- "@kungal/editor-vue": "0.34.0"
35
+ "@kungal/editor-core": "0.36.0",
36
+ "@kungal/editor-vue": "0.36.0"
37
37
  },
38
38
  "peerDependencies": {
39
39
  "@kungal/ui-vue": "^2.7.0",
@@ -119,7 +119,7 @@ const commandButtons = computed<Record<string, Tool>>(() => ({
119
119
  quote: { icon: 'lucide:text-quote', title: t.value.quote, run: () => props.run(wrapInBlockquoteCommand.key) },
120
120
  codeBlock: { icon: 'lucide:square-code', title: t.value.codeBlock, run: () => props.run(createCodeBlockCommand.key, '') },
121
121
  hr: { icon: 'lucide:minus', title: t.value.hr, run: () => props.run(insertHrCommand.key) },
122
- spoiler: { icon: 'lucide:eye-off', title: t.value.spoiler, run: () => props.run(insertKunSpoilerCommand.key) }
122
+ spoiler: { icon: 'lucide:eye-off', title: t.value.spoiler, run: () => props.run(insertKunSpoilerCommand.key), mark: 'spoiler' }
123
123
  }))
124
124
 
125
125
  type RenderItem =
@@ -319,10 +319,14 @@ const insertSticker = (src: string, name: string) =>
319
319
  </KunButton>
320
320
  </KunTooltip>
321
321
  </template>
322
+ <!-- `type="text"` + `inputmode="url"`, never `type="url"`: this IS a
323
+ form, so native URL validation would block submit on a schemeless
324
+ `www.a.com/x` — the very input insertLinkCommand normalizes. -->
322
325
  <form class="flex items-center gap-1" @submit.prevent="applyLink">
323
326
  <KunInput
324
327
  v-model="linkUrl"
325
- type="url"
328
+ type="text"
329
+ inputmode="url"
326
330
  size="sm"
327
331
  :placeholder="t.linkPlaceholder"
328
332
  :autofocus="true"