@abraca/nuxt 2.10.0 → 2.13.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.d.mts +14 -0
- package/dist/module.json +1 -1
- package/dist/module.mjs +9 -0
- package/dist/runtime/assets/editor.css +1 -1
- package/dist/runtime/components/AConnectionBadge.d.vue.ts +29 -0
- package/dist/runtime/components/AConnectionBadge.vue +79 -0
- package/dist/runtime/components/AConnectionBadge.vue.d.ts +29 -0
- package/dist/runtime/components/ADocPickerModal.d.vue.ts +31 -0
- package/dist/runtime/components/ADocPickerModal.vue +191 -0
- package/dist/runtime/components/ADocPickerModal.vue.d.ts +31 -0
- package/dist/runtime/components/ADocumentTree.vue +65 -0
- package/dist/runtime/components/AEditor.d.vue.ts +19 -12
- package/dist/runtime/components/AEditor.vue +243 -165
- package/dist/runtime/components/AEditor.vue.d.ts +19 -12
- package/dist/runtime/components/AEncryptionModePicker.d.vue.ts +33 -0
- package/dist/runtime/components/AEncryptionModePicker.vue +211 -0
- package/dist/runtime/components/AEncryptionModePicker.vue.d.ts +33 -0
- package/dist/runtime/components/AModalShell.d.vue.ts +48 -0
- package/dist/runtime/components/AModalShell.vue +105 -0
- package/dist/runtime/components/AModalShell.vue.d.ts +48 -0
- package/dist/runtime/components/ANodePanel.d.vue.ts +17 -7
- package/dist/runtime/components/ANodePanel.vue +550 -451
- package/dist/runtime/components/ANodePanel.vue.d.ts +17 -7
- package/dist/runtime/components/ANodePanelHeader.d.vue.ts +20 -10
- package/dist/runtime/components/ANodePanelHeader.vue +17 -3
- package/dist/runtime/components/ANodePanelHeader.vue.d.ts +20 -10
- package/dist/runtime/components/ANodeSettingsPanel.d.vue.ts +2 -0
- package/dist/runtime/components/ANodeSettingsPanel.vue +21 -1
- package/dist/runtime/components/ANodeSettingsPanel.vue.d.ts +2 -0
- package/dist/runtime/components/ASnapshotPreviewModal.d.vue.ts +33 -0
- package/dist/runtime/components/ASnapshotPreviewModal.vue +430 -0
- package/dist/runtime/components/ASnapshotPreviewModal.vue.d.ts +33 -0
- package/dist/runtime/components/ATagsEditor.d.vue.ts +19 -0
- package/dist/runtime/components/ATagsEditor.vue +60 -0
- package/dist/runtime/components/ATagsEditor.vue.d.ts +19 -0
- 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/components/chat/AChatInput.d.vue.ts +11 -6
- package/dist/runtime/components/chat/AChatInput.vue +33 -2
- package/dist/runtime/components/chat/AChatInput.vue.d.ts +11 -6
- package/dist/runtime/components/chat/AChatList.d.vue.ts +12 -0
- package/dist/runtime/components/chat/AChatList.vue +76 -32
- package/dist/runtime/components/chat/AChatList.vue.d.ts +12 -0
- package/dist/runtime/components/chat/AChatMessages.d.vue.ts +4 -0
- package/dist/runtime/components/chat/AChatMessages.vue +57 -4
- package/dist/runtime/components/chat/AChatMessages.vue.d.ts +4 -0
- package/dist/runtime/components/chat/AChatPanel.d.vue.ts +6 -2
- package/dist/runtime/components/chat/AChatPanel.vue +17 -1
- package/dist/runtime/components/chat/AChatPanel.vue.d.ts +6 -2
- package/dist/runtime/components/chat/ANodeChatPanel.vue +1 -1
- package/dist/runtime/components/docs/ADocsSearch.d.vue.ts +1 -1
- package/dist/runtime/components/docs/ADocsSearch.vue.d.ts +1 -1
- package/dist/runtime/components/editor/ALocationPickerPopover.vue +28 -7
- package/dist/runtime/components/registry/APluginDetail.d.vue.ts +2 -2
- package/dist/runtime/components/registry/APluginDetail.vue.d.ts +2 -2
- package/dist/runtime/components/renderers/AChartRenderer.client.d.vue.ts +17 -0
- package/dist/runtime/components/renderers/AChartRenderer.client.vue +622 -0
- package/dist/runtime/components/renderers/AChartRenderer.client.vue.d.ts +17 -0
- package/dist/runtime/components/renderers/AGraphRenderer.vue +64 -15
- package/dist/runtime/components/renderers/AProseRenderer.d.vue.ts +2 -2
- package/dist/runtime/components/renderers/AProseRenderer.vue.d.ts +2 -2
- package/dist/runtime/components/renderers/calendar/ACalendarToolbar.d.vue.ts +2 -2
- package/dist/runtime/components/renderers/calendar/ACalendarToolbar.vue.d.ts +2 -2
- package/dist/runtime/components/renderers/media/MediaTransportBar.d.vue.ts +2 -2
- package/dist/runtime/components/renderers/media/MediaTransportBar.vue.d.ts +2 -2
- package/dist/runtime/components/renderers/sheets/ASheetsGrid.d.vue.ts +2 -2
- package/dist/runtime/components/renderers/sheets/ASheetsGrid.vue.d.ts +2 -2
- package/dist/runtime/components/settings/ASettingsAppearancePanel.d.vue.ts +3 -0
- package/dist/runtime/components/settings/ASettingsAppearancePanel.vue +67 -0
- package/dist/runtime/components/settings/ASettingsAppearancePanel.vue.d.ts +3 -0
- package/dist/runtime/components/settings/ASettingsGroup.d.vue.ts +24 -0
- package/dist/runtime/components/settings/ASettingsGroup.vue +31 -0
- package/dist/runtime/components/settings/ASettingsGroup.vue.d.ts +24 -0
- package/dist/runtime/components/settings/ASettingsModal.vue +84 -53
- package/dist/runtime/components/settings/ASettingsPlaceholder.d.vue.ts +20 -0
- package/dist/runtime/components/settings/ASettingsPlaceholder.vue +32 -0
- package/dist/runtime/components/settings/ASettingsPlaceholder.vue.d.ts +20 -0
- package/dist/runtime/components/settings/ASettingsRow.d.vue.ts +34 -0
- package/dist/runtime/components/settings/ASettingsRow.vue +34 -0
- package/dist/runtime/components/settings/ASettingsRow.vue.d.ts +34 -0
- package/dist/runtime/components/settings/sections.d.ts +37 -0
- package/dist/runtime/components/settings/sections.js +45 -0
- package/dist/runtime/components/shell/ABreadcrumbForDoc.d.vue.ts +6 -0
- package/dist/runtime/components/shell/ABreadcrumbForDoc.vue +75 -3
- package/dist/runtime/components/shell/ABreadcrumbForDoc.vue.d.ts +6 -0
- package/dist/runtime/components/shell/ADocPanelServerSettings.d.vue.ts +17 -0
- package/dist/runtime/components/shell/ADocPanelServerSettings.vue +253 -0
- package/dist/runtime/components/shell/ADocPanelServerSettings.vue.d.ts +17 -0
- package/dist/runtime/components/shell/ADocPanelSettings.d.vue.ts +2 -0
- package/dist/runtime/components/shell/ADocPanelSettings.vue +15 -4
- package/dist/runtime/components/shell/ADocPanelSettings.vue.d.ts +2 -0
- package/dist/runtime/components/shell/AUserProfilePopover.d.vue.ts +1 -1
- package/dist/runtime/components/shell/AUserProfilePopover.vue.d.ts +1 -1
- package/dist/runtime/composables/useChat.d.ts +22 -1
- package/dist/runtime/composables/useChat.js +79 -8
- package/dist/runtime/composables/useDocBreadcrumb.d.ts +17 -2
- package/dist/runtime/composables/useDocBreadcrumb.js +17 -3
- package/dist/runtime/composables/useDocSnapshots.d.ts +2 -1
- package/dist/runtime/composables/useDocSnapshots.js +5 -0
- package/dist/runtime/composables/useEditor.d.ts +1 -1
- package/dist/runtime/composables/useEditor.js +120 -0
- package/dist/runtime/composables/useEditorToolbar.d.ts +12 -4
- package/dist/runtime/composables/useEditorToolbar.js +78 -56
- package/dist/runtime/composables/useNodeContextMenu.d.ts +14 -0
- package/dist/runtime/composables/useNodeContextMenu.js +59 -1
- package/dist/runtime/composables/useSettingsModal.d.ts +1 -1
- package/dist/runtime/composables/useSwipeGesture.d.ts +48 -0
- package/dist/runtime/composables/useSwipeGesture.js +140 -0
- package/dist/runtime/extensions/document-header.js +16 -6
- package/dist/runtime/extensions/document-meta.js +344 -19
- package/dist/runtime/extensions/meta-field.js +42 -0
- package/dist/runtime/extensions/views/DocumentMetaView.vue +33 -7
- package/dist/runtime/extensions/views/FieldView.vue +51 -19
- package/dist/runtime/extensions/views/MetaFieldView.vue +30 -4
- package/dist/runtime/locale.d.ts +8 -0
- package/dist/runtime/locale.js +9 -1
- package/dist/runtime/middleware/abracadabra-auth.d.ts +1 -1
- package/dist/runtime/plugin-abracadabra.client.d.ts +1 -1
- package/dist/runtime/plugin-abracadabra.client.js +12 -2
- package/dist/runtime/plugin-abracadabra.server.d.ts +1 -1
- package/dist/runtime/plugin-shared-globals.client.d.ts +1 -1
- package/dist/runtime/utils/chatContent.d.ts +20 -2
- package/dist/runtime/utils/chatContent.js +20 -1
- package/dist/runtime/utils/docTypes.js +43 -0
- package/dist/runtime/utils/titleSync.d.ts +130 -0
- package/dist/runtime/utils/titleSync.js +53 -0
- package/package.json +11 -4
package/dist/runtime/locale.js
CHANGED
|
@@ -47,6 +47,10 @@ export const DEFAULT_LOCALE = {
|
|
|
47
47
|
nodePanel: {
|
|
48
48
|
editorTab: "Editor",
|
|
49
49
|
propertiesTab: "Properties",
|
|
50
|
+
chatTab: "Chat",
|
|
51
|
+
settingsTab: "Settings",
|
|
52
|
+
serverTab: "Server",
|
|
53
|
+
openAsFullPage: "Open as full page",
|
|
50
54
|
close: "Close",
|
|
51
55
|
icon: "Icon",
|
|
52
56
|
color: "Color",
|
|
@@ -236,7 +240,11 @@ export const DEFAULT_LOCALE = {
|
|
|
236
240
|
edgeThin: "Thin",
|
|
237
241
|
edgeNormal: "Normal",
|
|
238
242
|
edgeThick: "Thick",
|
|
239
|
-
filter: "Filter"
|
|
243
|
+
filter: "Filter",
|
|
244
|
+
scrollBehavior: "Scroll behavior",
|
|
245
|
+
personalSetting: "Personal \u2014 this device only",
|
|
246
|
+
scrollPan: "Pan",
|
|
247
|
+
scrollZoom: "Zoom"
|
|
240
248
|
},
|
|
241
249
|
dashboard: {
|
|
242
250
|
addItem: "Add item",
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
declare const _default:
|
|
1
|
+
declare const _default: import("#app").RouteMiddleware;
|
|
2
2
|
export default _default;
|
|
@@ -208,6 +208,7 @@ export default defineNuxtPlugin({
|
|
|
208
208
|
const features = abraConfig.features ?? {};
|
|
209
209
|
const debug = abraConfig.debug ?? false;
|
|
210
210
|
const configEntryDocId = abraConfig.entryDocId || void 0;
|
|
211
|
+
const pinServer = abraConfig.pinServer ?? false;
|
|
211
212
|
const registry = new PluginRegistry();
|
|
212
213
|
const storedDisabledBuiltins = JSON.parse(
|
|
213
214
|
localStorage.getItem(STORAGE_KEY_DISABLED_BUILTINS) ?? "[]"
|
|
@@ -1398,10 +1399,19 @@ export default defineNuxtPlugin({
|
|
|
1398
1399
|
} catch {
|
|
1399
1400
|
}
|
|
1400
1401
|
const storedServer = localStorage.getItem(CURRENT_SERVER_KEY);
|
|
1401
|
-
|
|
1402
|
+
let initialUrl;
|
|
1403
|
+
if (pinServer) {
|
|
1404
|
+
initialUrl = defaultUrl;
|
|
1405
|
+
} else if (deepLinkServer) {
|
|
1406
|
+
initialUrl = deepLinkServer;
|
|
1407
|
+
} else if (storedServer && savedServers.value.some((s) => s.url === storedServer)) {
|
|
1408
|
+
initialUrl = storedServer;
|
|
1409
|
+
} else {
|
|
1410
|
+
initialUrl = currentServerUrl.value || savedServers.value[0]?.url || defaultUrl;
|
|
1411
|
+
}
|
|
1402
1412
|
if (initialUrl !== currentServerUrl.value) currentServerUrl.value = initialUrl;
|
|
1403
1413
|
_initPromise = init(initialUrl);
|
|
1404
|
-
if (deepLinkServer && !savedServers.value.some((s) => s.url === deepLinkServer)) {
|
|
1414
|
+
if (!pinServer && deepLinkServer && !savedServers.value.some((s) => s.url === deepLinkServer)) {
|
|
1405
1415
|
void addServer(deepLinkServer).catch(() => {
|
|
1406
1416
|
});
|
|
1407
1417
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
declare const _default:
|
|
1
|
+
declare const _default: import("#app").Plugin<Record<string, unknown>> & import("#app").ObjectPlugin<Record<string, unknown>>;
|
|
2
2
|
export default _default;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
declare const _default:
|
|
1
|
+
declare const _default: import("#app").Plugin<Record<string, unknown>> & import("#app").ObjectPlugin<Record<string, unknown>>;
|
|
2
2
|
export default _default;
|
|
@@ -24,7 +24,11 @@ export type ParsedMessage = {
|
|
|
24
24
|
icon?: string;
|
|
25
25
|
};
|
|
26
26
|
export declare function parseMessageContent(content: string): ParsedMessage;
|
|
27
|
-
/**
|
|
27
|
+
/**
|
|
28
|
+
* Segment types for rich text rendering. Markdown spans (bold/italic/strike/
|
|
29
|
+
* code) carry their inner `value` as plain text — rendered as styled spans, so
|
|
30
|
+
* there is NO HTML injection (no `v-html`); the renderer just picks a tag/class.
|
|
31
|
+
*/
|
|
28
32
|
export type TextSegment = {
|
|
29
33
|
type: 'text';
|
|
30
34
|
value: string;
|
|
@@ -34,8 +38,22 @@ export type TextSegment = {
|
|
|
34
38
|
} | {
|
|
35
39
|
type: 'mention';
|
|
36
40
|
name: string;
|
|
41
|
+
} | {
|
|
42
|
+
type: 'bold';
|
|
43
|
+
value: string;
|
|
44
|
+
} | {
|
|
45
|
+
type: 'italic';
|
|
46
|
+
value: string;
|
|
47
|
+
} | {
|
|
48
|
+
type: 'strike';
|
|
49
|
+
value: string;
|
|
50
|
+
} | {
|
|
51
|
+
type: 'code';
|
|
52
|
+
value: string;
|
|
37
53
|
};
|
|
38
|
-
/** Split plain text into segments for rich rendering (links, @mentions) */
|
|
54
|
+
/** Split plain text into segments for rich rendering (markdown, links, @mentions). */
|
|
39
55
|
export declare function renderMessageSegments(text: string): TextSegment[];
|
|
56
|
+
/** Whether a plain-text message contains any rich span (markdown/link/mention). */
|
|
57
|
+
export declare function hasRichText(text: string): boolean;
|
|
40
58
|
/** Return a short plain-text preview for any message content string. */
|
|
41
59
|
export declare function previewMessageContent(content: string): string;
|
|
@@ -28,16 +28,32 @@ export function parseMessageContent(content) {
|
|
|
28
28
|
}
|
|
29
29
|
const URL_RE = /https?:\/\/[^\s<>)"']+/g;
|
|
30
30
|
const MENTION_RE = /@(\w+)/g;
|
|
31
|
+
const CODE_RE = /`([^`\n]+)`/g;
|
|
32
|
+
const BOLD_RE = /\*\*([^*\n]+)\*\*/g;
|
|
33
|
+
const STRIKE_RE = /~~([^~\n]+)~~/g;
|
|
34
|
+
const ITALIC_RE = /\*([^*\n]+)\*|_([^_\n]+)_/g;
|
|
31
35
|
export function renderMessageSegments(text) {
|
|
32
36
|
const segments = [];
|
|
33
37
|
const matches = [];
|
|
38
|
+
for (const m of text.matchAll(CODE_RE)) {
|
|
39
|
+
matches.push({ index: m.index, length: m[0].length, segment: { type: "code", value: m[1] } });
|
|
40
|
+
}
|
|
41
|
+
for (const m of text.matchAll(BOLD_RE)) {
|
|
42
|
+
matches.push({ index: m.index, length: m[0].length, segment: { type: "bold", value: m[1] } });
|
|
43
|
+
}
|
|
44
|
+
for (const m of text.matchAll(STRIKE_RE)) {
|
|
45
|
+
matches.push({ index: m.index, length: m[0].length, segment: { type: "strike", value: m[1] } });
|
|
46
|
+
}
|
|
47
|
+
for (const m of text.matchAll(ITALIC_RE)) {
|
|
48
|
+
matches.push({ index: m.index, length: m[0].length, segment: { type: "italic", value: m[1] ?? m[2] } });
|
|
49
|
+
}
|
|
34
50
|
for (const m of text.matchAll(URL_RE)) {
|
|
35
51
|
matches.push({ index: m.index, length: m[0].length, segment: { type: "link", url: m[0] } });
|
|
36
52
|
}
|
|
37
53
|
for (const m of text.matchAll(MENTION_RE)) {
|
|
38
54
|
matches.push({ index: m.index, length: m[0].length, segment: { type: "mention", name: m[1] } });
|
|
39
55
|
}
|
|
40
|
-
matches.sort((a, b) => a.index - b.index);
|
|
56
|
+
matches.sort((a, b) => a.index - b.index || b.length - a.length);
|
|
41
57
|
let cursor = 0;
|
|
42
58
|
for (const m of matches) {
|
|
43
59
|
if (m.index < cursor) continue;
|
|
@@ -52,6 +68,9 @@ export function renderMessageSegments(text) {
|
|
|
52
68
|
}
|
|
53
69
|
return segments.length > 0 ? segments : [{ type: "text", value: text }];
|
|
54
70
|
}
|
|
71
|
+
export function hasRichText(text) {
|
|
72
|
+
return /@\w+|https?:\/\/|\*\*[^*\n]+\*\*|~~[^~\n]+~~|`[^`\n]+`|\*[^*\n]+\*|_[^_\n]+_/.test(text);
|
|
73
|
+
}
|
|
55
74
|
export function previewMessageContent(content) {
|
|
56
75
|
const parsed = parseMessageContent(content);
|
|
57
76
|
if (parsed.kind === "doc-quote") {
|
|
@@ -138,6 +138,19 @@ export const DOC_TYPES = {
|
|
|
138
138
|
() => import("../components/renderers/ATableRenderer.vue")
|
|
139
139
|
)
|
|
140
140
|
},
|
|
141
|
+
sheets: {
|
|
142
|
+
key: "sheets",
|
|
143
|
+
label: "Sheets",
|
|
144
|
+
icon: "i-lucide-grid-3x3",
|
|
145
|
+
description: "Spreadsheet \u2014 cells, formulas, and formatting in a collaborative grid",
|
|
146
|
+
available: true,
|
|
147
|
+
supportsChildren: true,
|
|
148
|
+
childLabel: "Column",
|
|
149
|
+
grandchildLabel: "Cell",
|
|
150
|
+
component: defineDocComponent(
|
|
151
|
+
() => import("../components/renderers/ASheetsRenderer.client.vue")
|
|
152
|
+
)
|
|
153
|
+
},
|
|
141
154
|
outline: {
|
|
142
155
|
key: "outline",
|
|
143
156
|
label: "Outline",
|
|
@@ -226,6 +239,24 @@ export const DOC_TYPES = {
|
|
|
226
239
|
() => import("../components/renderers/AGraphRenderer.vue")
|
|
227
240
|
)
|
|
228
241
|
},
|
|
242
|
+
chart: {
|
|
243
|
+
key: "chart",
|
|
244
|
+
label: "Chart",
|
|
245
|
+
icon: "i-lucide-bar-chart-3",
|
|
246
|
+
description: "Charts \u2014 manual data points or aggregation over document trees",
|
|
247
|
+
available: true,
|
|
248
|
+
supportsChildren: true,
|
|
249
|
+
childLabel: "Data Point",
|
|
250
|
+
grandchildLabel: "Data Point",
|
|
251
|
+
component: defineDocComponent(
|
|
252
|
+
() => import("../components/renderers/AChartRenderer.client.vue")
|
|
253
|
+
),
|
|
254
|
+
metaSchema: [
|
|
255
|
+
{ type: "number", key: "number", step: 0.01, label: "Value" },
|
|
256
|
+
{ type: "colorPreset", key: "color", presets: ["#6366f1", "#ec4899", "#f97316", "#22c55e", "#3b82f6", "#a855f7", "#14b8a6", "#eab308"], label: "Color" },
|
|
257
|
+
{ type: "tags", key: "tags", label: "Tags" }
|
|
258
|
+
]
|
|
259
|
+
},
|
|
229
260
|
dashboard: {
|
|
230
261
|
key: "dashboard",
|
|
231
262
|
label: "Dashboard",
|
|
@@ -271,6 +302,18 @@ export const DOC_TYPES = {
|
|
|
271
302
|
{ type: "select", key: "slidesTransition", options: ["none", "fade", "slide"], label: "Transition" },
|
|
272
303
|
{ type: "colorPreset", key: "color", presets: ["#6366f1", "#ec4899", "#f97316", "#22c55e", "#3b82f6", "#a855f7"], label: "Accent" }
|
|
273
304
|
]
|
|
305
|
+
},
|
|
306
|
+
overview: {
|
|
307
|
+
key: "overview",
|
|
308
|
+
label: "Overview",
|
|
309
|
+
icon: "i-lucide-radar",
|
|
310
|
+
description: "Space home \u2014 activity, people, stats, and health at a glance",
|
|
311
|
+
available: true,
|
|
312
|
+
supportsChildren: true,
|
|
313
|
+
childLabel: "Page",
|
|
314
|
+
component: defineDocComponent(
|
|
315
|
+
() => import("../components/renderers/AOverviewRenderer.vue")
|
|
316
|
+
)
|
|
274
317
|
}
|
|
275
318
|
};
|
|
276
319
|
export const DEFAULT_DOC_TYPE = DOC_TYPES.doc;
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* titleSync — pure decision logic for keeping the H1 documentHeader and the
|
|
3
|
+
* tree-entry `label` field in agreement, plus a defensive `setHeaderText`.
|
|
4
|
+
*
|
|
5
|
+
* The two sources of truth are:
|
|
6
|
+
* - the `documentHeader` Y.XmlElement inside the child doc's Y.XmlFragment
|
|
7
|
+
* (rendered by TipTap as the H1 at the top of the page);
|
|
8
|
+
* - the `label` field on the doc's tree entry in the root provider's treeMap
|
|
9
|
+
* (rendered by the sidebar, breadcrumb, browser title, etc.).
|
|
10
|
+
*
|
|
11
|
+
* Past regressions in this area lost user titles because:
|
|
12
|
+
* - the editor mounted on an empty Y.XmlFragment, y-prosemirror seeded an
|
|
13
|
+
* empty documentHeader, then the server snapshot arrived with the real
|
|
14
|
+
* title and the local empty got merged in — sometimes winning the
|
|
15
|
+
* "canonical pick" inside enforceDocumentShape;
|
|
16
|
+
* - the post-sync flow only wrote header → tree on LOCAL updates, so a
|
|
17
|
+
* server-delivered title never reflected back into the tree label and the
|
|
18
|
+
* sidebar stayed stuck on "Untitled";
|
|
19
|
+
* - the tree-label → header watcher unconditionally called
|
|
20
|
+
* `setHeaderText(editor, newLabel || '')`, which on a transient
|
|
21
|
+
* `newLabel = undefined` would erase the user's title.
|
|
22
|
+
*
|
|
23
|
+
* `decideTitleSync` is the canonical answer for "what should I do given the
|
|
24
|
+
* current state of both sides?", returning one of three actions. It is pure
|
|
25
|
+
* so it can be exhaustively table-tested.
|
|
26
|
+
*
|
|
27
|
+
* `setHeaderText` is the only sanctioned way for the renderer to write into
|
|
28
|
+
* the documentHeader. It refuses to overwrite a non-empty header with an
|
|
29
|
+
* empty string unless the caller passes `force: true`.
|
|
30
|
+
*
|
|
31
|
+
* Ported 1:1 from cou-sh/app/utils/titleSync.ts.
|
|
32
|
+
*/
|
|
33
|
+
/** Sentinel placeholder label used by the tree when no real label has been set. */
|
|
34
|
+
export declare const UNTITLED = "Untitled";
|
|
35
|
+
/**
|
|
36
|
+
* The tree label is "empty" — meaning it carries no user-supplied title —
|
|
37
|
+
* when it's the empty string, null/undefined, or the literal placeholder
|
|
38
|
+
* `"Untitled"`. The two former cases come from a freshly-created tree row
|
|
39
|
+
* (no label yet); the latter comes from `useChildTree.renameEntry`
|
|
40
|
+
* canonicalising a cleared title to `"Untitled"` so the UI never has to
|
|
41
|
+
* render `null`.
|
|
42
|
+
*/
|
|
43
|
+
export declare function isEmptyTreeLabel(label: string | null | undefined): boolean;
|
|
44
|
+
export type TitleSyncAction = {
|
|
45
|
+
kind: 'noop';
|
|
46
|
+
} | {
|
|
47
|
+
kind: 'header-from-tree';
|
|
48
|
+
text: string;
|
|
49
|
+
} | {
|
|
50
|
+
kind: 'tree-from-header';
|
|
51
|
+
label: string;
|
|
52
|
+
};
|
|
53
|
+
export interface TitleSyncInput {
|
|
54
|
+
/** Text content of the `documentHeader` node (what TipTap renders). */
|
|
55
|
+
headerText: string;
|
|
56
|
+
/**
|
|
57
|
+
* Current tree-entry label, or null/undefined if the entry hasn't loaded.
|
|
58
|
+
* Caller is expected to fall back to `props.docLabel` before passing in.
|
|
59
|
+
*/
|
|
60
|
+
treeLabel: string | null | undefined;
|
|
61
|
+
/**
|
|
62
|
+
* True when the originating ProseMirror transaction was driven by a Yjs
|
|
63
|
+
* remote update (i.e. `transaction.getMeta('y-sync$')?.isChangeOrigin`).
|
|
64
|
+
* Used to disambiguate "the user just typed this" from "the server told
|
|
65
|
+
* us this".
|
|
66
|
+
*/
|
|
67
|
+
isRemoteUpdate: boolean;
|
|
68
|
+
/**
|
|
69
|
+
* Whether `syncHeader` has already performed its first-mount reconciliation
|
|
70
|
+
* for this editor instance. Set by the caller; the first call must pass
|
|
71
|
+
* `false` and every subsequent call must pass `true`.
|
|
72
|
+
*/
|
|
73
|
+
initialSyncDone: boolean;
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* Decide what (if anything) needs to change to keep the header and the tree
|
|
77
|
+
* label in agreement.
|
|
78
|
+
*
|
|
79
|
+
* The truth table — every cell is pinned by `test/title-sync-decision.test.ts`:
|
|
80
|
+
*
|
|
81
|
+
* ┌──────────────┬───────────────────┬───────────────────────────────────────┐
|
|
82
|
+
* │ headerText │ treeLabel │ result │
|
|
83
|
+
* ├──────────────┼───────────────────┼───────────────────────────────────────┤
|
|
84
|
+
* │ empty │ empty/Untitled │ noop (no information either way) │
|
|
85
|
+
* │ same │ same │ noop │
|
|
86
|
+
* │ has text │ empty/Untitled │ tree-from-header (RESCUE — incl. │
|
|
87
|
+
* │ │ │ remote: server delivered the title │
|
|
88
|
+
* │ │ │ via the doc fragment, tree needs │
|
|
89
|
+
* │ │ │ to catch up) │
|
|
90
|
+
* │ empty │ has text │ initial OR remote → header-from-tree │
|
|
91
|
+
* │ │ │ local + post-initial → tree-from- │
|
|
92
|
+
* │ │ │ header('Untitled') (user emptied │
|
|
93
|
+
* │ │ │ the title, so canonicalise) │
|
|
94
|
+
* │ different │ different │ initial OR local → tree-from-header │
|
|
95
|
+
* │ │ │ remote + post-initial → noop (the │
|
|
96
|
+
* │ │ │ label watcher reconciles header │
|
|
97
|
+
* │ │ │ from tree if needed) │
|
|
98
|
+
* └──────────────┴───────────────────┴───────────────────────────────────────┘
|
|
99
|
+
*/
|
|
100
|
+
export declare function decideTitleSync(input: TitleSyncInput): TitleSyncAction;
|
|
101
|
+
export interface SetHeaderTextOptions {
|
|
102
|
+
/**
|
|
103
|
+
* Allow overwriting a non-empty `documentHeader` with an empty string.
|
|
104
|
+
* Default `false`. The watcher on the tree label MUST NOT pass `true` — a
|
|
105
|
+
* transient `newLabel = undefined` during reload would otherwise erase the
|
|
106
|
+
* user's title. Setting `force: true` is reserved for the explicit "user
|
|
107
|
+
* emptied the title locally" path.
|
|
108
|
+
*/
|
|
109
|
+
force?: boolean;
|
|
110
|
+
}
|
|
111
|
+
/**
|
|
112
|
+
* Replace the inline text content of the first `documentHeader` node in
|
|
113
|
+
* `ed.state.doc`. Refuses the write when:
|
|
114
|
+
* - there is no documentHeader at index 0;
|
|
115
|
+
* - the header already has the requested text (cheap no-op);
|
|
116
|
+
* - the user's selection is inside the header (an external sync echo must
|
|
117
|
+
* never clobber in-flight typing);
|
|
118
|
+
* - `text` is empty AND the existing header is non-empty AND `force`
|
|
119
|
+
* wasn't passed (the no-destroy invariant).
|
|
120
|
+
*
|
|
121
|
+
* Returns `true` if a transaction was dispatched, `false` otherwise. Used
|
|
122
|
+
* by tests to assert the no-destroy invariant.
|
|
123
|
+
*/
|
|
124
|
+
export declare function setHeaderText(ed: {
|
|
125
|
+
state: any;
|
|
126
|
+
view: {
|
|
127
|
+
dispatch: (tr: any) => void;
|
|
128
|
+
hasFocus?: () => boolean;
|
|
129
|
+
};
|
|
130
|
+
}, text: string, opts?: SetHeaderTextOptions): boolean;
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { Fragment } from "@tiptap/pm/model";
|
|
2
|
+
export const UNTITLED = "Untitled";
|
|
3
|
+
export function isEmptyTreeLabel(label) {
|
|
4
|
+
return !label || label === UNTITLED;
|
|
5
|
+
}
|
|
6
|
+
export function decideTitleSync(input) {
|
|
7
|
+
const { headerText, treeLabel, isRemoteUpdate, initialSyncDone } = input;
|
|
8
|
+
const treeEmpty = isEmptyTreeLabel(treeLabel);
|
|
9
|
+
const headerEmpty = isEmptyTreeLabel(headerText);
|
|
10
|
+
if (treeEmpty && headerEmpty) return { kind: "noop" };
|
|
11
|
+
if (!headerEmpty && !treeEmpty && headerText === treeLabel) {
|
|
12
|
+
return { kind: "noop" };
|
|
13
|
+
}
|
|
14
|
+
if (!headerEmpty && treeEmpty) {
|
|
15
|
+
return { kind: "tree-from-header", label: headerText };
|
|
16
|
+
}
|
|
17
|
+
if (headerEmpty && !treeEmpty) {
|
|
18
|
+
if (!initialSyncDone) {
|
|
19
|
+
return { kind: "header-from-tree", text: treeLabel };
|
|
20
|
+
}
|
|
21
|
+
if (isRemoteUpdate) {
|
|
22
|
+
return { kind: "header-from-tree", text: treeLabel };
|
|
23
|
+
}
|
|
24
|
+
return { kind: "noop" };
|
|
25
|
+
}
|
|
26
|
+
if (!initialSyncDone) {
|
|
27
|
+
return { kind: "tree-from-header", label: headerText };
|
|
28
|
+
}
|
|
29
|
+
if (!isRemoteUpdate) {
|
|
30
|
+
return { kind: "tree-from-header", label: headerText };
|
|
31
|
+
}
|
|
32
|
+
return { kind: "noop" };
|
|
33
|
+
}
|
|
34
|
+
export function setHeaderText(ed, text, opts = {}) {
|
|
35
|
+
const first = ed.state.doc.firstChild;
|
|
36
|
+
if (!first || first.type.name !== "documentHeader") return false;
|
|
37
|
+
if (first.textContent === text) return false;
|
|
38
|
+
const hasFocus = typeof ed.view.hasFocus === "function" ? ed.view.hasFocus() : false;
|
|
39
|
+
if (hasFocus) {
|
|
40
|
+
const { $head } = ed.state.selection;
|
|
41
|
+
if ($head?.parent?.type?.name === "documentHeader") return false;
|
|
42
|
+
}
|
|
43
|
+
if (!text && first.textContent && !opts.force) return false;
|
|
44
|
+
const { tr, schema } = ed.state;
|
|
45
|
+
const to = 1 + first.content.size;
|
|
46
|
+
if (text) {
|
|
47
|
+
tr.replaceWith(1, to, schema.text(text));
|
|
48
|
+
} else {
|
|
49
|
+
tr.replaceWith(1, to, Fragment.empty);
|
|
50
|
+
}
|
|
51
|
+
ed.view.dispatch(tr);
|
|
52
|
+
return true;
|
|
53
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@abraca/nuxt",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.13.0",
|
|
4
4
|
"description": "First-class Nuxt module for the Abracadabra CRDT collaboration platform",
|
|
5
5
|
"repository": "abracadabra/abracadabra-nuxt",
|
|
6
6
|
"license": "MIT",
|
|
@@ -70,6 +70,8 @@
|
|
|
70
70
|
"@tiptap/extension-text-style": "^3.0.0",
|
|
71
71
|
"@tiptap/starter-kit": "^3.0.0",
|
|
72
72
|
"@tiptap/vue-3": "^3.0.0",
|
|
73
|
+
"@unovis/ts": "^1.6.5",
|
|
74
|
+
"@unovis/vue": "^1.6.5",
|
|
73
75
|
"d3-force": "^3.0.0",
|
|
74
76
|
"jszip": "^3.0.0",
|
|
75
77
|
"lowlight": "^3.0.0",
|
|
@@ -120,9 +122,6 @@
|
|
|
120
122
|
"y-codemirror.next": {
|
|
121
123
|
"optional": true
|
|
122
124
|
},
|
|
123
|
-
"@tanstack/vue-virtual": {
|
|
124
|
-
"optional": true
|
|
125
|
-
},
|
|
126
125
|
"d3-force": {
|
|
127
126
|
"optional": true
|
|
128
127
|
},
|
|
@@ -134,6 +133,12 @@
|
|
|
134
133
|
},
|
|
135
134
|
"@tiptap/extension-emoji": {
|
|
136
135
|
"optional": true
|
|
136
|
+
},
|
|
137
|
+
"@unovis/vue": {
|
|
138
|
+
"optional": true
|
|
139
|
+
},
|
|
140
|
+
"@unovis/ts": {
|
|
141
|
+
"optional": true
|
|
137
142
|
}
|
|
138
143
|
},
|
|
139
144
|
"devDependencies": {
|
|
@@ -166,6 +171,8 @@
|
|
|
166
171
|
"@types/d3-force": "^3.0.10",
|
|
167
172
|
"@types/node": "latest",
|
|
168
173
|
"@types/ws": "^8.18.1",
|
|
174
|
+
"@unovis/ts": "^1.6.5",
|
|
175
|
+
"@unovis/vue": "^1.6.5",
|
|
169
176
|
"@vue/test-utils": "^2.4.10",
|
|
170
177
|
"changelogen": "^0.6.2",
|
|
171
178
|
"d3-force": "^3.0.0",
|