@cyberyozh/text-editor 0.1.4 → 0.1.5
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/editor.css +8 -0
- package/dist/editor.css.map +1 -1
- package/dist/editor.d.mts +5 -0
- package/dist/editor.d.ts +5 -0
- package/dist/editor.js +8 -7
- package/dist/editor.js.map +1 -1
- package/dist/editor.mjs +8 -7
- package/dist/editor.mjs.map +1 -1
- package/dist/styles/index.css +8 -0
- package/package.json +1 -5
- package/src/editor/editor.tsx +23 -15
- package/src/styles/editor/states.css +11 -0
package/dist/styles/index.css
CHANGED
|
@@ -1889,6 +1889,14 @@
|
|
|
1889
1889
|
outline: none;
|
|
1890
1890
|
background-color: transparent;
|
|
1891
1891
|
}
|
|
1892
|
+
.tiptap-content-wrapper.is-disabled {
|
|
1893
|
+
opacity: 0.6;
|
|
1894
|
+
cursor: not-allowed;
|
|
1895
|
+
pointer-events: none;
|
|
1896
|
+
}
|
|
1897
|
+
.tiptap-content-wrapper.is-disabled .ProseMirror {
|
|
1898
|
+
background-color: var(--tiptap-color-grey-1, #f5f5f5);
|
|
1899
|
+
}
|
|
1892
1900
|
|
|
1893
1901
|
/* src/styles/editor/callout-menu.css */
|
|
1894
1902
|
.tiptap__drag-handle-color-menu {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cyberyozh/text-editor",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.5",
|
|
4
4
|
"description": "Rich text editor library based on Tiptap for CyberYozh",
|
|
5
5
|
"author": "CyberYozh",
|
|
6
6
|
"license": "MIT",
|
|
@@ -42,10 +42,6 @@
|
|
|
42
42
|
"release": "npm run build && changeset publish",
|
|
43
43
|
"release:complete": "git add . && git commit -m \"chore: release v$(node -p \"require('./package.json').version\")\" && npm run release && git push --follow-tags"
|
|
44
44
|
},
|
|
45
|
-
"peerDependencies": {
|
|
46
|
-
"react": "^18.0.0 || ^19.0.0",
|
|
47
|
-
"react-dom": "^18.0.0 || ^19.0.0"
|
|
48
|
-
},
|
|
49
45
|
"dependencies": {
|
|
50
46
|
"@floating-ui/dom": "^1.7.4",
|
|
51
47
|
"@tiptap/core": "^3.10.6",
|
package/src/editor/editor.tsx
CHANGED
|
@@ -39,6 +39,11 @@ import { getTranslations, type SupportedLanguage } from "../utils/get-translatio
|
|
|
39
39
|
|
|
40
40
|
interface TiptapProps {
|
|
41
41
|
isEditable?: boolean;
|
|
42
|
+
/**
|
|
43
|
+
* When true, makes the editor completely disabled (non-editable with disabled styling)
|
|
44
|
+
* @default false
|
|
45
|
+
*/
|
|
46
|
+
isDisabled?: boolean;
|
|
42
47
|
content: string;
|
|
43
48
|
handleChange?: (value: JSONContent) => void;
|
|
44
49
|
/**
|
|
@@ -70,6 +75,7 @@ function TiptapContent({
|
|
|
70
75
|
handleChange,
|
|
71
76
|
imageHandlers,
|
|
72
77
|
isEditable = true,
|
|
78
|
+
isDisabled = false,
|
|
73
79
|
lang,
|
|
74
80
|
error,
|
|
75
81
|
}: TiptapProps) {
|
|
@@ -94,11 +100,11 @@ function TiptapContent({
|
|
|
94
100
|
|
|
95
101
|
const editor = useEditor(
|
|
96
102
|
{
|
|
97
|
-
editable: isEditable,
|
|
103
|
+
editable: isEditable && !isDisabled,
|
|
98
104
|
extensions: getEditorExtensions({
|
|
99
105
|
translations,
|
|
100
106
|
suggestion: createSuggestions(translations, !!imageHandlers),
|
|
101
|
-
isEditable,
|
|
107
|
+
isEditable: isEditable && !isDisabled,
|
|
102
108
|
getImageById: imageHandlers?.getImage,
|
|
103
109
|
onKatexClick: (latex, pos) => {
|
|
104
110
|
setKatexDialogContext({ latex, pos });
|
|
@@ -171,22 +177,24 @@ function TiptapContent({
|
|
|
171
177
|
|
|
172
178
|
return (
|
|
173
179
|
<>
|
|
174
|
-
<DragHandle editor={editor} />
|
|
175
|
-
{isEditable && <TableMenu editor={editor} />}
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
options={{ placement: "bottom", offset: 8, flip: true }}
|
|
180
|
-
>
|
|
181
|
-
<BubbleMenuContent
|
|
180
|
+
{!isDisabled && <DragHandle editor={editor} />}
|
|
181
|
+
{isEditable && !isDisabled && <TableMenu editor={editor} />}
|
|
182
|
+
{!isDisabled && (
|
|
183
|
+
<BubbleMenu
|
|
184
|
+
shouldShow={shouldBubbleMenuShow}
|
|
182
185
|
editor={editor}
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
+
options={{ placement: "bottom", offset: 8, flip: true }}
|
|
187
|
+
>
|
|
188
|
+
<BubbleMenuContent
|
|
189
|
+
editor={editor}
|
|
190
|
+
onLinkClick={(selectedText, url) => setLinkDialogContext({ selectedText, url })}
|
|
191
|
+
/>
|
|
192
|
+
</BubbleMenu>
|
|
193
|
+
)}
|
|
186
194
|
|
|
187
|
-
<div className={`tiptap-content-wrapper ${!!error ? "has-error" : ""}`}>
|
|
195
|
+
<div className={`tiptap-content-wrapper ${!!error ? "has-error" : ""} ${isDisabled ? "is-disabled" : ""}`}>
|
|
188
196
|
<EditorContent editor={editor} />
|
|
189
|
-
{isEditable && <CharacterCountComponent editor={editor} />}
|
|
197
|
+
{isEditable && !isDisabled && <CharacterCountComponent editor={editor} />}
|
|
190
198
|
</div>
|
|
191
199
|
{!!error && <p className="tiptap-error-message">{error}</p>}
|
|
192
200
|
|
|
@@ -41,3 +41,14 @@
|
|
|
41
41
|
outline: none;
|
|
42
42
|
background-color: transparent;
|
|
43
43
|
}
|
|
44
|
+
|
|
45
|
+
/* Disabled state styles */
|
|
46
|
+
.tiptap-content-wrapper.is-disabled {
|
|
47
|
+
opacity: 0.6;
|
|
48
|
+
cursor: not-allowed;
|
|
49
|
+
pointer-events: none;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
.tiptap-content-wrapper.is-disabled .ProseMirror {
|
|
53
|
+
background-color: var(--tiptap-color-grey-1, #f5f5f5);
|
|
54
|
+
}
|