@wakastellar/ui 6.0.1 → 6.0.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/dist/blocks/md-editor/WakaMdEditor.cjs.js +1 -1
- package/dist/blocks/md-editor/WakaMdEditor.es.js +169 -159
- package/dist/blocks/md-editor/index.cjs.js +1 -1
- package/dist/blocks/md-editor/index.es.js +14 -14
- package/dist/blocks/md-editor/types.d.ts +10 -0
- package/package.json +1 -1
- package/src/blocks/md-editor/WakaMdEditor.tsx +41 -3
- package/src/blocks/md-editor/types.ts +10 -0
- package/dist/node_modules/.pnpm/react-dom@19.2.4_react@19.2.4/node_modules/react-dom/cjs/react-dom-client.development.cjs.js +0 -218
- package/dist/node_modules/.pnpm/react-dom@19.2.4_react@19.2.4/node_modules/react-dom/cjs/react-dom-client.development.es.js +0 -11168
- package/dist/node_modules/.pnpm/react-dom@19.2.4_react@19.2.4/node_modules/react-dom/cjs/react-dom-client.production.cjs.js +0 -9
- package/dist/node_modules/.pnpm/react-dom@19.2.4_react@19.2.4/node_modules/react-dom/cjs/react-dom-client.production.es.js +0 -7385
- package/dist/node_modules/.pnpm/react-dom@19.2.4_react@19.2.4/node_modules/react-dom/client.cjs.js +0 -1
- package/dist/node_modules/.pnpm/react-dom@19.2.4_react@19.2.4/node_modules/react-dom/client.es.js +0 -21
- package/dist/node_modules/.pnpm/scheduler@0.27.0/node_modules/scheduler/cjs/scheduler.development.cjs.js +0 -1
- package/dist/node_modules/.pnpm/scheduler@0.27.0/node_modules/scheduler/cjs/scheduler.development.es.js +0 -204
- package/dist/node_modules/.pnpm/scheduler@0.27.0/node_modules/scheduler/cjs/scheduler.production.cjs.js +0 -1
- package/dist/node_modules/.pnpm/scheduler@0.27.0/node_modules/scheduler/cjs/scheduler.production.es.js +0 -204
- package/dist/node_modules/.pnpm/scheduler@0.27.0/node_modules/scheduler/index.cjs.js +0 -1
- package/dist/node_modules/.pnpm/scheduler@0.27.0/node_modules/scheduler/index.es.js +0 -11
|
@@ -1,19 +1,19 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { __toESM as e } from "../../_virtual/_rolldown/runtime.es.js";
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
3
|
+
import { MarkdownToHtml as t } from "../../node_modules/.pnpm/@muyajs_core@file_vendor_muyajs-core/node_modules/@muyajs/core/lib/es/index.es.js";
|
|
4
|
+
import { WakaMdEditor as n } from "./WakaMdEditor.es.js";
|
|
5
|
+
import { createElement as r } from "react";
|
|
6
|
+
import { createRoot as i } from "react-dom/client";
|
|
7
7
|
//#region src/blocks/md-editor/index.ts
|
|
8
|
-
var a =
|
|
9
|
-
typeof Intl < "u" && !
|
|
10
|
-
|
|
8
|
+
var a = Intl;
|
|
9
|
+
typeof Intl < "u" && !a.Segmenter && import("../../node_modules/.pnpm/intl-segmenter-polyfill@0.4.4/node_modules/intl-segmenter-polyfill/dist/bundled.es.js").then((t) => /* @__PURE__ */ e(t.default)).then(async (e) => {
|
|
10
|
+
a.Segmenter = await e.createIntlSegmenterPolyfill();
|
|
11
11
|
}).catch(() => {});
|
|
12
|
-
function
|
|
13
|
-
let
|
|
14
|
-
|
|
15
|
-
let o = { current: null }, s = null, c = (
|
|
16
|
-
return c.render(
|
|
12
|
+
function o(e, t = {}) {
|
|
13
|
+
let a = document.createElement("div");
|
|
14
|
+
a.style.height = "100%", e.appendChild(a);
|
|
15
|
+
let o = { current: null }, s = null, c = i(a);
|
|
16
|
+
return c.render(r(n, {
|
|
17
17
|
...t,
|
|
18
18
|
ref: (e) => {
|
|
19
19
|
o.current = e;
|
|
@@ -23,7 +23,7 @@ function s(e, t = {}) {
|
|
|
23
23
|
}
|
|
24
24
|
})), {
|
|
25
25
|
unmount: () => {
|
|
26
|
-
c.unmount(),
|
|
26
|
+
c.unmount(), a.remove();
|
|
27
27
|
},
|
|
28
28
|
getMarkdown: () => o.current?.getMarkdown() ?? "",
|
|
29
29
|
setMarkdown: (e, t) => o.current?.setMarkdown(e, t),
|
|
@@ -35,4 +35,4 @@ function s(e, t = {}) {
|
|
|
35
35
|
};
|
|
36
36
|
}
|
|
37
37
|
//#endregion
|
|
38
|
-
export {
|
|
38
|
+
export { t as MarkdownToHtml, n as WakaMdEditor, o as createMdEditor };
|
|
@@ -45,6 +45,16 @@ export interface WakaMdEditorProps {
|
|
|
45
45
|
onLoadingChange?: (loading: boolean) => void;
|
|
46
46
|
/** Un enregistrement est en cours (entre le déclenchement et la confirmation). */
|
|
47
47
|
onSavingChange?: (saving: boolean) => void;
|
|
48
|
+
/**
|
|
49
|
+
* Clic sur un lien du document. Sans ce callback, seuls les liens
|
|
50
|
+
* http(s) s'ouvrent (nouvel onglet) ; tout le reste (chemins relatifs,
|
|
51
|
+
* schémas applicatifs type `doc://…`) est silencieusement ignoré.
|
|
52
|
+
* Fourni, ce callback reçoit *tous* les clics — y compris http(s) — et
|
|
53
|
+
* décide : router en interne (ex. ouvrir un document applicatif dans
|
|
54
|
+
* votre propre visualiseur), ou appeler `openDefault()` pour retrouver
|
|
55
|
+
* le comportement d'origine sur ce lien précis.
|
|
56
|
+
*/
|
|
57
|
+
onLinkClick?: (href: string, openDefault: () => void) => void;
|
|
48
58
|
className?: string;
|
|
49
59
|
style?: React.CSSProperties;
|
|
50
60
|
}
|
package/package.json
CHANGED
|
@@ -98,6 +98,22 @@ const EDITOR_DEFAULTS: Partial<IMuyaOptions> = {
|
|
|
98
98
|
*/
|
|
99
99
|
let imageCallbacks: { picker?: () => Promise<string>; action?: (src: string) => Promise<string> } = {};
|
|
100
100
|
|
|
101
|
+
/**
|
|
102
|
+
* Clic sur un lien : même mécanisme délégué que les callbacks d'images.
|
|
103
|
+
* Sans `onLinkClick` fourni par l'hôte, le comportement par défaut (ouvrir
|
|
104
|
+
* les liens http(s) dans un nouvel onglet, ignorer le reste) est conservé.
|
|
105
|
+
* Avec `onLinkClick`, l'hôte reçoit *tous* les clics — y compris http(s) —
|
|
106
|
+
* et décide : router en interne (documents applicatifs, `doc://…`, chemins
|
|
107
|
+
* relatifs…), ou appeler `openDefault()` pour retrouver le comportement
|
|
108
|
+
* d'origine sur ce lien précis.
|
|
109
|
+
*/
|
|
110
|
+
let linkCallbacks: { onLinkClick?: (href: string, openDefault: () => void) => void } = {};
|
|
111
|
+
|
|
112
|
+
function openLinkDefault(href: string): void {
|
|
113
|
+
if (/^https?:\/\//.test(href))
|
|
114
|
+
window.open(href, '_blank', 'noopener,noreferrer');
|
|
115
|
+
}
|
|
116
|
+
|
|
101
117
|
let pluginsRegistered = false;
|
|
102
118
|
function registerPluginsOnce(): void {
|
|
103
119
|
if (pluginsRegistered)
|
|
@@ -118,8 +134,12 @@ function registerPluginsOnce(): void {
|
|
|
118
134
|
Muya.use(LinkTools, {
|
|
119
135
|
jumpClick: (linkInfo: { href?: string } | null) => {
|
|
120
136
|
const href = linkInfo?.href;
|
|
121
|
-
if (href
|
|
122
|
-
|
|
137
|
+
if (!href)
|
|
138
|
+
return;
|
|
139
|
+
if (linkCallbacks.onLinkClick)
|
|
140
|
+
linkCallbacks.onLinkClick(href, () => openLinkDefault(href));
|
|
141
|
+
else
|
|
142
|
+
openLinkDefault(href);
|
|
123
143
|
},
|
|
124
144
|
});
|
|
125
145
|
Muya.use(ParagraphFrontButton);
|
|
@@ -166,6 +186,7 @@ export const WakaMdEditor = forwardRef<WakaMdEditorRef, WakaMdEditorProps>(funct
|
|
|
166
186
|
onDirtyChange,
|
|
167
187
|
onLoadingChange,
|
|
168
188
|
onSavingChange,
|
|
189
|
+
onLinkClick,
|
|
169
190
|
getMuya,
|
|
170
191
|
className,
|
|
171
192
|
style,
|
|
@@ -176,6 +197,7 @@ export const WakaMdEditor = forwardRef<WakaMdEditorRef, WakaMdEditorProps>(funct
|
|
|
176
197
|
picker: props.imagePathPicker ?? pickImageAsDataUrl,
|
|
177
198
|
action: props.imageAction ?? (async src => src),
|
|
178
199
|
};
|
|
200
|
+
linkCallbacks = { onLinkClick };
|
|
179
201
|
|
|
180
202
|
const containerRef = useRef<HTMLDivElement | null>(null);
|
|
181
203
|
const muyaRef = useRef<Muya | null>(null);
|
|
@@ -258,7 +280,23 @@ export const WakaMdEditor = forwardRef<WakaMdEditorRef, WakaMdEditorProps>(funct
|
|
|
258
280
|
markdown: value ?? defaultValue,
|
|
259
281
|
} as Partial<IMuyaOptions>);
|
|
260
282
|
muya.locale(LOCALES[locale] ?? fr);
|
|
261
|
-
|
|
283
|
+
try {
|
|
284
|
+
muya.init();
|
|
285
|
+
}
|
|
286
|
+
catch (error) {
|
|
287
|
+
// Le moteur appelle focus()/setCursor() en interne à la fin de
|
|
288
|
+
// init(), qui échoue sur l'API Selection native du navigateur
|
|
289
|
+
// ("extend() requires a Range to be added to the Selection")
|
|
290
|
+
// quand cet effet est réinvoqué en double par React 19 en
|
|
291
|
+
// StrictMode (dev uniquement) : le Selection du document garde
|
|
292
|
+
// une référence périmée après le unmount/remount immédiat.
|
|
293
|
+
// Montage et contenu restent fonctionnels — seul le focus
|
|
294
|
+
// automatique initial échoue — donc on avale uniquement cette
|
|
295
|
+
// erreur précise plutôt que de casser tout l'effet de montage ;
|
|
296
|
+
// toute autre erreur d'init() reste une vraie régression à voir.
|
|
297
|
+
if (!(error instanceof Error) || !/Range to be added to the Selection/.test(error.message))
|
|
298
|
+
throw error;
|
|
299
|
+
}
|
|
262
300
|
muyaRef.current = muya;
|
|
263
301
|
getMuya?.(muya);
|
|
264
302
|
|
|
@@ -81,6 +81,16 @@ export interface WakaMdEditorProps {
|
|
|
81
81
|
onLoadingChange?: (loading: boolean) => void;
|
|
82
82
|
/** Un enregistrement est en cours (entre le déclenchement et la confirmation). */
|
|
83
83
|
onSavingChange?: (saving: boolean) => void;
|
|
84
|
+
/**
|
|
85
|
+
* Clic sur un lien du document. Sans ce callback, seuls les liens
|
|
86
|
+
* http(s) s'ouvrent (nouvel onglet) ; tout le reste (chemins relatifs,
|
|
87
|
+
* schémas applicatifs type `doc://…`) est silencieusement ignoré.
|
|
88
|
+
* Fourni, ce callback reçoit *tous* les clics — y compris http(s) — et
|
|
89
|
+
* décide : router en interne (ex. ouvrir un document applicatif dans
|
|
90
|
+
* votre propre visualiseur), ou appeler `openDefault()` pour retrouver
|
|
91
|
+
* le comportement d'origine sur ce lien précis.
|
|
92
|
+
*/
|
|
93
|
+
onLinkClick?: (href: string, openDefault: () => void) => void;
|
|
84
94
|
className?: string;
|
|
85
95
|
style?: React.CSSProperties;
|
|
86
96
|
}
|