@rufous/ui 0.1.91 → 0.1.92

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.
package/dist/main.cjs CHANGED
@@ -49843,6 +49843,7 @@ var RufousTextEditor = ({
49843
49843
  onSave: onSaveProp,
49844
49844
  onExport: onExportProp,
49845
49845
  onChange,
49846
+ onBlur,
49846
49847
  onAICommand,
49847
49848
  onTranslate,
49848
49849
  onSpeechToText,
@@ -49946,6 +49947,11 @@ var RufousTextEditor = ({
49946
49947
  if (onChange) {
49947
49948
  onChange(e.getHTML(), e.getJSON());
49948
49949
  }
49950
+ },
49951
+ onBlur: ({ editor: e }) => {
49952
+ if (onBlur) {
49953
+ onBlur(e.getHTML(), e.getJSON());
49954
+ }
49949
49955
  }
49950
49956
  });
49951
49957
  const [linkModalOpen, setLinkModalOpen] = (0, import_react60.useState)(false);
@@ -50053,17 +50059,22 @@ var RufousTextEditor = ({
50053
50059
  onImageUpload,
50054
50060
  onClose
50055
50061
  }
50056
- ), /* @__PURE__ */ import_react60.default.createElement(import_react61.EditorContent, { editor, className: "editor-content-wrapper" }), /* @__PURE__ */ import_react60.default.createElement(ImageToolbar_default, { editor }), /* @__PURE__ */ import_react60.default.createElement(VideoToolbar_default, { editor }), /* @__PURE__ */ import_react60.default.createElement(SpellCheckTooltip, { editor }), /* @__PURE__ */ import_react60.default.createElement(
50062
+ ), /* @__PURE__ */ import_react60.default.createElement(import_react61.EditorContent, { editor, className: "editor-content-wrapper" }), /* @__PURE__ */ import_react60.default.createElement(ImageToolbar_default, { editor }), /* @__PURE__ */ import_react60.default.createElement(VideoToolbar_default, { editor }), /* @__PURE__ */ import_react60.default.createElement(SpellCheckTooltip, { editor }), editor && /* @__PURE__ */ import_react60.default.createElement(
50057
50063
  import_react61.BubbleMenu,
50058
50064
  {
50059
50065
  editor,
50060
50066
  className: "bubble-menu",
50061
50067
  shouldShow: ({ editor: e }) => {
50062
- const { selection } = e.state;
50063
- if (selection?.node?.type.name === "image") return false;
50064
- if (selection?.node?.type.name === "youtube") return false;
50065
- if (selection?.node?.type.name === "video") return false;
50066
- return !selection.empty;
50068
+ if (!e || e.isDestroyed) return false;
50069
+ try {
50070
+ const { selection } = e.state;
50071
+ if (selection?.node?.type.name === "image") return false;
50072
+ if (selection?.node?.type.name === "youtube") return false;
50073
+ if (selection?.node?.type.name === "video") return false;
50074
+ return !selection.empty;
50075
+ } catch {
50076
+ return false;
50077
+ }
50067
50078
  }
50068
50079
  },
50069
50080
  /* @__PURE__ */ import_react60.default.createElement(
@@ -50106,42 +50117,62 @@ var RufousTextEditor = ({
50106
50117
  },
50107
50118
  "\u{1F517}"
50108
50119
  )
50109
- ), /* @__PURE__ */ import_react60.default.createElement(import_react61.FloatingMenu, { editor, className: "floating-menu" }, /* @__PURE__ */ import_react60.default.createElement(
50110
- "button",
50111
- {
50112
- onClick: () => editor?.chain().focus().toggleHeading({ level: 1 }).run(),
50113
- className: editor?.isActive("heading", { level: 1 }) ? "is-active" : ""
50114
- },
50115
- "H1"
50116
- ), /* @__PURE__ */ import_react60.default.createElement(
50117
- "button",
50118
- {
50119
- onClick: () => editor?.chain().focus().toggleHeading({ level: 2 }).run(),
50120
- className: editor?.isActive("heading", { level: 2 }) ? "is-active" : ""
50121
- },
50122
- "H2"
50123
- ), /* @__PURE__ */ import_react60.default.createElement(
50124
- "button",
50125
- {
50126
- onClick: () => editor?.chain().focus().toggleBulletList().run(),
50127
- className: editor?.isActive("bulletList") ? "is-active" : ""
50128
- },
50129
- "\u2022 List"
50130
- ), /* @__PURE__ */ import_react60.default.createElement(
50131
- "button",
50132
- {
50133
- onClick: () => editor?.chain().focus().toggleOrderedList().run(),
50134
- className: editor?.isActive("orderedList") ? "is-active" : ""
50135
- },
50136
- "1. List"
50137
- ), /* @__PURE__ */ import_react60.default.createElement(
50138
- "button",
50120
+ ), editor && /* @__PURE__ */ import_react60.default.createElement(
50121
+ import_react61.FloatingMenu,
50139
50122
  {
50140
- onClick: () => editor?.chain().focus().toggleBlockquote().run(),
50141
- className: editor?.isActive("blockquote") ? "is-active" : ""
50123
+ editor,
50124
+ className: "floating-menu",
50125
+ shouldShow: ({ editor: e }) => {
50126
+ if (!e || e.isDestroyed) return false;
50127
+ try {
50128
+ const { selection } = e.state;
50129
+ return selection.empty && e.state.doc.textContent.length === 0;
50130
+ } catch {
50131
+ return false;
50132
+ }
50133
+ }
50142
50134
  },
50143
- "\u201C Quote"
50144
- )), /* @__PURE__ */ import_react60.default.createElement("div", { className: "status-bar" }, /* @__PURE__ */ import_react60.default.createElement("div", { className: "status-bar-left" }, /* @__PURE__ */ import_react60.default.createElement(
50135
+ /* @__PURE__ */ import_react60.default.createElement(
50136
+ "button",
50137
+ {
50138
+ onClick: () => editor?.chain().focus().toggleHeading({ level: 1 }).run(),
50139
+ className: editor?.isActive("heading", { level: 1 }) ? "is-active" : ""
50140
+ },
50141
+ "H1"
50142
+ ),
50143
+ /* @__PURE__ */ import_react60.default.createElement(
50144
+ "button",
50145
+ {
50146
+ onClick: () => editor?.chain().focus().toggleHeading({ level: 2 }).run(),
50147
+ className: editor?.isActive("heading", { level: 2 }) ? "is-active" : ""
50148
+ },
50149
+ "H2"
50150
+ ),
50151
+ /* @__PURE__ */ import_react60.default.createElement(
50152
+ "button",
50153
+ {
50154
+ onClick: () => editor?.chain().focus().toggleBulletList().run(),
50155
+ className: editor?.isActive("bulletList") ? "is-active" : ""
50156
+ },
50157
+ "\u2022 List"
50158
+ ),
50159
+ /* @__PURE__ */ import_react60.default.createElement(
50160
+ "button",
50161
+ {
50162
+ onClick: () => editor?.chain().focus().toggleOrderedList().run(),
50163
+ className: editor?.isActive("orderedList") ? "is-active" : ""
50164
+ },
50165
+ "1. List"
50166
+ ),
50167
+ /* @__PURE__ */ import_react60.default.createElement(
50168
+ "button",
50169
+ {
50170
+ onClick: () => editor?.chain().focus().toggleBlockquote().run(),
50171
+ className: editor?.isActive("blockquote") ? "is-active" : ""
50172
+ },
50173
+ "\u201C Quote"
50174
+ )
50175
+ ), /* @__PURE__ */ import_react60.default.createElement("div", { className: "status-bar" }, /* @__PURE__ */ import_react60.default.createElement("div", { className: "status-bar-left" }, /* @__PURE__ */ import_react60.default.createElement(
50145
50176
  "select",
50146
50177
  {
50147
50178
  value: saveFormat,
package/dist/main.d.cts CHANGED
@@ -1683,6 +1683,7 @@ interface RufousTextEditorProps {
1683
1683
  onSave?: (html: string, json: any) => void;
1684
1684
  onExport?: (html: string, json: any) => void;
1685
1685
  onChange?: (html: string, json: any) => void;
1686
+ onBlur?: (html: string, json: any) => void;
1686
1687
  onAICommand?: (prompt: string, text: string, previousResults?: string[]) => Promise<string>;
1687
1688
  onTranslate?: (text: string, sourceLang: string, targetLang: string) => Promise<string>;
1688
1689
  onSpeechToText?: (text: string) => Promise<string>;
package/dist/main.d.ts CHANGED
@@ -1683,6 +1683,7 @@ interface RufousTextEditorProps {
1683
1683
  onSave?: (html: string, json: any) => void;
1684
1684
  onExport?: (html: string, json: any) => void;
1685
1685
  onChange?: (html: string, json: any) => void;
1686
+ onBlur?: (html: string, json: any) => void;
1686
1687
  onAICommand?: (prompt: string, text: string, previousResults?: string[]) => Promise<string>;
1687
1688
  onTranslate?: (text: string, sourceLang: string, targetLang: string) => Promise<string>;
1688
1689
  onSpeechToText?: (text: string) => Promise<string>;
package/dist/main.js CHANGED
@@ -21174,6 +21174,7 @@ var RufousTextEditor = ({
21174
21174
  onSave: onSaveProp,
21175
21175
  onExport: onExportProp,
21176
21176
  onChange,
21177
+ onBlur,
21177
21178
  onAICommand,
21178
21179
  onTranslate,
21179
21180
  onSpeechToText,
@@ -21277,6 +21278,11 @@ var RufousTextEditor = ({
21277
21278
  if (onChange) {
21278
21279
  onChange(e.getHTML(), e.getJSON());
21279
21280
  }
21281
+ },
21282
+ onBlur: ({ editor: e }) => {
21283
+ if (onBlur) {
21284
+ onBlur(e.getHTML(), e.getJSON());
21285
+ }
21280
21286
  }
21281
21287
  });
21282
21288
  const [linkModalOpen, setLinkModalOpen] = useState35(false);
@@ -21384,17 +21390,22 @@ var RufousTextEditor = ({
21384
21390
  onImageUpload,
21385
21391
  onClose
21386
21392
  }
21387
- ), /* @__PURE__ */ React117.createElement(EditorContent, { editor, className: "editor-content-wrapper" }), /* @__PURE__ */ React117.createElement(ImageToolbar_default, { editor }), /* @__PURE__ */ React117.createElement(VideoToolbar_default, { editor }), /* @__PURE__ */ React117.createElement(SpellCheckTooltip, { editor }), /* @__PURE__ */ React117.createElement(
21393
+ ), /* @__PURE__ */ React117.createElement(EditorContent, { editor, className: "editor-content-wrapper" }), /* @__PURE__ */ React117.createElement(ImageToolbar_default, { editor }), /* @__PURE__ */ React117.createElement(VideoToolbar_default, { editor }), /* @__PURE__ */ React117.createElement(SpellCheckTooltip, { editor }), editor && /* @__PURE__ */ React117.createElement(
21388
21394
  BubbleMenu,
21389
21395
  {
21390
21396
  editor,
21391
21397
  className: "bubble-menu",
21392
21398
  shouldShow: ({ editor: e }) => {
21393
- const { selection } = e.state;
21394
- if (selection?.node?.type.name === "image") return false;
21395
- if (selection?.node?.type.name === "youtube") return false;
21396
- if (selection?.node?.type.name === "video") return false;
21397
- return !selection.empty;
21399
+ if (!e || e.isDestroyed) return false;
21400
+ try {
21401
+ const { selection } = e.state;
21402
+ if (selection?.node?.type.name === "image") return false;
21403
+ if (selection?.node?.type.name === "youtube") return false;
21404
+ if (selection?.node?.type.name === "video") return false;
21405
+ return !selection.empty;
21406
+ } catch {
21407
+ return false;
21408
+ }
21398
21409
  }
21399
21410
  },
21400
21411
  /* @__PURE__ */ React117.createElement(
@@ -21437,42 +21448,62 @@ var RufousTextEditor = ({
21437
21448
  },
21438
21449
  "\u{1F517}"
21439
21450
  )
21440
- ), /* @__PURE__ */ React117.createElement(FloatingMenu, { editor, className: "floating-menu" }, /* @__PURE__ */ React117.createElement(
21441
- "button",
21442
- {
21443
- onClick: () => editor?.chain().focus().toggleHeading({ level: 1 }).run(),
21444
- className: editor?.isActive("heading", { level: 1 }) ? "is-active" : ""
21445
- },
21446
- "H1"
21447
- ), /* @__PURE__ */ React117.createElement(
21448
- "button",
21449
- {
21450
- onClick: () => editor?.chain().focus().toggleHeading({ level: 2 }).run(),
21451
- className: editor?.isActive("heading", { level: 2 }) ? "is-active" : ""
21452
- },
21453
- "H2"
21454
- ), /* @__PURE__ */ React117.createElement(
21455
- "button",
21456
- {
21457
- onClick: () => editor?.chain().focus().toggleBulletList().run(),
21458
- className: editor?.isActive("bulletList") ? "is-active" : ""
21459
- },
21460
- "\u2022 List"
21461
- ), /* @__PURE__ */ React117.createElement(
21462
- "button",
21463
- {
21464
- onClick: () => editor?.chain().focus().toggleOrderedList().run(),
21465
- className: editor?.isActive("orderedList") ? "is-active" : ""
21466
- },
21467
- "1. List"
21468
- ), /* @__PURE__ */ React117.createElement(
21469
- "button",
21451
+ ), editor && /* @__PURE__ */ React117.createElement(
21452
+ FloatingMenu,
21470
21453
  {
21471
- onClick: () => editor?.chain().focus().toggleBlockquote().run(),
21472
- className: editor?.isActive("blockquote") ? "is-active" : ""
21454
+ editor,
21455
+ className: "floating-menu",
21456
+ shouldShow: ({ editor: e }) => {
21457
+ if (!e || e.isDestroyed) return false;
21458
+ try {
21459
+ const { selection } = e.state;
21460
+ return selection.empty && e.state.doc.textContent.length === 0;
21461
+ } catch {
21462
+ return false;
21463
+ }
21464
+ }
21473
21465
  },
21474
- "\u201C Quote"
21475
- )), /* @__PURE__ */ React117.createElement("div", { className: "status-bar" }, /* @__PURE__ */ React117.createElement("div", { className: "status-bar-left" }, /* @__PURE__ */ React117.createElement(
21466
+ /* @__PURE__ */ React117.createElement(
21467
+ "button",
21468
+ {
21469
+ onClick: () => editor?.chain().focus().toggleHeading({ level: 1 }).run(),
21470
+ className: editor?.isActive("heading", { level: 1 }) ? "is-active" : ""
21471
+ },
21472
+ "H1"
21473
+ ),
21474
+ /* @__PURE__ */ React117.createElement(
21475
+ "button",
21476
+ {
21477
+ onClick: () => editor?.chain().focus().toggleHeading({ level: 2 }).run(),
21478
+ className: editor?.isActive("heading", { level: 2 }) ? "is-active" : ""
21479
+ },
21480
+ "H2"
21481
+ ),
21482
+ /* @__PURE__ */ React117.createElement(
21483
+ "button",
21484
+ {
21485
+ onClick: () => editor?.chain().focus().toggleBulletList().run(),
21486
+ className: editor?.isActive("bulletList") ? "is-active" : ""
21487
+ },
21488
+ "\u2022 List"
21489
+ ),
21490
+ /* @__PURE__ */ React117.createElement(
21491
+ "button",
21492
+ {
21493
+ onClick: () => editor?.chain().focus().toggleOrderedList().run(),
21494
+ className: editor?.isActive("orderedList") ? "is-active" : ""
21495
+ },
21496
+ "1. List"
21497
+ ),
21498
+ /* @__PURE__ */ React117.createElement(
21499
+ "button",
21500
+ {
21501
+ onClick: () => editor?.chain().focus().toggleBlockquote().run(),
21502
+ className: editor?.isActive("blockquote") ? "is-active" : ""
21503
+ },
21504
+ "\u201C Quote"
21505
+ )
21506
+ ), /* @__PURE__ */ React117.createElement("div", { className: "status-bar" }, /* @__PURE__ */ React117.createElement("div", { className: "status-bar-left" }, /* @__PURE__ */ React117.createElement(
21476
21507
  "select",
21477
21508
  {
21478
21509
  value: saveFormat,
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@rufous/ui",
3
3
  "private": false,
4
- "version": "0.1.91",
4
+ "version": "0.1.92",
5
5
  "type": "module",
6
6
  "description": "Experimental: A lightweight React UI component library (Beta)",
7
7
  "style": "./dist/main.css",