@haklex/rich-plugin-floating-toolbar 0.0.109 → 0.1.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.
@@ -1 +1 @@
1
- {"version":3,"file":"FloatingToolbarPlugin.d.ts","sourceRoot":"","sources":["../src/FloatingToolbarPlugin.tsx"],"names":[],"mappings":"AAmCA,OAAO,KAAK,EAAE,YAAY,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AA8LrD,MAAM,WAAW,0BAA0B;IACzC,OAAO,CAAC,EAAE,SAAS,CAAC;CACrB;AAED,wBAAgB,qBAAqB,CAAC,EACpC,OAAO,GACR,GAAE,0BAA+B,GAAG,YAAY,GAAG,IAAI,CAwhBvD"}
1
+ {"version":3,"file":"FloatingToolbarPlugin.d.ts","sourceRoot":"","sources":["../src/FloatingToolbarPlugin.tsx"],"names":[],"mappings":"AAwCA,OAAO,KAAK,EAAE,YAAY,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAoMrD,MAAM,WAAW,0BAA0B;IACzC,OAAO,CAAC,EAAE,SAAS,CAAC;CACrB;AAED,wBAAgB,qBAAqB,CAAC,EACpC,OAAO,GACR,GAAE,0BAA+B,GAAG,YAAY,GAAG,IAAI,CA2hBvD"}
package/dist/index.mjs CHANGED
@@ -1,7 +1,7 @@
1
1
  import { jsxs, Fragment, jsx } from "react/jsx-runtime";
2
2
  import { useTextSelectionSnapshot, getDOMRectFromTextSelection } from "@haklex/rich-editor";
3
3
  import { $toggleSpoilerSelection, $selectionTouchesSpoiler } from "@haklex/rich-editor/commands";
4
- import { $createRubyNode, $isRubyNode } from "@haklex/rich-editor/nodes";
4
+ import { $isKaTeXInlineNode, $createRubyNode, $isRubyNode } from "@haklex/rich-editor/nodes";
5
5
  import { ColorPicker } from "@haklex/rich-editor-ui";
6
6
  import { usePortalTheme, usePortalContainer, vars } from "@haklex/rich-style-token";
7
7
  import { TOGGLE_LINK_COMMAND, $isLinkNode, $isAutoLinkNode } from "@lexical/link";
@@ -85,6 +85,12 @@ function getSelectionState(selection) {
85
85
  return isEffectiveLinkNode(parent) || isEffectiveLinkNode(node);
86
86
  });
87
87
  const hasRuby = getSelectedRubyNodes(nodes).length > 0;
88
+ const textColor = $getSelectionStyleValueForProperty(selection, "color", "");
89
+ let fontColor = textColor;
90
+ if (!fontColor) {
91
+ const katex = nodes.find((n) => $isKaTeXInlineNode(n));
92
+ if (katex) fontColor = katex.getColor() ?? "";
93
+ }
88
94
  return {
89
95
  isBold: selection.hasFormat("bold"),
90
96
  isItalic: selection.hasFormat("italic"),
@@ -97,7 +103,7 @@ function getSelectionState(selection) {
97
103
  isLink: hasLink,
98
104
  isRuby: hasRuby,
99
105
  isSpoiler: $selectionTouchesSpoiler(selection),
100
- fontColor: $getSelectionStyleValueForProperty(selection, "color", "")
106
+ fontColor
101
107
  };
102
108
  }
103
109
  function computePosition(rect, toolbar2, container) {
@@ -296,8 +302,11 @@ function FloatingToolbarPlugin({
296
302
  (value) => {
297
303
  editor.update(() => {
298
304
  const sel = $getSelection();
299
- if ($isRangeSelection(sel)) {
300
- $patchStyleText(sel, { color: value === "inherit" ? null : value });
305
+ if (!$isRangeSelection(sel)) return;
306
+ const color = value === "inherit" ? null : value;
307
+ $patchStyleText(sel, { color });
308
+ for (const node of sel.getNodes()) {
309
+ if ($isKaTeXInlineNode(node)) node.setColor(color);
301
310
  }
302
311
  });
303
312
  },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@haklex/rich-plugin-floating-toolbar",
3
- "version": "0.0.109",
3
+ "version": "0.1.0",
4
4
  "description": "Floating toolbar plugin",
5
5
  "repository": {
6
6
  "type": "git",
@@ -21,9 +21,9 @@
21
21
  "dist"
22
22
  ],
23
23
  "dependencies": {
24
- "@haklex/rich-editor": "0.0.109",
25
- "@haklex/rich-style-token": "0.0.109",
26
- "@haklex/rich-editor-ui": "0.0.109"
24
+ "@haklex/rich-editor": "0.1.0",
25
+ "@haklex/rich-style-token": "0.1.0",
26
+ "@haklex/rich-editor-ui": "0.1.0"
27
27
  },
28
28
  "devDependencies": {
29
29
  "@lexical/link": "^0.43.0",