@mhamz.01/easyflow-texteditor 0.1.32 → 0.1.36
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/index.css +24 -24
- package/dist/index.css.map +1 -1
- package/dist/index.d.mts +16 -14
- package/dist/index.d.ts +16 -14
- package/dist/index.js +40 -41
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +40 -41
- package/dist/index.mjs.map +1 -1
- package/package.json +3 -5
package/dist/index.d.mts
CHANGED
|
@@ -25,12 +25,27 @@ interface EditorChangePayload {
|
|
|
25
25
|
source: EditorChangeSource;
|
|
26
26
|
}
|
|
27
27
|
|
|
28
|
+
type TabContent$1 = any | null;
|
|
29
|
+
interface EditorSubTab {
|
|
30
|
+
id: string;
|
|
31
|
+
title: string;
|
|
32
|
+
content: TabContent$1;
|
|
33
|
+
}
|
|
34
|
+
interface EditorTab {
|
|
35
|
+
id: string;
|
|
36
|
+
title: string;
|
|
37
|
+
content: TabContent$1;
|
|
38
|
+
subtabs: EditorSubTab[];
|
|
39
|
+
}
|
|
40
|
+
|
|
28
41
|
interface EditorProps {
|
|
29
42
|
onChange?: (payload: EditorChangePayload) => void;
|
|
43
|
+
initialTabs?: EditorTab[];
|
|
44
|
+
onTabsChange?: (tabs: any[]) => void;
|
|
30
45
|
className?: string;
|
|
31
46
|
style?: React.CSSProperties;
|
|
32
47
|
}
|
|
33
|
-
declare function Editor({ onChange, className, style }: EditorProps): react_jsx_runtime.JSX.Element;
|
|
48
|
+
declare function Editor({ onChange, className, style, onTabsChange, initialTabs }: EditorProps): react_jsx_runtime.JSX.Element;
|
|
34
49
|
|
|
35
50
|
type UserRef<T> = ((instance: T | null) => void) | React.RefObject<T | null> | null | undefined;
|
|
36
51
|
declare const useComposedRef: <T extends HTMLElement>(libRef: React.RefObject<T | null>, userRef: UserRef<T>) => (instance: T | null) => void;
|
|
@@ -251,19 +266,6 @@ declare function useEditorBridge(): EditorBridgeValue;
|
|
|
251
266
|
|
|
252
267
|
declare const GRADIENT_ROWS_70: string[];
|
|
253
268
|
|
|
254
|
-
type TabContent$1 = any | null;
|
|
255
|
-
interface EditorSubTab {
|
|
256
|
-
id: string;
|
|
257
|
-
title: string;
|
|
258
|
-
content: TabContent$1;
|
|
259
|
-
}
|
|
260
|
-
interface EditorTab {
|
|
261
|
-
id: string;
|
|
262
|
-
title: string;
|
|
263
|
-
content: TabContent$1;
|
|
264
|
-
subtabs: EditorSubTab[];
|
|
265
|
-
}
|
|
266
|
-
|
|
267
269
|
type TabContent = any;
|
|
268
270
|
declare function loadTabs(): EditorTab[];
|
|
269
271
|
declare function saveTabs(tabs: EditorTab[]): void;
|
package/dist/index.d.ts
CHANGED
|
@@ -25,12 +25,27 @@ interface EditorChangePayload {
|
|
|
25
25
|
source: EditorChangeSource;
|
|
26
26
|
}
|
|
27
27
|
|
|
28
|
+
type TabContent$1 = any | null;
|
|
29
|
+
interface EditorSubTab {
|
|
30
|
+
id: string;
|
|
31
|
+
title: string;
|
|
32
|
+
content: TabContent$1;
|
|
33
|
+
}
|
|
34
|
+
interface EditorTab {
|
|
35
|
+
id: string;
|
|
36
|
+
title: string;
|
|
37
|
+
content: TabContent$1;
|
|
38
|
+
subtabs: EditorSubTab[];
|
|
39
|
+
}
|
|
40
|
+
|
|
28
41
|
interface EditorProps {
|
|
29
42
|
onChange?: (payload: EditorChangePayload) => void;
|
|
43
|
+
initialTabs?: EditorTab[];
|
|
44
|
+
onTabsChange?: (tabs: any[]) => void;
|
|
30
45
|
className?: string;
|
|
31
46
|
style?: React.CSSProperties;
|
|
32
47
|
}
|
|
33
|
-
declare function Editor({ onChange, className, style }: EditorProps): react_jsx_runtime.JSX.Element;
|
|
48
|
+
declare function Editor({ onChange, className, style, onTabsChange, initialTabs }: EditorProps): react_jsx_runtime.JSX.Element;
|
|
34
49
|
|
|
35
50
|
type UserRef<T> = ((instance: T | null) => void) | React.RefObject<T | null> | null | undefined;
|
|
36
51
|
declare const useComposedRef: <T extends HTMLElement>(libRef: React.RefObject<T | null>, userRef: UserRef<T>) => (instance: T | null) => void;
|
|
@@ -251,19 +266,6 @@ declare function useEditorBridge(): EditorBridgeValue;
|
|
|
251
266
|
|
|
252
267
|
declare const GRADIENT_ROWS_70: string[];
|
|
253
268
|
|
|
254
|
-
type TabContent$1 = any | null;
|
|
255
|
-
interface EditorSubTab {
|
|
256
|
-
id: string;
|
|
257
|
-
title: string;
|
|
258
|
-
content: TabContent$1;
|
|
259
|
-
}
|
|
260
|
-
interface EditorTab {
|
|
261
|
-
id: string;
|
|
262
|
-
title: string;
|
|
263
|
-
content: TabContent$1;
|
|
264
|
-
subtabs: EditorSubTab[];
|
|
265
|
-
}
|
|
266
|
-
|
|
267
269
|
type TabContent = any;
|
|
268
270
|
declare function loadTabs(): EditorTab[];
|
|
269
271
|
declare function saveTabs(tabs: EditorTab[]): void;
|
package/dist/index.js
CHANGED
|
@@ -998,37 +998,9 @@ function useEditorBridge() {
|
|
|
998
998
|
return ctx;
|
|
999
999
|
}
|
|
1000
1000
|
|
|
1001
|
-
// src/lib/editorStorage.ts
|
|
1002
|
-
var STORAGE_KEY = "tiptap-tabs-v1";
|
|
1003
|
-
var ACTIVE_TAB_KEY = "tiptap-active-tab";
|
|
1004
|
-
function loadTabs() {
|
|
1005
|
-
if (typeof window === "undefined") return [];
|
|
1006
|
-
try {
|
|
1007
|
-
const raw = localStorage.getItem("tiptap-tabs-v1");
|
|
1008
|
-
if (!raw) return [];
|
|
1009
|
-
const parsed = JSON.parse(raw);
|
|
1010
|
-
if (!Array.isArray(parsed)) return [];
|
|
1011
|
-
return parsed;
|
|
1012
|
-
} catch {
|
|
1013
|
-
return [];
|
|
1014
|
-
}
|
|
1015
|
-
}
|
|
1016
|
-
function saveTabs(tabs) {
|
|
1017
|
-
if (typeof window === "undefined") return;
|
|
1018
|
-
localStorage.setItem(STORAGE_KEY, JSON.stringify(tabs));
|
|
1019
|
-
}
|
|
1020
|
-
function loadActiveTab() {
|
|
1021
|
-
if (typeof window === "undefined") return "1";
|
|
1022
|
-
return localStorage.getItem(ACTIVE_TAB_KEY) ?? "1";
|
|
1023
|
-
}
|
|
1024
|
-
function saveActiveTab(id) {
|
|
1025
|
-
if (typeof window === "undefined") return;
|
|
1026
|
-
localStorage.setItem(ACTIVE_TAB_KEY, id);
|
|
1027
|
-
}
|
|
1028
|
-
|
|
1029
1001
|
// src/components/editorLayout/editorLayout.tsx
|
|
1030
1002
|
var import_jsx_runtime11 = require("react/jsx-runtime");
|
|
1031
|
-
function EditorLayout({ children, onChange }) {
|
|
1003
|
+
function EditorLayout({ children, onChange, initialTabs, onTabsChange }) {
|
|
1032
1004
|
const [editor, setEditor] = (0, import_react3.useState)(null);
|
|
1033
1005
|
const [tabs, setTabs] = (0, import_react3.useState)([]);
|
|
1034
1006
|
const [activeTabId, setActiveTabId] = (0, import_react3.useState)("");
|
|
@@ -1062,18 +1034,17 @@ function EditorLayout({ children, onChange }) {
|
|
|
1062
1034
|
[emitChangeDebounced, tabs, activeTabId, activeSubTabId]
|
|
1063
1035
|
);
|
|
1064
1036
|
(0, import_react3.useEffect)(() => {
|
|
1065
|
-
|
|
1066
|
-
if (initialTabs.length === 0) {
|
|
1037
|
+
if (initialTabs?.length === 0) {
|
|
1067
1038
|
setTabs([{ id: "1", title: "Tab 1", content: null, subtabs: [] }]);
|
|
1068
1039
|
setActiveTabId("1");
|
|
1069
1040
|
} else {
|
|
1070
|
-
setTabs(initialTabs);
|
|
1071
|
-
setActiveTabId(initialTabs[0]
|
|
1041
|
+
setTabs(initialTabs ?? []);
|
|
1042
|
+
setActiveTabId(initialTabs?.[0]?.id ?? "");
|
|
1072
1043
|
}
|
|
1073
|
-
}, []);
|
|
1044
|
+
}, [initialTabs]);
|
|
1074
1045
|
(0, import_react3.useEffect)(() => {
|
|
1075
|
-
|
|
1076
|
-
}, [tabs]);
|
|
1046
|
+
onTabsChange?.(tabs);
|
|
1047
|
+
}, [tabs, onTabsChange]);
|
|
1077
1048
|
const saveCurrentContent = (0, import_react3.useCallback)(() => {
|
|
1078
1049
|
if (!editor) return tabs;
|
|
1079
1050
|
const json = editor.getJSON();
|
|
@@ -1318,7 +1289,7 @@ var import_extension_superscript = require("@tiptap/extension-superscript");
|
|
|
1318
1289
|
var import_extensions = require("@tiptap/extensions");
|
|
1319
1290
|
var import_extension_text_style = require("@tiptap/extension-text-style");
|
|
1320
1291
|
|
|
1321
|
-
//
|
|
1292
|
+
// node_modules/@tiptap/extension-document/dist/index.js
|
|
1322
1293
|
var import_core = require("@tiptap/core");
|
|
1323
1294
|
var Document = import_core.Node.create({
|
|
1324
1295
|
name: "doc",
|
|
@@ -1333,7 +1304,7 @@ var Document = import_core.Node.create({
|
|
|
1333
1304
|
});
|
|
1334
1305
|
var index_default = Document;
|
|
1335
1306
|
|
|
1336
|
-
//
|
|
1307
|
+
// node_modules/@tiptap/extension-paragraph/dist/index.js
|
|
1337
1308
|
var import_core2 = require("@tiptap/core");
|
|
1338
1309
|
var Paragraph = import_core2.Node.create({
|
|
1339
1310
|
name: "paragraph",
|
|
@@ -1384,7 +1355,7 @@ var Paragraph = import_core2.Node.create({
|
|
|
1384
1355
|
});
|
|
1385
1356
|
var index_default2 = Paragraph;
|
|
1386
1357
|
|
|
1387
|
-
//
|
|
1358
|
+
// node_modules/@tiptap/extension-text/dist/index.js
|
|
1388
1359
|
var import_core3 = require("@tiptap/core");
|
|
1389
1360
|
var Text = import_core3.Node.create({
|
|
1390
1361
|
name: "text",
|
|
@@ -7781,8 +7752,8 @@ function SimpleEditor() {
|
|
|
7781
7752
|
|
|
7782
7753
|
// src/components/editor/editor.tsx
|
|
7783
7754
|
var import_jsx_runtime77 = require("react/jsx-runtime");
|
|
7784
|
-
function Editor({ onChange, className, style }) {
|
|
7785
|
-
return /* @__PURE__ */ (0, import_jsx_runtime77.jsx)("div", { className, style, children: /* @__PURE__ */ (0, import_jsx_runtime77.jsx)(EditorShell, { children: /* @__PURE__ */ (0, import_jsx_runtime77.jsx)(EditorLayout, { onChange, children: /* @__PURE__ */ (0, import_jsx_runtime77.jsx)(SimpleEditor, {}) }) }) });
|
|
7755
|
+
function Editor({ onChange, className, style, onTabsChange, initialTabs }) {
|
|
7756
|
+
return /* @__PURE__ */ (0, import_jsx_runtime77.jsx)("div", { className, style, children: /* @__PURE__ */ (0, import_jsx_runtime77.jsx)(EditorShell, { children: /* @__PURE__ */ (0, import_jsx_runtime77.jsx)(EditorLayout, { onChange, initialTabs, onTabsChange, children: /* @__PURE__ */ (0, import_jsx_runtime77.jsx)(SimpleEditor, {}) }) }) });
|
|
7786
7757
|
}
|
|
7787
7758
|
|
|
7788
7759
|
// src/hooks/use-scrolling.ts
|
|
@@ -7820,6 +7791,34 @@ function useScrolling(target, options = {}) {
|
|
|
7820
7791
|
return isScrolling;
|
|
7821
7792
|
}
|
|
7822
7793
|
|
|
7794
|
+
// src/lib/editorStorage.ts
|
|
7795
|
+
var STORAGE_KEY = "tiptap-tabs-v1";
|
|
7796
|
+
var ACTIVE_TAB_KEY = "tiptap-active-tab";
|
|
7797
|
+
function loadTabs() {
|
|
7798
|
+
if (typeof window === "undefined") return [];
|
|
7799
|
+
try {
|
|
7800
|
+
const raw = localStorage.getItem("tiptap-tabs-v1");
|
|
7801
|
+
if (!raw) return [];
|
|
7802
|
+
const parsed = JSON.parse(raw);
|
|
7803
|
+
if (!Array.isArray(parsed)) return [];
|
|
7804
|
+
return parsed;
|
|
7805
|
+
} catch {
|
|
7806
|
+
return [];
|
|
7807
|
+
}
|
|
7808
|
+
}
|
|
7809
|
+
function saveTabs(tabs) {
|
|
7810
|
+
if (typeof window === "undefined") return;
|
|
7811
|
+
localStorage.setItem(STORAGE_KEY, JSON.stringify(tabs));
|
|
7812
|
+
}
|
|
7813
|
+
function loadActiveTab() {
|
|
7814
|
+
if (typeof window === "undefined") return "1";
|
|
7815
|
+
return localStorage.getItem(ACTIVE_TAB_KEY) ?? "1";
|
|
7816
|
+
}
|
|
7817
|
+
function saveActiveTab(id) {
|
|
7818
|
+
if (typeof window === "undefined") return;
|
|
7819
|
+
localStorage.setItem(ACTIVE_TAB_KEY, id);
|
|
7820
|
+
}
|
|
7821
|
+
|
|
7823
7822
|
// src/lib/local-image.ts
|
|
7824
7823
|
function fileToBase64(file) {
|
|
7825
7824
|
return new Promise((resolve, reject) => {
|