@rimori/react-client 0.4.9-next.3 → 0.4.9-next.4

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.
@@ -8,7 +8,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
8
8
  });
9
9
  };
10
10
  import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
11
- import { useCallback, useEffect, useRef, useState } from 'react';
11
+ import { useCallback, useEffect, useMemo, useRef, useState } from 'react';
12
12
  import { useRimori } from '../../providers/PluginProvider';
13
13
  import { Markdown } from 'tiptap-markdown';
14
14
  import StarterKit from '@tiptap/starter-kit';
@@ -42,12 +42,11 @@ const EditorButton = ({ editor, action, isActive, label, disabled, title }) => {
42
42
  .toggleHeading({ level: level })
43
43
  .run(), className: baseClass, children: label }));
44
44
  }
45
- // ChainedCommands is not index-typed; cast to call dynamic action names while keeping `.run()`
46
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
47
- const chain = editor.chain().focus();
48
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
49
- const canChain = editor.can().chain().focus();
50
- return (_jsx("button", { type: "button", title: title, onClick: () => chain[action]().run(), disabled: disabled ? !canChain[action]().run() : false, className: baseClass, children: label }));
45
+ return (_jsx("button", { type: "button", title: title,
46
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
47
+ onClick: () => editor.chain().focus()[action]().run(),
48
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
49
+ disabled: disabled ? !editor.can().chain()[action]().run() : false, className: baseClass, children: label }));
51
50
  };
52
51
  const InlinePanel = ({ panel, onClose, editor, onUpdate, labels }) => {
53
52
  const [value, setValue] = useState('');
@@ -160,34 +159,24 @@ export const MarkdownEditor = ({ content, editable, className, onUpdate, labels,
160
159
  return null;
161
160
  return data.url;
162
161
  }), [storage]);
163
- const extensions = [
164
- StarterKit.configure({
165
- bulletList: {
166
- HTMLAttributes: {
167
- class: 'list-disc list-inside dark:text-white p-1 mt-1 [&_li]:mb-1 [&_p]:inline m-0',
168
- },
169
- },
170
- orderedList: {
171
- HTMLAttributes: {
172
- className: 'list-decimal list-inside dark:text-white p-1 mt-1 [&_li]:mb-1 [&_p]:inline m-0',
173
- },
174
- },
175
- }),
162
+ const extensions = useMemo(() => [
163
+ StarterKit,
176
164
  Table.configure({ resizable: false }),
177
165
  TableRow,
178
166
  TableHeader,
179
167
  TableCell,
180
- Link.configure({ protocols: ['mailto'], defaultProtocol: 'https' }),
168
+ Link.configure({ defaultProtocol: 'https' }),
181
169
  Youtube,
182
170
  Markdown,
183
171
  ImageUploadExtension(stableUpload),
184
- ];
172
+ ], [stableUpload]);
185
173
  const editor = useEditor({
186
174
  extensions,
187
175
  content,
188
176
  editable,
177
+ autofocus: false,
189
178
  editorProps: {
190
- attributes: { class: 'outline-none min-h-[200px] p-3' },
179
+ attributes: { class: (editable ? 'p-3 min-h-[200px] ' : '') + 'outline-none' },
191
180
  },
192
181
  onUpdate: ({ editor: ed }) => {
193
182
  const markdown = getMarkdown(ed);
package/dist/style.css CHANGED
@@ -8,7 +8,7 @@ dialog::backdrop {
8
8
 
9
9
  /* Tiptap editor content styles */
10
10
  .tiptap {
11
- @apply focus:outline-none min-h-[200px];
11
+ @apply focus:outline-none;
12
12
  }
13
13
  .tiptap h1 {
14
14
  @apply text-4xl font-bold mt-6 mb-3 first:mt-0;
@@ -19,9 +19,6 @@ dialog::backdrop {
19
19
  .tiptap h3 {
20
20
  @apply text-2xl font-semibold mt-4 mb-2 first:mt-0;
21
21
  }
22
- .tiptap p {
23
- @apply mb-2 leading-relaxed;
24
- }
25
22
  .tiptap blockquote {
26
23
  @apply border-l-4 border-primary/30 pl-4 py-1 my-3 text-muted-foreground italic;
27
24
  }
@@ -50,7 +47,7 @@ dialog::backdrop {
50
47
  @apply mb-1;
51
48
  }
52
49
  .tiptap ul {
53
- @apply list-disc pl-4 m-0;
50
+ @apply list-disc list-inside dark:text-white pl-3 [&_p]:inline m-0;
54
51
  }
55
52
  .tiptap ul p {
56
53
  @apply m-0;
@@ -1 +1 @@
1
- {"version":3,"sourceRoot":"","sources":["../src/style.scss"],"names":[],"mappings":"AAAA;EACE;;;AAIF;EACE;;;AAGF;AACA;EACE;;AAEA;EACE;;AAGF;EACE;;AAGF;EACE;;AAGF;EACE;;AAGF;EACE;;AAGF;EACE;;AAGF;EACE;;AAGF;EACE;;AAGF;EACE;;AAGF;EACE;;AAxCJ;AA2CE;;AACA;EACE;;AAGF;EACE;;AAGF;EACE;;AAEA;EACE;;AAGF;EACE;;AAIJ;EACE;;AAEA;EACE;;AAGF;EACE;;AAxEN;AA4EE;;AACA;EACE;;AAEA;AAAA;EAEE;EACA;;AAEA;AAAA;EACE;;AAIJ;AACE;EACA;;AAIJ;EACE;EACA;;AAGF;EACE;EACA","file":"style.css"}
1
+ {"version":3,"sourceRoot":"","sources":["../src/style.scss"],"names":[],"mappings":"AAAA;EACE;;;AAIF;EACE;;;AAGF;AACA;EACE;;AAEA;EACE;;AAGF;EACE;;AAGF;EACE;;AAGF;EACE;;AAGF;EACE;;AAGF;EACE;;AAGF;EACE;;AAGF;EACE;;AAGF;EACE;;AApCJ;AAuCE;;AACA;EACE;;AAGF;EACE;;AAGF;EACE;;AAEA;EACE;;AAGF;EACE;;AAIJ;EACE;;AAEA;EACE;;AAGF;EACE;;AApEN;AAwEE;;AACA;EACE;;AAEA;AAAA;EAEE;EACA;;AAEA;AAAA;EACE;;AAIJ;AACE;EACA;;AAIJ;EACE;EACA;;AAGF;EACE;EACA","file":"style.css"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rimori/react-client",
3
- "version": "0.4.9-next.3",
3
+ "version": "0.4.9-next.4",
4
4
  "license": "Apache-2.0",
5
5
  "repository": {
6
6
  "type": "git",
@@ -1,4 +1,4 @@
1
- import { JSX, useCallback, useEffect, useRef, useState } from 'react';
1
+ import { JSX, useCallback, useEffect, useMemo, useRef, useState } from 'react';
2
2
  import { useRimori } from '../../providers/PluginProvider';
3
3
  import { Markdown } from 'tiptap-markdown';
4
4
  import StarterKit from '@tiptap/starter-kit';
@@ -72,18 +72,14 @@ const EditorButton = ({ editor, action, isActive, label, disabled, title }: Edit
72
72
  );
73
73
  }
74
74
 
75
- // ChainedCommands is not index-typed; cast to call dynamic action names while keeping `.run()`
76
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
77
- const chain = editor.chain().focus() as any;
78
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
79
- const canChain = editor.can().chain().focus() as any;
80
-
81
75
  return (
82
76
  <button
83
77
  type="button"
84
78
  title={title}
85
- onClick={() => (chain[action]() as { run: () => void }).run()}
86
- disabled={disabled ? !(canChain[action]() as { run: () => boolean }).run() : false}
79
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
80
+ onClick={() => (editor.chain().focus() as any)[action]().run()}
81
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
82
+ disabled={disabled ? !(editor.can().chain() as any)[action]().run() : false}
87
83
  className={baseClass}
88
84
  >
89
85
  {label}
@@ -561,35 +557,28 @@ export const MarkdownEditor = ({
561
557
  [storage],
562
558
  );
563
559
 
564
- const extensions = [
565
- StarterKit.configure({
566
- bulletList: {
567
- HTMLAttributes: {
568
- class: 'list-disc list-inside dark:text-white p-1 mt-1 [&_li]:mb-1 [&_p]:inline m-0',
569
- },
570
- },
571
- orderedList: {
572
- HTMLAttributes: {
573
- className: 'list-decimal list-inside dark:text-white p-1 mt-1 [&_li]:mb-1 [&_p]:inline m-0',
574
- },
575
- },
576
- }),
577
- Table.configure({ resizable: false }),
578
- TableRow,
579
- TableHeader,
580
- TableCell,
581
- Link.configure({ protocols: ['mailto'], defaultProtocol: 'https' }),
582
- Youtube,
583
- Markdown,
584
- ImageUploadExtension(stableUpload),
585
- ];
560
+ const extensions = useMemo(
561
+ () => [
562
+ StarterKit,
563
+ Table.configure({ resizable: false }),
564
+ TableRow,
565
+ TableHeader,
566
+ TableCell,
567
+ Link.configure({ defaultProtocol: 'https' }),
568
+ Youtube,
569
+ Markdown,
570
+ ImageUploadExtension(stableUpload),
571
+ ],
572
+ [stableUpload],
573
+ );
586
574
 
587
575
  const editor = useEditor({
588
576
  extensions,
589
577
  content,
590
578
  editable,
579
+ autofocus: false,
591
580
  editorProps: {
592
- attributes: { class: 'outline-none min-h-[200px] p-3' },
581
+ attributes: { class: (editable ? 'p-3 min-h-[200px] ' : '') + 'outline-none' },
593
582
  },
594
583
  onUpdate: ({ editor: ed }) => {
595
584
  const markdown = getMarkdown(ed);
package/src/style.scss CHANGED
@@ -9,7 +9,7 @@ dialog::backdrop {
9
9
 
10
10
  /* Tiptap editor content styles */
11
11
  .tiptap {
12
- @apply focus:outline-none min-h-[200px];
12
+ @apply focus:outline-none;
13
13
 
14
14
  h1 {
15
15
  @apply text-4xl font-bold mt-6 mb-3 first:mt-0;
@@ -23,10 +23,6 @@ dialog::backdrop {
23
23
  @apply text-2xl font-semibold mt-4 mb-2 first:mt-0;
24
24
  }
25
25
 
26
- p {
27
- @apply mb-2 leading-relaxed;
28
- }
29
-
30
26
  blockquote {
31
27
  @apply border-l-4 border-primary/30 pl-4 py-1 my-3 text-muted-foreground italic;
32
28
  }
@@ -61,7 +57,7 @@ dialog::backdrop {
61
57
  }
62
58
 
63
59
  ul {
64
- @apply list-disc pl-4 m-0;
60
+ @apply list-disc list-inside dark:text-white pl-3 [&_p]:inline m-0;
65
61
 
66
62
  p {
67
63
  @apply m-0;