@haklex/rich-plugin-toolbar 0.62.2 → 0.63.1

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.mjs CHANGED
@@ -587,6 +587,13 @@ var INITIAL_TOOLBAR_STATE = {
587
587
  isHighlight: false,
588
588
  isSpoiler: false
589
589
  };
590
+ function patchState(prev, patch) {
591
+ for (const key in patch) if (patch[key] !== prev[key]) return {
592
+ ...prev,
593
+ ...patch
594
+ };
595
+ return prev;
596
+ }
590
597
  /**
591
598
  * Subscribe to selection/format/history changes and return a reactive ToolbarState.
592
599
  * Use inside a component mounted under a LexicalComposer (e.g. via `header={...}`
@@ -617,8 +624,7 @@ function useToolbarState() {
617
624
  const isCode = selection.hasFormat("code");
618
625
  const isHighlight = selection.hasFormat("highlight");
619
626
  const isSpoiler = $selectionTouchesSpoiler(selection);
620
- setState((prev) => ({
621
- ...prev,
627
+ setState((prev) => patchState(prev, {
622
628
  blockType,
623
629
  fontFamily,
624
630
  elementFormat,
@@ -633,17 +639,11 @@ function useToolbarState() {
633
639
  }, []);
634
640
  useEffect(() => {
635
641
  const unregisterUndo = editor.registerCommand(CAN_UNDO_COMMAND, (payload) => {
636
- setState((prev) => ({
637
- ...prev,
638
- canUndo: payload
639
- }));
642
+ setState((prev) => patchState(prev, { canUndo: payload }));
640
643
  return false;
641
644
  }, COMMAND_PRIORITY_LOW);
642
645
  const unregisterRedo = editor.registerCommand(CAN_REDO_COMMAND, (payload) => {
643
- setState((prev) => ({
644
- ...prev,
645
- canRedo: payload
646
- }));
646
+ setState((prev) => patchState(prev, { canRedo: payload }));
647
647
  return false;
648
648
  }, COMMAND_PRIORITY_LOW);
649
649
  const unregisterUpdate = editor.registerUpdateListener(({ editorState }) => {
@@ -1 +1 @@
1
- {"version":3,"file":"use-toolbar-state.d.ts","sourceRoot":"","sources":["../src/use-toolbar-state.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,iBAAiB,EAA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AgB,eAAe,IAAI,YAAY,CAoF9C"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@haklex/rich-plugin-toolbar",
3
- "version": "0.62.2",
3
+ "version": "0.63.1",
4
4
  "description": "Top toolbar plugin for rich editor",
5
5
  "repository": {
6
6
  "type": "git",
@@ -39,10 +39,10 @@
39
39
  "vite": "^8.3.5"
40
40
  },
41
41
  "peerDependencies": {
42
- "@haklex/rich-editor": "^0.62.2",
43
- "@haklex/rich-editor-ui": "^0.62.2",
44
- "@haklex/rich-plugin-slash-menu": "^0.62.2",
45
- "@haklex/rich-style-token": "^0.62.2",
42
+ "@haklex/rich-editor": "^0.63.1",
43
+ "@haklex/rich-editor-ui": "^0.63.1",
44
+ "@haklex/rich-plugin-slash-menu": "^0.63.1",
45
+ "@haklex/rich-style-token": "^0.63.1",
46
46
  "@lexical/list": "^0.53.0",
47
47
  "@lexical/react": "^0.53.0",
48
48
  "@lexical/rich-text": "^0.53.0",