@abraca/nuxt 2.54.0 → 2.55.0
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/module.json +1 -1
- package/dist/runtime/components/AEditor.vue +197 -16
- package/dist/runtime/components/aware/AMedia.d.vue.ts +1 -1
- package/dist/runtime/components/aware/AMedia.vue.d.ts +1 -1
- package/dist/runtime/extensions/meta-field.d.ts +16 -0
- package/dist/runtime/extensions/meta-field.js +125 -0
- package/dist/runtime/extensions/views/DocumentMetaView.vue +1 -43
- package/dist/runtime/extensions/views/MetaFieldView.vue +49 -1
- package/dist/runtime/locale.d.ts +1 -0
- package/dist/runtime/locale.js +2 -1
- package/package.json +1 -1
package/dist/module.json
CHANGED
|
@@ -4,7 +4,8 @@ import { useNuxtApp, navigateTo, useRuntimeConfig } from "#imports";
|
|
|
4
4
|
import { Fragment } from "@tiptap/pm/model";
|
|
5
5
|
import { useSyncedMap } from "../composables/useYDoc";
|
|
6
6
|
import { resolveDocType, GEO_TYPE_META_SCHEMAS } from "../utils/docTypes";
|
|
7
|
-
import { schemaFieldToAttrs, userFieldToAttrs } from "../extensions/meta-field";
|
|
7
|
+
import { schemaFieldToAttrs, userFieldToAttrs, inferFieldAttrs, AUTO_DETECT_EXCLUDED } from "../extensions/meta-field";
|
|
8
|
+
import { DATE_SIBLING_KEY } from "../utils/dateField";
|
|
8
9
|
import { decideTitleSync, setHeaderText as applyHeaderText, UNTITLED } from "../utils/titleSync";
|
|
9
10
|
import { useEditor } from "../composables/useEditor";
|
|
10
11
|
import { useDocTree } from "../composables/useDocTree";
|
|
@@ -61,6 +62,10 @@ watch(() => [doc.value, connections.size], () => {
|
|
|
61
62
|
ownerDoc.value = getDocForDoc(props.docId) ?? doc.value;
|
|
62
63
|
}, { immediate: true });
|
|
63
64
|
const _treeMap = useSyncedMap(ownerDoc, "doc-tree");
|
|
65
|
+
const reactiveDocMeta = computed(() => {
|
|
66
|
+
const fromTree = _treeMap.data[props.docId]?.meta;
|
|
67
|
+
return fromTree ?? props.docMeta ?? null;
|
|
68
|
+
});
|
|
64
69
|
const childProvider = shallowRef(null);
|
|
65
70
|
watch(ownerProvider, async (prov) => {
|
|
66
71
|
if (!prov || !props.docId) return;
|
|
@@ -112,7 +117,7 @@ const { bubbleItems: toolbarItems } = useEditorToolbar({ docId: props.docId });
|
|
|
112
117
|
const docTree = useDocTree(props.docId);
|
|
113
118
|
const resolvedMetaSchema = computed(() => {
|
|
114
119
|
if (props.metaSchema) return props.metaSchema;
|
|
115
|
-
const geoType =
|
|
120
|
+
const geoType = reactiveDocMeta.value?.geoType;
|
|
116
121
|
if (geoType && geoType in GEO_TYPE_META_SCHEMAS)
|
|
117
122
|
return GEO_TYPE_META_SCHEMAS[geoType];
|
|
118
123
|
let pid = docTree.getEntry(props.docId)?.parentId ?? void 0;
|
|
@@ -153,7 +158,7 @@ const dragHandle = useEditorDragHandle();
|
|
|
153
158
|
watchEffect(() => {
|
|
154
159
|
const isReady = ready.value;
|
|
155
160
|
const editorInstance = editorRef.value;
|
|
156
|
-
const docMeta =
|
|
161
|
+
const docMeta = reactiveDocMeta.value;
|
|
157
162
|
if (!isReady || !editorInstance) return;
|
|
158
163
|
const storage = editorInstance.editor?.storage?.metaField;
|
|
159
164
|
if (!storage) return;
|
|
@@ -173,8 +178,122 @@ function handleMetaUpdate(patch) {
|
|
|
173
178
|
writeTreeMeta(patch);
|
|
174
179
|
emit("updateMeta", patch);
|
|
175
180
|
}
|
|
181
|
+
function collectExistingFieldKeys(metaNode) {
|
|
182
|
+
const keys = /* @__PURE__ */ new Set();
|
|
183
|
+
metaNode.forEach((child) => {
|
|
184
|
+
if (child.type.name === "metaField") {
|
|
185
|
+
for (const attr of ["metaKey", "startKey", "endKey", "allDayKey", "latKey", "lngKey"]) {
|
|
186
|
+
const v = child.attrs[attr];
|
|
187
|
+
if (v) keys.add(v);
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
});
|
|
191
|
+
return keys;
|
|
192
|
+
}
|
|
193
|
+
function buildOrphanFields(meta, coveredKeys, metaFieldType) {
|
|
194
|
+
const nodes = [];
|
|
195
|
+
for (const [key, value] of Object.entries(meta)) {
|
|
196
|
+
if (AUTO_DETECT_EXCLUDED.has(key)) continue;
|
|
197
|
+
if (coveredKeys.has(key)) continue;
|
|
198
|
+
if (key.startsWith("_")) continue;
|
|
199
|
+
if (value === void 0 || value === null) continue;
|
|
200
|
+
if (typeof value === "object" && !Array.isArray(value)) continue;
|
|
201
|
+
const attrs = inferFieldAttrs(key, value);
|
|
202
|
+
if (attrs) nodes.push(metaFieldType.create(attrs));
|
|
203
|
+
}
|
|
204
|
+
if (meta.geoLat != null && meta.geoLng != null && !coveredKeys.has("geoLat") && !coveredKeys.has("geoLng")) {
|
|
205
|
+
nodes.push(metaFieldType.create({
|
|
206
|
+
fieldType: "location",
|
|
207
|
+
fieldLabel: "Location",
|
|
208
|
+
userDefined: false,
|
|
209
|
+
latKey: "geoLat",
|
|
210
|
+
lngKey: "geoLng"
|
|
211
|
+
}));
|
|
212
|
+
}
|
|
213
|
+
return nodes;
|
|
214
|
+
}
|
|
215
|
+
function insertMissingSchemaFields(ed, fields) {
|
|
216
|
+
if (!fields.length) return;
|
|
217
|
+
const { doc: doc2 } = ed.state;
|
|
218
|
+
let metaPos = -1;
|
|
219
|
+
let metaNode = null;
|
|
220
|
+
doc2.forEach((node, offset) => {
|
|
221
|
+
if (node.type.name === "documentMeta") {
|
|
222
|
+
metaPos = offset;
|
|
223
|
+
metaNode = node;
|
|
224
|
+
}
|
|
225
|
+
});
|
|
226
|
+
if (metaPos === -1 || !metaNode) return;
|
|
227
|
+
const metaFieldType = ed.schema.nodes.metaField;
|
|
228
|
+
if (!metaFieldType) return;
|
|
229
|
+
const existingKeys = collectExistingFieldKeys(metaNode);
|
|
230
|
+
const missing = fields.filter((f) => {
|
|
231
|
+
if (f.key) return !existingKeys.has(String(f.key));
|
|
232
|
+
if (f.startKey) return !existingKeys.has(String(f.startKey));
|
|
233
|
+
if (f.latKey) return !existingKeys.has(String(f.latKey));
|
|
234
|
+
return false;
|
|
235
|
+
});
|
|
236
|
+
if (!missing.length) return;
|
|
237
|
+
const { tr } = ed.state;
|
|
238
|
+
const insertPos = metaPos + 1 + (metaNode.content?.size ?? 0);
|
|
239
|
+
tr.insert(insertPos, Fragment.fromArray(missing.map((f) => metaFieldType.create(schemaFieldToAttrs(f)))));
|
|
240
|
+
ed.view.dispatch(tr);
|
|
241
|
+
}
|
|
242
|
+
function deduplicateMetaFields(ed) {
|
|
243
|
+
const doc2 = ed.state.doc;
|
|
244
|
+
let metaPos = -1;
|
|
245
|
+
let metaNode = null;
|
|
246
|
+
doc2.forEach((node, offset) => {
|
|
247
|
+
if (node.type.name === "documentMeta") {
|
|
248
|
+
metaPos = offset;
|
|
249
|
+
metaNode = node;
|
|
250
|
+
}
|
|
251
|
+
});
|
|
252
|
+
if (metaPos === -1 || !metaNode) return;
|
|
253
|
+
const ownedAllDayKeys = /* @__PURE__ */ new Set();
|
|
254
|
+
const ownedDateSiblingKeys = /* @__PURE__ */ new Set();
|
|
255
|
+
metaNode.forEach((child) => {
|
|
256
|
+
if (child.type.name !== "metaField") return;
|
|
257
|
+
if (child.attrs.allDayKey) ownedAllDayKeys.add(String(child.attrs.allDayKey));
|
|
258
|
+
for (const k of [child.attrs.startKey, child.attrs.endKey]) {
|
|
259
|
+
const sib = DATE_SIBLING_KEY[String(k)];
|
|
260
|
+
if (sib) ownedDateSiblingKeys.add(sib);
|
|
261
|
+
}
|
|
262
|
+
});
|
|
263
|
+
const seen = /* @__PURE__ */ new Set();
|
|
264
|
+
const deletions = [];
|
|
265
|
+
metaNode.forEach((child, childOffset) => {
|
|
266
|
+
if (child.type.name !== "metaField") return;
|
|
267
|
+
const a = child.attrs;
|
|
268
|
+
if (a.metaKey && !a.allDayKey && ownedAllDayKeys.has(String(a.metaKey))) {
|
|
269
|
+
const from = metaPos + 1 + childOffset;
|
|
270
|
+
deletions.push({ from, to: from + child.nodeSize });
|
|
271
|
+
return;
|
|
272
|
+
}
|
|
273
|
+
if (a.metaKey && !a.startKey && ownedDateSiblingKeys.has(String(a.metaKey))) {
|
|
274
|
+
const from = metaPos + 1 + childOffset;
|
|
275
|
+
deletions.push({ from, to: from + child.nodeSize });
|
|
276
|
+
return;
|
|
277
|
+
}
|
|
278
|
+
const identity = a.metaKey || `${a.startKey ?? ""}:${a.endKey ?? ""}:${a.latKey ?? ""}:${a.lngKey ?? ""}`;
|
|
279
|
+
if (!identity || identity === ":::") return;
|
|
280
|
+
if (seen.has(identity)) {
|
|
281
|
+
const from = metaPos + 1 + childOffset;
|
|
282
|
+
deletions.push({ from, to: from + child.nodeSize });
|
|
283
|
+
} else {
|
|
284
|
+
seen.add(identity);
|
|
285
|
+
}
|
|
286
|
+
});
|
|
287
|
+
if (!deletions.length) return;
|
|
288
|
+
const { tr } = ed.state;
|
|
289
|
+
for (let i = deletions.length - 1; i >= 0; i--) {
|
|
290
|
+
tr.delete(deletions[i].from, deletions[i].to);
|
|
291
|
+
}
|
|
292
|
+
ed.view.dispatch(tr);
|
|
293
|
+
}
|
|
176
294
|
function initDocumentMeta(ed) {
|
|
177
295
|
if (metaInitDone) return;
|
|
296
|
+
const canPersistTreeMeta = effectiveEditable.value;
|
|
178
297
|
const doc2 = ed.state.doc;
|
|
179
298
|
let metaPos = -1;
|
|
180
299
|
let metaNode = null;
|
|
@@ -185,41 +304,103 @@ function initDocumentMeta(ed) {
|
|
|
185
304
|
}
|
|
186
305
|
});
|
|
187
306
|
if (metaPos === -1 || !metaNode) return;
|
|
307
|
+
const docMeta = reactiveDocMeta.value;
|
|
188
308
|
if (metaNode.childCount > 0) {
|
|
189
309
|
metaInitDone = true;
|
|
310
|
+
insertMissingSchemaFields(ed, resolvedMetaSchema.value);
|
|
311
|
+
if (docMeta) {
|
|
312
|
+
let updatedMetaNode = null;
|
|
313
|
+
ed.state.doc.forEach((node) => {
|
|
314
|
+
if (node.type.name === "documentMeta") updatedMetaNode = node;
|
|
315
|
+
});
|
|
316
|
+
const metaFieldType2 = ed.schema.nodes.metaField;
|
|
317
|
+
if (metaFieldType2 && updatedMetaNode) {
|
|
318
|
+
const existingKeys = collectExistingFieldKeys(updatedMetaNode);
|
|
319
|
+
const orphans2 = buildOrphanFields(docMeta, existingKeys, metaFieldType2);
|
|
320
|
+
if (orphans2.length) {
|
|
321
|
+
let mPos = -1;
|
|
322
|
+
let mNode = null;
|
|
323
|
+
ed.state.doc.forEach((node, offset) => {
|
|
324
|
+
if (node.type.name === "documentMeta") {
|
|
325
|
+
mPos = offset;
|
|
326
|
+
mNode = node;
|
|
327
|
+
}
|
|
328
|
+
});
|
|
329
|
+
if (mPos !== -1 && mNode) {
|
|
330
|
+
const { tr: tr2 } = ed.state;
|
|
331
|
+
const insertPos2 = mPos + 1 + (mNode.content?.size ?? 0);
|
|
332
|
+
tr2.insert(insertPos2, Fragment.fromArray(orphans2));
|
|
333
|
+
ed.view.dispatch(tr2);
|
|
334
|
+
}
|
|
335
|
+
}
|
|
336
|
+
}
|
|
337
|
+
}
|
|
338
|
+
deduplicateMetaFields(ed);
|
|
190
339
|
return;
|
|
191
340
|
}
|
|
192
|
-
const docMeta = props.docMeta;
|
|
193
341
|
if (!docMeta) return;
|
|
194
342
|
const schema = resolvedMetaSchema.value;
|
|
195
343
|
const userFields = docMeta._metaFields ?? [];
|
|
196
344
|
const wasAlreadyInitialized = !!docMeta._metaInitialized;
|
|
197
|
-
if (wasAlreadyInitialized &&
|
|
198
|
-
metaInitDone = true;
|
|
199
|
-
return;
|
|
200
|
-
}
|
|
201
|
-
if (!wasAlreadyInitialized) {
|
|
345
|
+
if (!wasAlreadyInitialized && canPersistTreeMeta) {
|
|
202
346
|
handleMetaUpdate({ _metaInitialized: true });
|
|
203
347
|
}
|
|
204
|
-
if (!schema.length && !userFields.length) {
|
|
205
|
-
metaInitDone = true;
|
|
206
|
-
return;
|
|
207
|
-
}
|
|
208
348
|
const metaFieldType = ed.schema.nodes.metaField;
|
|
209
349
|
if (!metaFieldType) return;
|
|
210
|
-
const
|
|
350
|
+
const coveredKeys = /* @__PURE__ */ new Set();
|
|
351
|
+
const coverWithSibling = (k) => {
|
|
352
|
+
coveredKeys.add(k);
|
|
353
|
+
const sib = DATE_SIBLING_KEY[k];
|
|
354
|
+
if (sib) coveredKeys.add(sib);
|
|
355
|
+
};
|
|
356
|
+
for (const f of [...schema, ...userFields]) {
|
|
357
|
+
if (f.key) coveredKeys.add(String(f.key));
|
|
358
|
+
if (f.startKey) coverWithSibling(String(f.startKey));
|
|
359
|
+
if (f.endKey) coverWithSibling(String(f.endKey));
|
|
360
|
+
if (f.allDayKey) coveredKeys.add(String(f.allDayKey));
|
|
361
|
+
if (f.latKey) coveredKeys.add(String(f.latKey));
|
|
362
|
+
if (f.lngKey) coveredKeys.add(String(f.lngKey));
|
|
363
|
+
}
|
|
364
|
+
const orphans = buildOrphanFields(docMeta, coveredKeys, metaFieldType);
|
|
365
|
+
const nodesToInsert = wasAlreadyInitialized ? [
|
|
211
366
|
...schema.map((f) => metaFieldType.create(schemaFieldToAttrs(f))),
|
|
212
|
-
...
|
|
367
|
+
...orphans
|
|
368
|
+
] : [
|
|
369
|
+
...schema.map((f) => metaFieldType.create(schemaFieldToAttrs(f))),
|
|
370
|
+
...userFields.map((f) => metaFieldType.create(userFieldToAttrs(f))),
|
|
371
|
+
...orphans
|
|
213
372
|
];
|
|
373
|
+
if (!nodesToInsert.length) {
|
|
374
|
+
metaInitDone = true;
|
|
375
|
+
return;
|
|
376
|
+
}
|
|
214
377
|
const { tr } = ed.state;
|
|
215
378
|
const insertPos = metaPos + 1;
|
|
216
379
|
tr.insert(insertPos, Fragment.fromArray(nodesToInsert));
|
|
217
380
|
ed.view.dispatch(tr);
|
|
218
|
-
|
|
381
|
+
deduplicateMetaFields(ed);
|
|
382
|
+
if (!wasAlreadyInitialized && userFields.length && canPersistTreeMeta) {
|
|
219
383
|
handleMetaUpdate({ _metaFields: void 0 });
|
|
220
384
|
}
|
|
221
385
|
metaInitDone = true;
|
|
222
386
|
}
|
|
387
|
+
watch(
|
|
388
|
+
() => {
|
|
389
|
+
const m = reactiveDocMeta.value;
|
|
390
|
+
return m ? Object.keys(m).sort().join("|") : "";
|
|
391
|
+
},
|
|
392
|
+
() => {
|
|
393
|
+
const ed = editorRef.value?.editor;
|
|
394
|
+
if (!ed) return;
|
|
395
|
+
metaInitDone = false;
|
|
396
|
+
initDocumentMeta(ed);
|
|
397
|
+
}
|
|
398
|
+
);
|
|
399
|
+
watch(resolvedMetaSchema, (newFields) => {
|
|
400
|
+
const ed = editorRef.value?.editor;
|
|
401
|
+
if (!ed || !newFields.length) return;
|
|
402
|
+
insertMissingSchemaFields(ed, newFields);
|
|
403
|
+
});
|
|
223
404
|
let syncingFromEditor = false;
|
|
224
405
|
let lastSyncedLabel = null;
|
|
225
406
|
function getHeaderText(ed) {
|
|
@@ -12,8 +12,8 @@ declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {
|
|
|
12
12
|
awareness: boolean;
|
|
13
13
|
tag: "video" | "audio";
|
|
14
14
|
live: boolean;
|
|
15
|
-
total: boolean;
|
|
16
15
|
controls: boolean;
|
|
16
|
+
total: boolean;
|
|
17
17
|
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
18
18
|
declare const _default: typeof __VLS_export;
|
|
19
19
|
export default _default;
|
|
@@ -12,8 +12,8 @@ declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {
|
|
|
12
12
|
awareness: boolean;
|
|
13
13
|
tag: "video" | "audio";
|
|
14
14
|
live: boolean;
|
|
15
|
-
total: boolean;
|
|
16
15
|
controls: boolean;
|
|
16
|
+
total: boolean;
|
|
17
17
|
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
18
18
|
declare const _default: typeof __VLS_export;
|
|
19
19
|
export default _default;
|
|
@@ -16,4 +16,20 @@ export declare const MetaField: Node<any, {
|
|
|
16
16
|
updateMeta: ((patch: Record<string, unknown>) => void) | null;
|
|
17
17
|
}>;
|
|
18
18
|
export declare function schemaFieldToAttrs(field: any): Record<string, unknown>;
|
|
19
|
+
/**
|
|
20
|
+
* Meta keys that must never surface as auto-detected chips: system flags,
|
|
21
|
+
* layout / positioning state, and view configuration written by renderers.
|
|
22
|
+
* Used by AEditor's orphan-detection path (`buildOrphanFields`) so tree-meta
|
|
23
|
+
* values written by MCP/seeders/renderers materialize as real metaField chips.
|
|
24
|
+
* Mirrors cou-sh's AUTO_DETECT_EXCLUDED.
|
|
25
|
+
*/
|
|
26
|
+
export declare const AUTO_DETECT_EXCLUDED: Set<string>;
|
|
27
|
+
export declare function labelFromKey(key: string): string;
|
|
28
|
+
/**
|
|
29
|
+
* Infer TipTap metaField node attrs from a meta key and its current value.
|
|
30
|
+
* Used by AEditor's orphan auto-detection: tree-meta values written outside
|
|
31
|
+
* the editor (MCP, seeders, kanban/table renderers) get a matching chip
|
|
32
|
+
* materialized on open. Ported 1:1 from cou-sh/app/extensions/meta-field.ts.
|
|
33
|
+
*/
|
|
34
|
+
export declare function inferFieldAttrs(key: string, value: unknown): Record<string, unknown> | null;
|
|
19
35
|
export declare function userFieldToAttrs(f: any): Record<string, unknown>;
|
|
@@ -136,6 +136,131 @@ export function schemaFieldToAttrs(field) {
|
|
|
136
136
|
if (t === "members") return { fieldType: "members", fieldLabel: field.label ?? "", userDefined: false, metaKey: String(field.key) };
|
|
137
137
|
return { fieldType: "colorPreset", fieldLabel: "" };
|
|
138
138
|
}
|
|
139
|
+
const DEFAULT_COLOR_PRESETS = '["#6366f1","#ef4444","#22c55e","#3b82f6","#f97316","#a855f7","#ec4899","#14b8a6"]';
|
|
140
|
+
const ISO_DATE_RE = /^\d{4}-\d{2}-\d{2}$/;
|
|
141
|
+
const ISO_DATETIME_RE = /^\d{4}-\d{2}-\d{2}T/;
|
|
142
|
+
const TIME_RE = /^\d{2}:\d{2}/;
|
|
143
|
+
export const AUTO_DETECT_EXCLUDED = /* @__PURE__ */ new Set([
|
|
144
|
+
// System
|
|
145
|
+
"_metaFields",
|
|
146
|
+
"_metaInitialized",
|
|
147
|
+
"order",
|
|
148
|
+
// Layout / positioning
|
|
149
|
+
"deskX",
|
|
150
|
+
"deskY",
|
|
151
|
+
"deskMode",
|
|
152
|
+
"deskZ",
|
|
153
|
+
"deskScrollY",
|
|
154
|
+
"mmX",
|
|
155
|
+
"mmY",
|
|
156
|
+
"graphX",
|
|
157
|
+
"graphY",
|
|
158
|
+
"graphPinned",
|
|
159
|
+
"spX",
|
|
160
|
+
"spY",
|
|
161
|
+
"spZ",
|
|
162
|
+
"spRX",
|
|
163
|
+
"spRY",
|
|
164
|
+
"spRZ",
|
|
165
|
+
"spSX",
|
|
166
|
+
"spSY",
|
|
167
|
+
"spSZ",
|
|
168
|
+
"spShape",
|
|
169
|
+
"spOpacity",
|
|
170
|
+
"spModelUploadId",
|
|
171
|
+
"spModelDocId",
|
|
172
|
+
// View configuration (surfaced via page-type settings, not chips)
|
|
173
|
+
"graphSpacing",
|
|
174
|
+
"mmSpacing",
|
|
175
|
+
"showRefEdges",
|
|
176
|
+
"tableMode",
|
|
177
|
+
"tableColumns",
|
|
178
|
+
"tableColumnOrder",
|
|
179
|
+
"tableColumnWidths",
|
|
180
|
+
"tableSortKey",
|
|
181
|
+
"tableSortDir",
|
|
182
|
+
"checklistFilter",
|
|
183
|
+
"checklistSort",
|
|
184
|
+
"timelineZoom",
|
|
185
|
+
"timelinePixelsPerDay",
|
|
186
|
+
"timelineCenterDate",
|
|
187
|
+
"mapShowLabels",
|
|
188
|
+
"calendarWeekStart",
|
|
189
|
+
"calendarView",
|
|
190
|
+
"calendarShowWeekNumbers",
|
|
191
|
+
"galleryColumns",
|
|
192
|
+
"galleryAspect",
|
|
193
|
+
"galleryCardStyle",
|
|
194
|
+
"galleryShowLabels",
|
|
195
|
+
"gallerySortBy",
|
|
196
|
+
"kanbanColumnWidth",
|
|
197
|
+
"kanbanShowIcon",
|
|
198
|
+
"kanbanShowTags",
|
|
199
|
+
"kanbanShowPriority",
|
|
200
|
+
"kanbanShowDueDate",
|
|
201
|
+
"kanbanShowCover",
|
|
202
|
+
"spatialGridVisible",
|
|
203
|
+
"mediaRepeat",
|
|
204
|
+
"mediaShuffle",
|
|
205
|
+
// Cover (managed by gallery / cover UI)
|
|
206
|
+
"coverUploadId",
|
|
207
|
+
"coverDocId",
|
|
208
|
+
"coverMimeType",
|
|
209
|
+
// Geo (managed by map renderer)
|
|
210
|
+
"geoType",
|
|
211
|
+
"geoLat",
|
|
212
|
+
"geoLng",
|
|
213
|
+
"geoDescription"
|
|
214
|
+
]);
|
|
215
|
+
export function labelFromKey(key) {
|
|
216
|
+
return key.replace(/([a-z])([A-Z])/g, "$1 $2").replace(/[_-]/g, " ").replace(/\b\w/g, (c) => c.toUpperCase());
|
|
217
|
+
}
|
|
218
|
+
export function inferFieldAttrs(key, value) {
|
|
219
|
+
const label = labelFromKey(key);
|
|
220
|
+
const base = { fieldLabel: label, userDefined: true, metaKey: key };
|
|
221
|
+
if (key === "allDay" || /^_allday_/.test(key)) return null;
|
|
222
|
+
if (key === "members")
|
|
223
|
+
return { ...base, fieldType: "members" };
|
|
224
|
+
if (key === "color")
|
|
225
|
+
return { ...base, fieldType: "colorPreset", presets: DEFAULT_COLOR_PRESETS };
|
|
226
|
+
if (key === "icon")
|
|
227
|
+
return { ...base, fieldType: "icon" };
|
|
228
|
+
if (key === "priority")
|
|
229
|
+
return { ...base, fieldType: "select", options: JSON.stringify(["none", "low", "medium", "high", "urgent"]) };
|
|
230
|
+
if (key === "status")
|
|
231
|
+
return { ...base, fieldType: "select", options: JSON.stringify([]) };
|
|
232
|
+
if (key === "checked")
|
|
233
|
+
return { ...base, fieldType: "toggle" };
|
|
234
|
+
if (key === "rating")
|
|
235
|
+
return { ...base, fieldType: "rating", sliderMax: 5 };
|
|
236
|
+
if (value === null || value === void 0) return null;
|
|
237
|
+
if (typeof value === "boolean")
|
|
238
|
+
return { ...base, fieldType: "toggle" };
|
|
239
|
+
if (typeof value === "number") {
|
|
240
|
+
if (/progress|opacity/i.test(key))
|
|
241
|
+
return { ...base, fieldType: "slider", sliderMin: 0, sliderMax: 100 };
|
|
242
|
+
return { ...base, fieldType: "number", sliderMin: 0, sliderMax: 999999, sliderStep: 1, unit: "" };
|
|
243
|
+
}
|
|
244
|
+
if (Array.isArray(value)) {
|
|
245
|
+
if (value.length > 0 && typeof value[0] === "object" && value[0] !== null && "id" in value[0])
|
|
246
|
+
return { ...base, fieldType: "members" };
|
|
247
|
+
return { ...base, fieldType: "tags", options: JSON.stringify([]) };
|
|
248
|
+
}
|
|
249
|
+
if (typeof value === "string") {
|
|
250
|
+
if (ISO_DATETIME_RE.test(value))
|
|
251
|
+
return { ...base, fieldType: "datetime" };
|
|
252
|
+
if (ISO_DATE_RE.test(value))
|
|
253
|
+
return { ...base, fieldType: "date" };
|
|
254
|
+
if (TIME_RE.test(value))
|
|
255
|
+
return { ...base, fieldType: "time" };
|
|
256
|
+
if (/^https?:\/\//i.test(value))
|
|
257
|
+
return { ...base, fieldType: "url" };
|
|
258
|
+
if (/^#[0-9a-f]{3,8}$/i.test(value))
|
|
259
|
+
return { ...base, fieldType: "colorPicker" };
|
|
260
|
+
return { ...base, fieldType: "textarea" };
|
|
261
|
+
}
|
|
262
|
+
return null;
|
|
263
|
+
}
|
|
139
264
|
export function userFieldToAttrs(f) {
|
|
140
265
|
const base = { fieldType: f.type, fieldLabel: f.label ?? "", userDefined: true };
|
|
141
266
|
if (f.type === "datetimerange") return { ...base, startKey: f.startKey ?? "", endKey: f.endKey ?? "", allDayKey: f.allDayKey ?? "" };
|
|
@@ -21,34 +21,8 @@ const items = computed(() => {
|
|
|
21
21
|
void props.node.content.size;
|
|
22
22
|
return buildMetaMenuItems(props.editor);
|
|
23
23
|
});
|
|
24
|
-
const pageMeta = computed(
|
|
25
|
-
() => props.editor.storage?.metaField?.pageMeta ?? null
|
|
26
|
-
);
|
|
27
|
-
const fallbackChips = computed(() => {
|
|
28
|
-
if (editable.value || props.node.childCount > 0) return [];
|
|
29
|
-
const m = pageMeta.value;
|
|
30
|
-
if (!m) return [];
|
|
31
|
-
const chips = [];
|
|
32
|
-
if (m.status && m.status !== "none") chips.push({ icon: "i-lucide-circle-dot", label: String(m.status) });
|
|
33
|
-
if (typeof m.priority === "number" && m.priority > 0) chips.push({ icon: "i-lucide-flag", label: `P${m.priority}` });
|
|
34
|
-
if (typeof m.rating === "number" && m.rating > 0) chips.push({ icon: "i-lucide-star", label: `${m.rating}/5` });
|
|
35
|
-
if (m.dateStart || m.dateEnd) chips.push({ icon: "i-lucide-calendar", label: [m.dateStart, m.dateEnd].filter(Boolean).join(" \u2192 ") });
|
|
36
|
-
if (Array.isArray(m.members)) {
|
|
37
|
-
for (const mem of m.members) {
|
|
38
|
-
if (mem?.label) chips.push({ icon: "i-lucide-user", label: mem.label });
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
if (Array.isArray(m.tags)) {
|
|
42
|
-
for (const t of m.tags) chips.push({ icon: "i-lucide-tag", label: t });
|
|
43
|
-
}
|
|
44
|
-
if (m.url) chips.push({ icon: "i-lucide-link", label: String(m.url) });
|
|
45
|
-
if (m.email) chips.push({ icon: "i-lucide-mail", label: String(m.email) });
|
|
46
|
-
if (m.phone) chips.push({ icon: "i-lucide-phone", label: String(m.phone) });
|
|
47
|
-
if (typeof m.number === "number") chips.push({ icon: "i-lucide-hash", label: `${m.number}${m.unit ? ` ${m.unit}` : ""}` });
|
|
48
|
-
return chips;
|
|
49
|
-
});
|
|
50
24
|
const hiddenWhenEmpty = computed(
|
|
51
|
-
() => !editable.value && props.node.childCount === 0
|
|
25
|
+
() => !editable.value && props.node.childCount === 0
|
|
52
26
|
);
|
|
53
27
|
function placeCursorInMeta(event) {
|
|
54
28
|
const target = event.target;
|
|
@@ -98,22 +72,6 @@ function placeCursorInMeta(event) {
|
|
|
98
72
|
class="meta-content"
|
|
99
73
|
style="display: contents"
|
|
100
74
|
/>
|
|
101
|
-
<!-- Read-only fallback: static chips from the doc-tree meta when no
|
|
102
|
-
metaField chips were ever materialized in the content. -->
|
|
103
|
-
<template v-if="!editable && props.node.childCount === 0">
|
|
104
|
-
<UBadge
|
|
105
|
-
v-for="(chip, i) in fallbackChips"
|
|
106
|
-
:key="`${chip.icon}-${chip.label}-${i}`"
|
|
107
|
-
:icon="chip.icon"
|
|
108
|
-
color="neutral"
|
|
109
|
-
variant="soft"
|
|
110
|
-
size="sm"
|
|
111
|
-
class="rounded-full"
|
|
112
|
-
contenteditable="false"
|
|
113
|
-
>
|
|
114
|
-
{{ chip.label }}
|
|
115
|
-
</UBadge>
|
|
116
|
-
</template>
|
|
117
75
|
<span
|
|
118
76
|
v-show="editable"
|
|
119
77
|
contenteditable="false"
|
|
@@ -369,6 +369,36 @@ function onGripPointerDown(e) {
|
|
|
369
369
|
document.addEventListener("pointerup", onUp, true);
|
|
370
370
|
}
|
|
371
371
|
const isEditable = useNodeViewEditable(props);
|
|
372
|
+
const disabledValue = computed(() => {
|
|
373
|
+
const meta = storage()?.pageMeta ?? {};
|
|
374
|
+
const fmt = (v) => {
|
|
375
|
+
if (v == null || v === "") return "";
|
|
376
|
+
if (typeof v === "object") {
|
|
377
|
+
try {
|
|
378
|
+
return JSON.stringify(v);
|
|
379
|
+
} catch {
|
|
380
|
+
return String(v);
|
|
381
|
+
}
|
|
382
|
+
}
|
|
383
|
+
return String(v);
|
|
384
|
+
};
|
|
385
|
+
const keys = [metaKey.value, startKey.value, endKey.value, allDayKey.value, latKey.value, lngKey.value].filter((k) => k && k in meta);
|
|
386
|
+
const vals = keys.map((k) => fmt(meta[k])).filter(Boolean);
|
|
387
|
+
return vals.join(" \xB7 ");
|
|
388
|
+
});
|
|
389
|
+
const justCopied = ref(false);
|
|
390
|
+
async function copyDisabledValue() {
|
|
391
|
+
const text = disabledValue.value;
|
|
392
|
+
if (!text || !import.meta.client || !navigator?.clipboard) return;
|
|
393
|
+
try {
|
|
394
|
+
await navigator.clipboard.writeText(text);
|
|
395
|
+
justCopied.value = true;
|
|
396
|
+
setTimeout(() => {
|
|
397
|
+
justCopied.value = false;
|
|
398
|
+
}, 1200);
|
|
399
|
+
} catch {
|
|
400
|
+
}
|
|
401
|
+
}
|
|
372
402
|
const isHovered = ref(false);
|
|
373
403
|
const colorPopoverOpen = ref(false);
|
|
374
404
|
const iconPopoverOpen = ref(false);
|
|
@@ -485,7 +515,7 @@ function removeOption(opt) {
|
|
|
485
515
|
class="meta-field-chip"
|
|
486
516
|
contenteditable="false"
|
|
487
517
|
:data-field-type="fieldType"
|
|
488
|
-
:class="{ '
|
|
518
|
+
:class="{ 'meta-field-chip--dragging': isDragging }"
|
|
489
519
|
@mouseenter="isHovered = true"
|
|
490
520
|
@mouseleave="isHovered = false"
|
|
491
521
|
>
|
|
@@ -1317,6 +1347,24 @@ function removeOption(opt) {
|
|
|
1317
1347
|
@click.stop="deleteField"
|
|
1318
1348
|
/>
|
|
1319
1349
|
</UTooltip>
|
|
1350
|
+
|
|
1351
|
+
<!-- Read-only overlay: on viewer / read-only docs the chip has no editable
|
|
1352
|
+
control, so this transparent layer (a) blocks clicks from reaching the
|
|
1353
|
+
disabled inner controls, (b) hosts a tooltip revealing the full stored
|
|
1354
|
+
value the compact chip stands for, and (c) copies that value to the
|
|
1355
|
+
clipboard on click. Editable chips never render it, so interaction is
|
|
1356
|
+
unchanged there. -->
|
|
1357
|
+
<UTooltip
|
|
1358
|
+
v-if="!isEditable && disabledValue"
|
|
1359
|
+
:text="justCopied ? t.copied : disabledValue"
|
|
1360
|
+
:content="{ side: 'top' }"
|
|
1361
|
+
:delay-duration="150"
|
|
1362
|
+
>
|
|
1363
|
+
<span
|
|
1364
|
+
class="absolute inset-0 z-20 cursor-pointer"
|
|
1365
|
+
@click.stop="copyDisabledValue"
|
|
1366
|
+
/>
|
|
1367
|
+
</UTooltip>
|
|
1320
1368
|
</NodeViewWrapper>
|
|
1321
1369
|
</template>
|
|
1322
1370
|
|
package/dist/runtime/locale.d.ts
CHANGED
package/dist/runtime/locale.js
CHANGED
|
@@ -31,7 +31,8 @@ export const DEFAULT_LOCALE = {
|
|
|
31
31
|
noMembersFound: "No members found",
|
|
32
32
|
addTag: "Add tag\u2026",
|
|
33
33
|
dragToReorder: "Drag to reorder",
|
|
34
|
-
deleteField: "Delete field"
|
|
34
|
+
deleteField: "Delete field",
|
|
35
|
+
copied: "Copied"
|
|
35
36
|
},
|
|
36
37
|
commandPalette: {
|
|
37
38
|
placeholder: "Search or type a command\u2026",
|