alinea 2.0.0-preview.0 → 2.0.0-preview.2
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/.init/content/pages/welcome.json +1 -1
- package/dist/LICENSES.md +134 -80
- package/dist/adapter/next/DevRemote.d.ts +3 -0
- package/dist/adapter/next/DevRemote.js +37 -0
- package/dist/adapter/next/ForwardCredentials.d.ts +1 -0
- package/dist/adapter/next/ForwardCredentials.js +17 -0
- package/dist/adapter/next/cms.js +86 -38
- package/dist/adapter/next/context.d.ts +1 -1
- package/dist/adapter/next/context.js +11 -3
- package/dist/adapter/next/handler.d.ts +2 -0
- package/dist/adapter/next/handler.js +23 -16
- package/dist/adapter/next/with-alinea.js +18 -16
- package/dist/backend/Handler.d.ts +14 -13
- package/dist/backend/Handler.js +70 -36
- package/dist/backend/resolver/ParsePreview.d.ts +8 -4
- package/dist/backend/resolver/ParsePreview.js +40 -43
- package/dist/backend/router/Router.d.ts +1 -0
- package/dist/backend/router/Router.js +21 -15
- package/dist/bundled.d.ts +369 -99
- package/dist/chunks/chunk-6UT4N4CO.js +919 -0
- package/dist/chunks/{chunk-LUBOGJCG.js → chunk-6V4TAD2N.js} +1 -1
- package/dist/chunks/{chunk-TL7ZW6BX.js → chunk-A3XXZBOQ.js} +2535 -2999
- package/dist/chunks/chunk-AC5ATYI3.js +1434 -0
- package/dist/chunks/{chunk-7ORQ7BYK.js → chunk-KMLLLZ6X.js} +202 -269
- package/dist/chunks/{chunk-IWN3T3FL.js → chunk-O7XWTMCB.js} +1 -1
- package/dist/chunks/{chunk-53DZYORR.js → chunk-PAYSVIYI.js} +76 -176
- package/dist/chunks/{chunk-YK3OSMDM.js → chunk-S4AU6SRS.js} +188 -158
- package/dist/chunks/{chunk-EQ3TDHYD.js → chunk-UVOEM4AH.js} +6 -3
- package/dist/chunks/{chunk-I7X64JTZ.js → chunk-VXZM6V4P.js} +4 -4
- package/dist/cli/Generate.js +3 -13
- package/dist/cli/Serve.js +7 -3
- package/dist/cli/bin.js +8 -5
- package/dist/cli/generate/CompileConfig.js +3 -2
- package/dist/cli/generate/CopyStaticFiles.js +2 -3
- package/dist/cli/generate/DevDB.d.ts +1 -1
- package/dist/cli/generate/DevDB.js +3 -5
- package/dist/cli/serve/CreateLocalServer.d.ts +1 -1
- package/dist/cli/serve/CreateLocalServer.js +3 -2
- package/dist/cli/serve/DevServer.d.ts +3 -2
- package/dist/cli/serve/DevServer.js +60 -3
- package/dist/cli/serve/ServeContext.d.ts +1 -0
- package/dist/cli/serve/StartServer.d.ts +1 -0
- package/dist/cli/serve/StartServer.js +6 -1
- package/dist/cli/util/EnsureLibs.js +2 -2
- package/dist/cli/util/EnsureNode.js +2 -2
- package/dist/cloud/CloudRemote.d.ts +2 -1
- package/dist/cloud/CloudRemote.js +3 -2
- package/dist/components/Breadcrumbs.js +8 -8
- package/dist/components/Button.js +6 -6
- package/dist/components/Calendar.js +11 -11
- package/dist/components/Checkbox.js +7 -7
- package/dist/components/CheckboxGroup.js +6 -6
- package/dist/components/ColorSwatch.js +6 -6
- package/dist/components/ColorSwatchPicker.js +6 -6
- package/dist/components/ComboBox.js +17 -17
- package/dist/components/DateField.js +9 -9
- package/dist/components/DatePicker.js +10 -10
- package/dist/components/DateRangePicker.js +14 -14
- package/dist/components/Dialog.js +6 -6
- package/dist/components/Disclosure.js +13 -13
- package/dist/components/DropZone.js +6 -6
- package/dist/components/Label.js +16 -16
- package/dist/components/Link.js +6 -6
- package/dist/components/List.js +34 -34
- package/dist/components/Menu.js +10 -10
- package/dist/components/Modal.js +8 -8
- package/dist/components/MultipleSelect.js +33 -33
- package/dist/components/NumberField.d.ts +2 -1
- package/dist/components/NumberField.js +21 -11
- package/dist/components/Popover.js +6 -6
- package/dist/components/ProgressCircle.js +10 -10
- package/dist/components/RadioGroup.js +6 -6
- package/dist/components/SearchField.js +11 -11
- package/dist/components/Select.js +13 -13
- package/dist/components/Surface.js +3 -3
- package/dist/components/Switch.js +6 -6
- package/dist/components/Table.js +13 -13
- package/dist/components/Tabs.js +8 -8
- package/dist/components/TagGroup.js +7 -7
- package/dist/components/TextField.js +10 -10
- package/dist/components/TimeField.js +6 -6
- package/dist/components/Toggle.js +6 -6
- package/dist/components/Toolbar.js +7 -7
- package/dist/components/Tooltip.js +10 -10
- package/dist/components/Tree.js +9 -9
- package/dist/core/BlobTransport.d.ts +5 -0
- package/dist/core/BlobTransport.js +79 -0
- package/dist/core/Client.d.ts +2 -1
- package/dist/core/Client.js +17 -12
- package/dist/core/Config.d.ts +4 -0
- package/dist/core/Config.js +6 -0
- package/dist/core/Connection.d.ts +4 -3
- package/dist/core/Connection.js +7 -0
- package/dist/core/Graph.d.ts +3 -4
- package/dist/core/ListRow.d.ts +2 -0
- package/dist/core/OrderBy.d.ts +7 -3
- package/dist/core/TextDoc.d.ts +11 -0
- package/dist/core/Trace.d.ts +8 -0
- package/dist/core/Trace.js +32 -0
- package/dist/core/Type.d.ts +7 -1
- package/dist/core/db/CommitRequest.d.ts +0 -3
- package/dist/core/db/CommitRequest.js +0 -9
- package/dist/core/db/EntryDB.js +1 -1
- package/dist/core/db/EntryIndex.d.ts +12 -2
- package/dist/core/db/EntryIndex.js +131 -22
- package/dist/core/db/EntryResolver.js +104 -29
- package/dist/core/db/EntryTransaction.d.ts +1 -2
- package/dist/core/db/EntryTransaction.js +29 -22
- package/dist/core/db/LocalDB.d.ts +5 -5
- package/dist/core/db/LocalDB.js +27 -12
- package/dist/core/field/RichTextField.d.ts +30 -3
- package/dist/core/field/RichTextField.js +124 -56
- package/dist/core/media/MediaAltField.d.ts +1 -0
- package/dist/core/media/MediaAltField.js +9 -1
- package/dist/core/media/MediaLocation.d.ts +5 -2
- package/dist/core/media/MediaLocation.js +6 -7
- package/dist/core/media/MediaTypes.js +11 -0
- package/dist/core/source/CombinedSource.d.ts +2 -2
- package/dist/core/source/CombinedSource.js +6 -3
- package/dist/core/source/FSSource.d.ts +4 -3
- package/dist/core/source/FSSource.js +59 -27
- package/dist/core/source/GithubSource.d.ts +2 -2
- package/dist/core/source/GithubSource.js +21 -9
- package/dist/core/source/IndexedDBSource.d.ts +2 -2
- package/dist/core/source/IndexedDBSource.js +3 -1
- package/dist/core/source/MemorySource.d.ts +2 -2
- package/dist/core/source/MemorySource.js +3 -1
- package/dist/core/source/OverlaySource.d.ts +12 -0
- package/dist/core/source/OverlaySource.js +50 -0
- package/dist/core/source/Source.d.ts +5 -2
- package/dist/core/source/Source.js +3 -3
- package/dist/core/util/Async.d.ts +8 -2
- package/dist/core/util/Async.js +67 -0
- package/dist/core/util/EntryFilenames.d.ts +2 -2
- package/dist/core/util/EntryFilenames.js +3 -3
- package/dist/dashboard/App.css +158 -0
- package/dist/dashboard/App.js +2 -2
- package/dist/dashboard/app/AccessDenied.js +3 -3
- package/dist/dashboard/app/ActivityStatus.js +15 -15
- package/dist/dashboard/app/AppShell.js +1 -1
- package/dist/dashboard/app/AuthView.js +11 -11
- package/dist/dashboard/app/CompactField.js +10 -10
- package/dist/dashboard/app/DashboardErrorBoundary.js +5 -5
- package/dist/dashboard/app/DashboardLayout.js +22 -19
- package/dist/dashboard/app/EntryHeader.js +12 -12
- package/dist/dashboard/app/EntryReferences.js +9 -9
- package/dist/dashboard/app/EntrySidebar.d.ts +1 -1
- package/dist/dashboard/app/EntrySidebar.js +17 -16
- package/dist/dashboard/app/EntrySidebarPreview.d.ts +1 -1
- package/dist/dashboard/app/EntrySidebarPreview.js +19 -14
- package/dist/dashboard/app/EntryTranslationBanner.js +7 -7
- package/dist/dashboard/app/Explorer.js +51 -43
- package/dist/dashboard/app/ExplorerCards.js +34 -34
- package/dist/dashboard/app/ExplorerFileCard.js +18 -18
- package/dist/dashboard/app/ExplorerList.js +13 -13
- package/dist/dashboard/app/ExplorerModal.js +3 -3
- package/dist/dashboard/app/ExplorerTable.js +76 -61
- package/dist/dashboard/app/ExternalLinkPicker.js +15 -4
- package/dist/dashboard/app/LinkPicker.js +8 -8
- package/dist/dashboard/app/LocaleMenu.js +12 -12
- package/dist/dashboard/app/SidebarLayout.d.ts +8 -0
- package/dist/dashboard/app/SidebarLayout.js +1169 -0
- package/dist/dashboard/app/SidebarTree.js +46 -46
- package/dist/dashboard/app/WorkspaceMenu.js +17 -17
- package/dist/dashboard/app/WorkspaceRoots.js +23 -23
- package/dist/dashboard/app/editor/FileEditor.d.ts +2 -1
- package/dist/dashboard/app/editor/FileEditor.js +41 -32
- package/dist/dashboard/app/editor/FilePreview.js +4 -4
- package/dist/dashboard/app/editor/MediaAltField.view.d.ts +1 -1
- package/dist/dashboard/app/editor/MediaAltField.view.js +6 -9
- package/dist/dashboard/app/modals/CreateEntry.js +4 -4
- package/dist/dashboard/app/pages/EntryPage.js +57 -31
- package/dist/dashboard/app/pages/UsersPage.js +33 -33
- package/dist/dashboard/app/ui/DashboardModal.js +23 -23
- package/dist/dashboard/app/ui/Rail.js +3 -3
- package/dist/dashboard/app/ui/Sidebar.js +2 -2
- package/dist/dashboard/atoms/auth.js +2 -0
- package/dist/dashboard/atoms/dashboard.d.ts +9 -0
- package/dist/dashboard/atoms/dashboard.js +17 -0
- package/dist/dashboard/atoms/editor.d.ts +7 -1
- package/dist/dashboard/atoms/editor.js +4 -1
- package/dist/dashboard/atoms/entry.d.ts +48 -2
- package/dist/dashboard/atoms/entry.js +222 -17
- package/dist/dashboard/atoms/explorer.js +4 -9
- package/dist/dashboard/atoms/preview.d.ts +3 -0
- package/dist/dashboard/atoms/preview.js +18 -1
- package/dist/dashboard/atoms/root.d.ts +4 -1
- package/dist/dashboard/atoms/root.js +96 -157
- package/dist/dashboard/hooks.d.ts +4 -2
- package/dist/dashboard/hooks.js +9 -5
- package/dist/dashboard/icons.d.ts +1 -0
- package/dist/dashboard/icons.js +10 -0
- package/dist/field/check/CheckField.view.js +2 -2
- package/dist/field/code/CodeField.view.js +12 -12
- package/dist/field/date/DateField.view.js +12 -2
- package/dist/field/link/FileLink.d.ts +2 -2
- package/dist/field/link/FileLink.js +5 -3
- package/dist/field/link/ImageLink.d.ts +1 -1
- package/dist/field/link/ImageLink.js +1 -1
- package/dist/field/link/Link.js +2 -2
- package/dist/field/link/LinkField.view.js +155 -128
- package/dist/field/list/ListField.view.js +22 -33
- package/dist/field/metadata/MetadataField.view.js +19 -19
- package/dist/field/number/NumberField.d.ts +2 -0
- package/dist/field/number/NumberField.view.js +4 -2
- package/dist/field/richtext/PickTextLink.d.ts +7 -0
- package/dist/field/richtext/PickTextLink.js +104 -2
- package/dist/field/richtext/ReferenceLink.d.ts +4 -1
- package/dist/field/richtext/ReferenceLink.js +18 -4
- package/dist/field/richtext/RichTextDocument.d.ts +7 -2
- package/dist/field/richtext/RichTextDocument.js +34 -5
- package/dist/field/richtext/RichTextExtensions.d.ts +3 -1
- package/dist/field/richtext/RichTextExtensions.js +2704 -7467
- package/dist/field/richtext/RichTextField.d.ts +4 -0
- package/dist/field/richtext/RichTextField.story.d.ts +4 -0
- package/dist/field/richtext/RichTextField.view.js +43 -20
- package/dist/field/richtext/RichTextInsertMenu.js +281 -495
- package/dist/field/richtext/RichTextToolbar.d.ts +5 -2
- package/dist/field/richtext/RichTextToolbar.js +38 -3
- package/dist/field/richtext/Toolbar.d.ts +19 -1
- package/dist/field/richtext/Toolbar.js +18 -13
- package/dist/field/richtext/extensions/Anchor.js +1 -1
- package/dist/field/richtext/extensions/Link.js +1 -1
- package/dist/field/richtext/extensions/Small.js +1 -1
- package/dist/field/select/SelectField.view.js +8 -6
- package/dist/index.css +227 -16
- package/dist/next.cjs +18 -16
- package/dist/next.d.ts +2 -1
- package/dist/next.edge.d.ts +2 -1
- package/dist/picker/entry/EntryPicker.js +9 -35
- package/dist/preview/PreviewPayload.js +35 -250
- package/dist/ui/RichText.d.ts +1 -0
- package/dist/ui/RichText.js +29 -2
- package/package.json +6 -3
- package/dist/cli/util/ExternalPlugin.d.ts +0 -2
- package/dist/cli/util/ExternalPlugin.js +0 -919
- package/dist/chunks/{chunk-JFROOUG6.js → chunk-NIVGVRDS.js} +17 -17
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
Editor
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-A3XXZBOQ.js";
|
|
4
4
|
import {
|
|
5
5
|
require_shim
|
|
6
6
|
} from "./chunk-RKDPDEF7.js";
|
|
@@ -19,18 +19,18 @@ var require_with_selector_production = __commonJS({
|
|
|
19
19
|
return x === y && (0 !== x || 1 / x === 1 / y) || x !== x && y !== y;
|
|
20
20
|
}
|
|
21
21
|
var objectIs = "function" === typeof Object.is ? Object.is : is;
|
|
22
|
-
var
|
|
22
|
+
var useSyncExternalStore2 = shim.useSyncExternalStore;
|
|
23
23
|
var useRef2 = React2.useRef;
|
|
24
|
-
var
|
|
25
|
-
var
|
|
26
|
-
var
|
|
24
|
+
var useEffect2 = React2.useEffect;
|
|
25
|
+
var useMemo2 = React2.useMemo;
|
|
26
|
+
var useDebugValue2 = React2.useDebugValue;
|
|
27
27
|
exports.useSyncExternalStoreWithSelector = function(subscribe, getSnapshot, getServerSnapshot, selector, isEqual) {
|
|
28
28
|
var instRef = useRef2(null);
|
|
29
29
|
if (null === instRef.current) {
|
|
30
30
|
var inst = { hasValue: false, value: null };
|
|
31
31
|
instRef.current = inst;
|
|
32
32
|
} else inst = instRef.current;
|
|
33
|
-
instRef =
|
|
33
|
+
instRef = useMemo2(
|
|
34
34
|
function() {
|
|
35
35
|
function memoizedSelector(nextSnapshot) {
|
|
36
36
|
if (!hasMemo) {
|
|
@@ -64,15 +64,15 @@ var require_with_selector_production = __commonJS({
|
|
|
64
64
|
},
|
|
65
65
|
[getSnapshot, getServerSnapshot, selector, isEqual]
|
|
66
66
|
);
|
|
67
|
-
var value =
|
|
68
|
-
|
|
67
|
+
var value = useSyncExternalStore2(subscribe, instRef[0], instRef[1]);
|
|
68
|
+
useEffect2(
|
|
69
69
|
function() {
|
|
70
70
|
inst.hasValue = true;
|
|
71
71
|
inst.value = value;
|
|
72
72
|
},
|
|
73
73
|
[value]
|
|
74
74
|
);
|
|
75
|
-
|
|
75
|
+
useDebugValue2(value);
|
|
76
76
|
return value;
|
|
77
77
|
};
|
|
78
78
|
}
|
|
@@ -87,14 +87,14 @@ var require_with_selector_development = __commonJS({
|
|
|
87
87
|
return x === y && (0 !== x || 1 / x === 1 / y) || x !== x && y !== y;
|
|
88
88
|
}
|
|
89
89
|
"undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ && "function" === typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart && __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(Error());
|
|
90
|
-
var React2 = __import_react2, shim = require_shim(), objectIs = "function" === typeof Object.is ? Object.is : is,
|
|
90
|
+
var React2 = __import_react2, shim = require_shim(), objectIs = "function" === typeof Object.is ? Object.is : is, useSyncExternalStore2 = shim.useSyncExternalStore, useRef2 = React2.useRef, useEffect2 = React2.useEffect, useMemo2 = React2.useMemo, useDebugValue2 = React2.useDebugValue;
|
|
91
91
|
exports.useSyncExternalStoreWithSelector = function(subscribe, getSnapshot, getServerSnapshot, selector, isEqual) {
|
|
92
92
|
var instRef = useRef2(null);
|
|
93
93
|
if (null === instRef.current) {
|
|
94
94
|
var inst = { hasValue: false, value: null };
|
|
95
95
|
instRef.current = inst;
|
|
96
96
|
} else inst = instRef.current;
|
|
97
|
-
instRef =
|
|
97
|
+
instRef = useMemo2(
|
|
98
98
|
function() {
|
|
99
99
|
function memoizedSelector(nextSnapshot) {
|
|
100
100
|
if (!hasMemo) {
|
|
@@ -129,15 +129,15 @@ var require_with_selector_development = __commonJS({
|
|
|
129
129
|
},
|
|
130
130
|
[getSnapshot, getServerSnapshot, selector, isEqual]
|
|
131
131
|
);
|
|
132
|
-
var value =
|
|
133
|
-
|
|
132
|
+
var value = useSyncExternalStore2(subscribe, instRef[0], instRef[1]);
|
|
133
|
+
useEffect2(
|
|
134
134
|
function() {
|
|
135
135
|
inst.hasValue = true;
|
|
136
136
|
inst.value = value;
|
|
137
137
|
},
|
|
138
138
|
[value]
|
|
139
139
|
);
|
|
140
|
-
|
|
140
|
+
useDebugValue2(value);
|
|
141
141
|
return value;
|
|
142
142
|
};
|
|
143
143
|
"undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ && "function" === typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop && __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(Error());
|
|
@@ -159,12 +159,9 @@ var require_with_selector = __commonJS({
|
|
|
159
159
|
|
|
160
160
|
// node_modules/@tiptap/react/dist/index.js
|
|
161
161
|
var import_shim = __toESM(require_shim(), 1);
|
|
162
|
-
import { createContext, useContext, useMemo } from "react";
|
|
163
|
-
import
|
|
164
|
-
import ReactDOM from "react-dom";
|
|
162
|
+
import React, { createContext, createElement, createRef, forwardRef, memo, useContext, useDebugValue, useEffect, useLayoutEffect, useMemo, useRef, useState, version } from "react";
|
|
163
|
+
import ReactDOM, { flushSync } from "react-dom";
|
|
165
164
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
166
|
-
var import_shim2 = __toESM(require_shim(), 1);
|
|
167
|
-
import { useDebugValue as useDebugValue2, useEffect as useEffect2, useRef, useState as useState2 } from "react";
|
|
168
165
|
|
|
169
166
|
// node_modules/fast-equals/dist/es/index.mjs
|
|
170
167
|
var { getOwnPropertyNames, getOwnPropertySymbols } = Object;
|
|
@@ -606,48 +603,34 @@ function createCustomEqual(options = {}) {
|
|
|
606
603
|
|
|
607
604
|
// node_modules/@tiptap/react/dist/index.js
|
|
608
605
|
var import_with_selector = __toESM(require_with_selector(), 1);
|
|
609
|
-
import { useDebugValue, useEffect, useLayoutEffect, useState } from "react";
|
|
610
|
-
import { jsx as jsx2, jsxs as jsxs2 } from "react/jsx-runtime";
|
|
611
|
-
import { createContext as createContext2, createElement, useContext as useContext2 } from "react";
|
|
612
|
-
import { jsx as jsx3 } from "react/jsx-runtime";
|
|
613
|
-
import React3 from "react";
|
|
614
|
-
import { jsx as jsx4 } from "react/jsx-runtime";
|
|
615
|
-
import React4 from "react";
|
|
616
|
-
import { version as reactVersion } from "react";
|
|
617
|
-
import { flushSync } from "react-dom";
|
|
618
|
-
import { jsx as jsx5 } from "react/jsx-runtime";
|
|
619
|
-
import { jsx as jsx6 } from "react/jsx-runtime";
|
|
620
|
-
import { createElement as createElement2, createRef, memo } from "react";
|
|
621
|
-
import { jsx as jsx7 } from "react/jsx-runtime";
|
|
622
|
-
import { createContext as createContext3, useContext as useContext3, useMemo as useMemo2 } from "react";
|
|
623
|
-
import { jsx as jsx8 } from "react/jsx-runtime";
|
|
624
606
|
var mergeRefs = (...refs) => {
|
|
625
607
|
return (node) => {
|
|
626
608
|
refs.forEach((ref) => {
|
|
627
|
-
if (typeof ref === "function")
|
|
628
|
-
|
|
629
|
-
} else if (ref) {
|
|
630
|
-
;
|
|
631
|
-
ref.current = node;
|
|
632
|
-
}
|
|
609
|
+
if (typeof ref === "function") ref(node);
|
|
610
|
+
else if (ref) ref.current = node;
|
|
633
611
|
});
|
|
634
612
|
};
|
|
635
613
|
};
|
|
636
614
|
var Portals = ({ contentComponent }) => {
|
|
637
|
-
const renderers = (0, import_shim.useSyncExternalStore)(
|
|
638
|
-
contentComponent.subscribe,
|
|
639
|
-
contentComponent.getSnapshot,
|
|
640
|
-
contentComponent.getServerSnapshot
|
|
641
|
-
);
|
|
615
|
+
const renderers = (0, import_shim.useSyncExternalStore)(contentComponent.subscribe, contentComponent.getSnapshot, contentComponent.getServerSnapshot);
|
|
642
616
|
return /* @__PURE__ */ jsx(Fragment, { children: Object.values(renderers) });
|
|
643
617
|
};
|
|
644
|
-
function
|
|
618
|
+
function createContentComponent() {
|
|
645
619
|
const subscribers = /* @__PURE__ */ new Set();
|
|
646
620
|
let renderers = {};
|
|
621
|
+
let isNotificationQueued = false;
|
|
622
|
+
const notifySubscribers = () => {
|
|
623
|
+
if (isNotificationQueued || !subscribers.size) return;
|
|
624
|
+
isNotificationQueued = true;
|
|
625
|
+
queueMicrotask(() => {
|
|
626
|
+
isNotificationQueued = false;
|
|
627
|
+
subscribers.forEach((subscriber) => subscriber());
|
|
628
|
+
});
|
|
629
|
+
};
|
|
647
630
|
return {
|
|
648
631
|
/**
|
|
649
|
-
|
|
650
|
-
|
|
632
|
+
* Subscribe to the editor instance's changes.
|
|
633
|
+
*/
|
|
651
634
|
subscribe(callback) {
|
|
652
635
|
subscribers.add(callback);
|
|
653
636
|
return () => {
|
|
@@ -661,23 +644,23 @@ function getInstance() {
|
|
|
661
644
|
return renderers;
|
|
662
645
|
},
|
|
663
646
|
/**
|
|
664
|
-
|
|
665
|
-
|
|
647
|
+
* Adds a new NodeView Renderer to the editor.
|
|
648
|
+
*/
|
|
666
649
|
setRenderer(id, renderer) {
|
|
667
650
|
renderers = {
|
|
668
651
|
...renderers,
|
|
669
652
|
[id]: ReactDOM.createPortal(renderer.reactElement, renderer.element, id)
|
|
670
653
|
};
|
|
671
|
-
|
|
654
|
+
notifySubscribers();
|
|
672
655
|
},
|
|
673
656
|
/**
|
|
674
|
-
|
|
675
|
-
|
|
657
|
+
* Removes a NodeView Renderer from the editor.
|
|
658
|
+
*/
|
|
676
659
|
removeRenderer(id) {
|
|
677
660
|
const nextRenderers = { ...renderers };
|
|
678
661
|
delete nextRenderers[id];
|
|
679
662
|
renderers = nextRenderers;
|
|
680
|
-
|
|
663
|
+
notifySubscribers();
|
|
681
664
|
}
|
|
682
665
|
};
|
|
683
666
|
}
|
|
@@ -693,68 +676,52 @@ var PureEditorContent = class extends React.Component {
|
|
|
693
676
|
this.init();
|
|
694
677
|
}
|
|
695
678
|
init() {
|
|
696
|
-
var
|
|
679
|
+
var _editor$view$dom;
|
|
697
680
|
const editor = this.props.editor;
|
|
698
|
-
if (editor && !editor.isDestroyed && ((
|
|
699
|
-
if (editor.contentComponent)
|
|
700
|
-
return;
|
|
701
|
-
}
|
|
681
|
+
if (editor && !editor.isDestroyed && ((_editor$view$dom = editor.view.dom) === null || _editor$view$dom === void 0 ? void 0 : _editor$view$dom.parentNode)) {
|
|
682
|
+
if (editor.contentComponent) return;
|
|
702
683
|
const element = this.editorContentRef.current;
|
|
703
684
|
element.append(...editor.view.dom.parentNode.childNodes);
|
|
704
|
-
editor.setOptions({
|
|
705
|
-
|
|
706
|
-
});
|
|
707
|
-
editor.contentComponent = getInstance();
|
|
685
|
+
editor.setOptions({ element });
|
|
686
|
+
editor.contentComponent = createContentComponent();
|
|
708
687
|
editor.createNodeViews();
|
|
709
688
|
editor.isEditorContentInitialized = true;
|
|
710
689
|
this.forceUpdate();
|
|
711
690
|
}
|
|
712
691
|
}
|
|
713
692
|
componentWillUnmount() {
|
|
714
|
-
var _a;
|
|
715
693
|
const editor = this.props.editor;
|
|
716
|
-
if (!editor)
|
|
717
|
-
return;
|
|
718
|
-
}
|
|
694
|
+
if (!editor) return;
|
|
719
695
|
editor.isEditorContentInitialized = false;
|
|
720
|
-
if (!editor.isDestroyed) {
|
|
721
|
-
editor.view.setProps({
|
|
722
|
-
nodeViews: {}
|
|
723
|
-
});
|
|
724
|
-
}
|
|
696
|
+
if (!editor.isDestroyed) editor.view.setProps({ nodeViews: {} });
|
|
725
697
|
editor.contentComponent = null;
|
|
726
698
|
try {
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
}
|
|
699
|
+
var _editor$view$dom2;
|
|
700
|
+
if (!((_editor$view$dom2 = editor.view.dom) === null || _editor$view$dom2 === void 0 ? void 0 : _editor$view$dom2.parentNode)) return;
|
|
730
701
|
const newElement = document.createElement("div");
|
|
731
702
|
newElement.append(...editor.view.dom.parentNode.childNodes);
|
|
732
|
-
editor.setOptions({
|
|
733
|
-
element: newElement
|
|
734
|
-
});
|
|
703
|
+
editor.setOptions({ element: newElement });
|
|
735
704
|
} catch {
|
|
736
705
|
}
|
|
737
706
|
}
|
|
738
707
|
render() {
|
|
739
708
|
const { editor, innerRef, ...rest } = this.props;
|
|
740
|
-
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
] });
|
|
709
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx("div", {
|
|
710
|
+
ref: mergeRefs(innerRef, this.editorContentRef),
|
|
711
|
+
...rest
|
|
712
|
+
}), (editor === null || editor === void 0 ? void 0 : editor.contentComponent) && /* @__PURE__ */ jsx(Portals, { contentComponent: editor.contentComponent })] });
|
|
744
713
|
}
|
|
745
714
|
};
|
|
746
|
-
var EditorContentWithKey = forwardRef(
|
|
747
|
-
(
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
}
|
|
757
|
-
);
|
|
715
|
+
var EditorContentWithKey = forwardRef((props, ref) => {
|
|
716
|
+
const key = React.useMemo(() => {
|
|
717
|
+
return Math.floor(Math.random() * 4294967295).toString();
|
|
718
|
+
}, [props.editor]);
|
|
719
|
+
return React.createElement(PureEditorContent, {
|
|
720
|
+
key,
|
|
721
|
+
innerRef: ref,
|
|
722
|
+
...props
|
|
723
|
+
});
|
|
724
|
+
});
|
|
758
725
|
var EditorContent = React.memo(EditorContentWithKey);
|
|
759
726
|
var useIsomorphicLayoutEffect = typeof window !== "undefined" ? useLayoutEffect : useEffect;
|
|
760
727
|
var EditorStateManager = class {
|
|
@@ -763,32 +730,39 @@ var EditorStateManager = class {
|
|
|
763
730
|
this.lastTransactionNumber = 0;
|
|
764
731
|
this.subscribers = /* @__PURE__ */ new Set();
|
|
765
732
|
this.editor = initialEditor;
|
|
766
|
-
this.lastSnapshot = {
|
|
733
|
+
this.lastSnapshot = {
|
|
734
|
+
editor: initialEditor,
|
|
735
|
+
transactionNumber: 0
|
|
736
|
+
};
|
|
767
737
|
this.getSnapshot = this.getSnapshot.bind(this);
|
|
768
738
|
this.getServerSnapshot = this.getServerSnapshot.bind(this);
|
|
769
739
|
this.watch = this.watch.bind(this);
|
|
770
740
|
this.subscribe = this.subscribe.bind(this);
|
|
771
741
|
}
|
|
772
742
|
/**
|
|
773
|
-
|
|
774
|
-
|
|
743
|
+
* Get the current editor instance.
|
|
744
|
+
*/
|
|
775
745
|
getSnapshot() {
|
|
776
|
-
if (this.transactionNumber === this.lastTransactionNumber)
|
|
777
|
-
return this.lastSnapshot;
|
|
778
|
-
}
|
|
746
|
+
if (this.transactionNumber === this.lastTransactionNumber) return this.lastSnapshot;
|
|
779
747
|
this.lastTransactionNumber = this.transactionNumber;
|
|
780
|
-
this.lastSnapshot = {
|
|
748
|
+
this.lastSnapshot = {
|
|
749
|
+
editor: this.editor,
|
|
750
|
+
transactionNumber: this.transactionNumber
|
|
751
|
+
};
|
|
781
752
|
return this.lastSnapshot;
|
|
782
753
|
}
|
|
783
754
|
/**
|
|
784
|
-
|
|
785
|
-
|
|
755
|
+
* Always disable the editor on the server-side.
|
|
756
|
+
*/
|
|
786
757
|
getServerSnapshot() {
|
|
787
|
-
return {
|
|
758
|
+
return {
|
|
759
|
+
editor: null,
|
|
760
|
+
transactionNumber: 0
|
|
761
|
+
};
|
|
788
762
|
}
|
|
789
763
|
/**
|
|
790
|
-
|
|
791
|
-
|
|
764
|
+
* Subscribe to the editor instance's changes.
|
|
765
|
+
*/
|
|
792
766
|
subscribe(callback) {
|
|
793
767
|
this.subscribers.add(callback);
|
|
794
768
|
return () => {
|
|
@@ -796,34 +770,32 @@ var EditorStateManager = class {
|
|
|
796
770
|
};
|
|
797
771
|
}
|
|
798
772
|
/**
|
|
799
|
-
|
|
800
|
-
|
|
773
|
+
* Watch the editor instance for changes.
|
|
774
|
+
*/
|
|
801
775
|
watch(nextEditor) {
|
|
802
776
|
this.editor = nextEditor;
|
|
803
777
|
if (this.editor) {
|
|
804
|
-
|
|
778
|
+
let lastTransaction;
|
|
779
|
+
const fn = (props) => {
|
|
780
|
+
if ((props === null || props === void 0 ? void 0 : props.transaction) !== void 0 && props.transaction === lastTransaction) return;
|
|
781
|
+
lastTransaction = props === null || props === void 0 ? void 0 : props.transaction;
|
|
805
782
|
this.transactionNumber += 1;
|
|
806
783
|
this.subscribers.forEach((callback) => callback());
|
|
807
784
|
};
|
|
808
785
|
const currentEditor = this.editor;
|
|
809
786
|
currentEditor.on("transaction", fn);
|
|
787
|
+
currentEditor.on("update", fn);
|
|
810
788
|
return () => {
|
|
811
789
|
currentEditor.off("transaction", fn);
|
|
790
|
+
currentEditor.off("update", fn);
|
|
812
791
|
};
|
|
813
792
|
}
|
|
814
|
-
return void 0;
|
|
815
793
|
}
|
|
816
794
|
};
|
|
817
795
|
function useEditorState(options) {
|
|
818
|
-
var
|
|
796
|
+
var _options$equalityFn;
|
|
819
797
|
const [editorStateManager] = useState(() => new EditorStateManager(options.editor));
|
|
820
|
-
const selectedState = (0, import_with_selector.useSyncExternalStoreWithSelector)(
|
|
821
|
-
editorStateManager.subscribe,
|
|
822
|
-
editorStateManager.getSnapshot,
|
|
823
|
-
editorStateManager.getServerSnapshot,
|
|
824
|
-
options.selector,
|
|
825
|
-
(_a = options.equalityFn) != null ? _a : deepEqual
|
|
826
|
-
);
|
|
798
|
+
const selectedState = (0, import_with_selector.useSyncExternalStoreWithSelector)(editorStateManager.subscribe, editorStateManager.getSnapshot, editorStateManager.getServerSnapshot, options.selector, (_options$equalityFn = options.equalityFn) !== null && _options$equalityFn !== void 0 ? _options$equalityFn : deepEqual);
|
|
827
799
|
useIsomorphicLayoutEffect(() => {
|
|
828
800
|
return editorStateManager.watch(options.editor);
|
|
829
801
|
}, [options.editor, editorStateManager]);
|
|
@@ -833,7 +805,7 @@ function useEditorState(options) {
|
|
|
833
805
|
var isDev = process.env.NODE_ENV !== "production";
|
|
834
806
|
var isSSR = typeof window === "undefined";
|
|
835
807
|
var isNext = isSSR || Boolean(typeof window !== "undefined" && window.next);
|
|
836
|
-
var EditorInstanceManager = class
|
|
808
|
+
var EditorInstanceManager = class EditorInstanceManager2 {
|
|
837
809
|
constructor(options) {
|
|
838
810
|
this.editor = null;
|
|
839
811
|
this.subscriptions = /* @__PURE__ */ new Set();
|
|
@@ -859,98 +831,96 @@ var EditorInstanceManager = class _EditorInstanceManager {
|
|
|
859
831
|
}
|
|
860
832
|
getInitialEditor() {
|
|
861
833
|
const explicit = this.options.current.immediatelyRender;
|
|
862
|
-
let immediatelyRender = explicit
|
|
834
|
+
let immediatelyRender = explicit !== null && explicit !== void 0 ? explicit : true;
|
|
863
835
|
if (isSSR) {
|
|
864
|
-
if (immediatelyRender && isDev)
|
|
865
|
-
console.warn(
|
|
866
|
-
"SSR detected. `immediatelyRender` has been set to false to avoid hydration mismatches"
|
|
867
|
-
);
|
|
868
|
-
}
|
|
836
|
+
if (immediatelyRender && isDev) console.warn("SSR detected. `immediatelyRender` has been set to false to avoid hydration mismatches");
|
|
869
837
|
immediatelyRender = false;
|
|
870
838
|
} else if (isNext && explicit === void 0) {
|
|
871
839
|
immediatelyRender = false;
|
|
872
|
-
if (isDev)
|
|
873
|
-
console.warn(
|
|
874
|
-
"Next.js detected. `immediatelyRender` defaults to false to avoid hydration mismatches. Pass `immediatelyRender: true` explicitly if you are rendering the editor only on the client."
|
|
875
|
-
);
|
|
876
|
-
}
|
|
840
|
+
if (isDev) console.warn("Next.js detected. `immediatelyRender` defaults to false to avoid hydration mismatches. Pass `immediatelyRender: true` explicitly if you are rendering the editor only on the client.");
|
|
877
841
|
}
|
|
878
842
|
return immediatelyRender ? this.createEditor() : null;
|
|
879
843
|
}
|
|
880
844
|
/**
|
|
881
|
-
|
|
882
|
-
|
|
845
|
+
* Create a new editor instance. And attach event listeners.
|
|
846
|
+
*/
|
|
883
847
|
createEditor() {
|
|
884
848
|
const optionsToApply = {
|
|
885
849
|
...this.options.current,
|
|
886
|
-
// Always call the most recent version of the callback function by default
|
|
887
850
|
onBeforeCreate: (...args) => {
|
|
888
|
-
var
|
|
889
|
-
return (
|
|
851
|
+
var _this$options$current, _this$options$current2;
|
|
852
|
+
return (_this$options$current = (_this$options$current2 = this.options.current).onBeforeCreate) === null || _this$options$current === void 0 ? void 0 : _this$options$current.call(_this$options$current2, ...args);
|
|
890
853
|
},
|
|
891
854
|
onBlur: (...args) => {
|
|
892
|
-
var
|
|
893
|
-
return (
|
|
855
|
+
var _this$options$current3, _this$options$current4;
|
|
856
|
+
return (_this$options$current3 = (_this$options$current4 = this.options.current).onBlur) === null || _this$options$current3 === void 0 ? void 0 : _this$options$current3.call(_this$options$current4, ...args);
|
|
894
857
|
},
|
|
895
858
|
onCreate: (...args) => {
|
|
896
|
-
var
|
|
897
|
-
return (
|
|
859
|
+
var _this$options$current5, _this$options$current6;
|
|
860
|
+
return (_this$options$current5 = (_this$options$current6 = this.options.current).onCreate) === null || _this$options$current5 === void 0 ? void 0 : _this$options$current5.call(_this$options$current6, ...args);
|
|
898
861
|
},
|
|
899
862
|
onDestroy: (...args) => {
|
|
900
|
-
var
|
|
901
|
-
return (
|
|
863
|
+
var _this$options$current7, _this$options$current8;
|
|
864
|
+
return (_this$options$current7 = (_this$options$current8 = this.options.current).onDestroy) === null || _this$options$current7 === void 0 ? void 0 : _this$options$current7.call(_this$options$current8, ...args);
|
|
902
865
|
},
|
|
903
866
|
onFocus: (...args) => {
|
|
904
|
-
var
|
|
905
|
-
return (
|
|
867
|
+
var _this$options$current9, _this$options$current10;
|
|
868
|
+
return (_this$options$current9 = (_this$options$current10 = this.options.current).onFocus) === null || _this$options$current9 === void 0 ? void 0 : _this$options$current9.call(_this$options$current10, ...args);
|
|
906
869
|
},
|
|
907
870
|
onSelectionUpdate: (...args) => {
|
|
908
|
-
var
|
|
909
|
-
return (
|
|
871
|
+
var _this$options$current11, _this$options$current12;
|
|
872
|
+
return (_this$options$current11 = (_this$options$current12 = this.options.current).onSelectionUpdate) === null || _this$options$current11 === void 0 ? void 0 : _this$options$current11.call(_this$options$current12, ...args);
|
|
910
873
|
},
|
|
911
874
|
onTransaction: (...args) => {
|
|
912
|
-
var
|
|
913
|
-
return (
|
|
875
|
+
var _this$options$current13, _this$options$current14;
|
|
876
|
+
return (_this$options$current13 = (_this$options$current14 = this.options.current).onTransaction) === null || _this$options$current13 === void 0 ? void 0 : _this$options$current13.call(_this$options$current14, ...args);
|
|
914
877
|
},
|
|
915
878
|
onUpdate: (...args) => {
|
|
916
|
-
var
|
|
917
|
-
return (
|
|
879
|
+
var _this$options$current15, _this$options$current16;
|
|
880
|
+
return (_this$options$current15 = (_this$options$current16 = this.options.current).onUpdate) === null || _this$options$current15 === void 0 ? void 0 : _this$options$current15.call(_this$options$current16, ...args);
|
|
918
881
|
},
|
|
919
882
|
onContentError: (...args) => {
|
|
920
|
-
var
|
|
921
|
-
return (
|
|
883
|
+
var _this$options$current17, _this$options$current18;
|
|
884
|
+
return (_this$options$current17 = (_this$options$current18 = this.options.current).onContentError) === null || _this$options$current17 === void 0 ? void 0 : _this$options$current17.call(_this$options$current18, ...args);
|
|
922
885
|
},
|
|
923
886
|
onDrop: (...args) => {
|
|
924
|
-
var
|
|
925
|
-
return (
|
|
887
|
+
var _this$options$current19, _this$options$current20;
|
|
888
|
+
return (_this$options$current19 = (_this$options$current20 = this.options.current).onDrop) === null || _this$options$current19 === void 0 ? void 0 : _this$options$current19.call(_this$options$current20, ...args);
|
|
926
889
|
},
|
|
927
890
|
onPaste: (...args) => {
|
|
928
|
-
var
|
|
929
|
-
return (
|
|
891
|
+
var _this$options$current21, _this$options$current22;
|
|
892
|
+
return (_this$options$current21 = (_this$options$current22 = this.options.current).onPaste) === null || _this$options$current21 === void 0 ? void 0 : _this$options$current21.call(_this$options$current22, ...args);
|
|
930
893
|
},
|
|
931
894
|
onDelete: (...args) => {
|
|
932
|
-
var
|
|
933
|
-
return (
|
|
895
|
+
var _this$options$current23, _this$options$current24;
|
|
896
|
+
return (_this$options$current23 = (_this$options$current24 = this.options.current).onDelete) === null || _this$options$current23 === void 0 ? void 0 : _this$options$current23.call(_this$options$current24, ...args);
|
|
897
|
+
},
|
|
898
|
+
onMount: (...args) => {
|
|
899
|
+
var _this$options$current25, _this$options$current26;
|
|
900
|
+
return (_this$options$current25 = (_this$options$current26 = this.options.current).onMount) === null || _this$options$current25 === void 0 ? void 0 : _this$options$current25.call(_this$options$current26, ...args);
|
|
901
|
+
},
|
|
902
|
+
onUnmount: (...args) => {
|
|
903
|
+
var _this$options$current27, _this$options$current28;
|
|
904
|
+
return (_this$options$current27 = (_this$options$current28 = this.options.current).onUnmount) === null || _this$options$current27 === void 0 ? void 0 : _this$options$current27.call(_this$options$current28, ...args);
|
|
934
905
|
}
|
|
935
906
|
};
|
|
936
|
-
|
|
937
|
-
return editor;
|
|
907
|
+
return new Editor(optionsToApply);
|
|
938
908
|
}
|
|
939
909
|
/**
|
|
940
|
-
|
|
941
|
-
|
|
910
|
+
* Get the current editor instance.
|
|
911
|
+
*/
|
|
942
912
|
getEditor() {
|
|
943
913
|
return this.editor;
|
|
944
914
|
}
|
|
945
915
|
/**
|
|
946
|
-
|
|
947
|
-
|
|
916
|
+
* Always disable the editor on the server-side.
|
|
917
|
+
*/
|
|
948
918
|
getServerSnapshot() {
|
|
949
919
|
return null;
|
|
950
920
|
}
|
|
951
921
|
/**
|
|
952
|
-
|
|
953
|
-
|
|
922
|
+
* Subscribe to the editor instance's changes.
|
|
923
|
+
*/
|
|
954
924
|
subscribe(onStoreChange) {
|
|
955
925
|
this.subscriptions.add(onStoreChange);
|
|
956
926
|
return () => {
|
|
@@ -971,46 +941,34 @@ var EditorInstanceManager = class _EditorInstanceManager {
|
|
|
971
941
|
"onContentError",
|
|
972
942
|
"onDrop",
|
|
973
943
|
"onPaste"
|
|
974
|
-
].includes(key))
|
|
975
|
-
return true;
|
|
976
|
-
}
|
|
944
|
+
].includes(key)) return true;
|
|
977
945
|
if (key === "extensions" && a.extensions && b.extensions) {
|
|
978
|
-
if (a.extensions.length !== b.extensions.length)
|
|
979
|
-
return false;
|
|
980
|
-
}
|
|
946
|
+
if (a.extensions.length !== b.extensions.length) return false;
|
|
981
947
|
return a.extensions.every((extension, index) => {
|
|
982
|
-
var
|
|
983
|
-
if (extension !== ((
|
|
984
|
-
return false;
|
|
985
|
-
}
|
|
948
|
+
var _b$extensions;
|
|
949
|
+
if (extension !== ((_b$extensions = b.extensions) === null || _b$extensions === void 0 ? void 0 : _b$extensions[index])) return false;
|
|
986
950
|
return true;
|
|
987
951
|
});
|
|
988
952
|
}
|
|
989
|
-
if (a[key] !== b[key])
|
|
990
|
-
return false;
|
|
991
|
-
}
|
|
953
|
+
if (a[key] !== b[key]) return false;
|
|
992
954
|
return true;
|
|
993
955
|
});
|
|
994
956
|
}
|
|
995
957
|
/**
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
|
|
958
|
+
* On each render, we will create, update, or destroy the editor instance.
|
|
959
|
+
* @param deps The dependencies to watch for changes
|
|
960
|
+
* @returns A cleanup function
|
|
961
|
+
*/
|
|
1000
962
|
onRender(deps) {
|
|
1001
963
|
return () => {
|
|
1002
964
|
this.isComponentMounted = true;
|
|
1003
965
|
clearTimeout(this.scheduledDestructionTimeout);
|
|
1004
966
|
if (this.editor && !this.editor.isDestroyed && deps.length === 0) {
|
|
1005
|
-
if (!
|
|
1006
|
-
this.
|
|
1007
|
-
|
|
1008
|
-
|
|
1009
|
-
|
|
1010
|
-
}
|
|
1011
|
-
} else {
|
|
1012
|
-
this.refreshEditorInstance(deps);
|
|
1013
|
-
}
|
|
967
|
+
if (!EditorInstanceManager2.compareOptions(this.options.current, this.editor.options)) this.editor.setOptions({
|
|
968
|
+
...this.options.current,
|
|
969
|
+
editable: this.editor.isEditable
|
|
970
|
+
});
|
|
971
|
+
} else this.refreshEditorInstance(deps);
|
|
1014
972
|
return () => {
|
|
1015
973
|
this.isComponentMounted = false;
|
|
1016
974
|
this.scheduleDestroy();
|
|
@@ -1018,45 +976,36 @@ var EditorInstanceManager = class _EditorInstanceManager {
|
|
|
1018
976
|
};
|
|
1019
977
|
}
|
|
1020
978
|
/**
|
|
1021
|
-
|
|
1022
|
-
|
|
979
|
+
* Recreate the editor instance if the dependencies have changed.
|
|
980
|
+
*/
|
|
1023
981
|
refreshEditorInstance(deps) {
|
|
1024
982
|
if (this.editor && !this.editor.isDestroyed) {
|
|
1025
983
|
if (this.previousDeps === null) {
|
|
1026
984
|
this.previousDeps = deps;
|
|
1027
985
|
return;
|
|
1028
986
|
}
|
|
1029
|
-
|
|
1030
|
-
if (depsAreEqual) {
|
|
1031
|
-
return;
|
|
1032
|
-
}
|
|
1033
|
-
}
|
|
1034
|
-
if (this.editor && !this.editor.isDestroyed) {
|
|
1035
|
-
this.editor.destroy();
|
|
987
|
+
if (this.previousDeps.length === deps.length && this.previousDeps.every((dep, index) => dep === deps[index])) return;
|
|
1036
988
|
}
|
|
989
|
+
if (this.editor && !this.editor.isDestroyed) this.editor.destroy();
|
|
1037
990
|
this.setEditor(this.createEditor());
|
|
1038
991
|
this.previousDeps = deps;
|
|
1039
992
|
}
|
|
1040
993
|
/**
|
|
1041
|
-
|
|
1042
|
-
|
|
1043
|
-
|
|
1044
|
-
|
|
994
|
+
* Schedule the destruction of the editor instance.
|
|
995
|
+
* This will only destroy the editor if it was not mounted on the next tick.
|
|
996
|
+
* This is to avoid destroying the editor instance when it's actually still mounted.
|
|
997
|
+
*/
|
|
1045
998
|
scheduleDestroy() {
|
|
1046
999
|
const currentInstanceId = this.instanceId;
|
|
1047
1000
|
const currentEditor = this.editor;
|
|
1048
1001
|
this.scheduledDestructionTimeout = setTimeout(() => {
|
|
1049
1002
|
if (this.isComponentMounted && this.instanceId === currentInstanceId) {
|
|
1050
|
-
if (currentEditor)
|
|
1051
|
-
currentEditor.setOptions(this.options.current);
|
|
1052
|
-
}
|
|
1003
|
+
if (currentEditor) currentEditor.setOptions(this.options.current);
|
|
1053
1004
|
return;
|
|
1054
1005
|
}
|
|
1055
1006
|
if (currentEditor && !currentEditor.isDestroyed) {
|
|
1056
1007
|
currentEditor.destroy();
|
|
1057
|
-
if (this.instanceId === currentInstanceId)
|
|
1058
|
-
this.setEditor(null);
|
|
1059
|
-
}
|
|
1008
|
+
if (this.instanceId === currentInstanceId) this.setEditor(null);
|
|
1060
1009
|
}
|
|
1061
1010
|
}, 1);
|
|
1062
1011
|
}
|
|
@@ -1064,95 +1013,79 @@ var EditorInstanceManager = class _EditorInstanceManager {
|
|
|
1064
1013
|
function useEditor(options = {}, deps = []) {
|
|
1065
1014
|
const mostRecentOptions = useRef(options);
|
|
1066
1015
|
mostRecentOptions.current = options;
|
|
1067
|
-
const [instanceManager] =
|
|
1068
|
-
const editor = (0,
|
|
1069
|
-
|
|
1070
|
-
|
|
1071
|
-
instanceManager.getServerSnapshot
|
|
1072
|
-
);
|
|
1073
|
-
useDebugValue2(editor);
|
|
1074
|
-
useEffect2(instanceManager.onRender(deps));
|
|
1016
|
+
const [instanceManager] = useState(() => new EditorInstanceManager(mostRecentOptions));
|
|
1017
|
+
const editor = (0, import_shim.useSyncExternalStore)(instanceManager.subscribe, instanceManager.getEditor, instanceManager.getServerSnapshot);
|
|
1018
|
+
useDebugValue(editor);
|
|
1019
|
+
useEffect(instanceManager.onRender(deps));
|
|
1075
1020
|
useEditorState({
|
|
1076
1021
|
editor,
|
|
1077
1022
|
selector: ({ transactionNumber }) => {
|
|
1078
|
-
if (options.shouldRerenderOnTransaction === false || options.shouldRerenderOnTransaction === void 0)
|
|
1079
|
-
|
|
1080
|
-
}
|
|
1081
|
-
if (options.immediatelyRender && transactionNumber === 0) {
|
|
1082
|
-
return 0;
|
|
1083
|
-
}
|
|
1023
|
+
if (options.shouldRerenderOnTransaction === false || options.shouldRerenderOnTransaction === void 0) return null;
|
|
1024
|
+
if (options.immediatelyRender && transactionNumber === 0) return 0;
|
|
1084
1025
|
return transactionNumber + 1;
|
|
1085
1026
|
}
|
|
1086
1027
|
});
|
|
1087
1028
|
return editor;
|
|
1088
1029
|
}
|
|
1089
|
-
var EditorContext = createContext({
|
|
1090
|
-
editor: null
|
|
1091
|
-
});
|
|
1030
|
+
var EditorContext = createContext({ editor: null });
|
|
1092
1031
|
var EditorConsumer = EditorContext.Consumer;
|
|
1093
1032
|
var useCurrentEditor = () => useContext(EditorContext);
|
|
1094
|
-
var ReactNodeViewContext =
|
|
1033
|
+
var ReactNodeViewContext = createContext({
|
|
1095
1034
|
onDragStart: () => {
|
|
1096
1035
|
},
|
|
1097
1036
|
nodeViewContentChildren: void 0,
|
|
1098
1037
|
nodeViewContentRef: () => {
|
|
1099
1038
|
}
|
|
1100
1039
|
});
|
|
1101
|
-
var useReactNodeView = () =>
|
|
1102
|
-
var NodeViewWrapper =
|
|
1040
|
+
var useReactNodeView = () => useContext(ReactNodeViewContext);
|
|
1041
|
+
var NodeViewWrapper = React.forwardRef((props, ref) => {
|
|
1103
1042
|
const { onDragStart } = useReactNodeView();
|
|
1104
1043
|
const Tag = props.as || "div";
|
|
1105
|
-
return (
|
|
1106
|
-
|
|
1107
|
-
|
|
1108
|
-
|
|
1109
|
-
|
|
1110
|
-
|
|
1111
|
-
|
|
1112
|
-
|
|
1113
|
-
|
|
1114
|
-
|
|
1115
|
-
whiteSpace: "normal",
|
|
1116
|
-
...props.style
|
|
1117
|
-
}
|
|
1118
|
-
}
|
|
1119
|
-
)
|
|
1120
|
-
);
|
|
1121
|
-
});
|
|
1122
|
-
var ReactMarkViewContext = React4.createContext({
|
|
1123
|
-
markViewContentRef: () => {
|
|
1124
|
-
}
|
|
1125
|
-
});
|
|
1126
|
-
var TiptapContext = createContext3({
|
|
1127
|
-
get editor() {
|
|
1128
|
-
throw new Error("useTiptap must be used within a <Tiptap> provider");
|
|
1129
|
-
}
|
|
1044
|
+
return /* @__PURE__ */ jsx(Tag, {
|
|
1045
|
+
...props,
|
|
1046
|
+
ref,
|
|
1047
|
+
"data-node-view-wrapper": "",
|
|
1048
|
+
onDragStart,
|
|
1049
|
+
style: {
|
|
1050
|
+
whiteSpace: "normal",
|
|
1051
|
+
...props.style
|
|
1052
|
+
}
|
|
1053
|
+
});
|
|
1130
1054
|
});
|
|
1055
|
+
var ReactMarkViewContext = React.createContext({ markViewContentRef: () => {
|
|
1056
|
+
} });
|
|
1057
|
+
var TiptapContext = createContext({ get editor() {
|
|
1058
|
+
throw new Error("useTiptap must be used within a <Tiptap> provider");
|
|
1059
|
+
} });
|
|
1131
1060
|
TiptapContext.displayName = "TiptapContext";
|
|
1132
|
-
var useTiptap = () =>
|
|
1061
|
+
var useTiptap = () => useContext(TiptapContext);
|
|
1133
1062
|
function TiptapWrapper({ children, ...props }) {
|
|
1134
1063
|
const resolvedEditor = "editor" in props ? props.editor : props.instance;
|
|
1135
|
-
if (!resolvedEditor)
|
|
1136
|
-
|
|
1137
|
-
}
|
|
1138
|
-
|
|
1139
|
-
|
|
1140
|
-
|
|
1141
|
-
|
|
1142
|
-
|
|
1143
|
-
|
|
1064
|
+
if (!resolvedEditor) throw new Error("Tiptap: An editor instance is required. Pass a non-null `editor` prop.");
|
|
1065
|
+
const tiptapContextValue = useMemo(() => ({ editor: resolvedEditor }), [resolvedEditor]);
|
|
1066
|
+
const legacyContextValue = useMemo(() => ({ editor: resolvedEditor }), [resolvedEditor]);
|
|
1067
|
+
return /* @__PURE__ */ jsx(EditorContext.Provider, {
|
|
1068
|
+
value: legacyContextValue,
|
|
1069
|
+
children: /* @__PURE__ */ jsx(TiptapContext.Provider, {
|
|
1070
|
+
value: tiptapContextValue,
|
|
1071
|
+
children
|
|
1072
|
+
})
|
|
1073
|
+
});
|
|
1144
1074
|
}
|
|
1145
1075
|
TiptapWrapper.displayName = "Tiptap";
|
|
1146
1076
|
function TiptapContent({ ...rest }) {
|
|
1147
1077
|
const { editor } = useTiptap();
|
|
1148
|
-
return /* @__PURE__ */
|
|
1078
|
+
return /* @__PURE__ */ jsx(EditorContent, {
|
|
1079
|
+
editor,
|
|
1080
|
+
...rest
|
|
1081
|
+
});
|
|
1149
1082
|
}
|
|
1150
1083
|
TiptapContent.displayName = "Tiptap.Content";
|
|
1151
1084
|
var Tiptap = Object.assign(TiptapWrapper, {
|
|
1152
1085
|
/**
|
|
1153
|
-
|
|
1154
|
-
|
|
1155
|
-
|
|
1086
|
+
* The Tiptap Content component that renders the EditorContent with the editor instance from the context.
|
|
1087
|
+
* @see TiptapContent
|
|
1088
|
+
*/
|
|
1156
1089
|
Content: TiptapContent
|
|
1157
1090
|
});
|
|
1158
1091
|
|