@kungal/editor-core 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,35 @@
1
1
  # @kungal/editor-core
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
+
3
33
  ## 0.27.0
4
34
 
5
35
  ### Minor Changes
package/dist/index.d.cts CHANGED
@@ -1,4 +1,4 @@
1
- export { K as KunEditorAdapters, a as KunEditorFeatures, b as KunEditorLocale, M as MentionUser, N as Notify, c as NotifyLevel, S as SearchMentionUsers, d as StickerItem, e as StickerPack, f as StickerSource, U as UploadImage } from './types-Dq7UxR_g.cjs';
1
+ export { K as KunEditorAdapters, a as KunEditorFeatures, b as KunEditorLocale, L as LinkPrompt, M as MentionUser, N as Notify, c as NotifyLevel, S as SearchMentionUsers, d as StickerItem, e as StickerPack, f as StickerSource, U as UploadImage } from './types-BazCkMGt.cjs';
2
2
 
3
3
  interface KunHeading {
4
4
  /** Heading level 1–6. */
package/dist/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- export { K as KunEditorAdapters, a as KunEditorFeatures, b as KunEditorLocale, M as MentionUser, N as Notify, c as NotifyLevel, S as SearchMentionUsers, d as StickerItem, e as StickerPack, f as StickerSource, U as UploadImage } from './types-Dq7UxR_g.js';
1
+ export { K as KunEditorAdapters, a as KunEditorFeatures, b as KunEditorLocale, L as LinkPrompt, M as MentionUser, N as Notify, c as NotifyLevel, S as SearchMentionUsers, d as StickerItem, e as StickerPack, f as StickerSource, U as UploadImage } from './types-BazCkMGt.js';
2
2
 
3
3
  interface KunHeading {
4
4
  /** Heading level 1–6. */
@@ -1,6 +1,6 @@
1
1
  import { MilkdownPlugin, Ctx } from '@milkdown/kit/ctx';
2
2
  import { KatexOptions } from 'katex';
3
- import { b as KunEditorLocale, N as Notify, U as UploadImage, K as KunEditorAdapters, a as KunEditorFeatures } from '../types-Dq7UxR_g.cjs';
3
+ import { b as KunEditorLocale, N as Notify, U as UploadImage, K as KunEditorAdapters, a as KunEditorFeatures } from '../types-BazCkMGt.cjs';
4
4
  import * as _milkdown_kit_utils from '@milkdown/kit/utils';
5
5
  import { Extension } from '@codemirror/state';
6
6
  import { Uploader } from '@milkdown/kit/plugin/upload';
@@ -1,6 +1,6 @@
1
1
  import { MilkdownPlugin, Ctx } from '@milkdown/kit/ctx';
2
2
  import { KatexOptions } from 'katex';
3
- import { b as KunEditorLocale, N as Notify, U as UploadImage, K as KunEditorAdapters, a as KunEditorFeatures } from '../types-Dq7UxR_g.js';
3
+ import { b as KunEditorLocale, N as Notify, U as UploadImage, K as KunEditorAdapters, a as KunEditorFeatures } from '../types-BazCkMGt.js';
4
4
  import * as _milkdown_kit_utils from '@milkdown/kit/utils';
5
5
  import { Extension } from '@codemirror/state';
6
6
  import { Uploader } from '@milkdown/kit/plugin/upload';
@@ -46,6 +46,17 @@ type NotifyLevel = 'info' | 'success' | 'warn' | 'error';
46
46
  * Forum today: `useMessage(code, level)`.
47
47
  */
48
48
  type Notify = (message: string, level: NotifyLevel) => void;
49
+ /**
50
+ * Ask the user for a link URL — provide this to show your OWN UI (a modal, an
51
+ * inline input, an article picker…) instead of the native `window.prompt` the
52
+ * headless toolbar / selection bubble fall back to. Gets the currently selected
53
+ * text (to prefill or search). Return the URL, or a falsy value to cancel. When
54
+ * set, the KunUI `<KunEditorToolbar>` uses it too instead of its inline popover,
55
+ * so one override covers every link entry point.
56
+ */
57
+ type LinkPrompt = (context: {
58
+ text: string;
59
+ }) => string | null | undefined | Promise<string | null | undefined>;
49
60
  /**
50
61
  * The full policy bundle a host passes when constructing the editor. Every
51
62
  * field is optional: omit `uploadImage` for an image-free editor (the galgame
@@ -57,6 +68,11 @@ interface KunEditorAdapters {
57
68
  searchMentionUsers?: SearchMentionUsers;
58
69
  stickerSource?: StickerSource;
59
70
  notify?: Notify;
71
+ /**
72
+ * Custom link-URL entry (replaces the native prompt in the headless toolbar /
73
+ * bubble, and the KunUI toolbar's popover). See {@link LinkPrompt}.
74
+ */
75
+ linkPrompt?: LinkPrompt;
60
76
  /**
61
77
  * How an @mention's user id becomes its markdown link URL. The URL form is a
62
78
  * server contract, so it's host policy — default `kungal-user:<id>` (the KUN
@@ -102,4 +118,4 @@ interface KunEditorFeatures {
102
118
  sticker?: boolean;
103
119
  }
104
120
 
105
- export type { KunEditorAdapters as K, MentionUser as M, Notify as N, SearchMentionUsers as S, UploadImage as U, KunEditorFeatures as a, KunEditorLocale as b, NotifyLevel as c, StickerItem as d, StickerPack as e, StickerSource as f };
121
+ export type { KunEditorAdapters as K, LinkPrompt as L, MentionUser as M, Notify as N, SearchMentionUsers as S, UploadImage as U, KunEditorFeatures as a, KunEditorLocale as b, NotifyLevel as c, StickerItem as d, StickerPack as e, StickerSource as f };
@@ -46,6 +46,17 @@ type NotifyLevel = 'info' | 'success' | 'warn' | 'error';
46
46
  * Forum today: `useMessage(code, level)`.
47
47
  */
48
48
  type Notify = (message: string, level: NotifyLevel) => void;
49
+ /**
50
+ * Ask the user for a link URL — provide this to show your OWN UI (a modal, an
51
+ * inline input, an article picker…) instead of the native `window.prompt` the
52
+ * headless toolbar / selection bubble fall back to. Gets the currently selected
53
+ * text (to prefill or search). Return the URL, or a falsy value to cancel. When
54
+ * set, the KunUI `<KunEditorToolbar>` uses it too instead of its inline popover,
55
+ * so one override covers every link entry point.
56
+ */
57
+ type LinkPrompt = (context: {
58
+ text: string;
59
+ }) => string | null | undefined | Promise<string | null | undefined>;
49
60
  /**
50
61
  * The full policy bundle a host passes when constructing the editor. Every
51
62
  * field is optional: omit `uploadImage` for an image-free editor (the galgame
@@ -57,6 +68,11 @@ interface KunEditorAdapters {
57
68
  searchMentionUsers?: SearchMentionUsers;
58
69
  stickerSource?: StickerSource;
59
70
  notify?: Notify;
71
+ /**
72
+ * Custom link-URL entry (replaces the native prompt in the headless toolbar /
73
+ * bubble, and the KunUI toolbar's popover). See {@link LinkPrompt}.
74
+ */
75
+ linkPrompt?: LinkPrompt;
60
76
  /**
61
77
  * How an @mention's user id becomes its markdown link URL. The URL form is a
62
78
  * server contract, so it's host policy — default `kungal-user:<id>` (the KUN
@@ -102,4 +118,4 @@ interface KunEditorFeatures {
102
118
  sticker?: boolean;
103
119
  }
104
120
 
105
- export type { KunEditorAdapters as K, MentionUser as M, Notify as N, SearchMentionUsers as S, UploadImage as U, KunEditorFeatures as a, KunEditorLocale as b, NotifyLevel as c, StickerItem as d, StickerPack as e, StickerSource as f };
121
+ export type { KunEditorAdapters as K, LinkPrompt as L, MentionUser as M, Notify as N, SearchMentionUsers as S, UploadImage as U, KunEditorFeatures as a, KunEditorLocale as b, NotifyLevel as c, StickerItem as d, StickerPack as e, StickerSource as f };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kungal/editor-core",
3
- "version": "0.27.0",
3
+ "version": "0.28.0",
4
4
  "description": "KunEditor framework-agnostic core — the Milkdown plugin bundle (spoiler / mention / quote / katex / upload / code-block) plus the adapter contracts. No Vue/React.",
5
5
  "type": "module",
6
6
  "keywords": [