@haklex/rich-plugin-slash-menu 0.33.0 → 0.35.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.
@@ -7,12 +7,14 @@ export declare class SlashMenuItem extends MenuOption {
7
7
  description: string;
8
8
  keywords: string[];
9
9
  section: string;
10
+ nested: boolean;
10
11
  onSelect: (editor: LexicalEditor, queryString: string) => void;
11
12
  constructor(title: string, options: {
12
13
  icon?: JSX.Element;
13
14
  description?: string;
14
15
  keywords?: string[];
15
16
  section?: string;
17
+ nested?: boolean;
16
18
  onSelect: (editor: LexicalEditor, queryString: string) => void;
17
19
  });
18
20
  }
@@ -1 +1 @@
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
+ {"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,MAAM,EAAE,OAAO,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,MAAM,CAAC,EAAE,OAAO,CAAC;QACjB,QAAQ,EAAE,CAAC,MAAM,EAAE,aAAa,EAAE,WAAW,EAAE,MAAM,KAAK,IAAI,CAAC;KAChE;CAWJ"}
@@ -3,8 +3,9 @@ import { SlashMenuItem } from './SlashMenuItem';
3
3
  export interface SlashMenuPluginProps {
4
4
  extraItems?: SlashMenuItem[];
5
5
  items?: SlashMenuItem[];
6
+ nested?: boolean;
6
7
  triggerChar?: string;
7
8
  }
8
9
  export declare function collectNodeSlashItems(editor: LexicalEditor): SlashMenuItem[];
9
- export declare function SlashMenuPlugin({ items, extraItems, triggerChar }: SlashMenuPluginProps): import("react").JSX.Element;
10
+ export declare function SlashMenuPlugin({ items, extraItems, nested, triggerChar, }: SlashMenuPluginProps): import("react").JSX.Element;
10
11
  //# sourceMappingURL=SlashMenuPlugin.d.ts.map
@@ -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,CAc5E;AAWD,wBAAgB,eAAe,CAAC,EAAE,KAAK,EAAE,UAAU,EAAE,WAAiB,EAAE,EAAE,oBAAoB,+BAuE7F"}
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,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAED,wBAAgB,qBAAqB,CAAC,MAAM,EAAE,aAAa,GAAG,aAAa,EAAE,CAe5E;AAWD,wBAAgB,eAAe,CAAC,EAC9B,KAAK,EACL,UAAU,EACV,MAAM,EACN,WAAiB,GAClB,EAAE,oBAAoB,+BA6EtB"}
@@ -1 +1 @@
1
- {"version":3,"file":"builtinItems.d.ts","sourceRoot":"","sources":["../src/builtinItems.ts"],"names":[],"mappings":"AAyBA,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAA;AAM/C,wBAAgB,eAAe,IAAI,aAAa,EAAE,CAiIjD"}
1
+ {"version":3,"file":"builtinItems.d.ts","sourceRoot":"","sources":["../src/builtinItems.ts"],"names":[],"mappings":"AAyBA,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAMhD,wBAAgB,eAAe,IAAI,aAAa,EAAE,CAkIjD"}
package/dist/index.mjs CHANGED
@@ -60,12 +60,14 @@ var SlashMenuItem = class extends MenuOption {
60
60
  _defineProperty(this, "description", void 0);
61
61
  _defineProperty(this, "keywords", void 0);
62
62
  _defineProperty(this, "section", void 0);
63
+ _defineProperty(this, "nested", void 0);
63
64
  _defineProperty(this, "onSelect", void 0);
64
65
  this.title = title;
65
66
  this.icon = options.icon;
66
67
  this.description = options.description ?? "";
67
68
  this.keywords = options.keywords ?? [];
68
69
  this.section = options.section ?? "BASIC BLOCKS";
70
+ this.nested = options.nested ?? true;
69
71
  this.onSelect = options.onSelect;
70
72
  }
71
73
  };
@@ -173,6 +175,7 @@ function getBuiltinItems() {
173
175
  icon: createElement(Table, { size: ICON_SIZE }),
174
176
  description: "Add a table",
175
177
  keywords: ["table", "grid"],
178
+ nested: false,
176
179
  section: SECTION_BASIC,
177
180
  onSelect: (editor) => {
178
181
  editor.dispatchCommand(INSERT_TABLE_COMMAND, {
@@ -336,6 +339,7 @@ function collectNodeSlashItems(editor) {
336
339
  description: c.description,
337
340
  icon: isValidElement(c.icon) ? c.icon : void 0,
338
341
  keywords: c.keywords,
342
+ nested: c.nested,
339
343
  section: c.section,
340
344
  onSelect: c.onSelect
341
345
  }));
@@ -348,18 +352,26 @@ function filterItems(query, items) {
348
352
  return item.keywords.some((kw) => kw.toLowerCase().includes(lower));
349
353
  });
350
354
  }
351
- function SlashMenuPlugin({ items, extraItems, triggerChar = "/" }) {
355
+ function SlashMenuPlugin({ items, extraItems, nested, triggerChar = "/" }) {
352
356
  const [editor] = useLexicalComposerContext();
353
357
  const [queryString, setQueryString] = useState(null);
354
358
  const allItems = useMemo(() => {
355
- if (items) return items;
356
- const builtins = getBuiltinItems();
357
- const nodeItems = collectNodeSlashItems(editor);
358
- const combined = [...builtins, ...nodeItems];
359
- return extraItems ? [...combined, ...extraItems] : combined;
359
+ let combined;
360
+ if (items) combined = items;
361
+ else {
362
+ const builtins = getBuiltinItems();
363
+ const nodeItems = collectNodeSlashItems(editor);
364
+ combined = extraItems ? [
365
+ ...builtins,
366
+ ...nodeItems,
367
+ ...extraItems
368
+ ] : [...builtins, ...nodeItems];
369
+ }
370
+ return nested ? combined.filter((item) => item.nested !== false) : combined;
360
371
  }, [
361
372
  items,
362
373
  extraItems,
374
+ nested,
363
375
  editor
364
376
  ]);
365
377
  const filteredItems = useMemo(() => filterItems(queryString ?? "", allItems), [queryString, allItems]);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@haklex/rich-plugin-slash-menu",
3
- "version": "0.33.0",
3
+ "version": "0.35.0",
4
4
  "description": "Slash command menu plugin",
5
5
  "repository": {
6
6
  "type": "git",
@@ -51,8 +51,8 @@
51
51
  "lucide-react": "^1.0.0",
52
52
  "react": ">=19",
53
53
  "react-dom": ">=19",
54
- "@haklex/rich-editor": "^0.33.0",
55
- "@haklex/rich-style-token": "^0.33.0"
54
+ "@haklex/rich-editor": "^0.35.0",
55
+ "@haklex/rich-style-token": "^0.35.0"
56
56
  },
57
57
  "publishConfig": {
58
58
  "access": "public"