@phtngyn/cms 0.2.0-beta.3 → 0.2.0-beta.5
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/README.md +31 -13
- package/package.json +7 -7
- package/src/ApplicationTypes.d.ts +3 -3
- package/src/Authoring.d.ts +11 -3
- package/src/{Configuration-BU-UyGoH.js → Configuration-JQ1qyaU0.js} +347 -189
- package/src/Configuration-JQ1qyaU0.js.map +1 -0
- package/src/Configuration.d.ts +1 -1
- package/src/Content.d.ts +7 -6
- package/src/Content.js +106 -47
- package/src/Content.js.map +1 -1
- package/src/ContentTransfer-BxwswWn3.js +86 -0
- package/src/ContentTransfer-BxwswWn3.js.map +1 -0
- package/src/{ContentTransfer-CRQet3QJ.d.ts → ContentTransfer-Z9FHyLez.d.ts} +33 -9
- package/src/{DocumentEngine-ClhFXW9M.js → DocumentEngine-j6Vi7nQo.js} +279 -178
- package/src/DocumentEngine-j6Vi7nQo.js.map +1 -0
- package/src/DocumentModel.d.ts +9 -2
- package/src/DocumentModel.js +17 -4
- package/src/DocumentModel.js.map +1 -1
- package/src/{Forms-DoB56hfe.js → Forms-CX-hwmJF.js} +18 -11
- package/src/Forms-CX-hwmJF.js.map +1 -0
- package/src/{Forms-BbkE7QfC.js → Forms-CfNPTiCr.js} +2 -2
- package/src/{Forms-BbkE7QfC.js.map → Forms-CfNPTiCr.js.map} +1 -1
- package/src/Media-j1bTritO.js +112 -0
- package/src/Media-j1bTritO.js.map +1 -0
- package/src/Module.js +0 -4
- package/src/Module.js.map +1 -1
- package/src/References-CCPDAPve.js +45 -0
- package/src/References-CCPDAPve.js.map +1 -0
- package/src/{S3MediaObjects-CR3p1WTg.js → S3MediaObjects-BRuPQbxl.js} +454 -516
- package/src/S3MediaObjects-BRuPQbxl.js.map +1 -0
- package/src/cli/content.js +6 -5
- package/src/cli/content.js.map +1 -1
- package/src/cli.js +16 -3
- package/src/cli.js.map +1 -1
- package/src/{connection-D5S9Iph-.js → connection-BP80q4d-.js} +2 -2
- package/src/{connection-D5S9Iph-.js.map → connection-BP80q4d-.js.map} +1 -1
- package/src/{dev-lifecycle-D3f9-upa.js → dev-lifecycle-DdBluSiR.js} +26 -6
- package/src/dev-lifecycle-DdBluSiR.js.map +1 -0
- package/src/{installation-fZtNxtoW.js → installation-BoG8E3nJ.js} +7982 -7155
- package/src/installation-BoG8E3nJ.js.map +1 -0
- package/src/internal/authoring-catalog.js +2 -2
- package/src/internal/authoring-compiler.js +35 -9
- package/src/internal/authoring-compiler.js.map +1 -1
- package/src/internal/authoring-metadata.js +14 -5
- package/src/internal/authoring-metadata.js.map +1 -1
- package/src/internal/configuration.js +27 -3
- package/src/internal/configuration.js.map +1 -1
- package/src/internal/dev-lifecycle.js +2 -2
- package/src/internal/document-model.js +134 -43
- package/src/internal/document-model.js.map +1 -1
- package/src/internal/field-metadata.js +2 -1
- package/src/internal/field-metadata.js.map +1 -1
- package/src/internal/form-capabilities.js +1 -1
- package/src/{location-CPX7oj0o.js → location-CMNGO3lU.js} +2 -2
- package/src/{location-CPX7oj0o.js.map → location-CMNGO3lU.js.map} +1 -1
- package/src/{metadata-BEZPWh-3.js → metadata-UzZmjwxM.js} +2 -2
- package/src/{metadata-BEZPWh-3.js.map → metadata-UzZmjwxM.js.map} +1 -1
- package/src/{models-C9kF9JlQ.js → models-5j67LMqW.js} +4 -4
- package/src/{models-C9kF9JlQ.js.map → models-5j67LMqW.js.map} +1 -1
- package/src/{models-ChRxBChy.js → models-VmGmG19-.js} +42 -130
- package/src/models-VmGmG19-.js.map +1 -0
- package/src/runtime/delivery/DocumentRenderer.js +5 -1
- package/src/runtime/delivery/DocumentRenderer.js.map +1 -1
- package/src/runtime/delivery/context.js +1 -1
- package/src/runtime/delivery/document-page.js +1 -5
- package/src/runtime/delivery/document-page.js.map +1 -1
- package/src/runtime/delivery/plugin.js +34 -5
- package/src/runtime/delivery/plugin.js.map +1 -1
- package/src/runtime/delivery/preview.d.ts +1 -1
- package/src/runtime/delivery/types.d.ts +1 -1
- package/src/runtime/delivery/useCmsDocumentSeo.d.ts +2 -1
- package/src/runtime/delivery/useCmsDocumentSeo.js +5 -4
- package/src/runtime/delivery/useCmsDocumentSeo.js.map +1 -1
- package/src/runtime/forms/document.js +2 -2
- package/src/runtime/forms/useCmsForm.js +2 -2
- package/src/runtime/installation.js +1 -1
- package/src/runtime/plugin.js +1 -1
- package/src/runtime/preview/CmsStudioPreviewMarker.js +18 -4
- package/src/runtime/preview/CmsStudioPreviewMarker.js.map +1 -1
- package/src/runtime/preview/connection.js +1 -1
- package/src/runtime/preview/controller.js +65 -74
- package/src/runtime/preview/controller.js.map +1 -1
- package/src/runtime/preview/overlay.js +85 -28
- package/src/runtime/preview/overlay.js.map +1 -1
- package/src/runtime/preview/plugin.client.js +4 -4
- package/src/runtime/preview/preview.css +50 -36
- package/src/runtime/preview/protocol.d.ts +11 -5
- package/src/runtime/preview/protocol.js +17 -5
- package/src/runtime/preview/protocol.js.map +1 -1
- package/src/runtime/preview/regions.js +142 -0
- package/src/runtime/preview/regions.js.map +1 -0
- package/src/runtime/preview/store.js +1 -1
- package/src/runtime/sitemap.js +9 -10
- package/src/runtime/sitemap.js.map +1 -1
- package/src/{scalars-B2lgGUnj.js → scalars-CVZqT3L0.js} +2 -6
- package/src/scalars-CVZqT3L0.js.map +1 -0
- package/src/{store-CCsjHaZm.js → store-PKKB8xa2.js} +49 -66
- package/src/store-PKKB8xa2.js.map +1 -0
- package/src/{types-DutFRtaG.d.ts → types-DZ0IV-Ow.d.ts} +14 -3
- package/studio/CreateDocumentDialog-vQ8hDs2C.js +253 -0
- package/studio/{documentPlanning-CDb31mnl.js → documentPlanning-Bx3W9KkD.js} +12054 -12085
- package/studio/{editor-Bzlh3zXt.js → editor-P2rB7Csp.js} +11228 -11927
- package/studio/host.css +1 -1
- package/studio/host.js +23595 -24903
- package/studio/rolldown-runtime-Dy4uBu1J.js +11 -0
- package/src/Configuration-BU-UyGoH.js.map +0 -1
- package/src/ContentTransfer-BhF9G56s.js +0 -57
- package/src/ContentTransfer-BhF9G56s.js.map +0 -1
- package/src/DocumentEngine-ClhFXW9M.js.map +0 -1
- package/src/Forms-DoB56hfe.js.map +0 -1
- package/src/S3MediaObjects-CR3p1WTg.js.map +0 -1
- package/src/dev-lifecycle-D3f9-upa.js.map +0 -1
- package/src/installation-fZtNxtoW.js.map +0 -1
- package/src/models-ChRxBChy.js.map +0 -1
- package/src/runtime/preview/targets.js +0 -101
- package/src/runtime/preview/targets.js.map +0 -1
- package/src/scalars-B2lgGUnj.js.map +0 -1
- package/src/store-CCsjHaZm.js.map +0 -1
- package/studio/CreateDocumentDialog-DJ8c0WZb.js +0 -256
- package/studio/dom-to-image-more.min-D6jGGdrW.js +0 -877
- package/studio/rolldown-runtime-B0aSnxlc.js +0 -20
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { o as PublicPath, r as DocumentId } from "./scalars-
|
|
2
|
-
import {
|
|
3
|
-
import { f as mutableJson, p as mutableJsonObject } from "./Forms-
|
|
4
|
-
import { n as editorMetadata } from "./metadata-
|
|
1
|
+
import { o as PublicPath, r as DocumentId } from "./scalars-CVZqT3L0.js";
|
|
2
|
+
import { it as CollectionName, n as CmsMarkdownDocument } from "./models-VmGmG19-.js";
|
|
3
|
+
import { f as mutableJson, p as mutableJsonObject } from "./Forms-CX-hwmJF.js";
|
|
4
|
+
import { n as editorMetadata } from "./metadata-UzZmjwxM.js";
|
|
5
5
|
import { prepareFormDocument } from "./runtime/forms/document.js";
|
|
6
|
-
import {
|
|
6
|
+
import { CMS_PREVIEW_EDGE_PROPERTY, CMS_PREVIEW_KIND_PROPERTY, CMS_PREVIEW_MARKER_TAG, CMS_PREVIEW_NODE_PROPERTY } from "./runtime/preview/protocol.js";
|
|
7
7
|
import { toPreviewRenderDocument } from "./runtime/preview/comark-document.js";
|
|
8
8
|
import { Predicate, Result, Schema } from "effect";
|
|
9
9
|
import { shallowRef } from "vue";
|
|
@@ -37,16 +37,6 @@ const NATIVE_BLOCK_TAGS = /* @__PURE__ */ new Set([
|
|
|
37
37
|
"tr",
|
|
38
38
|
"ul"
|
|
39
39
|
]);
|
|
40
|
-
const INLINE_TAGS = /* @__PURE__ */ new Set([
|
|
41
|
-
"a",
|
|
42
|
-
"br",
|
|
43
|
-
"code",
|
|
44
|
-
"del",
|
|
45
|
-
"em",
|
|
46
|
-
"img",
|
|
47
|
-
"strong",
|
|
48
|
-
"u"
|
|
49
|
-
]);
|
|
50
40
|
function projectPreviewDocument(body, markers) {
|
|
51
41
|
return Result.try({
|
|
52
42
|
try: () => projectPreviewDocumentUnsafe(body, markers),
|
|
@@ -59,8 +49,8 @@ function projectPreviewDocument(body, markers) {
|
|
|
59
49
|
function projectPreviewDocumentUnsafe(body, markers) {
|
|
60
50
|
const fallbacks = {};
|
|
61
51
|
let identifiedTargets = 0;
|
|
62
|
-
|
|
63
|
-
if (Predicate.isString(node) || node[0] === null) return mutableJson(node);
|
|
52
|
+
function cloneNode(node, componentId, slotId) {
|
|
53
|
+
if (Predicate.isString(node) || node[0] === null) return [mutableJson(node)];
|
|
64
54
|
const [tag, originalAttributes, ...originalChildren] = node;
|
|
65
55
|
const isSlot = tag === "template";
|
|
66
56
|
const isNative = NATIVE_BLOCK_TAGS.has(tag);
|
|
@@ -69,44 +59,33 @@ function projectPreviewDocumentUnsafe(body, markers) {
|
|
|
69
59
|
const id = metadata?.nodeId;
|
|
70
60
|
if (id) {
|
|
71
61
|
identifiedTargets++;
|
|
72
|
-
|
|
73
|
-
if (
|
|
74
|
-
attributes[markers.nodeAttribute] = id;
|
|
75
|
-
attributes[markers.targetAttribute] = "component";
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
const children = [...cloneNodes(originalChildren, !isNative && !isSlot && id ? id : componentId)];
|
|
79
|
-
if (id && metadata?.implicitSlotId && !isNative && !isSlot && hasImplicitDefaultContent(originalChildren)) {
|
|
80
|
-
const slotId = metadata.implicitSlotId;
|
|
81
|
-
fallbacks[slotId] = id;
|
|
82
|
-
const markerChildren = hasInlineImplicitDefaultContent(originalChildren) ? children.splice(0) : [];
|
|
83
|
-
const markerAttributes = {
|
|
84
|
-
[markers.nodeAttribute]: slotId,
|
|
85
|
-
[markers.targetAttribute]: "slot",
|
|
86
|
-
[markers.wrapperAttribute]: ""
|
|
87
|
-
};
|
|
88
|
-
if (markerChildren.length) markerAttributes[markers.inlineHostAttribute] = "";
|
|
89
|
-
children.unshift([
|
|
90
|
-
markers.markerTag,
|
|
91
|
-
markerAttributes,
|
|
92
|
-
...markerChildren
|
|
93
|
-
]);
|
|
62
|
+
const parentId = slotId ?? componentId;
|
|
63
|
+
if (parentId) fallbacks[id] = parentId;
|
|
94
64
|
}
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
65
|
+
const nextComponentId = !isNative && !isSlot && id ? id : componentId;
|
|
66
|
+
const implicitSlotId = id && metadata?.implicitSlotId && !isNative && !isSlot && hasImplicitDefaultContent(originalChildren) ? metadata.implicitSlotId : void 0;
|
|
67
|
+
const children = originalChildren.flatMap((child) => {
|
|
68
|
+
const childSlotId = explicitSlotId(child) ?? (isSlot ? id : implicitSlotId) ?? slotId;
|
|
69
|
+
const projected = cloneNode(child, nextComponentId, childSlotId);
|
|
70
|
+
return implicitSlotId && !isSlot && !isSlotNode(child) ? previewRange(implicitSlotId, "field", projected, markers) : projected;
|
|
71
|
+
});
|
|
72
|
+
if (id && implicitSlotId) fallbacks[implicitSlotId] = id;
|
|
73
|
+
if (isSlot && id && componentId) fallbacks[id] = componentId;
|
|
100
74
|
const cloned = [
|
|
101
75
|
tag,
|
|
102
76
|
attributes,
|
|
103
77
|
...children
|
|
104
78
|
];
|
|
105
|
-
if (id &&
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
79
|
+
if (isSlot && id && componentId) return [[
|
|
80
|
+
tag,
|
|
81
|
+
attributes,
|
|
82
|
+
...previewRange(id, "field", children, markers)
|
|
83
|
+
]];
|
|
84
|
+
if (id && isNative) return previewRange(id, "native", [cloned], markers);
|
|
85
|
+
if (id && !isSlot) return previewRange(id, "component", [cloned], markers);
|
|
86
|
+
return [cloned];
|
|
87
|
+
}
|
|
88
|
+
const nodes = body.nodes.flatMap((node) => cloneNode(node));
|
|
110
89
|
if (body.nodes.length && !identifiedTargets) throw new Error("Studio preview requires an identified authoring document.");
|
|
111
90
|
return {
|
|
112
91
|
body: CmsMarkdownDocument.make({
|
|
@@ -117,23 +96,28 @@ function projectPreviewDocumentUnsafe(body, markers) {
|
|
|
117
96
|
fallbacks
|
|
118
97
|
};
|
|
119
98
|
}
|
|
120
|
-
function
|
|
99
|
+
function previewRange(nodeId, kind, children, markers) {
|
|
100
|
+
const marker = (edge) => [markers.tag, {
|
|
101
|
+
[markers.edgeProperty]: edge,
|
|
102
|
+
[markers.kindProperty]: kind,
|
|
103
|
+
[markers.nodeProperty]: nodeId
|
|
104
|
+
}];
|
|
121
105
|
return [
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
[markers.targetAttribute]: kind,
|
|
126
|
-
[markers.wrapperAttribute]: ""
|
|
127
|
-
},
|
|
128
|
-
child
|
|
106
|
+
marker("start"),
|
|
107
|
+
...children,
|
|
108
|
+
marker("end")
|
|
129
109
|
];
|
|
130
110
|
}
|
|
111
|
+
function explicitSlotId(node) {
|
|
112
|
+
if (Predicate.isString(node) || node[0] !== "template") return void 0;
|
|
113
|
+
return editorMetadata(node[1])?.nodeId;
|
|
114
|
+
}
|
|
115
|
+
function isSlotNode(node) {
|
|
116
|
+
return !Predicate.isString(node) && node[0] === "template";
|
|
117
|
+
}
|
|
131
118
|
function hasImplicitDefaultContent(nodes) {
|
|
132
119
|
return !nodes.some((node) => Array.isArray(node) && node[0] === "template" && node[1].name === "default") && nodes.some((node) => Predicate.isString(node) ? Boolean(node) : node[0] !== "template");
|
|
133
120
|
}
|
|
134
|
-
function hasInlineImplicitDefaultContent(nodes) {
|
|
135
|
-
return nodes.length > 0 && nodes.every((node) => Predicate.isString(node) || Array.isArray(node) && node[0] !== null && INLINE_TAGS.has(node[0]));
|
|
136
|
-
}
|
|
137
121
|
|
|
138
122
|
//#endregion
|
|
139
123
|
//#region src/runtime/preview/store.ts
|
|
@@ -211,11 +195,10 @@ function renderedDocuments(registrations, patches) {
|
|
|
211
195
|
}
|
|
212
196
|
function createPreviewDocument(body) {
|
|
213
197
|
const projection = projectPreviewDocument(body, {
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
wrapperAttribute: CMS_PREVIEW_WRAPPER_ATTRIBUTE
|
|
198
|
+
edgeProperty: CMS_PREVIEW_EDGE_PROPERTY,
|
|
199
|
+
kindProperty: CMS_PREVIEW_KIND_PROPERTY,
|
|
200
|
+
nodeProperty: CMS_PREVIEW_NODE_PROPERTY,
|
|
201
|
+
tag: CMS_PREVIEW_MARKER_TAG
|
|
219
202
|
});
|
|
220
203
|
if (Result.isFailure(projection)) throw projection.failure;
|
|
221
204
|
return projection.success;
|
|
@@ -223,4 +206,4 @@ function createPreviewDocument(body) {
|
|
|
223
206
|
|
|
224
207
|
//#endregion
|
|
225
208
|
export { createStudioPreviewStore as t };
|
|
226
|
-
//# sourceMappingURL=store-
|
|
209
|
+
//# sourceMappingURL=store-PKKB8xa2.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"store-PKKB8xa2.js","names":["CmsMarkdownDocumentSchema"],"sources":["../../../../document/src/PreviewProjection.ts","../../../src/runtime/preview/store.ts"],"sourcesContent":["import type { CmsMarkdownDocument, MarkdownNode } from '@internal/protocol/Documents'\nimport type { EditorNodeId } from '@internal/protocol/Documents'\nimport { CmsMarkdownDocument as CmsMarkdownDocumentSchema } from '@internal/protocol/Documents'\nimport { Predicate, Result, Schema } from 'effect'\nimport { mutableJson, mutableJsonObject } from './internal/comark/document-adapter'\nimport { editorMetadata } from './internal/editor/metadata'\n\nexport interface PreviewProjectionMarkers {\n readonly edgeProperty: string\n readonly kindProperty: string\n readonly nodeProperty: string\n readonly tag: string\n}\n\nexport interface PreviewProjection {\n readonly body: CmsMarkdownDocument\n readonly fallbacks: Readonly<Record<string, string>>\n}\n\nexport class PreviewProjectionInvalid extends Schema.TaggedError<PreviewProjectionInvalid>()(\n 'PreviewProjection.Invalid',\n {\n message: Schema.NonEmptyString,\n cause: Schema.Defect(),\n },\n) {}\n\nconst NATIVE_BLOCK_TAGS = new Set([\n 'blockquote',\n 'h1',\n 'h2',\n 'h3',\n 'h4',\n 'h5',\n 'h6',\n 'hr',\n 'img',\n 'li',\n 'math',\n 'ol',\n 'p',\n 'pre',\n 'table',\n 'tbody',\n 'td',\n 'th',\n 'thead',\n 'tr',\n 'ul',\n])\n\nexport function projectPreviewDocument(\n body: CmsMarkdownDocument,\n markers: PreviewProjectionMarkers,\n): Result.Result<PreviewProjection, PreviewProjectionInvalid> {\n return Result.try({\n try: () => projectPreviewDocumentUnsafe(body, markers),\n catch: (cause) =>\n new PreviewProjectionInvalid({\n cause,\n message: cause instanceof Error && cause.message ? cause.message : 'The preview projection is invalid.',\n }),\n })\n}\n\nfunction projectPreviewDocumentUnsafe(body: CmsMarkdownDocument, markers: PreviewProjectionMarkers): PreviewProjection {\n const fallbacks: Record<string, string> = {}\n let identifiedTargets = 0\n\n function cloneNode(\n node: MarkdownNode,\n componentId?: EditorNodeId,\n slotId?: EditorNodeId,\n ): ReadonlyArray<Schema.Json> {\n if (Predicate.isString(node) || node[0] === null) return [mutableJson(node)]\n const [tag, originalAttributes, ...originalChildren] = node\n const isSlot = tag === 'template'\n const isNative = NATIVE_BLOCK_TAGS.has(tag)\n const attributes = mutableJsonObject(originalAttributes)\n const metadata = editorMetadata(attributes)\n const id = metadata?.nodeId\n\n if (id) {\n identifiedTargets++\n const parentId = slotId ?? componentId\n\n if (parentId) fallbacks[id] = parentId\n }\n\n const nextComponentId = !isNative && !isSlot && id ? id : componentId\n\n const implicitSlotId =\n id && metadata?.implicitSlotId && !isNative && !isSlot && hasImplicitDefaultContent(originalChildren)\n ? metadata.implicitSlotId\n : undefined\n\n const children = originalChildren.flatMap((child) => {\n const childSlotId = explicitSlotId(child) ?? (isSlot ? id : implicitSlotId) ?? slotId\n const projected = cloneNode(child, nextComponentId, childSlotId)\n\n return implicitSlotId && !isSlot && !isSlotNode(child)\n ? previewRange(implicitSlotId, 'field', projected, markers)\n : projected\n })\n\n if (id && implicitSlotId) fallbacks[implicitSlotId] = id\n\n if (isSlot && id && componentId) fallbacks[id] = componentId\n\n const cloned: Schema.Json = [tag, attributes, ...children]\n\n if (isSlot && id && componentId) return [[tag, attributes, ...previewRange(id, 'field', children, markers)]]\n\n if (id && isNative) return previewRange(id, 'native', [cloned], markers)\n\n if (id && !isSlot) return previewRange(id, 'component', [cloned], markers)\n\n return [cloned]\n }\n\n const nodes = body.nodes.flatMap((node) => cloneNode(node))\n\n if (body.nodes.length && !identifiedTargets)\n throw new Error('Studio preview requires an identified authoring document.')\n\n return {\n body: CmsMarkdownDocumentSchema.make({\n frontmatter: mutableJsonObject(body.frontmatter),\n meta: mutableJsonObject(body.meta),\n nodes,\n }),\n fallbacks,\n }\n}\n\nfunction previewRange(\n nodeId: EditorNodeId,\n kind: 'component' | 'field' | 'native',\n children: ReadonlyArray<Schema.Json>,\n markers: PreviewProjectionMarkers,\n): ReadonlyArray<Schema.Json> {\n const marker = (edge: 'end' | 'start'): Schema.Json => [\n markers.tag,\n {\n [markers.edgeProperty]: edge,\n [markers.kindProperty]: kind,\n [markers.nodeProperty]: nodeId,\n },\n ]\n\n return [marker('start'), ...children, marker('end')]\n}\n\nfunction explicitSlotId(node: MarkdownNode): EditorNodeId | undefined {\n if (Predicate.isString(node) || node[0] !== 'template') return undefined\n\n return editorMetadata(node[1])?.nodeId\n}\n\nfunction isSlotNode(node: MarkdownNode): boolean {\n return !Predicate.isString(node) && node[0] === 'template'\n}\n\nfunction hasImplicitDefaultContent(nodes: ReadonlyArray<MarkdownNode>): boolean {\n const hasExplicitDefault = nodes.some(\n (node) => Array.isArray(node) && node[0] === 'template' && node[1].name === 'default',\n )\n\n return (\n !hasExplicitDefault && nodes.some((node) => (Predicate.isString(node) ? Boolean(node) : node[0] !== 'template'))\n )\n}\n","import { prepareFormDocument } from '../forms/document'\nimport type { ComponentDefinition } from '@internal/protocol/Configuration'\nimport type { RenderedCompiledDocument, RenderedDocumentManifest } from '@internal/protocol/Preview'\nimport { projectPreviewDocument } from '@internal/document/PreviewProjection'\nimport { CollectionName } from '@internal/protocol/Configuration'\nimport { DocumentId, PublicPath } from '@internal/protocol/Documents'\nimport { Result } from 'effect'\nimport { createComarkContext } from 'comark'\nimport { shallowRef } from 'vue'\nimport type { DeliveryDocument as PreviewCompiledDocument } from '../delivery/types'\nimport type { DocumentPreviewStore, PreviewDocumentRole } from '../delivery/preview'\nimport { toPreviewRenderDocument } from './comark-document'\nimport {\n CMS_PREVIEW_EDGE_PROPERTY,\n CMS_PREVIEW_KIND_PROPERTY,\n CMS_PREVIEW_MARKER_TAG,\n CMS_PREVIEW_NODE_PROPERTY,\n} from './protocol'\n\nexport { documentPreviewStoreKey, type DocumentPreviewStore, type PreviewDocumentRole } from '../delivery/preview'\n\nexport type { DeliveryDocument as PreviewCompiledDocument } from '../delivery/types'\n\nexport interface StudioPreviewStore extends DocumentPreviewStore {\n readonly manifest: () => RenderedDocumentManifest\n readonly patch: (document: PreviewCompiledDocument) => Promise<Readonly<Record<string, string>>>\n readonly routeChanged: () => void\n readonly subscribe: (listener: (manifest: RenderedDocumentManifest) => void) => () => void\n}\n\nexport function createStudioPreviewStore(\n route: () => RenderedDocumentManifest['route'],\n forms: () => ReadonlyArray<ComponentDefinition> = () => [],\n): StudioPreviewStore {\n const context = createComarkContext()\n const patches = shallowRef(new Map<string, PreviewCompiledDocument>())\n\n const registrations = new Map<\n symbol,\n { readonly document: PreviewCompiledDocument; readonly role: PreviewDocumentRole }\n >()\n\n const listeners = new Set<(manifest: RenderedDocumentManifest) => void>()\n\n const manifest = (): RenderedDocumentManifest => ({\n documents: renderedDocuments(registrations.values(), patches.value),\n route: route(),\n })\n\n const notify = (): void => {\n const value = manifest()\n\n for (const listener of listeners) listener(value)\n }\n\n return {\n manifest,\n // oxlint-disable-next-line effecttsgo/async-function -- The Promise contract turns synchronous projection failures into patch rejections for the preview controller.\n async patch(document) {\n const preview = createPreviewDocument(document.body)\n const patched = prepareFormDocument({ ...document, body: preview.body }, forms(), true)\n patches.value = new Map(patches.value).set(document.id, patched)\n const renderBody = toPreviewRenderDocument(patched.body)\n context.get(document.id, renderBody).set(renderBody)\n notify()\n\n return preview.fallbacks\n },\n register(document, role) {\n const registration = Symbol(document.id)\n registrations.set(registration, { document, role })\n notify()\n\n return () => {\n registrations.delete(registration)\n notify()\n }\n },\n resolve(document) {\n return patches.value.get(document.id) ?? document\n },\n routeChanged: notify,\n subscribe(listener) {\n listeners.add(listener)\n listener(manifest())\n\n return () => listeners.delete(listener)\n },\n }\n}\n\nfunction renderedDocuments(\n registrations: Iterable<{ readonly document: PreviewCompiledDocument; readonly role: PreviewDocumentRole }>,\n patches: ReadonlyMap<string, PreviewCompiledDocument>,\n): ReadonlyArray<RenderedCompiledDocument> {\n const priority = { embedded: 1, primary: 4, related: 2, summary: 3 } satisfies Record<PreviewDocumentRole, number>\n const documents = new Map<string, RenderedCompiledDocument>()\n\n for (const registration of registrations) {\n const document = patches.get(registration.document.id) ?? registration.document\n const current = documents.get(document.id)\n\n if (current && priority[current.role] >= priority[registration.role]) continue\n documents.set(document.id, {\n collection: CollectionName.make(document.collection),\n documentId: DocumentId.make(document.id),\n path: PublicPath.make(document.path),\n role: registration.role,\n title: document.title,\n })\n }\n\n return [...documents.values()].sort(\n (left, right) => priority[right.role] - priority[left.role] || left.title.localeCompare(right.title),\n )\n}\n\nfunction createPreviewDocument(body: PreviewCompiledDocument['body']) {\n const projection = projectPreviewDocument(body, {\n edgeProperty: CMS_PREVIEW_EDGE_PROPERTY,\n kindProperty: CMS_PREVIEW_KIND_PROPERTY,\n nodeProperty: CMS_PREVIEW_NODE_PROPERTY,\n tag: CMS_PREVIEW_MARKER_TAG,\n })\n\n if (Result.isFailure(projection)) throw projection.failure\n\n return projection.success\n}\n"],"mappings":";;;;;;;;;;;;AAmBA,IAAa,2BAAb,cAA8C,OAAO,YAAsC,CAAC,CAC1F,6BACA;CACE,SAAS,OAAO;CAChB,OAAO,OAAO,OAAO;AACvB,CACF,CAAC,CAAC,CAAC;AAEH,MAAM,oCAAoB,IAAI,IAAI;CAChC;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF,CAAC;AAED,SAAgB,uBACd,MACA,SAC4D;CAC5D,OAAO,OAAO,IAAI;EAChB,WAAW,6BAA6B,MAAM,OAAO;EACrD,QAAQ,UACN,IAAI,yBAAyB;GAC3B;GACA,SAAS,iBAAiB,SAAS,MAAM,UAAU,MAAM,UAAU;EACrE,CAAC;CACL,CAAC;AACH;AAEA,SAAS,6BAA6B,MAA2B,SAAsD;CACrH,MAAM,YAAoC,CAAC;CAC3C,IAAI,oBAAoB;CAExB,SAAS,UACP,MACA,aACA,QAC4B;EAC5B,IAAI,UAAU,SAAS,IAAI,KAAK,KAAK,OAAO,MAAM,OAAO,CAAC,YAAY,IAAI,CAAC;EAC3E,MAAM,CAAC,KAAK,oBAAoB,GAAG,oBAAoB;EACvD,MAAM,SAAS,QAAQ;EACvB,MAAM,WAAW,kBAAkB,IAAI,GAAG;EAC1C,MAAM,aAAa,kBAAkB,kBAAkB;EACvD,MAAM,WAAW,eAAe,UAAU;EAC1C,MAAM,KAAK,UAAU;EAErB,IAAI,IAAI;GACN;GACA,MAAM,WAAW,UAAU;GAE3B,IAAI,UAAU,UAAU,MAAM;EAChC;EAEA,MAAM,kBAAkB,CAAC,YAAY,CAAC,UAAU,KAAK,KAAK;EAE1D,MAAM,iBACJ,MAAM,UAAU,kBAAkB,CAAC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11 @@ interface DeliveryDocument {
|
|
|
33
33
|
readonly draft: boolean;
|
|
34
34
|
readonly engineFingerprint: string;
|
|
35
35
|
readonly id: string;
|
|
36
|
+
readonly identity: {
|
|
37
|
+
readonly collection: string;
|
|
38
|
+
readonly documentId: string;
|
|
39
|
+
readonly locale?: string;
|
|
40
|
+
};
|
|
36
41
|
readonly issues: ReadonlyArray<{
|
|
37
42
|
readonly code: string;
|
|
38
43
|
readonly collection?: string;
|
|
@@ -41,11 +46,18 @@ interface DeliveryDocument {
|
|
|
41
46
|
readonly locale?: string;
|
|
42
47
|
readonly message: string;
|
|
43
48
|
readonly severity: 'error' | 'warning';
|
|
44
|
-
readonly
|
|
49
|
+
readonly documentId?: string;
|
|
45
50
|
}>;
|
|
46
51
|
readonly key: string;
|
|
47
52
|
readonly locale?: string;
|
|
48
53
|
readonly path: string;
|
|
54
|
+
readonly placement: {
|
|
55
|
+
readonly kind: 'home';
|
|
56
|
+
} | {
|
|
57
|
+
readonly kind: 'entry';
|
|
58
|
+
readonly parentDocumentId: string;
|
|
59
|
+
readonly slug: string;
|
|
60
|
+
};
|
|
49
61
|
readonly resolvedSeo?: ResolvedSeo;
|
|
50
62
|
readonly seo?: DocumentSeo;
|
|
51
63
|
readonly source: {
|
|
@@ -64,7 +76,6 @@ interface DeliveryDocument {
|
|
|
64
76
|
};
|
|
65
77
|
};
|
|
66
78
|
}>;
|
|
67
|
-
readonly path: string;
|
|
68
79
|
readonly publishedAt?: DateTime.Utc;
|
|
69
80
|
};
|
|
70
81
|
readonly title: string;
|
|
@@ -87,4 +98,4 @@ interface DeliveryDocumentQuery {
|
|
|
87
98
|
}
|
|
88
99
|
//#endregion
|
|
89
100
|
export { DeliveryJson as a, DeliveryMarkdownNode as c, DeliveryDocumentQuerySort as i, DeliveryDocumentPage as n, DeliveryJsonObject as o, DeliveryDocumentQuery as r, DeliveryMarkdownDocument as s, DeliveryDocument as t };
|
|
90
|
-
//# sourceMappingURL=types-
|
|
101
|
+
//# sourceMappingURL=types-DZ0IV-Ow.d.ts.map
|
|
@@ -0,0 +1,253 @@
|
|
|
1
|
+
import { $ as e, Bt as t, Et as n, It as r, Nt as i, Q as a, Y as ee, at as o, cn as s, dn as c, en as l, et as u, mt as d, nt as f, on as p, q as te, st as m, tt as h, wt as g } from "./editor-P2rB7Csp.js";
|
|
2
|
+
import { D as ne, I as _, M as v, N as y, O as b, P as x, j as S, n as C, or as w, sr as re, t as T, vr as ie } from "./documentPlanning-Bx3W9KkD.js";
|
|
3
|
+
//#region src/documents/CreateDocumentDialog.vue?vue&type=script&setup=true&lang.ts
|
|
4
|
+
var ae = { key: 2 }, oe = { class: "grid grid-flow-col auto-cols-fr overflow-x-auto rounded-md border border-default" }, se = ["title", "onClick"], ce = { class: "block truncate" }, E = {
|
|
5
|
+
key: 0,
|
|
6
|
+
class: "mt-2 flex min-w-0 items-center justify-between gap-3 text-xs text-muted"
|
|
7
|
+
}, D = { class: "truncate" }, le = { class: "shrink-0 font-mono text-[11px] text-dimmed" }, ue = {
|
|
8
|
+
key: 5,
|
|
9
|
+
class: "flex min-w-0 items-center gap-3 rounded-md border border-default px-3 py-2"
|
|
10
|
+
}, O = {
|
|
11
|
+
key: 6,
|
|
12
|
+
class: "-mt-2 text-xs text-error"
|
|
13
|
+
}, k = {
|
|
14
|
+
key: 7,
|
|
15
|
+
class: "-mt-2 text-xs text-error"
|
|
16
|
+
}, de = { class: "flex w-full justify-end gap-2" }, A = "__top_level__", j = /* @__PURE__ */ m({
|
|
17
|
+
__name: "CreateDocumentDialog",
|
|
18
|
+
props: /*@__PURE__*/ d({
|
|
19
|
+
catalog: {},
|
|
20
|
+
context: {}
|
|
21
|
+
}, {
|
|
22
|
+
open: { type: Boolean },
|
|
23
|
+
openModifiers: {}
|
|
24
|
+
}),
|
|
25
|
+
emits: /*@__PURE__*/ d(["close"], ["update:open"]),
|
|
26
|
+
setup(d, { emit: m }) {
|
|
27
|
+
let j = m, M = i(d, "open"), N = S(), P = N.bootstrap.documents, F = P.types.filter((e) => e.canCreate), I = (P.locales?.locales ?? []).map((e) => ({
|
|
28
|
+
label: he(e),
|
|
29
|
+
value: String(e)
|
|
30
|
+
})), L = l(""), R = l(!1), z = l(""), B = l(""), V = l(!1), H = l(""), U = l(A), W = l(P.locales?.defaultLocale ?? ""), G = a(() => {
|
|
31
|
+
let e = F.map((e) => ({
|
|
32
|
+
collection: e.collection,
|
|
33
|
+
description: e.description,
|
|
34
|
+
key: `entry:${e.collection}`,
|
|
35
|
+
kind: "entry",
|
|
36
|
+
label: e.label,
|
|
37
|
+
type: e,
|
|
38
|
+
urlHint: e.routes.entry.replace(/:[a-z][\w.]*\*?/giu, "…")
|
|
39
|
+
}));
|
|
40
|
+
return [...F.filter((e) => !d.catalog.entries.value.some((t) => t.document.collection === e.collection && t.document.locale === (W.value || void 0) && t.document.placement.kind === "home")).flatMap((e) => {
|
|
41
|
+
let t = T(P, {
|
|
42
|
+
collection: e.collection,
|
|
43
|
+
locale: W.value || void 0,
|
|
44
|
+
placement: { kind: "home" },
|
|
45
|
+
title: "Home"
|
|
46
|
+
});
|
|
47
|
+
return w(t) || d.catalog.entries.value.some((e) => e.document.path === t.success.path) ? [] : [{
|
|
48
|
+
collection: e.collection,
|
|
49
|
+
description: "The first document visitors see when they open the website.",
|
|
50
|
+
key: `home:${e.collection}`,
|
|
51
|
+
kind: "home",
|
|
52
|
+
label: "Home",
|
|
53
|
+
type: e,
|
|
54
|
+
urlHint: t.success.path
|
|
55
|
+
}];
|
|
56
|
+
}), ...e];
|
|
57
|
+
}), K = a(() => G.value.find((e) => e.key === H.value)), fe = a(() => d.catalog.entries.value.find((e) => e.document.collection === K.value?.collection && e.document.locale === (W.value || void 0) && e.document.placement.kind === "home")), q = a(() => {
|
|
58
|
+
if (K.value?.kind === "home") return { kind: "home" };
|
|
59
|
+
let e = U.value === A ? fe.value?.document.id : U.value;
|
|
60
|
+
return e ? {
|
|
61
|
+
kind: "entry",
|
|
62
|
+
parentDocumentId: e,
|
|
63
|
+
slug: B.value
|
|
64
|
+
} : void 0;
|
|
65
|
+
}), J = a(() => {
|
|
66
|
+
let e = K.value, t = q.value;
|
|
67
|
+
if (!e || !t || e.kind === "entry" && !B.value.trim()) return;
|
|
68
|
+
let n = {
|
|
69
|
+
collection: e.collection,
|
|
70
|
+
placement: t,
|
|
71
|
+
title: z.value || "Untitled"
|
|
72
|
+
}, r = n.placement.kind === "entry" ? d.catalog.byId(n.placement.parentDocumentId)?.document.path : void 0;
|
|
73
|
+
return T(P, W.value ? {
|
|
74
|
+
...n,
|
|
75
|
+
locale: W.value
|
|
76
|
+
} : n, r);
|
|
77
|
+
}), Y = a(() => {
|
|
78
|
+
let e = J.value;
|
|
79
|
+
return e && re(e) ? e.success : void 0;
|
|
80
|
+
}), X = a(() => {
|
|
81
|
+
let e = J.value;
|
|
82
|
+
return e && w(e) ? e.failure : "";
|
|
83
|
+
}), Z = a(() => Y.value && d.catalog.entries.value.some((e) => e.document.path === Y.value?.path)), pe = a(() => {
|
|
84
|
+
let e = K.value;
|
|
85
|
+
if (!e || e.kind === "home" || !e.type.hierarchy) return [];
|
|
86
|
+
let t = d.catalog.entries.value.flatMap((t) => t.document.collection !== e.collection || t.document.locale !== (W.value || void 0) ? [] : [{
|
|
87
|
+
label: `${t.document.title} · ${t.document.path}`,
|
|
88
|
+
value: String(t.document.id)
|
|
89
|
+
}]);
|
|
90
|
+
return d.context?.parent && !t.some((e) => e.value === d.context.parent) && t.push({
|
|
91
|
+
label: d.context.parent,
|
|
92
|
+
value: d.context.parent
|
|
93
|
+
}), [{
|
|
94
|
+
label: "Top level",
|
|
95
|
+
value: A
|
|
96
|
+
}, ...t];
|
|
97
|
+
}), Q = a(() => !!z.value.trim() && !!K.value && !!Y.value && !Z.value);
|
|
98
|
+
r(z, (e) => {
|
|
99
|
+
V.value || (B.value = C(e));
|
|
100
|
+
}), r(H, () => U.value = A, { flush: "sync" }), r(W, () => {
|
|
101
|
+
U.value = A, K.value || (H.value = $());
|
|
102
|
+
}, { flush: "sync" }), r(M, (e) => {
|
|
103
|
+
e && (L.value = "", z.value = "", B.value = "", V.value = !1, W.value = d.context?.locale ?? P.locales?.defaultLocale ?? "", H.value = d.context?.collection ? `entry:${d.context.collection}` : $(), U.value = d.context?.parent || A, d.context?.slug && (B.value = d.context.slug, V.value = !0));
|
|
104
|
+
}, { immediate: !0 });
|
|
105
|
+
async function me() {
|
|
106
|
+
let e = K.value, t = q.value;
|
|
107
|
+
if (Q.value && e && t && !R.value) {
|
|
108
|
+
R.value = !0, L.value = "";
|
|
109
|
+
try {
|
|
110
|
+
let n = {
|
|
111
|
+
collection: e.collection,
|
|
112
|
+
placement: t,
|
|
113
|
+
title: z.value
|
|
114
|
+
}, r = await N.gateway.documents.create(W.value ? {
|
|
115
|
+
...n,
|
|
116
|
+
locale: W.value
|
|
117
|
+
} : n);
|
|
118
|
+
await d.catalog.refresh(!0);
|
|
119
|
+
let i = d.catalog.byId(r.documentId);
|
|
120
|
+
if (!i) throw Error("The page was created but could not be opened.");
|
|
121
|
+
j("close", i.document.id);
|
|
122
|
+
} catch (e) {
|
|
123
|
+
L.value = _(e);
|
|
124
|
+
} finally {
|
|
125
|
+
R.value = !1;
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
function $() {
|
|
130
|
+
return G.value[0]?.key ?? "";
|
|
131
|
+
}
|
|
132
|
+
function he(e) {
|
|
133
|
+
try {
|
|
134
|
+
return new Intl.DisplayNames(void 0, { type: "language" }).of(e) ?? e.toLocaleUpperCase();
|
|
135
|
+
} catch {
|
|
136
|
+
return e.toLocaleUpperCase();
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
return (r, i) => {
|
|
140
|
+
let a = x, l = v, d = y, m = ne, _ = ie, S = b;
|
|
141
|
+
return g(), u(S, {
|
|
142
|
+
open: M.value,
|
|
143
|
+
"onUpdate:open": i[6] ||= (e) => M.value = e,
|
|
144
|
+
title: "New page",
|
|
145
|
+
description: "Add a document to your website.",
|
|
146
|
+
ui: { content: "max-w-lg" }
|
|
147
|
+
}, {
|
|
148
|
+
body: t(() => [e("form", {
|
|
149
|
+
id: "create-document-form",
|
|
150
|
+
class: "space-y-4",
|
|
151
|
+
onSubmit: te(me, ["prevent"])
|
|
152
|
+
}, [
|
|
153
|
+
L.value ? (g(), u(a, {
|
|
154
|
+
key: 0,
|
|
155
|
+
description: L.value,
|
|
156
|
+
color: "error",
|
|
157
|
+
variant: "subtle"
|
|
158
|
+
}, null, 8, ["description"])) : h("", !0),
|
|
159
|
+
G.value.length ? G.value.length > 1 ? (g(), f("fieldset", ae, [
|
|
160
|
+
i[7] ||= e("legend", { class: "mb-2 text-sm font-medium text-highlighted" }, "Collection", -1),
|
|
161
|
+
e("div", oe, [(g(!0), f(ee, null, n(G.value, (t) => (g(), f("button", {
|
|
162
|
+
key: t.key,
|
|
163
|
+
type: "button",
|
|
164
|
+
title: t.description,
|
|
165
|
+
class: s(["min-w-28 border-l border-default px-3 py-2 text-center text-sm transition-colors first:border-l-0", t.key === H.value ? "bg-muted font-medium text-highlighted" : "bg-default text-muted hover:bg-muted/50 hover:text-highlighted"]),
|
|
166
|
+
onClick: (e) => H.value = t.key
|
|
167
|
+
}, [e("span", ce, c(t.label), 1)], 10, se))), 128))]),
|
|
168
|
+
K.value ? (g(), f("div", E, [e("span", D, c(K.value.description), 1), e("code", le, c(K.value.urlHint), 1)])) : h("", !0)
|
|
169
|
+
])) : h("", !0) : (g(), u(a, {
|
|
170
|
+
key: 1,
|
|
171
|
+
title: "Document creation is not configured",
|
|
172
|
+
description: "A developer needs to make at least one collection creatable in Studio.",
|
|
173
|
+
color: "warning",
|
|
174
|
+
variant: "subtle"
|
|
175
|
+
})),
|
|
176
|
+
K.value ? (g(), f("div", {
|
|
177
|
+
key: 3,
|
|
178
|
+
class: s(["grid gap-4", p(I).length ? "sm:grid-cols-[minmax(0,2fr)_minmax(9rem,1fr)]" : ""])
|
|
179
|
+
}, [o(d, {
|
|
180
|
+
label: "Title",
|
|
181
|
+
required: ""
|
|
182
|
+
}, {
|
|
183
|
+
default: t(() => [o(l, {
|
|
184
|
+
modelValue: z.value,
|
|
185
|
+
"onUpdate:modelValue": i[0] ||= (e) => z.value = e,
|
|
186
|
+
autofocus: "",
|
|
187
|
+
placeholder: "About us",
|
|
188
|
+
class: "w-full"
|
|
189
|
+
}, null, 8, ["modelValue"])]),
|
|
190
|
+
_: 1
|
|
191
|
+
}), p(I).length ? (g(), u(d, {
|
|
192
|
+
key: 0,
|
|
193
|
+
label: "Language"
|
|
194
|
+
}, {
|
|
195
|
+
default: t(() => [o(m, {
|
|
196
|
+
modelValue: W.value,
|
|
197
|
+
"onUpdate:modelValue": i[1] ||= (e) => W.value = e,
|
|
198
|
+
items: p(I),
|
|
199
|
+
"value-key": "value",
|
|
200
|
+
class: "w-full"
|
|
201
|
+
}, null, 8, ["modelValue", "items"])]),
|
|
202
|
+
_: 1
|
|
203
|
+
})) : h("", !0)], 2)) : h("", !0),
|
|
204
|
+
K.value?.kind === "entry" ? (g(), f("div", {
|
|
205
|
+
key: 4,
|
|
206
|
+
class: s(["grid gap-4", K.value.type.hierarchy ? "sm:grid-cols-2" : ""])
|
|
207
|
+
}, [K.value.type.hierarchy ? (g(), u(d, {
|
|
208
|
+
key: 0,
|
|
209
|
+
label: "Parent document"
|
|
210
|
+
}, {
|
|
211
|
+
default: t(() => [o(m, {
|
|
212
|
+
modelValue: U.value,
|
|
213
|
+
"onUpdate:modelValue": i[2] ||= (e) => U.value = e,
|
|
214
|
+
items: pe.value,
|
|
215
|
+
"value-key": "value",
|
|
216
|
+
class: "w-full"
|
|
217
|
+
}, null, 8, ["modelValue", "items"])]),
|
|
218
|
+
_: 1
|
|
219
|
+
})) : h("", !0), o(d, {
|
|
220
|
+
label: "URL ending",
|
|
221
|
+
required: ""
|
|
222
|
+
}, {
|
|
223
|
+
default: t(() => [o(l, {
|
|
224
|
+
modelValue: B.value,
|
|
225
|
+
"onUpdate:modelValue": [i[3] ||= (e) => B.value = e, i[4] ||= (e) => V.value = !0],
|
|
226
|
+
placeholder: "about-us",
|
|
227
|
+
class: "w-full"
|
|
228
|
+
}, null, 8, ["modelValue"])]),
|
|
229
|
+
_: 1
|
|
230
|
+
})], 2)) : h("", !0),
|
|
231
|
+
K.value ? (g(), f("div", ue, [i[8] ||= e("span", { class: "shrink-0 text-xs text-muted" }, "URL", -1), e("p", { class: s(["min-w-0 flex-1 truncate text-right font-mono text-xs", Z.value ? "text-error" : "text-highlighted"]) }, c(Y.value?.path || K.value.urlHint), 3)])) : h("", !0),
|
|
232
|
+
Z.value ? (g(), f("p", O, "This URL is already in use.")) : X.value ? (g(), f("p", k, c(X.value), 1)) : h("", !0)
|
|
233
|
+
], 32)]),
|
|
234
|
+
footer: t(() => [e("div", de, [o(_, {
|
|
235
|
+
color: "neutral",
|
|
236
|
+
variant: "ghost",
|
|
237
|
+
label: "Cancel",
|
|
238
|
+
onClick: i[5] ||= (e) => M.value = !1
|
|
239
|
+
}), o(_, {
|
|
240
|
+
type: "submit",
|
|
241
|
+
form: "create-document-form",
|
|
242
|
+
color: "neutral",
|
|
243
|
+
label: "Create page",
|
|
244
|
+
loading: R.value,
|
|
245
|
+
disabled: !Q.value
|
|
246
|
+
}, null, 8, ["loading", "disabled"])])]),
|
|
247
|
+
_: 1
|
|
248
|
+
}, 8, ["open"]);
|
|
249
|
+
};
|
|
250
|
+
}
|
|
251
|
+
});
|
|
252
|
+
//#endregion
|
|
253
|
+
export { j as default };
|