@haklex/rich-renderer-katex 0.0.104 → 0.0.106

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.
@@ -1 +1 @@
1
- {"version":3,"file":"KaTeXBlockEditNode.d.ts","sourceRoot":"","sources":["../src/KaTeXBlockEditNode.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,KAAK,wBAAwB,EAAE,MAAM,2BAA2B,CAAC;AAE1F,OAAO,KAAK,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAC3D,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,OAAO,CAAC;AAK1C,qBAAa,kBAAmB,SAAQ,cAAc;IACpD,MAAM,CAAC,KAAK,CAAC,IAAI,EAAE,kBAAkB,GAAG,kBAAkB;IAI1D,MAAM,CAAC,UAAU,CAAC,cAAc,EAAE,wBAAwB,GAAG,kBAAkB;IAI/E,QAAQ,CAAC,OAAO,EAAE,aAAa,EAAE,OAAO,EAAE,YAAY,GAAG,YAAY;CAYtE"}
1
+ {"version":3,"file":"KaTeXBlockEditNode.d.ts","sourceRoot":"","sources":["../src/KaTeXBlockEditNode.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,KAAK,wBAAwB,EAAE,MAAM,2BAA2B,CAAC;AAE1F,OAAO,KAAK,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAC3D,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,OAAO,CAAC;AAK1C,qBAAa,kBAAmB,SAAQ,cAAc;IACpD,MAAM,CAAC,KAAK,CAAC,IAAI,EAAE,kBAAkB,GAAG,kBAAkB;IAQ1D,MAAM,CAAC,UAAU,CAAC,cAAc,EAAE,wBAAwB,GAAG,kBAAkB;IAI/E,QAAQ,CAAC,OAAO,EAAE,aAAa,EAAE,OAAO,EAAE,YAAY,GAAG,YAAY;CAatE"}
@@ -1,10 +1,11 @@
1
1
  import { ReactElement } from 'react';
2
2
  interface KaTeXEditDecoratorProps {
3
+ autoOpenOnMount: boolean;
3
4
  children: ReactElement;
4
5
  displayMode: boolean;
5
6
  equation: string;
6
7
  nodeKey: string;
7
8
  }
8
- export declare function KaTeXEditDecorator({ nodeKey, equation, displayMode, children, }: KaTeXEditDecoratorProps): import("react/jsx-runtime").JSX.Element;
9
+ export declare function KaTeXEditDecorator({ nodeKey, equation, displayMode, autoOpenOnMount, children, }: KaTeXEditDecoratorProps): import("react/jsx-runtime").JSX.Element;
9
10
  export {};
10
11
  //# sourceMappingURL=KaTeXEditDecorator.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"KaTeXEditDecorator.d.ts","sourceRoot":"","sources":["../src/KaTeXEditDecorator.tsx"],"names":[],"mappings":"AAaA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,OAAO,CAAC;AAM1C,UAAU,uBAAuB;IAC/B,QAAQ,EAAE,YAAY,CAAC;IACvB,WAAW,EAAE,OAAO,CAAC;IACrB,QAAQ,EAAE,MAAM,CAAC;IACjB,OAAO,EAAE,MAAM,CAAC;CACjB;AAID,wBAAgB,kBAAkB,CAAC,EACjC,OAAO,EACP,QAAQ,EACR,WAAW,EACX,QAAQ,GACT,EAAE,uBAAuB,2CAwWzB"}
1
+ {"version":3,"file":"KaTeXEditDecorator.d.ts","sourceRoot":"","sources":["../src/KaTeXEditDecorator.tsx"],"names":[],"mappings":"AAaA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,OAAO,CAAC;AAM1C,UAAU,uBAAuB;IAC/B,eAAe,EAAE,OAAO,CAAC;IACzB,QAAQ,EAAE,YAAY,CAAC;IACvB,WAAW,EAAE,OAAO,CAAC;IACrB,QAAQ,EAAE,MAAM,CAAC;IACjB,OAAO,EAAE,MAAM,CAAC;CACjB;AAID,wBAAgB,kBAAkB,CAAC,EACjC,OAAO,EACP,QAAQ,EACR,WAAW,EACX,eAAe,EACf,QAAQ,GACT,EAAE,uBAAuB,2CA6XzB"}
@@ -1 +1 @@
1
- {"version":3,"file":"KaTeXInlineEditNode.d.ts","sourceRoot":"","sources":["../src/KaTeXInlineEditNode.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,KAAK,yBAAyB,EAAE,MAAM,2BAA2B,CAAC;AAE5F,OAAO,KAAK,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAC3D,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,OAAO,CAAC;AAK1C,qBAAa,mBAAoB,SAAQ,eAAe;IACtD,MAAM,CAAC,KAAK,CAAC,IAAI,EAAE,mBAAmB,GAAG,mBAAmB;IAI5D,MAAM,CAAC,UAAU,CAAC,cAAc,EAAE,yBAAyB,GAAG,mBAAmB;IAIjF,QAAQ,CAAC,OAAO,EAAE,aAAa,EAAE,OAAO,EAAE,YAAY,GAAG,YAAY;CAYtE"}
1
+ {"version":3,"file":"KaTeXInlineEditNode.d.ts","sourceRoot":"","sources":["../src/KaTeXInlineEditNode.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,KAAK,yBAAyB,EAAE,MAAM,2BAA2B,CAAC;AAE5F,OAAO,KAAK,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAC3D,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,OAAO,CAAC;AAK1C,qBAAa,mBAAoB,SAAQ,eAAe;IACtD,MAAM,CAAC,KAAK,CAAC,IAAI,EAAE,mBAAmB,GAAG,mBAAmB;IAQ5D,MAAM,CAAC,UAAU,CAAC,cAAc,EAAE,yBAAyB,GAAG,mBAAmB;IAIjF,QAAQ,CAAC,OAAO,EAAE,aAAa,EAAE,OAAO,EAAE,YAAY,GAAG,YAAY;CAatE"}
package/dist/index.mjs CHANGED
@@ -142,11 +142,12 @@ function KaTeXEditDecorator({
142
142
  nodeKey,
143
143
  equation,
144
144
  displayMode,
145
+ autoOpenOnMount,
145
146
  children
146
147
  }) {
147
148
  const [editor] = useLexicalComposerContext();
148
149
  const editable = editor.isEditable();
149
- const [open, setOpen] = useState(false);
150
+ const [open, setOpen] = useState(autoOpenOnMount);
150
151
  const [value, setValue] = useState(equation);
151
152
  const [copied, setCopied] = useState(false);
152
153
  const [activeTab, setActiveTab] = useState("editor");
@@ -163,6 +164,16 @@ function KaTeXEditDecorator({
163
164
  end: target.selectionEnd
164
165
  };
165
166
  }, []);
167
+ useEffect(() => {
168
+ if (autoOpenOnMount) {
169
+ editor.update(() => {
170
+ const node = $getNodeByKey(nodeKey);
171
+ if ($isKaTeXInlineNode(node) || $isKaTeXBlockNode(node)) {
172
+ node.setShouldAutoOpenOnMount(false);
173
+ }
174
+ });
175
+ }
176
+ }, [autoOpenOnMount, editor, nodeKey]);
166
177
  useEffect(() => {
167
178
  setValue(equation);
168
179
  }, [equation]);
@@ -254,257 +265,274 @@ function KaTeXEditDecorator({
254
265
  if (!editable) {
255
266
  return children;
256
267
  }
257
- return /* @__PURE__ */ jsxs(Popover, { open, onOpenChange: setOpen, children: [
258
- /* @__PURE__ */ jsx(
259
- PopoverTrigger,
260
- {
261
- nativeButton: false,
262
- render: /* @__PURE__ */ jsx(
263
- "span",
268
+ return /* @__PURE__ */ jsxs(
269
+ Popover,
270
+ {
271
+ open,
272
+ onOpenChange: (nextOpen) => {
273
+ setOpen(nextOpen);
274
+ if (!nextOpen) {
275
+ setValue(equation);
276
+ }
277
+ },
278
+ children: [
279
+ /* @__PURE__ */ jsx(
280
+ PopoverTrigger,
264
281
  {
265
- className: `${editWrapper} ${semanticClassNames.editWrapper}`,
266
- title: "Click to edit"
282
+ nativeButton: false,
283
+ render: /* @__PURE__ */ jsx(
284
+ "span",
285
+ {
286
+ className: `${editWrapper} ${semanticClassNames.editWrapper}`,
287
+ title: "Click to edit"
288
+ }
289
+ ),
290
+ children
267
291
  }
268
292
  ),
269
- children
270
- }
271
- ),
272
- /* @__PURE__ */ jsxs(
273
- PopoverPanel,
274
- {
275
- className: `${panel} ${semanticClassNames.panel}`,
276
- side: "bottom",
277
- sideOffset: 8,
278
- children: [
279
- /* @__PURE__ */ jsxs("div", { className: `${header} ${semanticClassNames.header}`, children: [
280
- /* @__PURE__ */ jsxs("div", { className: `${headerLeft} ${semanticClassNames.headerLeft}`, children: [
281
- /* @__PURE__ */ jsx("div", { className: `${iconWrap} ${semanticClassNames.iconWrap}`, children: /* @__PURE__ */ jsx(Terminal, { size: 12 }) }),
282
- /* @__PURE__ */ jsx("span", { className: `${title} ${semanticClassNames.title}`, children: "Math Editor" })
283
- ] }),
284
- /* @__PURE__ */ jsxs("div", { className: `${headerRight} ${semanticClassNames.headerRight}`, children: [
285
- /* @__PURE__ */ jsx("span", { className: `${mode} ${semanticClassNames.mode}`, children: displayMode ? "Block" : "Inline" }),
293
+ /* @__PURE__ */ jsxs(
294
+ PopoverPanel,
295
+ {
296
+ className: `${panel} ${semanticClassNames.panel}`,
297
+ initialFocus: inputRef,
298
+ side: "bottom",
299
+ sideOffset: 8,
300
+ children: [
301
+ /* @__PURE__ */ jsxs("div", { className: `${header} ${semanticClassNames.header}`, children: [
302
+ /* @__PURE__ */ jsxs("div", { className: `${headerLeft} ${semanticClassNames.headerLeft}`, children: [
303
+ /* @__PURE__ */ jsx("div", { className: `${iconWrap} ${semanticClassNames.iconWrap}`, children: /* @__PURE__ */ jsx(Terminal, { size: 12 }) }),
304
+ /* @__PURE__ */ jsx("span", { className: `${title} ${semanticClassNames.title}`, children: "Math Editor" })
305
+ ] }),
306
+ /* @__PURE__ */ jsxs("div", { className: `${headerRight} ${semanticClassNames.headerRight}`, children: [
307
+ /* @__PURE__ */ jsx("span", { className: `${mode} ${semanticClassNames.mode}`, children: displayMode ? "Block" : "Inline" }),
308
+ /* @__PURE__ */ jsx(
309
+ "button",
310
+ {
311
+ className: `${deleteButton} ${semanticClassNames.deleteButton}`,
312
+ title: "Delete node",
313
+ type: "button",
314
+ onClick: handleDelete,
315
+ children: /* @__PURE__ */ jsx(Trash2, { size: 14 })
316
+ }
317
+ )
318
+ ] })
319
+ ] }),
286
320
  /* @__PURE__ */ jsx(
287
- "button",
321
+ AnimatedTabs,
288
322
  {
289
- className: `${deleteButton} ${semanticClassNames.deleteButton}`,
290
- title: "Delete node",
291
- type: "button",
292
- onClick: handleDelete,
293
- children: /* @__PURE__ */ jsx(Trash2, { size: 14 })
323
+ className: `${tabs} ${semanticClassNames.tabs}`,
324
+ value: activeTab,
325
+ tabs: [
326
+ { id: "editor", label: "Editor" },
327
+ { id: "snippets", label: "Snippets" }
328
+ ],
329
+ onChange: (id) => setActiveTab(id)
294
330
  }
295
- )
296
- ] })
297
- ] }),
298
- /* @__PURE__ */ jsx(
299
- AnimatedTabs,
300
- {
301
- className: `${tabs} ${semanticClassNames.tabs}`,
302
- value: activeTab,
303
- tabs: [
304
- { id: "editor", label: "Editor" },
305
- { id: "snippets", label: "Snippets" }
306
- ],
307
- onChange: (id) => setActiveTab(id)
308
- }
309
- ),
310
- /* @__PURE__ */ jsxs("div", { className: `${bodyScrollArea} ${semanticClassNames.bodyScrollArea}`, children: [
311
- activeTab === "editor" && /* @__PURE__ */ jsxs("div", { className: `${body} ${semanticClassNames.body}`, children: [
312
- /* @__PURE__ */ jsxs("div", { className: `${field} ${semanticClassNames.field}`, children: [
313
- /* @__PURE__ */ jsx("label", { className: `${label} ${semanticClassNames.label}`, children: "LaTeX Input" }),
314
- /* @__PURE__ */ jsxs("div", { className: `${inputWrap} ${semanticClassNames.inputWrap}`, children: [
315
- /* @__PURE__ */ jsx(
316
- "textarea",
317
- {
318
- autoCapitalize: "off",
319
- autoComplete: "off",
320
- autoCorrect: "off",
321
- className: `${textarea} ${semanticClassNames.textarea}`,
322
- placeholder: "e.g. \\frac{-b \\pm \\sqrt{b^2-4ac}}{2a}",
323
- ref: inputRef,
324
- rows: displayMode ? 4 : 3,
325
- spellCheck: false,
326
- value,
327
- onClick: (e) => syncSelection(e.currentTarget),
328
- onKeyDown: handleKeyDown,
329
- onKeyUp: (e) => syncSelection(e.currentTarget),
330
- onSelect: (e) => syncSelection(e.currentTarget),
331
- onChange: (e) => {
332
- setValue(e.target.value);
333
- syncSelection(e.target);
331
+ ),
332
+ /* @__PURE__ */ jsxs("div", { className: `${bodyScrollArea} ${semanticClassNames.bodyScrollArea}`, children: [
333
+ activeTab === "editor" && /* @__PURE__ */ jsxs("div", { className: `${body} ${semanticClassNames.body}`, children: [
334
+ /* @__PURE__ */ jsxs("div", { className: `${field} ${semanticClassNames.field}`, children: [
335
+ /* @__PURE__ */ jsx("label", { className: `${label} ${semanticClassNames.label}`, children: "LaTeX Input" }),
336
+ /* @__PURE__ */ jsxs("div", { className: `${inputWrap} ${semanticClassNames.inputWrap}`, children: [
337
+ /* @__PURE__ */ jsx(
338
+ "textarea",
339
+ {
340
+ autoCapitalize: "off",
341
+ autoComplete: "off",
342
+ autoCorrect: "off",
343
+ className: `${textarea} ${semanticClassNames.textarea}`,
344
+ placeholder: "e.g. \\frac{-b \\pm \\sqrt{b^2-4ac}}{2a}",
345
+ ref: inputRef,
346
+ rows: displayMode ? 4 : 3,
347
+ spellCheck: false,
348
+ value,
349
+ onClick: (e) => syncSelection(e.currentTarget),
350
+ onKeyDown: handleKeyDown,
351
+ onKeyUp: (e) => syncSelection(e.currentTarget),
352
+ onSelect: (e) => syncSelection(e.currentTarget),
353
+ onChange: (e) => {
354
+ setValue(e.target.value);
355
+ syncSelection(e.target);
356
+ }
357
+ }
358
+ ),
359
+ /* @__PURE__ */ jsxs(
360
+ "div",
361
+ {
362
+ className: `${inputActions} ${semanticClassNames.inputActions}`,
363
+ children: [
364
+ /* @__PURE__ */ jsx(
365
+ ActionButton,
366
+ {
367
+ icon: true,
368
+ disabled: !value.trim(),
369
+ size: "sm",
370
+ title: "Copy LaTeX",
371
+ onClick: handleCopy,
372
+ children: copied ? /* @__PURE__ */ jsx(Check, { size: 12, style: { color: "#22c55e" } }) : /* @__PURE__ */ jsx(Copy, { size: 12 })
373
+ }
374
+ ),
375
+ /* @__PURE__ */ jsx(
376
+ ActionButton,
377
+ {
378
+ icon: true,
379
+ disabled: value === equation,
380
+ size: "sm",
381
+ title: "Reset",
382
+ onClick: handleReset,
383
+ children: /* @__PURE__ */ jsx(RotateCcw, { size: 12 })
384
+ }
385
+ )
386
+ ]
387
+ }
388
+ )
389
+ ] })
390
+ ] }),
391
+ /* @__PURE__ */ jsxs("div", { className: `${field} ${semanticClassNames.field}`, children: [
392
+ /* @__PURE__ */ jsx("label", { className: `${label} ${semanticClassNames.label}`, children: "Preview" }),
393
+ /* @__PURE__ */ jsx("div", { className: `${preview} ${semanticClassNames.preview}`, children: value.trim() ? /* @__PURE__ */ jsx(KaTeXRenderer, { displayMode, equation: value }) : /* @__PURE__ */ jsx(
394
+ "span",
395
+ {
396
+ className: `${previewEmpty} ${semanticClassNames.previewEmpty}`,
397
+ children: "Enter a formula"
334
398
  }
335
- }
336
- ),
399
+ ) })
400
+ ] })
401
+ ] }),
402
+ activeTab === "snippets" && /* @__PURE__ */ jsxs("div", { className: `${body} ${semanticClassNames.body}`, children: [
337
403
  /* @__PURE__ */ jsxs(
338
404
  "div",
339
405
  {
340
- className: `${inputActions} ${semanticClassNames.inputActions}`,
406
+ className: `${snippetSearchWrap} ${semanticClassNames.snippetSearchWrap}`,
341
407
  children: [
342
408
  /* @__PURE__ */ jsx(
343
- ActionButton,
409
+ Search,
344
410
  {
345
- icon: true,
346
- disabled: !value.trim(),
347
- size: "sm",
348
- title: "Copy LaTeX",
349
- onClick: handleCopy,
350
- children: copied ? /* @__PURE__ */ jsx(Check, { size: 12, style: { color: "#22c55e" } }) : /* @__PURE__ */ jsx(Copy, { size: 12 })
411
+ className: `${snippetSearchIcon} ${semanticClassNames.snippetSearchIcon}`,
412
+ size: 14
351
413
  }
352
414
  ),
353
415
  /* @__PURE__ */ jsx(
354
- ActionButton,
416
+ "input",
355
417
  {
356
- icon: true,
357
- disabled: value === equation,
358
- size: "sm",
359
- title: "Reset",
360
- onClick: handleReset,
361
- children: /* @__PURE__ */ jsx(RotateCcw, { size: 12 })
418
+ autoComplete: "off",
419
+ className: `${snippetSearchInput} ${semanticClassNames.snippetSearchInput}`,
420
+ placeholder: "Search snippets: frac, matrix, sum...",
421
+ type: "text",
422
+ value: snippetQuery,
423
+ onChange: (e) => setSnippetQuery(e.target.value)
362
424
  }
363
425
  )
364
426
  ]
365
427
  }
366
- )
367
- ] })
368
- ] }),
369
- /* @__PURE__ */ jsxs("div", { className: `${field} ${semanticClassNames.field}`, children: [
370
- /* @__PURE__ */ jsx("label", { className: `${label} ${semanticClassNames.label}`, children: "Preview" }),
371
- /* @__PURE__ */ jsx("div", { className: `${preview} ${semanticClassNames.preview}`, children: value.trim() ? /* @__PURE__ */ jsx(KaTeXRenderer, { displayMode, equation: value }) : /* @__PURE__ */ jsx(
372
- "span",
373
- {
374
- className: `${previewEmpty} ${semanticClassNames.previewEmpty}`,
375
- children: "Enter a formula"
376
- }
377
- ) })
378
- ] })
379
- ] }),
380
- activeTab === "snippets" && /* @__PURE__ */ jsxs("div", { className: `${body} ${semanticClassNames.body}`, children: [
381
- /* @__PURE__ */ jsxs(
382
- "div",
383
- {
384
- className: `${snippetSearchWrap} ${semanticClassNames.snippetSearchWrap}`,
385
- children: [
386
- /* @__PURE__ */ jsx(
387
- Search,
388
- {
389
- className: `${snippetSearchIcon} ${semanticClassNames.snippetSearchIcon}`,
390
- size: 14
391
- }
392
- ),
393
- /* @__PURE__ */ jsx(
394
- "input",
395
- {
396
- autoComplete: "off",
397
- className: `${snippetSearchInput} ${semanticClassNames.snippetSearchInput}`,
398
- placeholder: "Search snippets: frac, matrix, sum...",
399
- type: "text",
400
- value: snippetQuery,
401
- onChange: (e) => setSnippetQuery(e.target.value)
402
- }
403
- )
404
- ]
405
- }
406
- ),
407
- groupedSnippets.length > 0 ? /* @__PURE__ */ jsx(
408
- "div",
409
- {
410
- className: `${snippetGroups} ${semanticClassNames.snippetGroups}`,
411
- children: groupedSnippets.map((group) => /* @__PURE__ */ jsxs(
412
- "section",
428
+ ),
429
+ groupedSnippets.length > 0 ? /* @__PURE__ */ jsx(
430
+ "div",
413
431
  {
414
- className: `${snippetGroup} ${semanticClassNames.snippetGroup}`,
415
- children: [
416
- /* @__PURE__ */ jsx(
417
- "div",
418
- {
419
- className: `${snippetGroupLabel} ${semanticClassNames.snippetGroupLabel}`,
420
- children: group.category
421
- }
422
- ),
423
- /* @__PURE__ */ jsx(
424
- "div",
425
- {
426
- className: `${snippetList} ${semanticClassNames.snippetList}`,
427
- children: group.items.map((snippet) => /* @__PURE__ */ jsxs(
428
- "button",
432
+ className: `${snippetGroups} ${semanticClassNames.snippetGroups}`,
433
+ children: groupedSnippets.map((group) => /* @__PURE__ */ jsxs(
434
+ "section",
435
+ {
436
+ className: `${snippetGroup} ${semanticClassNames.snippetGroup}`,
437
+ children: [
438
+ /* @__PURE__ */ jsx(
439
+ "div",
440
+ {
441
+ className: `${snippetGroupLabel} ${semanticClassNames.snippetGroupLabel}`,
442
+ children: group.category
443
+ }
444
+ ),
445
+ /* @__PURE__ */ jsx(
446
+ "div",
429
447
  {
430
- className: `${snippetButton} ${semanticClassNames.snippetButton}`,
431
- type: "button",
432
- onClick: () => handleInsertSnippet(snippet.template),
433
- children: [
434
- /* @__PURE__ */ jsxs(
435
- "div",
436
- {
437
- className: `${snippetMeta} ${semanticClassNames.snippetMeta}`,
438
- children: [
439
- /* @__PURE__ */ jsx(
440
- "span",
441
- {
442
- className: `${snippetName} ${semanticClassNames.snippetName}`,
443
- children: snippet.title
444
- }
445
- ),
446
- /* @__PURE__ */ jsx(
447
- "span",
448
- {
449
- className: `${snippetHint} ${semanticClassNames.snippetHint}`,
450
- children: snippet.template.replace(CURSOR_TOKEN, "")
451
- }
452
- )
453
- ]
454
- }
455
- ),
456
- /* @__PURE__ */ jsx(
457
- "span",
458
- {
459
- className: `${snippetPreview} ${semanticClassNames.snippetPreview}`,
460
- children: /* @__PURE__ */ jsx(
461
- KaTeXRenderer,
448
+ className: `${snippetList} ${semanticClassNames.snippetList}`,
449
+ children: group.items.map((snippet) => /* @__PURE__ */ jsxs(
450
+ "button",
451
+ {
452
+ className: `${snippetButton} ${semanticClassNames.snippetButton}`,
453
+ type: "button",
454
+ onClick: () => handleInsertSnippet(snippet.template),
455
+ children: [
456
+ /* @__PURE__ */ jsxs(
457
+ "div",
458
+ {
459
+ className: `${snippetMeta} ${semanticClassNames.snippetMeta}`,
460
+ children: [
461
+ /* @__PURE__ */ jsx(
462
+ "span",
463
+ {
464
+ className: `${snippetName} ${semanticClassNames.snippetName}`,
465
+ children: snippet.title
466
+ }
467
+ ),
468
+ /* @__PURE__ */ jsx(
469
+ "span",
470
+ {
471
+ className: `${snippetHint} ${semanticClassNames.snippetHint}`,
472
+ children: snippet.template.replace(CURSOR_TOKEN, "")
473
+ }
474
+ )
475
+ ]
476
+ }
477
+ ),
478
+ /* @__PURE__ */ jsx(
479
+ "span",
462
480
  {
463
- displayMode: false,
464
- equation: snippet.previewEquation
481
+ className: `${snippetPreview} ${semanticClassNames.snippetPreview}`,
482
+ children: /* @__PURE__ */ jsx(
483
+ KaTeXRenderer,
484
+ {
485
+ displayMode: false,
486
+ equation: snippet.previewEquation
487
+ }
488
+ )
465
489
  }
466
490
  )
467
- }
468
- )
469
- ]
470
- },
471
- snippet.id
472
- ))
473
- }
474
- )
491
+ ]
492
+ },
493
+ snippet.id
494
+ ))
495
+ }
496
+ )
497
+ ]
498
+ },
499
+ group.category
500
+ ))
501
+ }
502
+ ) : /* @__PURE__ */ jsxs(
503
+ "div",
504
+ {
505
+ className: `${snippetsPlaceholder} ${semanticClassNames.snippetsPlaceholder}`,
506
+ children: [
507
+ "No snippets match “",
508
+ snippetQuery.trim(),
509
+ "”"
475
510
  ]
476
- },
477
- group.category
478
- ))
479
- }
480
- ) : /* @__PURE__ */ jsxs(
481
- "div",
482
- {
483
- className: `${snippetsPlaceholder} ${semanticClassNames.snippetsPlaceholder}`,
484
- children: [
485
- "No snippets match “",
486
- snippetQuery.trim(),
487
- "”"
488
- ]
489
- }
490
- )
491
- ] })
492
- ] }),
493
- /* @__PURE__ */ jsxs("div", { className: `${footer} ${semanticClassNames.footer}`, children: [
494
- /* @__PURE__ */ jsx("span", { className: `${charCount} ${semanticClassNames.charCount}`, children: value.trim() ? `${value.length} chars` : "Enter a formula" }),
495
- /* @__PURE__ */ jsxs(ActionBar, { children: [
496
- /* @__PURE__ */ jsx(ActionButton, { size: "md", variant: "ghost", onClick: cancel, children: "Cancel" }),
497
- /* @__PURE__ */ jsx(ActionButton, { disabled: !value.trim(), size: "md", variant: "accent", onClick: commit, children: "Save" })
498
- ] })
499
- ] })
500
- ]
501
- }
502
- )
503
- ] });
511
+ }
512
+ )
513
+ ] })
514
+ ] }),
515
+ /* @__PURE__ */ jsxs("div", { className: `${footer} ${semanticClassNames.footer}`, children: [
516
+ /* @__PURE__ */ jsx("span", { className: `${charCount} ${semanticClassNames.charCount}`, children: value.trim() ? `${value.length} chars` : "Enter a formula" }),
517
+ /* @__PURE__ */ jsxs(ActionBar, { children: [
518
+ /* @__PURE__ */ jsx(ActionButton, { size: "md", variant: "ghost", onClick: cancel, children: "Cancel" }),
519
+ /* @__PURE__ */ jsx(ActionButton, { disabled: !value.trim(), size: "md", variant: "accent", onClick: commit, children: "Save" })
520
+ ] })
521
+ ] })
522
+ ]
523
+ }
524
+ )
525
+ ]
526
+ }
527
+ );
504
528
  }
505
529
  class KaTeXBlockEditNode extends KaTeXBlockNode {
506
530
  static clone(node) {
507
- return new KaTeXBlockEditNode(node.__equation, node.__key);
531
+ return new KaTeXBlockEditNode(
532
+ node.__equation,
533
+ node.__key,
534
+ node.getShouldAutoOpenOnMount()
535
+ );
508
536
  }
509
537
  static importJSON(serializedNode) {
510
538
  return new KaTeXBlockEditNode(serializedNode.equation);
@@ -518,13 +546,18 @@ class KaTeXBlockEditNode extends KaTeXBlockNode {
518
546
  nodeKey: this.__key,
519
547
  equation: this.__equation,
520
548
  displayMode: true,
549
+ autoOpenOnMount: this.getShouldAutoOpenOnMount(),
521
550
  children: rendererEl
522
551
  });
523
552
  }
524
553
  }
525
554
  class KaTeXInlineEditNode extends KaTeXInlineNode {
526
555
  static clone(node) {
527
- return new KaTeXInlineEditNode(node.__equation, node.__key);
556
+ return new KaTeXInlineEditNode(
557
+ node.__equation,
558
+ node.__key,
559
+ node.getShouldAutoOpenOnMount()
560
+ );
528
561
  }
529
562
  static importJSON(serializedNode) {
530
563
  return new KaTeXInlineEditNode(serializedNode.equation);
@@ -538,6 +571,7 @@ class KaTeXInlineEditNode extends KaTeXInlineNode {
538
571
  nodeKey: this.__key,
539
572
  equation: this.__equation,
540
573
  displayMode: false,
574
+ autoOpenOnMount: this.getShouldAutoOpenOnMount(),
541
575
  children: rendererEl
542
576
  });
543
577
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@haklex/rich-renderer-katex",
3
- "version": "0.0.104",
3
+ "version": "0.0.106",
4
4
  "description": "KaTeX math renderer for haklex rich editor",
5
5
  "repository": {
6
6
  "type": "git",
@@ -22,19 +22,19 @@
22
22
  ],
23
23
  "dependencies": {
24
24
  "lucide-react": "^1.0.0",
25
- "@haklex/rich-editor": "0.0.104",
26
- "@haklex/rich-style-token": "0.0.104",
27
- "@haklex/rich-editor-ui": "0.0.104"
25
+ "@haklex/rich-editor-ui": "0.0.106",
26
+ "@haklex/rich-editor": "0.0.106",
27
+ "@haklex/rich-style-token": "0.0.106"
28
28
  },
29
29
  "devDependencies": {
30
- "@lexical/react": "^0.42.0",
30
+ "@lexical/react": "^0.43.0",
31
31
  "@types/react": "^19.2.14",
32
32
  "@types/react-dom": "^19.2.3",
33
33
  "@vanilla-extract/css": "^1.18.0",
34
34
  "@vanilla-extract/recipes": "^0.5.7",
35
35
  "@vanilla-extract/vite-plugin": "^5.1.4",
36
36
  "katex": "^0.16.37",
37
- "lexical": "^0.42.0",
37
+ "lexical": "^0.43.0",
38
38
  "react": "^19.2.4",
39
39
  "react-dom": "^19.2.4",
40
40
  "typescript": "^5.9.3",
@@ -42,9 +42,9 @@
42
42
  "vite-plugin-dts": "^4.5.4"
43
43
  },
44
44
  "peerDependencies": {
45
- "@lexical/react": "^0.42.0",
45
+ "@lexical/react": "^0.43.0",
46
46
  "katex": ">=0.16.0",
47
- "lexical": "^0.42.0",
47
+ "lexical": "^0.43.0",
48
48
  "react": ">=19",
49
49
  "react-dom": ">=19"
50
50
  },