@rufous/ui 0.1.90 → 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,11 +49843,13 @@ var RufousTextEditor = ({
49843
49843
  onSave: onSaveProp,
49844
49844
  onExport: onExportProp,
49845
49845
  onChange,
49846
+ onBlur,
49846
49847
  onAICommand,
49847
49848
  onTranslate,
49848
49849
  onSpeechToText,
49849
49850
  onTextToSpeech,
49850
49851
  onImageUpload,
49852
+ onClose,
49851
49853
  mentions,
49852
49854
  className,
49853
49855
  style
@@ -49945,6 +49947,11 @@ var RufousTextEditor = ({
49945
49947
  if (onChange) {
49946
49948
  onChange(e.getHTML(), e.getJSON());
49947
49949
  }
49950
+ },
49951
+ onBlur: ({ editor: e }) => {
49952
+ if (onBlur) {
49953
+ onBlur(e.getHTML(), e.getJSON());
49954
+ }
49948
49955
  }
49949
49956
  });
49950
49957
  const [linkModalOpen, setLinkModalOpen] = (0, import_react60.useState)(false);
@@ -50049,19 +50056,25 @@ var RufousTextEditor = ({
50049
50056
  onTranslate,
50050
50057
  onSpeechToText,
50051
50058
  onTextToSpeech,
50052
- onImageUpload
50059
+ onImageUpload,
50060
+ onClose
50053
50061
  }
50054
- ), /* @__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(
50055
50063
  import_react61.BubbleMenu,
50056
50064
  {
50057
50065
  editor,
50058
50066
  className: "bubble-menu",
50059
50067
  shouldShow: ({ editor: e }) => {
50060
- const { selection } = e.state;
50061
- if (selection?.node?.type.name === "image") return false;
50062
- if (selection?.node?.type.name === "youtube") return false;
50063
- if (selection?.node?.type.name === "video") return false;
50064
- 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
+ }
50065
50078
  }
50066
50079
  },
50067
50080
  /* @__PURE__ */ import_react60.default.createElement(
@@ -50104,42 +50117,62 @@ var RufousTextEditor = ({
50104
50117
  },
50105
50118
  "\u{1F517}"
50106
50119
  )
50107
- ), /* @__PURE__ */ import_react60.default.createElement(import_react61.FloatingMenu, { editor, className: "floating-menu" }, /* @__PURE__ */ import_react60.default.createElement(
50108
- "button",
50120
+ ), editor && /* @__PURE__ */ import_react60.default.createElement(
50121
+ import_react61.FloatingMenu,
50109
50122
  {
50110
- onClick: () => editor?.chain().focus().toggleHeading({ level: 1 }).run(),
50111
- className: editor?.isActive("heading", { level: 1 }) ? "is-active" : ""
50112
- },
50113
- "H1"
50114
- ), /* @__PURE__ */ import_react60.default.createElement(
50115
- "button",
50116
- {
50117
- onClick: () => editor?.chain().focus().toggleHeading({ level: 2 }).run(),
50118
- className: editor?.isActive("heading", { level: 2 }) ? "is-active" : ""
50119
- },
50120
- "H2"
50121
- ), /* @__PURE__ */ import_react60.default.createElement(
50122
- "button",
50123
- {
50124
- onClick: () => editor?.chain().focus().toggleBulletList().run(),
50125
- className: editor?.isActive("bulletList") ? "is-active" : ""
50126
- },
50127
- "\u2022 List"
50128
- ), /* @__PURE__ */ import_react60.default.createElement(
50129
- "button",
50130
- {
50131
- onClick: () => editor?.chain().focus().toggleOrderedList().run(),
50132
- className: editor?.isActive("orderedList") ? "is-active" : ""
50133
- },
50134
- "1. List"
50135
- ), /* @__PURE__ */ import_react60.default.createElement(
50136
- "button",
50137
- {
50138
- onClick: () => editor?.chain().focus().toggleBlockquote().run(),
50139
- 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
+ }
50140
50134
  },
50141
- "\u201C Quote"
50142
- )), /* @__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(
50143
50176
  "select",
50144
50177
  {
50145
50178
  value: saveFormat,
package/dist/main.d.cts CHANGED
@@ -1683,11 +1683,13 @@ 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>;
1689
1690
  onTextToSpeech?: (text: string, voice?: string) => Promise<string>;
1690
1691
  onImageUpload?: (file: File) => Promise<string>;
1692
+ onClose?: () => void;
1691
1693
  mentions?: Array<{
1692
1694
  id: string;
1693
1695
  name: string;
package/dist/main.d.ts CHANGED
@@ -1683,11 +1683,13 @@ 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>;
1689
1690
  onTextToSpeech?: (text: string, voice?: string) => Promise<string>;
1690
1691
  onImageUpload?: (file: File) => Promise<string>;
1692
+ onClose?: () => void;
1691
1693
  mentions?: Array<{
1692
1694
  id: string;
1693
1695
  name: string;
package/dist/main.js CHANGED
@@ -21174,11 +21174,13 @@ var RufousTextEditor = ({
21174
21174
  onSave: onSaveProp,
21175
21175
  onExport: onExportProp,
21176
21176
  onChange,
21177
+ onBlur,
21177
21178
  onAICommand,
21178
21179
  onTranslate,
21179
21180
  onSpeechToText,
21180
21181
  onTextToSpeech,
21181
21182
  onImageUpload,
21183
+ onClose,
21182
21184
  mentions,
21183
21185
  className,
21184
21186
  style
@@ -21276,6 +21278,11 @@ var RufousTextEditor = ({
21276
21278
  if (onChange) {
21277
21279
  onChange(e.getHTML(), e.getJSON());
21278
21280
  }
21281
+ },
21282
+ onBlur: ({ editor: e }) => {
21283
+ if (onBlur) {
21284
+ onBlur(e.getHTML(), e.getJSON());
21285
+ }
21279
21286
  }
21280
21287
  });
21281
21288
  const [linkModalOpen, setLinkModalOpen] = useState35(false);
@@ -21380,19 +21387,25 @@ var RufousTextEditor = ({
21380
21387
  onTranslate,
21381
21388
  onSpeechToText,
21382
21389
  onTextToSpeech,
21383
- onImageUpload
21390
+ onImageUpload,
21391
+ onClose
21384
21392
  }
21385
- ), /* @__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(
21386
21394
  BubbleMenu,
21387
21395
  {
21388
21396
  editor,
21389
21397
  className: "bubble-menu",
21390
21398
  shouldShow: ({ editor: e }) => {
21391
- const { selection } = e.state;
21392
- if (selection?.node?.type.name === "image") return false;
21393
- if (selection?.node?.type.name === "youtube") return false;
21394
- if (selection?.node?.type.name === "video") return false;
21395
- 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
+ }
21396
21409
  }
21397
21410
  },
21398
21411
  /* @__PURE__ */ React117.createElement(
@@ -21435,42 +21448,62 @@ var RufousTextEditor = ({
21435
21448
  },
21436
21449
  "\u{1F517}"
21437
21450
  )
21438
- ), /* @__PURE__ */ React117.createElement(FloatingMenu, { editor, className: "floating-menu" }, /* @__PURE__ */ React117.createElement(
21439
- "button",
21451
+ ), editor && /* @__PURE__ */ React117.createElement(
21452
+ FloatingMenu,
21440
21453
  {
21441
- onClick: () => editor?.chain().focus().toggleHeading({ level: 1 }).run(),
21442
- className: editor?.isActive("heading", { level: 1 }) ? "is-active" : ""
21443
- },
21444
- "H1"
21445
- ), /* @__PURE__ */ React117.createElement(
21446
- "button",
21447
- {
21448
- onClick: () => editor?.chain().focus().toggleHeading({ level: 2 }).run(),
21449
- className: editor?.isActive("heading", { level: 2 }) ? "is-active" : ""
21450
- },
21451
- "H2"
21452
- ), /* @__PURE__ */ React117.createElement(
21453
- "button",
21454
- {
21455
- onClick: () => editor?.chain().focus().toggleBulletList().run(),
21456
- className: editor?.isActive("bulletList") ? "is-active" : ""
21457
- },
21458
- "\u2022 List"
21459
- ), /* @__PURE__ */ React117.createElement(
21460
- "button",
21461
- {
21462
- onClick: () => editor?.chain().focus().toggleOrderedList().run(),
21463
- className: editor?.isActive("orderedList") ? "is-active" : ""
21464
- },
21465
- "1. List"
21466
- ), /* @__PURE__ */ React117.createElement(
21467
- "button",
21468
- {
21469
- onClick: () => editor?.chain().focus().toggleBlockquote().run(),
21470
- 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
+ }
21471
21465
  },
21472
- "\u201C Quote"
21473
- )), /* @__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(
21474
21507
  "select",
21475
21508
  {
21476
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.90",
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",