@kungal/editor-vue 0.27.0 → 0.28.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,40 @@
1
1
  # @kungal/editor-vue
2
2
 
3
+ ## 0.28.0
4
+
5
+ ### Minor Changes
6
+
7
+ - 8d278e5: Make the insert-link URL entry customizable via a `linkPrompt` adapter.
8
+
9
+ The headless toolbar and the selection bubble asked for the link URL with the
10
+ native `window.prompt` (the KunUI toolbar used an inline popover). Hosts can now
11
+ supply their own UI instead — a modal, an article picker, etc.:
12
+
13
+ ```ts
14
+ const adapters = {
15
+ // …uploadImage, notify…
16
+ linkPrompt: async ({ text }) => await openLinkModal(text), // return the URL, or null to cancel
17
+ };
18
+ ```
19
+
20
+ - **editor-core**: new `LinkPrompt` type + `linkPrompt?` on `KunEditorAdapters`.
21
+ It receives the selected text (to prefill / search).
22
+ - **editor-vue**: the default toolbar and the selection bubble use `linkPrompt`
23
+ when supplied, else fall back to `window.prompt`.
24
+ - **editor-nuxt**: when `linkPrompt` is set, `<KunEditorToolbar>`'s link button
25
+ uses it instead of its inline popover — so one override covers every link entry
26
+ point (toolbar, default toolbar, bubble).
27
+
28
+ Verified in the docs production build: with a `linkPrompt` that derives a URL from
29
+ the selected text, the selection bubble inserts
30
+ `[…](https://example.com/search?q=…)` with no native dialog, and the KunUI
31
+ toolbar link becomes a plain button (no popover); 0 console errors.
32
+
33
+ ### Patch Changes
34
+
35
+ - Updated dependencies [8d278e5]
36
+ - @kungal/editor-core@0.28.0
37
+
3
38
  ## 0.27.0
4
39
 
5
40
  ### Minor Changes
@@ -1 +1 @@
1
- {"version":3,"file":"EditorToolbar.vue.d.ts","sourceRoot":"","sources":["../../src/components/EditorToolbar.vue"],"names":[],"mappings":"AAieA,QAAA,MAAM,YAAY,+QAChB,CAAC;wBACkB,OAAO,YAAY;AAAxC,wBAAyC"}
1
+ {"version":3,"file":"EditorToolbar.vue.d.ts","sourceRoot":"","sources":["../../src/components/EditorToolbar.vue"],"names":[],"mappings":"AAufA,QAAA,MAAM,YAAY,+QAChB,CAAC;wBACkB,OAAO,YAAY;AAAxC,wBAAyC"}
@@ -1 +1 @@
1
- {"version":3,"file":"SelectionTooltip.vue.d.ts","sourceRoot":"","sources":["../../src/components/SelectionTooltip.vue"],"names":[],"mappings":"AAiTA,QAAA,MAAM,YAAY,+QAChB,CAAC;wBACkB,OAAO,YAAY;AAAxC,wBAAyC"}
1
+ {"version":3,"file":"SelectionTooltip.vue.d.ts","sourceRoot":"","sources":["../../src/components/SelectionTooltip.vue"],"names":[],"mappings":"AAiUA,QAAA,MAAM,YAAY,+QAChB,CAAC;wBACkB,OAAO,YAAY;AAAxC,wBAAyC"}
package/dist/index.js CHANGED
@@ -171,9 +171,12 @@ var X = Symbol("kun-editor-context"), Se = [
171
171
  setup(n) {
172
172
  let { view: r, prevState: o } = j(), [, s] = k(), c = l(X), u = t(() => (c?.locale ?? "zh-cn").toLowerCase().startsWith("en")), d = g(null), h, v = (e, t) => {
173
173
  s()?.action(W(e, t));
174
- }, y = () => {
175
- let e = window.prompt(u.value ? "Link URL" : "链接 URL")?.trim();
176
- e && v(J.key, { href: e });
174
+ }, y = async () => {
175
+ let e = r.value, { from: t, to: n } = e?.state.selection ?? {
176
+ from: 0,
177
+ to: 0
178
+ }, i = e ? e.state.doc.textBetween(t, n, " ") : "", a = c?.adapters.linkPrompt, o = (a ? await a({ text: i }) : window.prompt(u.value ? "Link URL" : "链接 URL"))?.trim();
179
+ o && v(J.key, { href: o });
177
180
  }, b = t(() => {
178
181
  let e = u.value;
179
182
  return {
@@ -432,9 +435,14 @@ var X = Symbol("kun-editor-context"), Se = [
432
435
  setup(n) {
433
436
  let [, s] = k(), c = l(X), u = t(() => c?.adapters.uploadImage), d = t(() => c?.features.sticker !== !1), f = t(() => (c?.locale ?? "zh-cn").toLowerCase().startsWith("en")), p = (e, t) => {
434
437
  s()?.action(W(e, t));
435
- }, h = () => {
436
- let e = window.prompt(f.value ? "Link URL" : "链接 URL")?.trim();
437
- e && p(J.key, { href: e });
438
+ }, h = async () => {
439
+ let e = "";
440
+ s()?.action((t) => {
441
+ let n = t.get(I), { from: r, to: i } = n.state.selection;
442
+ e = n.state.doc.textBetween(r, i, " ");
443
+ });
444
+ let t = c?.adapters.linkPrompt, n = (t ? await t({ text: e }) : window.prompt(f.value ? "Link URL" : "链接 URL"))?.trim();
445
+ n && p(J.key, { href: n });
438
446
  }, v = t(() => {
439
447
  let e = f.value;
440
448
  return {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kungal/editor-vue",
3
- "version": "0.27.0",
3
+ "version": "0.28.0",
4
4
  "description": "KunEditor Vue 3 layer — the headless <KunEditor> component (dual WYSIWYG / markdown-source), toolbar and plugin views. Ships zero CSS and no UI-kit dependency; consumes @kungal/editor-core, and pairs with @kungal/editor-nuxt for optional KunUI chrome.",
5
5
  "type": "module",
6
6
  "keywords": [
@@ -40,7 +40,7 @@
40
40
  },
41
41
  "dependencies": {
42
42
  "@prosemirror-adapter/vue": "^0.4.6",
43
- "@kungal/editor-core": "0.27.0"
43
+ "@kungal/editor-core": "0.28.0"
44
44
  },
45
45
  "peerDependencies": {
46
46
  "@codemirror/lang-markdown": "^6.0.0",
@@ -80,7 +80,7 @@
80
80
  "vite": "^8.0.16",
81
81
  "vue": "^3.5.35",
82
82
  "vue-tsc": "^3.3.3",
83
- "@kungal/editor-core": "0.27.0"
83
+ "@kungal/editor-core": "0.28.0"
84
84
  },
85
85
  "scripts": {
86
86
  "build": "vite build && vue-tsc -p tsconfig.build.json",