alinea 2.0.0-preview.1 → 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.
Files changed (201) hide show
  1. package/dist/.init/content/pages/welcome.json +1 -1
  2. package/dist/LICENSES.md +61 -34
  3. package/dist/adapter/next/DevRemote.d.ts +3 -0
  4. package/dist/adapter/next/DevRemote.js +37 -0
  5. package/dist/adapter/next/ForwardCredentials.d.ts +1 -0
  6. package/dist/adapter/next/ForwardCredentials.js +17 -0
  7. package/dist/adapter/next/cms.js +86 -38
  8. package/dist/adapter/next/context.d.ts +1 -1
  9. package/dist/adapter/next/context.js +11 -3
  10. package/dist/adapter/next/handler.d.ts +2 -0
  11. package/dist/adapter/next/handler.js +23 -16
  12. package/dist/adapter/next/with-alinea.js +18 -16
  13. package/dist/backend/Handler.d.ts +14 -13
  14. package/dist/backend/Handler.js +53 -22
  15. package/dist/backend/resolver/ParsePreview.d.ts +8 -4
  16. package/dist/backend/resolver/ParsePreview.js +40 -43
  17. package/dist/bundled.d.ts +255 -60
  18. package/dist/chunks/{chunk-LUBOGJCG.js → chunk-6V4TAD2N.js} +1 -1
  19. package/dist/chunks/{chunk-TL7ZW6BX.js → chunk-A3XXZBOQ.js} +2535 -2999
  20. package/dist/chunks/chunk-AC5ATYI3.js +1434 -0
  21. package/dist/chunks/{chunk-7ORQ7BYK.js → chunk-KMLLLZ6X.js} +202 -269
  22. package/dist/chunks/{chunk-IWN3T3FL.js → chunk-O7XWTMCB.js} +1 -1
  23. package/dist/chunks/{chunk-53DZYORR.js → chunk-PAYSVIYI.js} +76 -176
  24. package/dist/chunks/{chunk-YK3OSMDM.js → chunk-S4AU6SRS.js} +188 -158
  25. package/dist/chunks/{chunk-FRYHNUEK.js → chunk-UVOEM4AH.js} +6 -3
  26. package/dist/chunks/{chunk-I7X64JTZ.js → chunk-VXZM6V4P.js} +4 -4
  27. package/dist/cli/Generate.js +3 -13
  28. package/dist/cli/Serve.js +7 -3
  29. package/dist/cli/bin.js +8 -5
  30. package/dist/cli/generate/CopyStaticFiles.js +2 -3
  31. package/dist/cli/generate/DevDB.d.ts +1 -1
  32. package/dist/cli/generate/DevDB.js +3 -5
  33. package/dist/cli/serve/CreateLocalServer.d.ts +1 -1
  34. package/dist/cli/serve/CreateLocalServer.js +3 -2
  35. package/dist/cli/serve/DevServer.d.ts +3 -2
  36. package/dist/cli/serve/DevServer.js +60 -3
  37. package/dist/cli/serve/ServeContext.d.ts +1 -0
  38. package/dist/cli/serve/StartServer.d.ts +1 -0
  39. package/dist/cli/serve/StartServer.js +6 -1
  40. package/dist/cli/util/EnsureLibs.js +2 -2
  41. package/dist/cli/util/EnsureNode.js +2 -2
  42. package/dist/cloud/CloudRemote.js +1 -1
  43. package/dist/components/Breadcrumbs.js +8 -8
  44. package/dist/components/Button.js +6 -6
  45. package/dist/components/Calendar.js +9 -9
  46. package/dist/components/Checkbox.js +9 -9
  47. package/dist/components/CheckboxGroup.js +6 -6
  48. package/dist/components/ColorSwatch.js +6 -6
  49. package/dist/components/ColorSwatchPicker.js +6 -6
  50. package/dist/components/ComboBox.js +16 -16
  51. package/dist/components/DateField.js +9 -9
  52. package/dist/components/DatePicker.js +11 -11
  53. package/dist/components/DateRangePicker.js +14 -14
  54. package/dist/components/Dialog.js +6 -6
  55. package/dist/components/Disclosure.js +14 -14
  56. package/dist/components/DropZone.js +6 -6
  57. package/dist/components/Label.js +14 -14
  58. package/dist/components/Link.js +6 -6
  59. package/dist/components/List.js +32 -32
  60. package/dist/components/Menu.js +10 -10
  61. package/dist/components/Modal.js +8 -8
  62. package/dist/components/MultipleSelect.js +25 -25
  63. package/dist/components/NumberField.d.ts +2 -1
  64. package/dist/components/NumberField.js +25 -15
  65. package/dist/components/Popover.js +6 -6
  66. package/dist/components/ProgressCircle.js +9 -9
  67. package/dist/components/RadioGroup.js +8 -8
  68. package/dist/components/SearchField.js +15 -15
  69. package/dist/components/Select.js +14 -14
  70. package/dist/components/Surface.js +2 -2
  71. package/dist/components/Switch.js +8 -8
  72. package/dist/components/Table.js +14 -14
  73. package/dist/components/Tabs.js +7 -7
  74. package/dist/components/TagGroup.js +8 -8
  75. package/dist/components/TextField.js +10 -10
  76. package/dist/components/TimeField.js +8 -8
  77. package/dist/components/Toggle.js +8 -8
  78. package/dist/components/Toolbar.js +9 -9
  79. package/dist/components/Tooltip.js +7 -7
  80. package/dist/components/Tree.js +10 -10
  81. package/dist/core/Client.js +3 -2
  82. package/dist/core/Config.d.ts +4 -0
  83. package/dist/core/Config.js +6 -0
  84. package/dist/core/Connection.d.ts +2 -2
  85. package/dist/core/Connection.js +7 -0
  86. package/dist/core/Graph.d.ts +3 -4
  87. package/dist/core/ListRow.d.ts +2 -0
  88. package/dist/core/OrderBy.d.ts +7 -3
  89. package/dist/core/TextDoc.d.ts +11 -0
  90. package/dist/core/Trace.d.ts +8 -0
  91. package/dist/core/Trace.js +32 -0
  92. package/dist/core/db/CommitRequest.d.ts +0 -3
  93. package/dist/core/db/CommitRequest.js +0 -9
  94. package/dist/core/db/EntryDB.js +1 -1
  95. package/dist/core/db/EntryIndex.d.ts +10 -0
  96. package/dist/core/db/EntryIndex.js +117 -9
  97. package/dist/core/db/EntryResolver.js +104 -29
  98. package/dist/core/db/EntryTransaction.d.ts +1 -2
  99. package/dist/core/db/EntryTransaction.js +25 -13
  100. package/dist/core/db/LocalDB.d.ts +2 -3
  101. package/dist/core/db/LocalDB.js +24 -19
  102. package/dist/core/field/RichTextField.d.ts +30 -3
  103. package/dist/core/field/RichTextField.js +125 -41
  104. package/dist/core/media/MediaAltField.d.ts +1 -0
  105. package/dist/core/media/MediaAltField.js +9 -1
  106. package/dist/core/source/OverlaySource.d.ts +12 -0
  107. package/dist/core/source/OverlaySource.js +50 -0
  108. package/dist/core/source/Source.d.ts +1 -1
  109. package/dist/core/source/Source.js +3 -3
  110. package/dist/dashboard/App.css +158 -0
  111. package/dist/dashboard/App.js +3 -3
  112. package/dist/dashboard/app/AccessDenied.js +1 -1
  113. package/dist/dashboard/app/ActivityStatus.js +14 -14
  114. package/dist/dashboard/app/AppShell.js +2 -2
  115. package/dist/dashboard/app/AuthView.js +12 -12
  116. package/dist/dashboard/app/Badge.js +2 -2
  117. package/dist/dashboard/app/CompactField.js +13 -13
  118. package/dist/dashboard/app/DashboardErrorBoundary.js +6 -6
  119. package/dist/dashboard/app/DashboardLayout.js +22 -19
  120. package/dist/dashboard/app/EntryHeader.js +10 -10
  121. package/dist/dashboard/app/EntryReferences.js +9 -9
  122. package/dist/dashboard/app/EntrySidebar.d.ts +1 -1
  123. package/dist/dashboard/app/EntrySidebar.js +19 -18
  124. package/dist/dashboard/app/EntrySidebarPreview.d.ts +1 -1
  125. package/dist/dashboard/app/EntrySidebarPreview.js +20 -15
  126. package/dist/dashboard/app/EntryTranslationBanner.js +6 -6
  127. package/dist/dashboard/app/Explorer.js +46 -46
  128. package/dist/dashboard/app/ExplorerCards.js +42 -42
  129. package/dist/dashboard/app/ExplorerFileCard.js +16 -16
  130. package/dist/dashboard/app/ExplorerList.js +15 -15
  131. package/dist/dashboard/app/ExplorerModal.js +5 -5
  132. package/dist/dashboard/app/ExplorerTable.js +54 -54
  133. package/dist/dashboard/app/ExternalLinkPicker.js +15 -4
  134. package/dist/dashboard/app/LinkPicker.js +6 -6
  135. package/dist/dashboard/app/LocaleMenu.js +11 -11
  136. package/dist/dashboard/app/SidebarLayout.d.ts +8 -0
  137. package/dist/dashboard/app/SidebarLayout.js +1169 -0
  138. package/dist/dashboard/app/SidebarTree.js +44 -44
  139. package/dist/dashboard/app/WorkspaceMenu.js +17 -17
  140. package/dist/dashboard/app/WorkspaceRoots.js +26 -26
  141. package/dist/dashboard/app/editor/FileEditor.js +28 -29
  142. package/dist/dashboard/app/editor/FilePreview.js +2 -2
  143. package/dist/dashboard/app/editor/MediaAltField.view.d.ts +1 -1
  144. package/dist/dashboard/app/editor/MediaAltField.view.js +6 -9
  145. package/dist/dashboard/app/modals/CreateEntry.js +4 -4
  146. package/dist/dashboard/app/pages/EntryPage.js +49 -25
  147. package/dist/dashboard/app/pages/UsersPage.js +38 -38
  148. package/dist/dashboard/app/ui/DashboardModal.js +22 -22
  149. package/dist/dashboard/app/ui/Rail.js +2 -2
  150. package/dist/dashboard/app/ui/Sidebar.js +2 -2
  151. package/dist/dashboard/atoms/auth.js +2 -0
  152. package/dist/dashboard/atoms/dashboard.d.ts +9 -0
  153. package/dist/dashboard/atoms/dashboard.js +17 -0
  154. package/dist/dashboard/atoms/editor.d.ts +7 -1
  155. package/dist/dashboard/atoms/editor.js +4 -1
  156. package/dist/dashboard/atoms/entry.d.ts +3 -1
  157. package/dist/dashboard/atoms/entry.js +55 -15
  158. package/dist/dashboard/atoms/explorer.js +3 -8
  159. package/dist/dashboard/atoms/preview.d.ts +3 -0
  160. package/dist/dashboard/atoms/preview.js +18 -1
  161. package/dist/dashboard/hooks.d.ts +4 -2
  162. package/dist/dashboard/hooks.js +9 -5
  163. package/dist/dashboard/icons.d.ts +1 -0
  164. package/dist/dashboard/icons.js +10 -0
  165. package/dist/field/check/CheckField.view.js +2 -2
  166. package/dist/field/code/CodeField.view.js +13 -13
  167. package/dist/field/date/DateField.view.js +12 -2
  168. package/dist/field/link/Link.js +2 -2
  169. package/dist/field/link/LinkField.view.js +88 -77
  170. package/dist/field/list/ListField.view.js +22 -33
  171. package/dist/field/metadata/MetadataField.view.js +20 -20
  172. package/dist/field/number/NumberField.d.ts +2 -0
  173. package/dist/field/number/NumberField.view.js +4 -2
  174. package/dist/field/richtext/PickTextLink.d.ts +7 -0
  175. package/dist/field/richtext/PickTextLink.js +104 -2
  176. package/dist/field/richtext/ReferenceLink.d.ts +4 -1
  177. package/dist/field/richtext/ReferenceLink.js +18 -4
  178. package/dist/field/richtext/RichTextDocument.d.ts +7 -2
  179. package/dist/field/richtext/RichTextDocument.js +34 -5
  180. package/dist/field/richtext/RichTextExtensions.d.ts +3 -1
  181. package/dist/field/richtext/RichTextExtensions.js +2704 -7467
  182. package/dist/field/richtext/RichTextField.d.ts +4 -0
  183. package/dist/field/richtext/RichTextField.story.d.ts +4 -0
  184. package/dist/field/richtext/RichTextField.view.js +44 -21
  185. package/dist/field/richtext/RichTextInsertMenu.js +281 -495
  186. package/dist/field/richtext/RichTextToolbar.d.ts +5 -2
  187. package/dist/field/richtext/RichTextToolbar.js +38 -3
  188. package/dist/field/richtext/Toolbar.d.ts +19 -1
  189. package/dist/field/richtext/Toolbar.js +18 -13
  190. package/dist/field/richtext/extensions/Anchor.js +1 -1
  191. package/dist/field/richtext/extensions/Link.js +1 -1
  192. package/dist/field/richtext/extensions/Small.js +1 -1
  193. package/dist/field/select/SelectField.view.js +8 -6
  194. package/dist/index.css +219 -14
  195. package/dist/next.cjs +18 -16
  196. package/dist/next.d.ts +2 -1
  197. package/dist/next.edge.d.ts +2 -1
  198. package/dist/ui/RichText.d.ts +1 -0
  199. package/dist/ui/RichText.js +29 -2
  200. package/package.json +6 -3
  201. package/dist/chunks/{chunk-JFROOUG6.js → chunk-NIVGVRDS.js} +17 -17
@@ -8,11 +8,20 @@ import {
8
8
  import "../../chunks/chunk-CQ52GEHY.js";
9
9
 
10
10
  // src/field/richtext/PickTextLink.tsx
11
- import { Button, TextField } from "alinea/components";
11
+ import { Button, DialogTrigger, TextField } from "alinea/components";
12
+ import { Config } from "alinea/core/Config";
13
+ import { Entry } from "alinea/core/Entry";
14
+ import { createId } from "alinea/core/Id";
15
+ import { imageExtensions } from "alinea/core/media/IsImage";
16
+ import { mediaAltText } from "alinea/core/media/MediaAltField";
17
+ import { MediaFile } from "alinea/core/media/MediaTypes";
12
18
  import { Reference } from "alinea/core/Reference";
13
19
  import { type as createType, Type } from "alinea/core/Type";
14
20
  import { NodeEditor } from "alinea/dashboard/app/EntryFields";
15
21
  import { ReactiveNode } from "alinea/dashboard/atoms/ReactiveNode";
22
+ import { configAtom, graphAtom } from "alinea/dashboard/atoms/core";
23
+ import { useDashboardContext } from "alinea/dashboard/hooks";
24
+ import { ImagePicker } from "alinea/dashboard/app/ImagePicker";
16
25
  import {
17
26
  DashboardModal,
18
27
  DashboardModalCloseButton,
@@ -28,6 +37,7 @@ import { link as createLink } from "alinea/field/link";
28
37
  import {
29
38
  useCallback,
30
39
  useMemo,
40
+ useRef,
31
41
  useState
32
42
  } from "react";
33
43
 
@@ -43,7 +53,12 @@ function usePickTextLink() {
43
53
  const [pending, setPending] = useState();
44
54
  const pickLink = useCallback((options) => {
45
55
  return new Promise((resolve) => {
46
- setPending({ options, resolve });
56
+ setPending({ kind: "link", options, resolve });
57
+ });
58
+ }, []);
59
+ const pickImage = useCallback((options) => {
60
+ return new Promise((resolve) => {
61
+ setPending({ kind: "image", options, resolve });
47
62
  });
48
63
  }, []);
49
64
  const cancel = useCallback(() => {
@@ -60,7 +75,9 @@ function usePickTextLink() {
60
75
  }, []);
61
76
  return {
62
77
  isOpen: Boolean(pending),
78
+ kind: pending?.kind ?? "link",
63
79
  options: pending?.options ?? {},
80
+ pickImage,
64
81
  pickLink,
65
82
  cancel,
66
83
  confirm
@@ -68,6 +85,7 @@ function usePickTextLink() {
68
85
  }
69
86
  function PickTextLink({ picker }) {
70
87
  if (!picker.isOpen) return null;
88
+ if (picker.kind === "image") return /* @__PURE__ */ jsx(PickRichTextImage, { picker });
71
89
  return /* @__PURE__ */ jsx(
72
90
  DashboardModal,
73
91
  {
@@ -79,6 +97,90 @@ function PickTextLink({ picker }) {
79
97
  }
80
98
  );
81
99
  }
100
+ function PickRichTextImage({ picker }) {
101
+ const config = useAtomValue(configAtom);
102
+ const graph = useAtomValue(graphAtom);
103
+ const locale = useDashboardContext().page.locale ?? void 0;
104
+ const confirming = useRef(false);
105
+ const initialEntry = imageReferenceEntryId(picker.options.link);
106
+ const initialSelection = initialEntry ? [initialEntry] : [];
107
+ function onConfirm(selection) {
108
+ const [entryId] = selection;
109
+ if (!entryId) {
110
+ picker.confirm({ link: void 0 });
111
+ return;
112
+ }
113
+ confirming.current = true;
114
+ void resolveRichTextImage(
115
+ config,
116
+ graph,
117
+ entryId,
118
+ picker.options.link,
119
+ locale
120
+ ).then(picker.confirm, (error) => {
121
+ console.error(error);
122
+ picker.cancel();
123
+ });
124
+ }
125
+ return /* @__PURE__ */ jsxs(
126
+ DialogTrigger,
127
+ {
128
+ isOpen: true,
129
+ onOpenChange: (isOpen) => {
130
+ if (!isOpen && !confirming.current) picker.cancel();
131
+ },
132
+ children: [
133
+ /* @__PURE__ */ jsx(Button, { style: { display: "none" }, children: "Pick image" }),
134
+ /* @__PURE__ */ jsx(
135
+ ImagePicker,
136
+ {
137
+ condition: richTextImageCondition,
138
+ initialSelection,
139
+ label: "Pick image",
140
+ selectionBehavior: "replace",
141
+ selectionMode: "single",
142
+ onConfirm
143
+ }
144
+ )
145
+ ]
146
+ }
147
+ );
148
+ }
149
+ async function resolveRichTextImage(config, graph, entryId, existing, locale) {
150
+ const image = await graph.first({
151
+ id: entryId,
152
+ status: "preferDraft",
153
+ select: {
154
+ url: Entry.url,
155
+ alt: MediaFile.alt
156
+ }
157
+ });
158
+ if (!image) throw new Error(`Image entry not found: ${entryId}`);
159
+ const link = {
160
+ [Reference.id]: existing?._id ?? createId(),
161
+ [Reference.type]: "image",
162
+ _entry: entryId
163
+ };
164
+ return {
165
+ alt: mediaAltText(image.alt, locale),
166
+ link,
167
+ src: URL.parse(image.url, Config.baseUrl(config) ?? window.location.href)?.href
168
+ };
169
+ }
170
+ var richTextImageCondition = {
171
+ _type: "MediaFile",
172
+ extension: {
173
+ in: [
174
+ ...imageExtensions,
175
+ ...imageExtensions.map((extension) => extension.toUpperCase())
176
+ ]
177
+ }
178
+ };
179
+ function imageReferenceEntryId(reference) {
180
+ if (!reference || reference._type !== "image" || !("_entry" in reference))
181
+ return;
182
+ return typeof reference._entry === "string" ? reference._entry : void 0;
183
+ }
82
184
  function PickTextLinkForm({ picker }) {
83
185
  const modal = useDashboardModal();
84
186
  const options = picker.options;
@@ -1,10 +1,13 @@
1
1
  import { Reference } from 'alinea/core/Reference';
2
2
  import type { HTMLProps } from 'react';
3
3
  interface Anchor extends HTMLProps<HTMLAnchorElement> {
4
+ _id?: string;
5
+ _entry?: string;
6
+ _link?: 'entry' | 'file' | 'image' | 'url';
4
7
  'data-id'?: string;
5
8
  'data-entry'?: string;
6
9
  'data-anchor'?: string;
7
- 'data-link'?: 'entry' | 'file' | 'url';
10
+ 'data-link'?: 'entry' | 'file' | 'image' | 'url';
8
11
  'data-suffix'?: string;
9
12
  }
10
13
  export declare function referenceToAttributes(reference: Reference): Anchor;
@@ -42,12 +42,26 @@ function referenceToAttributes(reference) {
42
42
  target: void 0
43
43
  };
44
44
  }
45
+ case "image": {
46
+ const ref = reference;
47
+ return {
48
+ "data-id": ref[Reference.id],
49
+ "data-entry": ref[EntryReference.entry],
50
+ "data-anchor": void 0,
51
+ "data-link": "image",
52
+ "data-suffix": void 0,
53
+ href: void 0,
54
+ target: void 0
55
+ };
56
+ }
45
57
  default:
46
58
  throw new Error(`Unexpected reference type: ${reference[Reference.type]}`);
47
59
  }
48
60
  }
49
61
  function attributesToReference(attributes) {
50
- const id = attributes["data-id"];
62
+ const id = attributes["data-id"] ?? attributes._id;
63
+ const entry = attributes["data-entry"] ?? attributes._entry;
64
+ const link = attributes["data-link"] ?? attributes._link;
51
65
  if (!id) {
52
66
  if (attributes.href)
53
67
  return {
@@ -58,12 +72,12 @@ function attributesToReference(attributes) {
58
72
  };
59
73
  return;
60
74
  }
61
- if (attributes["data-entry"]) {
62
- const type = attributes["data-link"] === "file" ? "file" : "entry";
75
+ if (entry) {
76
+ const type = link === "file" ? "file" : link === "image" ? "image" : "entry";
63
77
  return {
64
78
  [Reference.id]: id,
65
79
  [Reference.type]: type,
66
- [EntryReference.entry]: attributes["data-entry"],
80
+ [EntryReference.entry]: entry,
67
81
  [EntryReference.anchor]: type === "entry" ? attributes["data-anchor"] : void 0,
68
82
  [EntryReference.suffix]: type === "entry" ? attributes["data-suffix"] : void 0
69
83
  };
@@ -1,4 +1,9 @@
1
1
  import { BlockNode, type TextDoc } from 'alinea/core/TextDoc';
2
- import type { JSONContent } from '@tiptap/core';
3
- export declare function editorContent(nodes: TextDoc): JSONContent;
2
+ import { type Editor, type JSONContent } from '@tiptap/core';
3
+ /** Include data attributes produced by custom extensions in the stored document. */
4
+ export declare function editorDocument(editor: Editor): JSONContent;
5
+ export declare function editorContent(nodes: TextDoc, images?: ReadonlyMap<string, {
6
+ src: string;
7
+ alt: string;
8
+ }>): JSONContent;
4
9
  export declare function editorNodes(content: JSONContent, resolveBlock?: (id: string, typeName: string, snapshot: BlockNode | undefined) => BlockNode | undefined): TextDoc;
@@ -1,3 +1,6 @@
1
+ import {
2
+ getRenderedAttributes
3
+ } from "../../chunks/chunk-A3XXZBOQ.js";
1
4
  import "../../chunks/chunk-CQ52GEHY.js";
2
5
 
3
6
  // src/field/richtext/RichTextDocument.ts
@@ -14,17 +17,37 @@ import {
14
17
  richTextBlockValueAttribute
15
18
  } from "./RichTextBlockValue.js";
16
19
  import { isRecord } from "alinea/core/util/Objects";
17
- function editorContent(nodes) {
20
+ function editorDocument(editor) {
21
+ function serialize(node) {
22
+ const content = node.toJSON();
23
+ if (!node.isText) {
24
+ const dataAttributes = Object.fromEntries(
25
+ Object.entries(
26
+ getRenderedAttributes(node, editor.extensionManager.attributes)
27
+ ).filter(([key, value]) => key.startsWith("data-") && value != null)
28
+ );
29
+ if (Object.keys(dataAttributes).length)
30
+ content.attrs = { ...content.attrs, ...dataAttributes };
31
+ if (node.childCount) {
32
+ content.content = [];
33
+ node.forEach((child) => content.content.push(serialize(child)));
34
+ }
35
+ }
36
+ return content;
37
+ }
38
+ return serialize(editor.state.doc);
39
+ }
40
+ function editorContent(nodes, images) {
18
41
  return {
19
42
  type: "doc",
20
- content: nodes.map(nodeToContent)
43
+ content: nodes.length ? nodes.map((node) => nodeToContent(node, images)) : [{ type: "paragraph" }]
21
44
  };
22
45
  }
23
46
  function editorNodes(content, resolveBlock) {
24
47
  const nodes = content.content?.flatMap((node) => contentToNodes(node, resolveBlock)) ?? [];
25
48
  return isEmptyDocument(nodes) ? [] : nodes;
26
49
  }
27
- function nodeToContent(node) {
50
+ function nodeToContent(node, images) {
28
51
  if (isBlock(node)) {
29
52
  return {
30
53
  type: node[Node.type],
@@ -40,6 +63,7 @@ function nodeToContent(node) {
40
63
  }
41
64
  if (isElement(node)) {
42
65
  const { [Node.type]: type, [ElementNode.content]: content, ...attrs } = node;
66
+ const resolvedImage = type === "image" && typeof attrs._entry === "string" ? images?.get(attrs._entry) : void 0;
43
67
  let editorContent2 = content;
44
68
  if (type === "listItem" && content?.some(isText)) {
45
69
  let flushInline2 = function() {
@@ -66,8 +90,8 @@ function nodeToContent(node) {
66
90
  }
67
91
  return {
68
92
  type,
69
- attrs: withoutNullish(attrs),
70
- content: editorContent2?.map(nodeToContent)
93
+ attrs: withoutNullish({ ...attrs, ...resolvedImage }),
94
+ content: editorContent2?.map((child) => nodeToContent(child, images))
71
95
  };
72
96
  }
73
97
  throw new TypeError(
@@ -98,6 +122,10 @@ function contentToNodes(content, resolveBlock) {
98
122
  return [node];
99
123
  }
100
124
  const { [richTextBlockValueAttribute]: _blockSnapshot, ...elementAttributes } = attrs ?? {};
125
+ if (type === "image" && elementAttributes._link === "image" && typeof elementAttributes._entry === "string") {
126
+ delete elementAttributes.src;
127
+ delete elementAttributes.alt;
128
+ }
101
129
  const children = content.content?.flatMap(
102
130
  (node) => contentToNodes(node, resolveBlock)
103
131
  );
@@ -158,5 +186,6 @@ function isMatchingBlock(value, id, typeName) {
158
186
  }
159
187
  export {
160
188
  editorContent,
189
+ editorDocument,
161
190
  editorNodes
162
191
  };
@@ -13,6 +13,7 @@ export declare const extensions: {
13
13
  Italic: import("@tiptap/core").Mark<import("@tiptap/extension-italic").ItalicOptions, any>;
14
14
  Strike: import("@tiptap/core").Mark<import("@tiptap/extension-strike").StrikeOptions, any>;
15
15
  HorizontalRule: TipTapNode<import("@tiptap/extension-horizontal-rule").HorizontalRuleOptions, any>;
16
+ Image: TipTapNode<import("@tiptap/extension-image").ImageOptions, any>;
16
17
  BulletList: TipTapNode<import("@tiptap/extension-list").BulletListOptions, any>;
17
18
  OrderedList: TipTapNode<import("@tiptap/extension-list").OrderedListOptions, any>;
18
19
  ListItem: TipTapNode<import("@tiptap/extension-list").ListItemOptions, any>;
@@ -33,7 +34,7 @@ export declare const extensions: {
33
34
  Highlight: import("@tiptap/core").Mark<import("@tiptap/extension-highlight").HighlightOptions, any>;
34
35
  UndoRedo: Extension<import("@tiptap/extensions").UndoRedoOptions, any>;
35
36
  };
36
- export declare function defaultExtensionConfig(getEntryAnchors?: () => Iterable<string>): {
37
+ export declare function defaultExtensionConfig(getEntryAnchors?: () => Iterable<string>, enableImageResize?: boolean): {
37
38
  Document: TipTapNode<any, any>;
38
39
  Text: TipTapNode<any, any>;
39
40
  Paragraph: TipTapNode<import("@tiptap/extension-paragraph").ParagraphOptions, any>;
@@ -43,6 +44,7 @@ export declare function defaultExtensionConfig(getEntryAnchors?: () => Iterable<
43
44
  Italic: import("@tiptap/core").Mark<import("@tiptap/extension-italic").ItalicOptions, any>;
44
45
  Strike: import("@tiptap/core").Mark<import("@tiptap/extension-strike").StrikeOptions, any>;
45
46
  HorizontalRule: TipTapNode<import("@tiptap/extension-horizontal-rule").HorizontalRuleOptions, any>;
47
+ Image: TipTapNode<import("@tiptap/extension-image").ImageOptions, any>;
46
48
  BulletList: TipTapNode<import("@tiptap/extension-list").BulletListOptions, any>;
47
49
  OrderedList: TipTapNode<import("@tiptap/extension-list").OrderedListOptions, any>;
48
50
  ListItem: TipTapNode<import("@tiptap/extension-list").ListItemOptions, any>;