@haklex/rich-plugin-slash-menu 0.0.94 → 0.0.95

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,15 +1,15 @@
1
1
  import { MenuOption } from '@lexical/react/LexicalTypeaheadMenuPlugin';
2
2
  import { LexicalEditor } from 'lexical';
3
- import { ReactNode } from 'react';
3
+ import { JSX } from 'react';
4
4
  export declare class SlashMenuItem extends MenuOption {
5
5
  title: string;
6
- icon: ReactNode;
6
+ icon: JSX.Element | undefined;
7
7
  description: string;
8
8
  keywords: string[];
9
9
  section: string;
10
10
  onSelect: (editor: LexicalEditor, queryString: string) => void;
11
11
  constructor(title: string, options: {
12
- icon?: ReactNode;
12
+ icon?: JSX.Element;
13
13
  description?: string;
14
14
  keywords?: string[];
15
15
  section?: string;
@@ -1 +1 @@
1
- {"version":3,"file":"SlashMenuItem.d.ts","sourceRoot":"","sources":["../src/SlashMenuItem.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,2CAA2C,CAAA;AACtE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,SAAS,CAAA;AAC5C,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAA;AAEtC,qBAAa,aAAc,SAAQ,UAAU;IAC3C,KAAK,EAAE,MAAM,CAAA;IACb,IAAI,EAAE,SAAS,CAAA;IACf,WAAW,EAAE,MAAM,CAAA;IACnB,QAAQ,EAAE,MAAM,EAAE,CAAA;IAClB,OAAO,EAAE,MAAM,CAAA;IACf,QAAQ,EAAE,CAAC,MAAM,EAAE,aAAa,EAAE,WAAW,EAAE,MAAM,KAAK,IAAI,CAAA;gBAG5D,KAAK,EAAE,MAAM,EACb,OAAO,EAAE;QACP,IAAI,CAAC,EAAE,SAAS,CAAA;QAChB,WAAW,CAAC,EAAE,MAAM,CAAA;QACpB,QAAQ,CAAC,EAAE,MAAM,EAAE,CAAA;QACnB,OAAO,CAAC,EAAE,MAAM,CAAA;QAChB,QAAQ,EAAE,CAAC,MAAM,EAAE,aAAa,EAAE,WAAW,EAAE,MAAM,KAAK,IAAI,CAAA;KAC/D;CAUJ"}
1
+ {"version":3,"file":"SlashMenuItem.d.ts","sourceRoot":"","sources":["../src/SlashMenuItem.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,2CAA2C,CAAC;AACvE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAC7C,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,OAAO,CAAC;AAEjC,qBAAa,aAAc,SAAQ,UAAU;IAC3C,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,GAAG,CAAC,OAAO,GAAG,SAAS,CAAC;IAC9B,WAAW,EAAE,MAAM,CAAC;IACpB,QAAQ,EAAE,MAAM,EAAE,CAAC;IACnB,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,EAAE,CAAC,MAAM,EAAE,aAAa,EAAE,WAAW,EAAE,MAAM,KAAK,IAAI,CAAC;gBAG7D,KAAK,EAAE,MAAM,EACb,OAAO,EAAE;QACP,IAAI,CAAC,EAAE,GAAG,CAAC,OAAO,CAAC;QACnB,WAAW,CAAC,EAAE,MAAM,CAAC;QACrB,QAAQ,CAAC,EAAE,MAAM,EAAE,CAAC;QACpB,OAAO,CAAC,EAAE,MAAM,CAAC;QACjB,QAAQ,EAAE,CAAC,MAAM,EAAE,aAAa,EAAE,WAAW,EAAE,MAAM,KAAK,IAAI,CAAC;KAChE;CAUJ"}
@@ -1 +1 @@
1
- {"version":3,"file":"SlashMenuPlugin.d.ts","sourceRoot":"","sources":["../src/SlashMenuPlugin.tsx"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,aAAa,EAAY,MAAM,SAAS,CAAC;AAMvD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAIrD,MAAM,WAAW,oBAAoB;IACnC,UAAU,CAAC,EAAE,aAAa,EAAE,CAAC;IAC7B,KAAK,CAAC,EAAE,aAAa,EAAE,CAAC;IACxB,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAED,wBAAgB,qBAAqB,CAAC,MAAM,EAAE,aAAa,GAAG,aAAa,EAAE,CAK5E;AAWD,wBAAgB,eAAe,CAAC,EAAE,KAAK,EAAE,UAAU,EAAE,WAAiB,EAAE,EAAE,oBAAoB,2CAuE7F"}
1
+ {"version":3,"file":"SlashMenuPlugin.d.ts","sourceRoot":"","sources":["../src/SlashMenuPlugin.tsx"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,aAAa,EAAY,MAAM,SAAS,CAAC;AAMvD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAIrD,MAAM,WAAW,oBAAoB;IACnC,UAAU,CAAC,EAAE,aAAa,EAAE,CAAC;IAC7B,KAAK,CAAC,EAAE,aAAa,EAAE,CAAC;IACxB,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAED,wBAAgB,qBAAqB,CAAC,MAAM,EAAE,aAAa,GAAG,aAAa,EAAE,CAc5E;AAWD,wBAAgB,eAAe,CAAC,EAAE,KAAK,EAAE,UAAU,EAAE,WAAiB,EAAE,EAAE,oBAAoB,2CAuE7F"}
package/dist/index.mjs CHANGED
@@ -8,7 +8,7 @@ import { $setBlocksType } from "@lexical/selection";
8
8
  import { INSERT_TABLE_COMMAND } from "@lexical/table";
9
9
  import { $getSelection, $isRangeSelection, $createParagraphNode } from "lexical";
10
10
  import { Type, Heading1, Heading2, Heading3, TextQuote, Minus, Table, List, ListOrdered, ListChecks } from "lucide-react";
11
- import { createElement, useEffect, useMemo, useState, useCallback } from "react";
11
+ import { createElement, useEffect, useMemo, useState, useCallback, isValidElement } from "react";
12
12
  import { MenuOption, useBasicTypeaheadTriggerMatch, LexicalTypeaheadMenuPlugin } from "@lexical/react/LexicalTypeaheadMenuPlugin";
13
13
  import { jsx, jsxs } from "react/jsx-runtime";
14
14
  import { useFloating, autoUpdate, offset, flip, shift } from "@floating-ui/react-dom";
@@ -26,7 +26,7 @@ class SlashMenuItem extends MenuOption {
26
26
  __publicField(this, "section");
27
27
  __publicField(this, "onSelect");
28
28
  this.title = title;
29
- this.icon = options.icon ?? "";
29
+ this.icon = options.icon;
30
30
  this.description = options.description ?? "";
31
31
  this.keywords = options.keywords ?? [];
32
32
  this.section = options.section ?? "BASIC BLOCKS";
@@ -247,7 +247,15 @@ function SlashMenuList({
247
247
  }
248
248
  function collectNodeSlashItems(editor) {
249
249
  const configs = collectCommandItems(editor);
250
- return configs.filter((c) => !c.placement || c.placement.includes("slash")).map((c) => new SlashMenuItem(c.title, c));
250
+ return configs.filter((c) => !c.placement || c.placement.includes("slash")).map(
251
+ (c) => new SlashMenuItem(c.title, {
252
+ description: c.description,
253
+ icon: isValidElement(c.icon) ? c.icon : void 0,
254
+ keywords: c.keywords,
255
+ section: c.section,
256
+ onSelect: c.onSelect
257
+ })
258
+ );
251
259
  }
252
260
  function filterItems(query, items) {
253
261
  if (!query) return items;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@haklex/rich-plugin-slash-menu",
3
- "version": "0.0.94",
3
+ "version": "0.0.95",
4
4
  "description": "Slash command menu plugin",
5
5
  "repository": {
6
6
  "type": "git",
@@ -22,8 +22,8 @@
22
22
  ],
23
23
  "dependencies": {
24
24
  "@floating-ui/react-dom": "^2.1.8",
25
- "@haklex/rich-style-token": "0.0.94",
26
- "@haklex/rich-editor": "0.0.94"
25
+ "@haklex/rich-editor": "0.0.95",
26
+ "@haklex/rich-style-token": "0.0.95"
27
27
  },
28
28
  "devDependencies": {
29
29
  "@lexical/list": "^0.42.0",