@mhamz.01/easyflow-texteditor 0.1.32 → 0.1.33

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.d.mts CHANGED
@@ -27,10 +27,11 @@ interface EditorChangePayload {
27
27
 
28
28
  interface EditorProps {
29
29
  onChange?: (payload: EditorChangePayload) => void;
30
+ onTabsChange?: (tabs: any[]) => void;
30
31
  className?: string;
31
32
  style?: React.CSSProperties;
32
33
  }
33
- declare function Editor({ onChange, className, style }: EditorProps): react_jsx_runtime.JSX.Element;
34
+ declare function Editor({ onChange, className, style, onTabsChange }: EditorProps): react_jsx_runtime.JSX.Element;
34
35
 
35
36
  type UserRef<T> = ((instance: T | null) => void) | React.RefObject<T | null> | null | undefined;
36
37
  declare const useComposedRef: <T extends HTMLElement>(libRef: React.RefObject<T | null>, userRef: UserRef<T>) => (instance: T | null) => void;
package/dist/index.d.ts CHANGED
@@ -27,10 +27,11 @@ interface EditorChangePayload {
27
27
 
28
28
  interface EditorProps {
29
29
  onChange?: (payload: EditorChangePayload) => void;
30
+ onTabsChange?: (tabs: any[]) => void;
30
31
  className?: string;
31
32
  style?: React.CSSProperties;
32
33
  }
33
- declare function Editor({ onChange, className, style }: EditorProps): react_jsx_runtime.JSX.Element;
34
+ declare function Editor({ onChange, className, style, onTabsChange }: EditorProps): react_jsx_runtime.JSX.Element;
34
35
 
35
36
  type UserRef<T> = ((instance: T | null) => void) | React.RefObject<T | null> | null | undefined;
36
37
  declare const useComposedRef: <T extends HTMLElement>(libRef: React.RefObject<T | null>, userRef: UserRef<T>) => (instance: T | null) => 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
- const initialTabs = loadTabs();
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].id);
1041
+ setTabs(initialTabs ?? []);
1042
+ setActiveTabId(initialTabs?.[0]?.id ?? "");
1072
1043
  }
1073
- }, []);
1044
+ }, [initialTabs]);
1074
1045
  (0, import_react3.useEffect)(() => {
1075
- saveTabs(tabs);
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
- // ../node_modules/@tiptap/extension-document/dist/index.js
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
- // ../node_modules/@tiptap/extension-paragraph/dist/index.js
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
- // ../node_modules/@tiptap/extension-text/dist/index.js
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 }) {
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, 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) => {