@clevertask/scribe 0.1.2 → 0.1.3

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,5 +1,14 @@
1
1
  import { Extension } from "@tiptap/core";
2
2
  import { PluginKey } from "@tiptap/pm/state";
3
+ import { SuggestionOptions } from "@tiptap/suggestion";
4
+ import type { SlashCommandItemsProvider, SuggestionItem } from "./items";
3
5
  export declare const slashMenuPluginKey: PluginKey<any>;
4
- export declare const SlashCommand: Extension<any, any>;
6
+ export type ScribeSlashCommandOptions = Omit<Partial<SuggestionOptions<SuggestionItem, SuggestionItem>>, "command" | "editor" | "items"> & {
7
+ items?: SlashCommandItemsProvider;
8
+ };
9
+ export type { SlashCommandContext, SlashCommandItemsProvider, SlashCommandItemsProviderProps, SuggestionItem, } from "./items";
10
+ type SlashCommandOptions = {
11
+ slashSuggestion: Partial<SuggestionOptions<SuggestionItem, SuggestionItem>>;
12
+ };
13
+ export declare const SlashCommand: Extension<SlashCommandOptions, any>;
5
14
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../lib/components/Scribe/extension/slashCommand/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AACzC,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAG7C,eAAO,MAAM,kBAAkB,gBAAmC,CAAC;AAEnE,eAAO,MAAM,YAAY,qBAyBvB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../lib/components/Scribe/extension/slashCommand/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AACzC,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAC7C,OAAmB,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AACnE,OAAO,KAAK,EAAE,yBAAyB,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AAEzE,eAAO,MAAM,kBAAkB,gBAAmC,CAAC;AAEnE,MAAM,MAAM,yBAAyB,GAAG,IAAI,CAC1C,OAAO,CAAC,iBAAiB,CAAC,cAAc,EAAE,cAAc,CAAC,CAAC,EAC1D,SAAS,GAAG,QAAQ,GAAG,OAAO,CAC/B,GAAG;IACF,KAAK,CAAC,EAAE,yBAAyB,CAAC;CACnC,CAAC;AAEF,YAAY,EACV,mBAAmB,EACnB,yBAAyB,EACzB,8BAA8B,EAC9B,cAAc,GACf,MAAM,SAAS,CAAC;AAEjB,KAAK,mBAAmB,GAAG;IACzB,eAAe,EAAE,OAAO,CAAC,iBAAiB,CAAC,cAAc,EAAE,cAAc,CAAC,CAAC,CAAC;CAC7E,CAAC;AAEF,eAAO,MAAM,YAAY,qCAyBvB,CAAC"}
@@ -7,7 +7,26 @@ export declare enum SuggestionItemType {
7
7
  interface CommandProps {
8
8
  editor: Editor;
9
9
  range: Range;
10
+ props: SuggestionItem;
10
11
  }
12
+ export interface SlashCommandContext {
13
+ isInsideListItem: boolean;
14
+ isInsideBulletList: boolean;
15
+ isInsideOrderedList: boolean;
16
+ isInsideTaskList: boolean;
17
+ listDepth: number;
18
+ parentListType: string | null;
19
+ parentNodeType: string;
20
+ selectionFrom: number;
21
+ selectionTo: number;
22
+ }
23
+ export interface SlashCommandItemsProviderProps {
24
+ query: string;
25
+ editor: Editor;
26
+ context: SlashCommandContext;
27
+ defaultItems: SuggestionItem[];
28
+ }
29
+ export type SlashCommandItemsProvider = (props: SlashCommandItemsProviderProps) => SuggestionItem[] | Promise<SuggestionItem[]>;
11
30
  export interface SuggestionItem {
12
31
  title: string;
13
32
  description: string;
@@ -16,6 +35,7 @@ export interface SuggestionItem {
16
35
  icon?: ReactNode;
17
36
  command: (props: CommandProps) => void;
18
37
  }
38
+ export declare const getSlashCommandContext: (editor: Editor) => SlashCommandContext;
19
39
  export declare const getSuggestionItems: (props: {
20
40
  query: string;
21
41
  editor: Editor;
@@ -1 +1 @@
1
- {"version":3,"file":"items.d.ts","sourceRoot":"","sources":["../../../../../lib/components/Scribe/extension/slashCommand/items.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,cAAc,CAAC;AAC7C,OAAO,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAElC,oBAAY,kBAAkB;IAC5B,YAAY,UAAU;IACtB,eAAe,aAAa;CAC7B;AAED,UAAU,YAAY;IACpB,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,KAAK,CAAC;CACd;AAED,MAAM,WAAW,cAAc;IAC7B,KAAK,EAAE,MAAM,CAAC;IACd,WAAW,EAAE,MAAM,CAAC;IACpB,IAAI,EAAE,kBAAkB,CAAC;IACzB,WAAW,EAAE,MAAM,EAAE,CAAC;IACtB,IAAI,CAAC,EAAE,SAAS,CAAC;IACjB,OAAO,EAAE,CAAC,KAAK,EAAE,YAAY,KAAK,IAAI,CAAC;CACxC;AAED,eAAO,MAAM,kBAAkB,GAAI,OAAO;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,qBAkM1E,CAAC"}
1
+ {"version":3,"file":"items.d.ts","sourceRoot":"","sources":["../../../../../lib/components/Scribe/extension/slashCommand/items.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,cAAc,CAAC;AAC7C,OAAO,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAElC,oBAAY,kBAAkB;IAC5B,YAAY,UAAU;IACtB,eAAe,aAAa;CAC7B;AAED,UAAU,YAAY;IACpB,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,KAAK,CAAC;IACb,KAAK,EAAE,cAAc,CAAC;CACvB;AAED,MAAM,WAAW,mBAAmB;IAClC,gBAAgB,EAAE,OAAO,CAAC;IAC1B,kBAAkB,EAAE,OAAO,CAAC;IAC5B,mBAAmB,EAAE,OAAO,CAAC;IAC7B,gBAAgB,EAAE,OAAO,CAAC;IAC1B,SAAS,EAAE,MAAM,CAAC;IAClB,cAAc,EAAE,MAAM,GAAG,IAAI,CAAC;IAC9B,cAAc,EAAE,MAAM,CAAC;IACvB,aAAa,EAAE,MAAM,CAAC;IACtB,WAAW,EAAE,MAAM,CAAC;CACrB;AAED,MAAM,WAAW,8BAA8B;IAC7C,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,mBAAmB,CAAC;IAC7B,YAAY,EAAE,cAAc,EAAE,CAAC;CAChC;AAED,MAAM,MAAM,yBAAyB,GAAG,CACtC,KAAK,EAAE,8BAA8B,KAClC,cAAc,EAAE,GAAG,OAAO,CAAC,cAAc,EAAE,CAAC,CAAC;AAElD,MAAM,WAAW,cAAc;IAC7B,KAAK,EAAE,MAAM,CAAC;IACd,WAAW,EAAE,MAAM,CAAC;IACpB,IAAI,EAAE,kBAAkB,CAAC;IACzB,WAAW,EAAE,MAAM,EAAE,CAAC;IACtB,IAAI,CAAC,EAAE,SAAS,CAAC;IACjB,OAAO,EAAE,CAAC,KAAK,EAAE,YAAY,KAAK,IAAI,CAAC;CACxC;AAED,eAAO,MAAM,sBAAsB,GAAI,QAAQ,MAAM,KAAG,mBA6BvD,CAAC;AAEF,eAAO,MAAM,kBAAkB,GAAI,OAAO;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,qBAkM1E,CAAC"}
@@ -1,13 +1,31 @@
1
1
  import { jsx as t } from "react/jsx-runtime";
2
- var o = /* @__PURE__ */ ((c) => (c.BASIC_BLOCKS = "Basic", c.ADVANCED_BLOCKS = "Advanced", c))(o || {});
3
- const C = (c) => {
4
- const { query: i } = c;
2
+ var l = /* @__PURE__ */ ((i) => (i.BASIC_BLOCKS = "Basic", i.ADVANCED_BLOCKS = "Advanced", i))(l || {});
3
+ const C = (i) => {
4
+ const { from: n, to: r } = i.state.selection, o = i.state.doc.resolve(n);
5
+ let s = 0, e = null;
6
+ for (let c = o.depth; c > 0; c -= 1) {
7
+ const a = o.node(c).type.name;
8
+ a === "listItem" && (s += 1), !e && ["bulletList", "orderedList", "taskList"].includes(a) && (e = a);
9
+ }
10
+ return {
11
+ isInsideListItem: s > 0,
12
+ isInsideBulletList: e === "bulletList",
13
+ isInsideOrderedList: e === "orderedList",
14
+ isInsideTaskList: e === "taskList",
15
+ listDepth: s,
16
+ parentListType: e,
17
+ parentNodeType: o.parent.type.name,
18
+ selectionFrom: n,
19
+ selectionTo: r
20
+ };
21
+ }, L = (i) => {
22
+ const { query: n } = i;
5
23
  return [
6
24
  {
7
25
  title: "Text",
8
26
  description: "Start writing with plain text",
9
27
  type: "Basic",
10
- command: ({ editor: e, range: s }) => e.chain().focus().deleteRange(s).toggleNode("paragraph", "paragraph").run(),
28
+ command: ({ editor: s, range: e }) => s.chain().focus().deleteRange(e).toggleNode("paragraph", "paragraph").run(),
11
29
  searchTerms: ["p", "paragraph"],
12
30
  icon: /* @__PURE__ */ t("svg", { className: "slash-menu-icon", viewBox: "0 0 448 512", children: /* @__PURE__ */ t("path", { d: "M448 48v72a8 8 0 01-8 8h-16a8 8 0 01-8-8V64H240v384h72a8 8 0 018 8v16a8 8 0 01-8 8H136a8 8 0 01-8-8v-16a8 8 0 018-8h72V64H32v56a8 8 0 01-8 8H8a8 8 0 01-8-8V48a16 16 0 0116-16h416a16 16 0 0116 16z" }) })
13
31
  },
@@ -15,7 +33,7 @@ const C = (c) => {
15
33
  title: "H1",
16
34
  description: "Big heading",
17
35
  type: "Basic",
18
- command: ({ editor: e, range: s }) => e.chain().focus().deleteRange(s).setNode("heading", { level: 1 }).run(),
36
+ command: ({ editor: s, range: e }) => s.chain().focus().deleteRange(e).setNode("heading", { level: 1 }).run(),
19
37
  searchTerms: ["title", "big", "large"],
20
38
  icon: /* @__PURE__ */ t(
21
39
  "svg",
@@ -40,7 +58,7 @@ const C = (c) => {
40
58
  title: "H2",
41
59
  description: "Medium heading",
42
60
  type: "Basic",
43
- command: ({ editor: e, range: s }) => e.chain().focus().deleteRange(s).setNode("heading", { level: 2 }).run(),
61
+ command: ({ editor: s, range: e }) => s.chain().focus().deleteRange(e).setNode("heading", { level: 2 }).run(),
44
62
  searchTerms: ["subtitle", "medium"],
45
63
  icon: /* @__PURE__ */ t(
46
64
  "svg",
@@ -65,7 +83,7 @@ const C = (c) => {
65
83
  title: "H3",
66
84
  description: "Small heading",
67
85
  type: "Basic",
68
- command: ({ editor: e, range: s }) => e.chain().focus().deleteRange(s).setNode("heading", { level: 3 }).run(),
86
+ command: ({ editor: s, range: e }) => s.chain().focus().deleteRange(e).setNode("heading", { level: 3 }).run(),
69
87
  searchTerms: ["subtitle", "small"],
70
88
  icon: /* @__PURE__ */ t(
71
89
  "svg",
@@ -90,7 +108,7 @@ const C = (c) => {
90
108
  title: "Bullet List",
91
109
  description: "Create a simple bullet list",
92
110
  type: "Basic",
93
- command: ({ editor: e, range: s }) => e.chain().focus().deleteRange(s).toggleBulletList().run(),
111
+ command: ({ editor: s, range: e }) => s.chain().focus().deleteRange(e).toggleBulletList().run(),
94
112
  searchTerms: ["unordered", "point"],
95
113
  icon: /* @__PURE__ */ t("svg", { className: "slash-menu-icon", viewBox: "0 0 512 512", children: /* @__PURE__ */ t("path", { d: "M64 64c17.67 0 32 14.33 32 32 0 17.7-14.33 32-32 32s-32-14.3-32-32c0-17.67 14.33-32 32-32zm432 16c8.8 0 16 7.16 16 16 0 8.8-7.2 16-16 16H176c-8.8 0-16-7.2-16-16 0-8.84 7.2-16 16-16h320zm0 160c8.8 0 16 7.2 16 16s-7.2 16-16 16H176c-8.8 0-16-7.2-16-16s7.2-16 16-16h320zm0 160c8.8 0 16 7.2 16 16s-7.2 16-16 16H176c-8.8 0-16-7.2-16-16s7.2-16 16-16h320zM64 288c-17.67 0-32-14.3-32-32s14.33-32 32-32 32 14.3 32 32-14.33 32-32 32zm0 96c17.67 0 32 14.3 32 32s-14.33 32-32 32-32-14.3-32-32 14.33-32 32-32z" }) })
96
114
  },
@@ -98,7 +116,7 @@ const C = (c) => {
98
116
  title: "Numbered List",
99
117
  description: "Create a simple numbered list",
100
118
  type: "Basic",
101
- command: ({ editor: e, range: s }) => e.chain().focus().deleteRange(s).toggleOrderedList().run(),
119
+ command: ({ editor: s, range: e }) => s.chain().focus().deleteRange(e).toggleOrderedList().run(),
102
120
  searchTerms: ["ordered"],
103
121
  icon: /* @__PURE__ */ t("svg", { className: "slash-menu-icon", viewBox: "0 0 576 512", children: /* @__PURE__ */ t("path", { d: "M64 48.04c0-8.84 7.16-16 16-16h32c8.8 0 16 7.16 16 16V192h32c8.8 0 16 7.2 16 16 0 8.9-7.2 16-16 16H64c-8.84 0-16-7.1-16-16 0-8.8 7.16-16 16-16h32V64.04H80c-8.84 0-16-7.17-16-16zM224 96c0-8.84 7.2-16 16-16h288c8.8 0 16 7.16 16 16 0 8.8-7.2 16-16 16H240c-8.8 0-16-7.2-16-16zm0 160c0-8.8 7.2-16 16-16h288c8.8 0 16 7.2 16 16s-7.2 16-16 16H240c-8.8 0-16-7.2-16-16zm0 160c0-8.8 7.2-16 16-16h288c8.8 0 16 7.2 16 16s-7.2 16-16 16H240c-8.8 0-16-7.2-16-16zM75.31 339.3c-6.24 6.3-16.37 6.3-22.62 0-6.25-6.2-6.25-16.4 0-22.6l15.41-15.4c24.18-24.2 63.8-22.9 86.3 2.8 20 22 19.4 57.1-1.3 79.3L92.82 448H160c8.8 0 16 7.2 16 16s-7.2 16-16 16H56c-6.37 0-12.13-3.8-14.67-9.6-2.54-5.9-1.37-12.7 2.97-17.3l85.4-91.5c9.5-10.2 9.8-25.9.6-36.4-11.2-11.8-28.5-12.4-39.57-1.3l-15.42 15.4z" }) })
104
122
  },
@@ -106,7 +124,7 @@ const C = (c) => {
106
124
  title: "Divider",
107
125
  description: "Insert a dividing line",
108
126
  type: "Basic",
109
- command: ({ editor: e, range: s }) => e.chain().focus().deleteRange(s).setHorizontalRule().run(),
127
+ command: ({ editor: s, range: e }) => s.chain().focus().deleteRange(e).setHorizontalRule().run(),
110
128
  searchTerms: ["separator"],
111
129
  icon: /* @__PURE__ */ t("svg", { className: "slash-menu-icon", viewBox: "0 0 24 24", children: /* @__PURE__ */ t("path", { d: "M21 12.75C21.4142 12.75 21.75 12.4142 21.75 12C21.75 11.5858 21.4142 11.25 21 11.25V12.75ZM3 11.25C2.58579 11.25 2.25 11.5858 2.25 12C2.25 12.4142 2.58579 12.75 3 12.75V11.25ZM7.54601 7.89101L7.8865 7.22275L7.54601 7.89101ZM7.10899 7.45399L7.77725 7.1135L7.10899 7.45399ZM16.891 7.45399L16.2228 7.1135L16.891 7.45399ZM16.454 7.89101L16.1135 7.22275L16.454 7.89101ZM16.454 4.10899L16.1135 4.77725L16.454 4.10899ZM16.891 4.54601L16.2228 4.8865L16.891 4.54601ZM7.54601 4.10899L7.8865 4.77725L7.54601 4.10899ZM7.10899 4.54601L7.77725 4.8865L7.10899 4.54601ZM7.54601 19.891L7.8865 19.2228L7.54601 19.891ZM7.10899 19.454L7.77725 19.1135L7.10899 19.454ZM16.891 19.454L16.2228 19.1135L16.891 19.454ZM16.454 19.891L16.1135 19.2228L16.454 19.891ZM16.454 16.109L16.1135 16.7772L16.454 16.109ZM16.891 16.546L16.2228 16.8865L16.891 16.546ZM7.54601 16.109L7.8865 16.7772L7.54601 16.109ZM7.10899 16.546L7.77725 16.8865L7.10899 16.546ZM21 11.25H3V12.75H21V11.25ZM8.6 4.75H15.4V3.25H8.6V4.75ZM16.25 5.6V6.4H17.75V5.6H16.25ZM15.4 7.25H8.6V8.75H15.4V7.25ZM7.75 6.4V5.6H6.25V6.4H7.75ZM8.6 7.25C8.3076 7.25 8.1334 7.24942 8.00428 7.23887C7.8839 7.22903 7.87011 7.2144 7.8865 7.22275L7.20552 8.55926C7.43582 8.67661 7.669 8.71647 7.88213 8.73388C8.08651 8.75058 8.33235 8.75 8.6 8.75V7.25ZM6.25 6.4C6.25 6.66765 6.24942 6.91349 6.26611 7.11787C6.28353 7.331 6.32339 7.56418 6.44074 7.79448L7.77725 7.1135C7.7856 7.12989 7.77097 7.1161 7.76113 6.99572C7.75058 6.8666 7.75 6.6924 7.75 6.4H6.25ZM7.8865 7.22275C7.83946 7.19878 7.80122 7.16054 7.77725 7.1135L6.44074 7.79448C6.60852 8.12377 6.87623 8.39148 7.20552 8.55926L7.8865 7.22275ZM16.25 6.4C16.25 6.6924 16.2494 6.8666 16.2389 6.99572C16.229 7.1161 16.2144 7.12989 16.2228 7.1135L17.5593 7.79448C17.6766 7.56418 17.7165 7.331 17.7339 7.11787C17.7506 6.91349 17.75 6.66765 17.75 6.4H16.25ZM15.4 8.75C15.6677 8.75 15.9135 8.75058 16.1179 8.73388C16.331 8.71647 16.5642 8.67661 16.7945 8.55926L16.1135 7.22275C16.1299 7.2144 16.1161 7.22903 15.9957 7.23887C15.8666 7.24942 15.6924 7.25 15.4 7.25V8.75ZM16.2228 7.1135C16.1988 7.16054 16.1605 7.19878 16.1135 7.22275L16.7945 8.55926C17.1238 8.39148 17.3915 8.12377 17.5593 7.79448L16.2228 7.1135ZM15.4 4.75C15.6924 4.75 15.8666 4.75058 15.9957 4.76113C16.1161 4.77097 16.1299 4.7856 16.1135 4.77725L16.7945 3.44074C16.5642 3.32339 16.331 3.28353 16.1179 3.26612C15.9135 3.24942 15.6677 3.25 15.4 3.25V4.75ZM17.75 5.6C17.75 5.33235 17.7506 5.08651 17.7339 4.88213C17.7165 4.669 17.6766 4.43582 17.5593 4.20552L16.2228 4.8865C16.2144 4.87011 16.229 4.8839 16.2389 5.00428C16.2494 5.1334 16.25 5.3076 16.25 5.6H17.75ZM16.1135 4.77725C16.1605 4.80122 16.1988 4.83946 16.2228 4.8865L17.5593 4.20552C17.3915 3.87623 17.1238 3.60852 16.7945 3.44074L16.1135 4.77725ZM8.6 3.25C8.33235 3.25 8.08651 3.24942 7.88213 3.26612C7.669 3.28353 7.43582 3.32339 7.20552 3.44074L7.8865 4.77725C7.87011 4.7856 7.8839 4.77097 8.00428 4.76113C8.1334 4.75058 8.3076 4.75 8.6 4.75V3.25ZM7.75 5.6C7.75 5.3076 7.75058 5.1334 7.76113 5.00428C7.77097 4.8839 7.7856 4.87011 7.77725 4.8865L6.44074 4.20552C6.32339 4.43582 6.28353 4.669 6.26611 4.88213C6.24942 5.08651 6.25 5.33235 6.25 5.6H7.75ZM7.20552 3.44074C6.87623 3.60852 6.60852 3.87623 6.44074 4.20552L7.77725 4.8865C7.80122 4.83946 7.83946 4.80122 7.8865 4.77725L7.20552 3.44074ZM8.6 16.75H15.4V15.25H8.6V16.75ZM16.25 17.6V18.4H17.75V17.6H16.25ZM15.4 19.25H8.6V20.75H15.4V19.25ZM7.75 18.4V17.6H6.25V18.4H7.75ZM8.6 19.25C8.3076 19.25 8.1334 19.2494 8.00428 19.2389C7.8839 19.229 7.87011 19.2144 7.8865 19.2228L7.20552 20.5593C7.43582 20.6766 7.669 20.7165 7.88213 20.7339C8.08651 20.7506 8.33235 20.75 8.6 20.75V19.25ZM6.25 18.4C6.25 18.6677 6.24942 18.9135 6.26611 19.1179C6.28353 19.331 6.32339 19.5642 6.44074 19.7945L7.77725 19.1135C7.7856 19.1299 7.77097 19.1161 7.76113 18.9957C7.75058 18.8666 7.75 18.6924 7.75 18.4H6.25ZM7.8865 19.2228C7.83946 19.1988 7.80122 19.1605 7.77725 19.1135L6.44074 19.7945C6.60852 20.1238 6.87623 20.3915 7.20552 20.5593L7.8865 19.2228ZM16.25 18.4C16.25 18.6924 16.2494 18.8666 16.2389 18.9957C16.229 19.1161 16.2144 19.1299 16.2228 19.1135L17.5593 19.7945C17.6766 19.5642 17.7165 19.331 17.7339 19.1179C17.7506 18.9135 17.75 18.6677 17.75 18.4H16.25ZM15.4 20.75C15.6677 20.75 15.9135 20.7506 16.1179 20.7339C16.331 20.7165 16.5642 20.6766 16.7945 20.5593L16.1135 19.2228C16.1299 19.2144 16.1161 19.229 15.9957 19.2389C15.8666 19.2494 15.6924 19.25 15.4 19.25V20.75ZM16.2228 19.1135C16.1988 19.1605 16.1605 19.1988 16.1135 19.2228L16.7945 20.5593C17.1238 20.3915 17.3915 20.1238 17.5593 19.7945L16.2228 19.1135ZM15.4 16.75C15.6924 16.75 15.8666 16.7506 15.9957 16.7611C16.1161 16.771 16.1299 16.7856 16.1135 16.7772L16.7945 15.4407C16.5642 15.3234 16.331 15.2835 16.1179 15.2661C15.9135 15.2494 15.6677 15.25 15.4 15.25V16.75ZM17.75 17.6C17.75 17.3323 17.7506 17.0865 17.7339 16.8821C17.7165 16.669 17.6766 16.4358 17.5593 16.2055L16.2228 16.8865C16.2144 16.8701 16.229 16.8839 16.2389 17.0043C16.2494 17.1334 16.25 17.3076 16.25 17.6H17.75ZM16.1135 16.7772C16.1605 16.8012 16.1988 16.8395 16.2228 16.8865L17.5593 16.2055C17.3915 15.8762 17.1238 15.6085 16.7945 15.4407L16.1135 16.7772ZM8.6 15.25C8.33235 15.25 8.08651 15.2494 7.88213 15.2661C7.66899 15.2835 7.43582 15.3234 7.20552 15.4407L7.8865 16.7772C7.87011 16.7856 7.8839 16.771 8.00428 16.7611C8.1334 16.7506 8.3076 16.75 8.6 16.75V15.25ZM7.75 17.6C7.75 17.3076 7.75058 17.1334 7.76113 17.0043C7.77097 16.8839 7.7856 16.8701 7.77725 16.8865L6.44074 16.2055C6.32339 16.4358 6.28353 16.669 6.26611 16.8821C6.24942 17.0865 6.25 17.3323 6.25 17.6H7.75ZM7.20552 15.4407C6.87623 15.6085 6.60852 15.8762 6.44074 16.2055L7.77725 16.8865C7.80122 16.8395 7.83946 16.8012 7.8865 16.7772L7.20552 15.4407Z" }) })
112
130
  },
@@ -115,7 +133,7 @@ const C = (c) => {
115
133
  title: "Code Block",
116
134
  description: "Add a block of code",
117
135
  type: "Advanced",
118
- command: ({ editor: e, range: s }) => e.chain().focus().deleteRange(s).toggleCodeBlock().run(),
136
+ command: ({ editor: s, range: e }) => s.chain().focus().deleteRange(e).toggleCodeBlock().run(),
119
137
  searchTerms: ["codeblock"],
120
138
  icon: /* @__PURE__ */ t(
121
139
  "svg",
@@ -140,19 +158,20 @@ const C = (c) => {
140
158
  title: "Quote",
141
159
  description: "Add a quote",
142
160
  type: "Advanced",
143
- command: ({ editor: e, range: s }) => e.chain().focus().deleteRange(s).toggleNode("paragraph", "paragraph").toggleBlockquote().run(),
161
+ command: ({ editor: s, range: e }) => s.chain().focus().deleteRange(e).toggleNode("paragraph", "paragraph").toggleBlockquote().run(),
144
162
  searchTerms: ["blockquote"],
145
163
  icon: /* @__PURE__ */ t("svg", { className: "slash-menu-icon", viewBox: "0 0 448 512", children: /* @__PURE__ */ t("path", { d: "M432 80c8.8 0 16 7.16 16 16 0 8.8-7.2 16-16 16H16c-8.836 0-16-7.2-16-16 0-8.84 7.164-16 16-16h416zm0 160c8.8 0 16 7.2 16 16s-7.2 16-16 16H144c-8.8 0-16-7.2-16-16s7.2-16 16-16h288zM128 416c0-8.8 7.2-16 16-16h288c8.8 0 16 7.2 16 16s-7.2 16-16 16H144c-8.8 0-16-7.2-16-16zM0 240c0-8.8 7.164-16 16-16 8.84 0 16 7.2 16 16v192c0 8.8-7.16 16-16 16-8.836 0-16-7.2-16-16V240z" }) })
146
164
  }
147
- ].filter((e) => {
148
- if (typeof i == "string" && i.length > 0) {
149
- const s = i.toLowerCase();
150
- return e.title.toLowerCase().includes(s) || e.description.toLowerCase().includes(s) || e.searchTerms?.some((n) => n.includes(s));
165
+ ].filter((s) => {
166
+ if (typeof n == "string" && n.length > 0) {
167
+ const e = n.toLowerCase();
168
+ return s.title.toLowerCase().includes(e) || s.description.toLowerCase().includes(e) || s.searchTerms?.some((c) => c.includes(e));
151
169
  }
152
170
  return !0;
153
171
  });
154
172
  };
155
173
  export {
156
- o as SuggestionItemType,
157
- C as getSuggestionItems
174
+ l as SuggestionItemType,
175
+ C as getSlashCommandContext,
176
+ L as getSuggestionItems
158
177
  };
@@ -1,8 +1,11 @@
1
1
  import "katex/dist/katex.css";
2
2
  import { ClassValue } from "clsx";
3
+ import type { ScribeSlashCommandOptions } from "./extension/slashCommand";
3
4
  import type { ScribeTableOfContentsChangeHandler, ScribeTableOfContentsScrollTarget } from "./extension/tableOfContents";
4
5
  import { Content, Editor, Extension, JSONContent, UseEditorOptions } from "@tiptap/react";
5
6
  import { KeyboardEventHandler } from "react";
7
+ export type { ScribeSlashCommandOptions, SlashCommandContext, SlashCommandItemsProvider, SlashCommandItemsProviderProps, SuggestionItem, } from "./extension/slashCommand";
8
+ export { SuggestionItemType } from "./extension/slashCommand/items";
6
9
  export type { ScribeTableOfContentsChangeHandler, ScribeTableOfContentsItem, ScribeTableOfContentsScrollTarget, } from "./extension/tableOfContents";
7
10
  export type ScribeOnChangeContents = {
8
11
  jsonContent: Content;
@@ -38,6 +41,11 @@ export interface ScribeProps {
38
41
  mainContainerClassName?: ClassValue;
39
42
  onKeyDown?: KeyboardEventHandler;
40
43
  mobile?: boolean;
44
+ /**
45
+ * Allows callers to customize Scribe's slash command menu while keeping
46
+ * Scribe's default command list available.
47
+ */
48
+ slashCommand?: ScribeSlashCommandOptions;
41
49
  /** @experimental Enables Scribe's app-owned table-of-contents API. */
42
50
  enableTableOfContents?: boolean;
43
51
  /** @experimental Receives the current table-of-contents items when they change. */
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../lib/components/Scribe/index.tsx"],"names":[],"mappings":"AAAA,OAAO,sBAAsB,CAAC;AAE9B,OAAO,EAAE,UAAU,EAAQ,MAAM,MAAM,CAAC;AAIxC,OAAO,KAAK,EACV,kCAAkC,EAElC,iCAAiC,EAClC,MAAM,6BAA6B,CAAC;AACrC,OAAO,EACL,OAAO,EACP,MAAM,EAGN,SAAS,EACT,WAAW,EACX,gBAAgB,EACjB,MAAM,eAAe,CAAC;AACvB,OAAO,EAEL,oBAAoB,EAMrB,MAAM,OAAO,CAAC;AAGf,YAAY,EACV,kCAAkC,EAClC,y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AAC;IACvC,2FAA2F;IAC3F,2BAA2B,EAAE,CAAC,MAAM,EAAE,iCAAiC,KAAK,IAAI,CAAC;IACjF,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,WAAW,WAAW;IAC1B,eAAe,CAAC,EAAE,CAAC,OAAO,EAAE,sBAAsB,KAAK,IAAI,CAAC;IAC5D;;;OAGG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,UAAU,CAAC,EAAE,SAAS,EAAE,CAAC;IACzB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,WAAW,CAAC,EAAE,gBAAgB,CAAC;IAC/B,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,kBAAkB,CAAC,EAAE,KAAK,CAAC,aAAa,CAAC;IACzC,sBAAsB,CAAC,EAAE,UAAU,CAAC;IACpC,kBAAkB,CAAC,EAAE,KAAK,CAAC,aAAa,CAAC;IACzC,sBAAsB,CAAC,EAAE,UAAU,CAAC;IACpC,SAAS,CAAC,EAAE,oBAAoB,CAAC;IACjC,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB;;;OAGG;IACH,YAAY,CAAC,EAAE,yBAAyB,CAAC;IACzC,sEAAsE;IACtE,qBAAqB,CAAC,EAAE,OAAO,CAAC;IAChC,mFAAmF;IACnF,uBAAuB,CAAC,EAAE,kCAAkC,CAAC;CAC9D;AAED,eAAO,MAAM,MAAM,mGAyMjB,CAAC"}
@@ -1,6 +1,6 @@
1
- import { jsxs as x, jsx as a } from "react/jsx-runtime";
1
+ import { jsxs as I, jsx as a } from "react/jsx-runtime";
2
2
  import { B as A, c as b } from "../../BarMenu-DaKIz3zZ.js";
3
- import { html2md as I } from "../../utils/html-to-markdown.js";
3
+ import { html2md as N } from "../../utils/html-to-markdown.js";
4
4
  import "../../markdown-to-html-pL7ckd-m.js";
5
5
  import "../../purify.es-exIQuqhb.js";
6
6
  import { E as F } from "../../index-BiBV5TQx.js";
@@ -9,6 +9,7 @@ import { SCRIBE_TABLE_OF_CONTENTS_META as U } from "./extension/tableOfContents.
9
9
  import { E as V } from "../../index-DxF-1P4n.js";
10
10
  import { forwardRef as K, useRef as E, useEffect as c, useCallback as r, useState as q, useImperativeHandle as G } from "react";
11
11
  import { ListOptionBar as Q } from "../Menu/Mobile/ListOptionBar.js";
12
+ import { SuggestionItemType as mt } from "./extension/slashCommand/items.js";
12
13
  import '../../assets/index.css';const it = K((h, B) => {
13
14
  const {
14
15
  autoFocus: g = !1,
@@ -26,25 +27,25 @@ import '../../assets/index.css';const it = K((h, B) => {
26
27
  externalEditor: T,
27
28
  mobile: D,
28
29
  onTableOfContentsChange: f
29
- } = h, O = E(!T && i !== void 0), y = E([]), M = E(f);
30
+ } = h, y = E(!T && i !== void 0), O = E([]), M = E(f);
30
31
  c(() => {
31
32
  M.current = f;
32
33
  }, [f]);
33
34
  const z = r(
34
35
  (e, s) => {
35
- y.current = e, M.current?.(e, s);
36
+ O.current = e, M.current?.(e, s);
36
37
  },
37
38
  []
38
- ), u = r(
39
+ ), p = r(
39
40
  ({ editor: e, transaction: s }) => {
40
41
  if (s.getMeta(U))
41
42
  return;
42
- const n = e.getHTML(), m = e.getJSON(), p = !o;
43
+ const n = e.getHTML(), m = e.getJSON(), u = !o;
43
44
  l && l({
44
45
  jsonContent: e.isEmpty ? "" : m,
45
46
  htmlContent: e.isEmpty ? "" : n,
46
- markdownContent: e.isEmpty ? "" : I(n),
47
- source: p ? "programmatic" : "user"
47
+ markdownContent: e.isEmpty ? "" : N(n),
48
+ source: u ? "programmatic" : "user"
48
49
  });
49
50
  },
50
51
  [o, l]
@@ -65,29 +66,29 @@ import '../../assets/index.css';const it = K((h, B) => {
65
66
  },
66
67
  ...d?.editorProps
67
68
  }
68
- })), v = r(() => {
69
+ })), S = r(() => {
69
70
  t.commands.setContent("");
70
- }, [t]), w = r(
71
+ }, [t]), v = r(
71
72
  (e) => {
72
73
  const s = {
73
74
  html: () => t.getHTML(),
74
75
  json: () => t.getJSON(),
75
- markdown: () => I(t.getHTML())
76
+ markdown: () => N(t.getHTML())
76
77
  };
77
78
  return t.isEmpty ? "" : s[e]?.();
78
79
  },
79
80
  [t]
80
- ), N = r(
81
+ ), w = r(
81
82
  (e) => {
82
83
  t.commands.setContent(e);
83
84
  },
84
85
  [t]
85
- ), S = r(
86
+ ), x = r(
86
87
  (e) => {
87
- const s = typeof e == "string" ? e : e.id, n = y.current.find((C) => C.id === s) ?? (typeof e == "string" ? void 0 : e);
88
+ const s = typeof e == "string" ? e : e.id, n = O.current.find((C) => C.id === s) ?? (typeof e == "string" ? void 0 : e);
88
89
  if (!n || t.isDestroyed)
89
90
  return;
90
- const m = t.view.nodeDOM(n.pos), p = m instanceof HTMLElement ? m : n.dom;
91
+ const m = t.view.nodeDOM(n.pos), u = m instanceof HTMLElement ? m : n.dom;
91
92
  if (t.isEditable) {
92
93
  const C = Math.max(
93
94
  0,
@@ -95,38 +96,38 @@ import '../../assets/index.css';const it = K((h, B) => {
95
96
  );
96
97
  t.commands.focus(C, { scrollIntoView: !1 });
97
98
  }
98
- p.scrollIntoView({ behavior: "smooth", block: "start" });
99
+ u.scrollIntoView({ behavior: "smooth", block: "start" });
99
100
  },
100
101
  [t]
101
102
  );
102
103
  return G(B, () => ({
103
- resetContent: v,
104
- setContent: N,
105
- getContent: w,
106
- scrollToTableOfContentsItem: S,
104
+ resetContent: S,
105
+ setContent: w,
106
+ getContent: v,
107
+ scrollToTableOfContentsItem: x,
107
108
  editor: t
108
- }), [t, w, v, S, N]), c(() => {
109
+ }), [t, v, S, x, w]), c(() => {
109
110
  if (i !== void 0) {
110
- if (O.current) {
111
- O.current = !1;
111
+ if (y.current) {
112
+ y.current = !1;
112
113
  return;
113
114
  }
114
115
  t.commands.setContent(i, { emitUpdate: !1 });
115
116
  }
116
117
  }, [i, t]), c(() => {
117
118
  t.setEditable(!!o);
118
- }, [o, t]), c(() => (t.off("update"), t.on("update", u), () => {
119
- t.off("update", u);
120
- }), [t, u]), c(() => {
119
+ }, [o, t]), c(() => (t.off("update"), t.on("update", p), () => {
120
+ t.off("update", p);
121
+ }), [t, p]), c(() => {
121
122
  g && t.commands.focus("end");
122
- }, [g, t]), /* @__PURE__ */ x(
123
+ }, [g, t]), /* @__PURE__ */ I(
123
124
  "div",
124
125
  {
125
126
  className: b("scribe-wrapper", "scribe-root", k),
126
127
  "data-scribe-root": !0,
127
128
  style: P,
128
129
  children: [
129
- /* @__PURE__ */ x("div", { className: b("scribe-frame", o && "scribe-frame--editable"), children: [
130
+ /* @__PURE__ */ I("div", { className: b("scribe-frame", o && "scribe-frame--editable"), children: [
130
131
  t && R ? /* @__PURE__ */ a(A, { editor: t }) : null,
131
132
  /* @__PURE__ */ a(
132
133
  "div",
@@ -148,5 +149,6 @@ import '../../assets/index.css';const it = K((h, B) => {
148
149
  );
149
150
  });
150
151
  export {
151
- it as Scribe
152
+ it as Scribe,
153
+ mt as SuggestionItemType
152
154
  };
package/dist/main.js CHANGED
@@ -1,14 +1,16 @@
1
1
  import { Scribe as o } from "./components/Scribe/index.js";
2
2
  import { html2md as m } from "./utils/html-to-markdown.js";
3
- import { m as p } from "./markdown-to-html-pL7ckd-m.js";
3
+ import { m as i } from "./markdown-to-html-pL7ckd-m.js";
4
4
  import { isInViewport as x } from "./utils/is-in-viewport.js";
5
5
  import { convertLegacyMathDelimiters as a } from "./utils/convert-legacy-math-delimiters.js";
6
- import { createScribeEditor as h } from "./utils/create-scribe-editor.js";
6
+ import { createScribeEditor as d } from "./utils/create-scribe-editor.js";
7
+ import { SuggestionItemType as h } from "./components/Scribe/extension/slashCommand/items.js";
7
8
  export {
8
9
  o as Scribe,
10
+ h as SuggestionItemType,
9
11
  a as convertLegacyMathDelimiters,
10
- h as createScribeEditor,
12
+ d as createScribeEditor,
11
13
  m as html2md,
12
14
  x as isInViewport,
13
- p as md2html
15
+ i as md2html
14
16
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@clevertask/scribe",
3
- "version": "0.1.2",
3
+ "version": "0.1.3",
4
4
  "private": false,
5
5
  "description": "A Radix-based Tiptap rich text editor with a Notion-style block interface for viewing and creating content. Perfect for diverse needs like notes, documents, AI chat, Markdown parsing, and comments.",
6
6
  "keywords": [