@rolder/kit 3.0.0-alpha.78 → 3.0.0-alpha.79
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/ui/editor/Root.d.ts +7 -1
- package/dist/ui/editor/Root.js +42 -5
- package/dist/ui/editor/Toolbar.js +3 -3
- package/dist/ui/editor/index.d.ts +2 -3
- package/dist/ui/editor/index.js +3 -4
- package/dist/ui/editor/store.d.ts +6 -0
- package/dist/ui/editor/store.js +10 -0
- package/package.json +5 -5
- package/dist/ui/editor/Provider.d.ts +0 -17
- package/dist/ui/editor/Provider.js +0 -80
- package/dist/ui/editor/types.d.ts +0 -7
- package/dist/ui/editor/types.js +0 -0
package/dist/ui/editor/Root.d.ts
CHANGED
|
@@ -1,2 +1,8 @@
|
|
|
1
1
|
import { type RichTextEditorProps } from '@mantine/tiptap';
|
|
2
|
-
|
|
2
|
+
import { type EditorOptions } from '@tiptap/react';
|
|
3
|
+
export interface EditorProps extends RichTextEditorProps {
|
|
4
|
+
editable?: boolean;
|
|
5
|
+
disabledToolbar?: boolean;
|
|
6
|
+
onUpdate: EditorOptions['onUpdate'];
|
|
7
|
+
}
|
|
8
|
+
export declare const Root: ({ children, classNames, content, editable, disabledToolbar, onUpdate, editor: customEditor, ...props }: EditorProps) => import("react/jsx-runtime").JSX.Element;
|
package/dist/ui/editor/Root.js
CHANGED
|
@@ -1,10 +1,47 @@
|
|
|
1
1
|
import { jsx } from "react/jsx-runtime";
|
|
2
|
-
import { RichTextEditor } from "@mantine/tiptap";
|
|
3
|
-
import
|
|
4
|
-
|
|
5
|
-
|
|
2
|
+
import { Link, RichTextEditor, getTaskListExtension } from "@mantine/tiptap";
|
|
3
|
+
import extension_highlight from "@tiptap/extension-highlight";
|
|
4
|
+
import extension_placeholder from "@tiptap/extension-placeholder";
|
|
5
|
+
import { TableKit } from "@tiptap/extension-table";
|
|
6
|
+
import extension_task_item from "@tiptap/extension-task-item";
|
|
7
|
+
import extension_task_list from "@tiptap/extension-task-list";
|
|
8
|
+
import extension_text_align from "@tiptap/extension-text-align";
|
|
9
|
+
import { useEditor } from "@tiptap/react";
|
|
10
|
+
import starter_kit from "@tiptap/starter-kit";
|
|
11
|
+
import { useEffect } from "react";
|
|
12
|
+
import { setDisabledToolbar } from "./store.js";
|
|
13
|
+
const Root = ({ children, classNames, content, editable = true, disabledToolbar, onUpdate, editor: customEditor, ...props })=>{
|
|
14
|
+
useEffect(()=>setDisabledToolbar(disabledToolbar || false));
|
|
15
|
+
const editor = useEditor({
|
|
16
|
+
shouldRerenderOnTransaction: false,
|
|
17
|
+
immediatelyRender: false,
|
|
18
|
+
extensions: [
|
|
19
|
+
starter_kit.configure({
|
|
20
|
+
link: false
|
|
21
|
+
}),
|
|
22
|
+
extension_placeholder.configure({
|
|
23
|
+
placeholder: 'Документ пуст'
|
|
24
|
+
}),
|
|
25
|
+
Link,
|
|
26
|
+
extension_highlight,
|
|
27
|
+
extension_text_align.configure({
|
|
28
|
+
types: [
|
|
29
|
+
'heading',
|
|
30
|
+
'paragraph'
|
|
31
|
+
]
|
|
32
|
+
}),
|
|
33
|
+
getTaskListExtension(extension_task_list),
|
|
34
|
+
extension_task_item.configure({
|
|
35
|
+
nested: true
|
|
36
|
+
}),
|
|
37
|
+
TableKit
|
|
38
|
+
],
|
|
39
|
+
content,
|
|
40
|
+
onUpdate,
|
|
41
|
+
editable
|
|
42
|
+
});
|
|
6
43
|
return /*#__PURE__*/ jsx(RichTextEditor, {
|
|
7
|
-
editor: editor,
|
|
44
|
+
editor: customEditor || editor,
|
|
8
45
|
classNames: {
|
|
9
46
|
root: 'rolder-editor-root',
|
|
10
47
|
content: 'rolder-editor-content',
|
|
@@ -2,10 +2,10 @@ import { jsx, jsxs } from "react/jsx-runtime";
|
|
|
2
2
|
import { Loader } from "@mantine/core";
|
|
3
3
|
import { RichTextEditor } from "@mantine/tiptap";
|
|
4
4
|
import { IconCheck } from "@tabler/icons-react";
|
|
5
|
-
import { useEditor } from "./
|
|
5
|
+
import { getDisabledToolbar, useEditor } from "./store.js";
|
|
6
6
|
const Toolbar = ({ saving, children })=>{
|
|
7
|
-
const
|
|
8
|
-
return
|
|
7
|
+
const editor = useEditor();
|
|
8
|
+
return getDisabledToolbar() ? null : /*#__PURE__*/ jsxs(RichTextEditor.Toolbar, {
|
|
9
9
|
sticky: true,
|
|
10
10
|
children: [
|
|
11
11
|
/*#__PURE__*/ jsxs(RichTextEditor.ControlsGroup, {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export declare const Editor: {
|
|
2
|
-
Root: ({ children, classNames, ...props }:
|
|
2
|
+
Root: ({ children, classNames, content, editable, disabledToolbar, onUpdate, editor: customEditor, ...props }: import("./Root").EditorProps) => import("react/jsx-runtime").JSX.Element;
|
|
3
3
|
Content: ({ height }: {
|
|
4
4
|
height: string;
|
|
5
5
|
}) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -7,6 +7,5 @@ export declare const Editor: {
|
|
|
7
7
|
saving?: boolean;
|
|
8
8
|
children?: import("react").ReactNode;
|
|
9
9
|
}) => import("react/jsx-runtime").JSX.Element | null;
|
|
10
|
-
Provider: ({ children, initialContent, initialEditable, initialDisabledToolbar, onChange, }: import("./types").EditorProps) => import("react/jsx-runtime").JSX.Element;
|
|
11
10
|
};
|
|
12
|
-
export
|
|
11
|
+
export * from './store';
|
package/dist/ui/editor/index.js
CHANGED
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
import { Content } from "./Content.js";
|
|
2
|
-
import { Provider, useEditor } from "./Provider.js";
|
|
3
2
|
import { Root } from "./Root.js";
|
|
4
3
|
import { Toolbar } from "./Toolbar.js";
|
|
4
|
+
export * from "./store.js";
|
|
5
5
|
const Editor = {
|
|
6
6
|
Root: Root,
|
|
7
7
|
Content: Content,
|
|
8
|
-
Toolbar: Toolbar
|
|
9
|
-
Provider: Provider
|
|
8
|
+
Toolbar: Toolbar
|
|
10
9
|
};
|
|
11
|
-
export { Editor
|
|
10
|
+
export { Editor };
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { Editor } from '@tiptap/react';
|
|
2
|
+
export declare const getEditor: () => Editor | null;
|
|
3
|
+
export declare const useEditor: () => Editor | null;
|
|
4
|
+
export declare const setEditor: (editor: Editor) => void;
|
|
5
|
+
export declare const getDisabledToolbar: () => boolean;
|
|
6
|
+
export declare const setDisabledToolbar: (disabled: boolean) => void;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { useStore } from "@nanostores/react";
|
|
2
|
+
import { atom } from "nanostores";
|
|
3
|
+
const $editor = atom(null);
|
|
4
|
+
const getEditor = ()=>$editor.get();
|
|
5
|
+
const useEditor = ()=>useStore($editor);
|
|
6
|
+
const setEditor = (editor)=>$editor.set(editor);
|
|
7
|
+
const $disabledToolbar = atom(false);
|
|
8
|
+
const getDisabledToolbar = ()=>$disabledToolbar.get();
|
|
9
|
+
const setDisabledToolbar = (disabled)=>$disabledToolbar.set(disabled);
|
|
10
|
+
export { getDisabledToolbar, getEditor, setDisabledToolbar, setEditor, useEditor };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rolder/kit",
|
|
3
|
-
"version": "3.0.0-alpha.
|
|
3
|
+
"version": "3.0.0-alpha.79",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"exports": {
|
|
6
6
|
".": {
|
|
@@ -42,9 +42,9 @@
|
|
|
42
42
|
"@nanostores/react": "^1.0.0",
|
|
43
43
|
"@tanstack/react-form": "^1.27.7",
|
|
44
44
|
"@tanstack/react-query": "^5.90.19",
|
|
45
|
-
"@tanstack/react-router": "^1.151.
|
|
46
|
-
"@tanstack/react-router-ssr-query": "^1.151.
|
|
47
|
-
"@tanstack/react-start": "^1.151.
|
|
45
|
+
"@tanstack/react-router": "^1.151.2",
|
|
46
|
+
"@tanstack/react-router-ssr-query": "^1.151.2",
|
|
47
|
+
"@tanstack/react-start": "^1.151.2",
|
|
48
48
|
"@tiptap/extension-highlight": "^3.15.3",
|
|
49
49
|
"@tiptap/extension-placeholder": "^3.15.3",
|
|
50
50
|
"@tiptap/extension-table": "^3.15.3",
|
|
@@ -65,7 +65,7 @@
|
|
|
65
65
|
"react": "^19.2.3",
|
|
66
66
|
"react-dom": "^19.2.3",
|
|
67
67
|
"streamdown": "^2.0.1",
|
|
68
|
-
"surrealdb": "
|
|
68
|
+
"surrealdb": "2.0.0-alpha.16",
|
|
69
69
|
"xlsx": "^0.18.5",
|
|
70
70
|
"zod": "^4.3.5"
|
|
71
71
|
},
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import type { Editor } from '@tiptap/react';
|
|
2
|
-
import type { EditorProps } from './types';
|
|
3
|
-
interface EditorContext {
|
|
4
|
-
editor: Editor | null;
|
|
5
|
-
editable?: boolean;
|
|
6
|
-
setEditable: (value: boolean) => void;
|
|
7
|
-
disabledToolbar: boolean;
|
|
8
|
-
setDisabledToolbar: (value: boolean) => void;
|
|
9
|
-
focused: boolean;
|
|
10
|
-
setFocused: (value: boolean) => void;
|
|
11
|
-
editedByUser: boolean;
|
|
12
|
-
setEditedByUser: (value: boolean) => void;
|
|
13
|
-
}
|
|
14
|
-
declare const EditorContext: import("react").Context<EditorContext | null>;
|
|
15
|
-
export declare const Provider: ({ children, initialContent, initialEditable, initialDisabledToolbar, onChange, }: EditorProps) => import("react/jsx-runtime").JSX.Element;
|
|
16
|
-
export declare const useEditor: () => EditorContext;
|
|
17
|
-
export {};
|
|
@@ -1,80 +0,0 @@
|
|
|
1
|
-
import { jsx } from "react/jsx-runtime";
|
|
2
|
-
import { Link, getTaskListExtension } from "@mantine/tiptap";
|
|
3
|
-
import extension_highlight from "@tiptap/extension-highlight";
|
|
4
|
-
import extension_placeholder from "@tiptap/extension-placeholder";
|
|
5
|
-
import { TableKit } from "@tiptap/extension-table";
|
|
6
|
-
import extension_task_item from "@tiptap/extension-task-item";
|
|
7
|
-
import extension_task_list from "@tiptap/extension-task-list";
|
|
8
|
-
import extension_text_align from "@tiptap/extension-text-align";
|
|
9
|
-
import { useEditor } from "@tiptap/react";
|
|
10
|
-
import starter_kit from "@tiptap/starter-kit";
|
|
11
|
-
import { createContext, useContext, useEffect, useState } from "react";
|
|
12
|
-
const EditorContext = /*#__PURE__*/ createContext(null);
|
|
13
|
-
const Provider = ({ children, initialContent, initialEditable = true, initialDisabledToolbar, onChange })=>{
|
|
14
|
-
const editor = useEditor({
|
|
15
|
-
shouldRerenderOnTransaction: false,
|
|
16
|
-
immediatelyRender: false,
|
|
17
|
-
extensions: [
|
|
18
|
-
starter_kit.configure({
|
|
19
|
-
link: false
|
|
20
|
-
}),
|
|
21
|
-
extension_placeholder.configure({
|
|
22
|
-
placeholder: 'Документ пуст'
|
|
23
|
-
}),
|
|
24
|
-
Link,
|
|
25
|
-
extension_highlight,
|
|
26
|
-
extension_text_align.configure({
|
|
27
|
-
types: [
|
|
28
|
-
'heading',
|
|
29
|
-
'paragraph'
|
|
30
|
-
]
|
|
31
|
-
}),
|
|
32
|
-
getTaskListExtension(extension_task_list),
|
|
33
|
-
extension_task_item.configure({
|
|
34
|
-
nested: true
|
|
35
|
-
}),
|
|
36
|
-
TableKit
|
|
37
|
-
],
|
|
38
|
-
content: initialContent,
|
|
39
|
-
onUpdate: ({ editor })=>{
|
|
40
|
-
onChange?.(editor.getHTML());
|
|
41
|
-
},
|
|
42
|
-
editable: initialEditable
|
|
43
|
-
});
|
|
44
|
-
const [editable, setEditable] = useState(initialEditable);
|
|
45
|
-
const [disabledToolbar, setDisabledToolbar] = useState(!!initialDisabledToolbar);
|
|
46
|
-
const [editedByUser, setEditedByUser] = useState(true);
|
|
47
|
-
const [focused, setFocused] = useState(false);
|
|
48
|
-
useEffect(()=>{
|
|
49
|
-
editor?.on('focus', ()=>setFocused(true));
|
|
50
|
-
editor?.on('blur', ()=>setFocused(false));
|
|
51
|
-
editor?.on('update', ({ transaction })=>{
|
|
52
|
-
if (transaction.docChanged && focused) setEditedByUser(true);
|
|
53
|
-
if (transaction.docChanged && !focused) setEditedByUser(false);
|
|
54
|
-
});
|
|
55
|
-
}, [
|
|
56
|
-
editor,
|
|
57
|
-
focused
|
|
58
|
-
]);
|
|
59
|
-
const value = {
|
|
60
|
-
editor,
|
|
61
|
-
editable,
|
|
62
|
-
setEditable,
|
|
63
|
-
disabledToolbar,
|
|
64
|
-
setDisabledToolbar,
|
|
65
|
-
editedByUser,
|
|
66
|
-
setEditedByUser,
|
|
67
|
-
focused,
|
|
68
|
-
setFocused
|
|
69
|
-
};
|
|
70
|
-
return /*#__PURE__*/ jsx(EditorContext.Provider, {
|
|
71
|
-
value: value,
|
|
72
|
-
children: children
|
|
73
|
-
});
|
|
74
|
-
};
|
|
75
|
-
const Provider_useEditor = ()=>{
|
|
76
|
-
const context = useContext(EditorContext);
|
|
77
|
-
if (!context) throw new Error('useEditor must be used within EditorProvider');
|
|
78
|
-
return context;
|
|
79
|
-
};
|
|
80
|
-
export { Provider, Provider_useEditor as useEditor };
|
package/dist/ui/editor/types.js
DELETED
|
File without changes
|