@djangocfg/ui-tools 2.1.290 → 2.1.291
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/index.cjs +8 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +17 -1
- package/dist/index.d.ts +17 -1
- package/dist/index.mjs +8 -0
- package/dist/index.mjs.map +1 -1
- package/package.json +8 -7
- package/src/tools/MarkdownEditor/MarkdownEditor.tsx +42 -1
package/dist/index.d.cts
CHANGED
|
@@ -2473,7 +2473,23 @@ interface MarkdownEditorProps {
|
|
|
2473
2473
|
className?: string;
|
|
2474
2474
|
disabled?: boolean;
|
|
2475
2475
|
showToolbar?: boolean;
|
|
2476
|
-
/**
|
|
2476
|
+
/**
|
|
2477
|
+
* `@`-mention autocomplete config.
|
|
2478
|
+
*
|
|
2479
|
+
* IMPORTANT: Tiptap's `useEditor` initialises the editor exactly once.
|
|
2480
|
+
* The `Mention` extension is only registered when `mentions` is truthy
|
|
2481
|
+
* on the FIRST render — handing in a real config later (e.g. after an
|
|
2482
|
+
* async items fetch) silently does nothing, and typing `@` will not
|
|
2483
|
+
* open the popover.
|
|
2484
|
+
*
|
|
2485
|
+
* If you want mentions even with async-loaded items, pass
|
|
2486
|
+
* `{ items: [] }` from the very first render and update the array
|
|
2487
|
+
* when data arrives. Either keep the `MentionConfig` object identity
|
|
2488
|
+
* stable across renders and mutate `items` in place (the suggestion
|
|
2489
|
+
* plugin captures the config by closure and reads `items` on each
|
|
2490
|
+
* query), or accept that swapping the whole object reference is a
|
|
2491
|
+
* no-op for the live editor.
|
|
2492
|
+
*/
|
|
2477
2493
|
mentions?: MentionConfig;
|
|
2478
2494
|
/** Called when mentioned IDs change */
|
|
2479
2495
|
onMentionIdsChange?: (ids: string[]) => void;
|
package/dist/index.d.ts
CHANGED
|
@@ -2473,7 +2473,23 @@ interface MarkdownEditorProps {
|
|
|
2473
2473
|
className?: string;
|
|
2474
2474
|
disabled?: boolean;
|
|
2475
2475
|
showToolbar?: boolean;
|
|
2476
|
-
/**
|
|
2476
|
+
/**
|
|
2477
|
+
* `@`-mention autocomplete config.
|
|
2478
|
+
*
|
|
2479
|
+
* IMPORTANT: Tiptap's `useEditor` initialises the editor exactly once.
|
|
2480
|
+
* The `Mention` extension is only registered when `mentions` is truthy
|
|
2481
|
+
* on the FIRST render — handing in a real config later (e.g. after an
|
|
2482
|
+
* async items fetch) silently does nothing, and typing `@` will not
|
|
2483
|
+
* open the popover.
|
|
2484
|
+
*
|
|
2485
|
+
* If you want mentions even with async-loaded items, pass
|
|
2486
|
+
* `{ items: [] }` from the very first render and update the array
|
|
2487
|
+
* when data arrives. Either keep the `MentionConfig` object identity
|
|
2488
|
+
* stable across renders and mutate `items` in place (the suggestion
|
|
2489
|
+
* plugin captures the config by closure and reads `items` on each
|
|
2490
|
+
* query), or accept that swapping the whole object reference is a
|
|
2491
|
+
* no-op for the live editor.
|
|
2492
|
+
*/
|
|
2477
2493
|
mentions?: MentionConfig;
|
|
2478
2494
|
/** Called when mentioned IDs change */
|
|
2479
2495
|
onMentionIdsChange?: (ids: string[]) => void;
|
package/dist/index.mjs
CHANGED
|
@@ -1274,6 +1274,14 @@ function MarkdownEditor({
|
|
|
1274
1274
|
onMentionIdsChange
|
|
1275
1275
|
}) {
|
|
1276
1276
|
const isExternalUpdate = useRef(false);
|
|
1277
|
+
const initialMentionsDefinedRef = useRef(mentions !== void 0);
|
|
1278
|
+
const warnedRef = useRef(false);
|
|
1279
|
+
if (process.env.NODE_ENV !== "production" && !initialMentionsDefinedRef.current && mentions !== void 0 && !warnedRef.current) {
|
|
1280
|
+
warnedRef.current = true;
|
|
1281
|
+
console.warn(
|
|
1282
|
+
"[MarkdownEditor] `mentions` flipped from undefined to a config after mount. Tiptap only installs the Mention extension on first render \u2014 the @-popover will NOT work for this editor instance. Pass `{ items: [] }` from the very first render and mutate `.items` in place instead."
|
|
1283
|
+
);
|
|
1284
|
+
}
|
|
1277
1285
|
const extensions = useMemo(() => {
|
|
1278
1286
|
const exts = [
|
|
1279
1287
|
StarterKit.configure({ heading: { levels: [1, 2, 3] } }),
|