@haklex/rich-plugin-toolbar 0.0.87 → 0.0.89

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":"ToolbarPlugin.d.ts","sourceRoot":"","sources":["../src/ToolbarPlugin.tsx"],"names":[],"mappings":"AAgEA,OAAO,KAAK,EAAiB,YAAY,EAAE,MAAM,OAAO,CAAC;AAkHzD,MAAM,WAAW,kBAAkB;IACjC,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,eAAe,CAAC,EAAE,MAAM,EAAE,CAAC;IAC3B,qBAAqB,CAAC,EAAE,MAAM,CAAC;CAChC;AAED,wBAAgB,aAAa,CAAC,EAC5B,SAAS,EACT,qBAAwD,EACxD,eAAe,GAChB,EAAE,kBAAkB,GAAG,YAAY,CA4YnC"}
1
+ {"version":3,"file":"ToolbarPlugin.d.ts","sourceRoot":"","sources":["../src/ToolbarPlugin.tsx"],"names":[],"mappings":"AAqEA,OAAO,KAAK,EAAiB,YAAY,EAAE,MAAM,OAAO,CAAC;AAoHzD,MAAM,WAAW,kBAAkB;IACjC,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,eAAe,CAAC,EAAE,MAAM,EAAE,CAAC;IAC3B,qBAAqB,CAAC,EAAE,MAAM,CAAC;CAChC;AAED,wBAAgB,aAAa,CAAC,EAC5B,SAAS,EACT,qBAAwD,EACxD,eAAe,GAChB,EAAE,kBAAkB,GAAG,YAAY,CA4ZnC"}
package/dist/index.mjs CHANGED
@@ -1,5 +1,5 @@
1
1
  import { jsx, jsxs, Fragment } from "react/jsx-runtime";
2
- import { collectCommandItems } from "@haklex/rich-editor/commands";
2
+ import { collectCommandItems, $selectionTouchesSpoiler, $toggleSpoilerSelection } from "@haklex/rich-editor/commands";
3
3
  import { TooltipTrigger, TooltipRoot, TooltipContent, DropdownMenuContent, DropdownMenuItem, DropdownMenu, DropdownMenuTrigger, createTooltipHandle, TooltipProvider } from "@haklex/rich-editor-ui";
4
4
  import { $isListNode, INSERT_UNORDERED_LIST_COMMAND, INSERT_ORDERED_LIST_COMMAND, INSERT_CHECK_LIST_COMMAND } from "@lexical/list";
5
5
  import { useLexicalComposerContext } from "@lexical/react/LexicalComposerContext";
@@ -7,7 +7,7 @@ import { $createHeadingNode, $isHeadingNode } from "@lexical/rich-text";
7
7
  import { $getSelectionStyleValueForProperty, $patchStyleText, $setBlocksType } from "@lexical/selection";
8
8
  import { $findMatchingParent } from "@lexical/utils";
9
9
  import { $getSelection, $isRangeSelection, $isRootOrShadowRoot, $isElementNode, CAN_UNDO_COMMAND, COMMAND_PRIORITY_LOW, CAN_REDO_COMMAND, $createParagraphNode, UNDO_COMMAND, REDO_COMMAND, FORMAT_TEXT_COMMAND, FORMAT_ELEMENT_COMMAND } from "lexical";
10
- import { ChevronDown, Pilcrow, Heading1, Heading2, Heading3, Undo, Redo, Bold, Italic, Underline, Strikethrough, Code, Highlighter, List, ListOrdered, ListChecks, AlignLeft, AlignCenter, AlignRight, AlignJustify, Ellipsis } from "lucide-react";
10
+ import { ChevronDown, Pilcrow, Heading1, Heading2, Heading3, Undo, Redo, Bold, Italic, Underline, Strikethrough, Code, Highlighter, EyeOff, List, ListOrdered, ListChecks, AlignLeft, AlignCenter, AlignRight, AlignJustify, Ellipsis } from "lucide-react";
11
11
  import { useState, useMemo, useCallback, useEffect } from "react";
12
12
  var toolbarContainer = "_1e1ersc0";
13
13
  var toolbarRow = "_1e1ersc1";
@@ -178,7 +178,8 @@ const INITIAL_STATE = {
178
178
  isUnderline: false,
179
179
  isStrikethrough: false,
180
180
  isCode: false,
181
- isHighlight: false
181
+ isHighlight: false,
182
+ isSpoiler: false
182
183
  };
183
184
  function getBlockType(anchorNode) {
184
185
  if ($isHeadingNode(anchorNode)) {
@@ -234,17 +235,25 @@ function ToolbarPlugin({
234
235
  const blockType = getBlockType(element);
235
236
  const fontFamily = $getSelectionStyleValueForProperty(selection, "font-family", "");
236
237
  const elementFormat = $isElementNode(element) ? element.getFormatType() : "left";
238
+ const isBold = selection.hasFormat("bold");
239
+ const isItalic = selection.hasFormat("italic");
240
+ const isUnderline = selection.hasFormat("underline");
241
+ const isStrikethrough = selection.hasFormat("strikethrough");
242
+ const isCode = selection.hasFormat("code");
243
+ const isHighlight = selection.hasFormat("highlight");
244
+ const isSpoiler = $selectionTouchesSpoiler(selection);
237
245
  setState((prev) => ({
238
246
  ...prev,
239
247
  blockType,
240
248
  fontFamily,
241
249
  elementFormat,
242
- isBold: selection.hasFormat("bold"),
243
- isItalic: selection.hasFormat("italic"),
244
- isUnderline: selection.hasFormat("underline"),
245
- isStrikethrough: selection.hasFormat("strikethrough"),
246
- isCode: selection.hasFormat("code"),
247
- isHighlight: selection.hasFormat("highlight")
250
+ isBold,
251
+ isItalic,
252
+ isUnderline,
253
+ isStrikethrough,
254
+ isCode,
255
+ isHighlight,
256
+ isSpoiler
248
257
  }));
249
258
  }, []);
250
259
  useEffect(() => {
@@ -469,6 +478,16 @@ function ToolbarPlugin({
469
478
  onClick: () => editor.dispatchCommand(FORMAT_TEXT_COMMAND, "highlight")
470
479
  }
471
480
  ),
481
+ /* @__PURE__ */ jsx(
482
+ ToolbarButton,
483
+ {
484
+ active: state.isSpoiler,
485
+ icon: /* @__PURE__ */ jsx(EyeOff, { size: ICON_SIZE, strokeWidth: ICON_STROKE }),
486
+ title: "Spoiler",
487
+ tooltipHandle: h,
488
+ onClick: () => editor.update($toggleSpoilerSelection)
489
+ }
490
+ ),
472
491
  /* @__PURE__ */ jsx(ToolbarSeparator, {}),
473
492
  /* @__PURE__ */ jsx(
474
493
  ToolbarButton,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@haklex/rich-plugin-toolbar",
3
- "version": "0.0.87",
3
+ "version": "0.0.89",
4
4
  "description": "Top toolbar plugin for rich editor",
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.87",
25
- "@haklex/rich-editor-ui": "0.0.87",
26
- "@haklex/rich-style-token": "0.0.87"
24
+ "@haklex/rich-editor": "0.0.89",
25
+ "@haklex/rich-style-token": "0.0.89",
26
+ "@haklex/rich-editor-ui": "0.0.89"
27
27
  },
28
28
  "devDependencies": {
29
29
  "@lexical/list": "^0.42.0",
@@ -36,7 +36,7 @@
36
36
  "@vanilla-extract/css": "^1.18.0",
37
37
  "@vanilla-extract/vite-plugin": "^5.1.4",
38
38
  "lexical": "^0.42.0",
39
- "lucide-react": "^0.577.0",
39
+ "lucide-react": "^1.0.0",
40
40
  "react": "19.2.4",
41
41
  "react-dom": "19.2.4",
42
42
  "typescript": "^5.9.3",
@@ -50,7 +50,7 @@
50
50
  "@lexical/selection": "^0.42.0",
51
51
  "@lexical/utils": "^0.42.0",
52
52
  "lexical": "^0.42.0",
53
- "lucide-react": "^0.574.0",
53
+ "lucide-react": "^1.0.0",
54
54
  "react": ">=19",
55
55
  "react-dom": ">=19"
56
56
  },