@abraca/nuxt 2.50.0 → 2.52.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/ADocRenderer.vue +6 -1
- package/dist/runtime/components/ADocViewToggle.vue +10 -2
- package/dist/runtime/components/ADocumentTree.vue +92 -78
- package/dist/runtime/components/AEditor.vue +7 -1
- 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/renderers/AMediaRenderer.vue +2 -0
- package/dist/runtime/components/renderers/table/ATableColumnHeader.d.vue.ts +6 -0
- package/dist/runtime/components/renderers/table/ATableColumnHeader.vue +24 -19
- package/dist/runtime/components/renderers/table/ATableColumnHeader.vue.d.ts +6 -0
- package/dist/runtime/components/renderers/table/ATableFlatMode.vue +2 -0
- package/dist/runtime/components/renderers/table/ATableHierarchyMode.vue +2 -0
- package/dist/runtime/components/renderers/table/ATableToolbar.vue +18 -2
- package/dist/runtime/composables/useDocSeo.js +11 -5
- package/dist/runtime/composables/useNodeContextMenu.d.ts +11 -0
- package/dist/runtime/composables/useNodeContextMenu.js +13 -3
- package/dist/runtime/extensions/views/DocLinkView.d.vue.ts +12 -0
- package/dist/runtime/extensions/views/DocLinkView.vue +139 -20
- package/dist/runtime/extensions/views/DocLinkView.vue.d.ts +12 -0
- package/dist/runtime/server/utils/docCache.js +6 -3
- package/dist/runtime/server/utils/serverSchemaStubs.d.ts +9 -0
- package/dist/runtime/server/utils/serverSchemaStubs.js +41 -0
- package/package.json +1 -1
package/dist/module.json
CHANGED
|
@@ -4,6 +4,7 @@ import { useFetch } from "#imports";
|
|
|
4
4
|
import { useAbracadabra } from "../composables/useAbracadabra";
|
|
5
5
|
import { useSpaceConnections } from "../composables/useSpaceConnections";
|
|
6
6
|
import { usePluginRegistry } from "../composables/usePluginRegistry";
|
|
7
|
+
import { useDocumentPermissions } from "../composables/useDocumentPermissions";
|
|
7
8
|
import { resolveDocType } from "../utils/docTypes";
|
|
8
9
|
const props = defineProps({
|
|
9
10
|
docId: { type: String, required: true },
|
|
@@ -22,6 +23,10 @@ const docType = computed(() => props.entry?.type ?? resolvedEntry.value?.type ??
|
|
|
22
23
|
const docMeta = computed(() => props.entry?.meta ?? resolvedEntry.value?.meta ?? {});
|
|
23
24
|
const registry = usePluginRegistry();
|
|
24
25
|
const docTypeDef = computed(() => resolveDocType(docType.value, registry));
|
|
26
|
+
const { canWrite: canWriteRole } = useDocumentPermissions(abra.effectiveRole);
|
|
27
|
+
const effectiveEditable = computed(
|
|
28
|
+
() => props.editable !== false && (!abra.effectiveRole.value || canWriteRole.value)
|
|
29
|
+
);
|
|
25
30
|
const childProvider = shallowRef(null);
|
|
26
31
|
async function loadChildProvider(id) {
|
|
27
32
|
childProvider.value = null;
|
|
@@ -112,7 +117,7 @@ const wrapperClass = computed(
|
|
|
112
117
|
:doc-label="docTitle"
|
|
113
118
|
:doc-meta="docMeta"
|
|
114
119
|
:child-provider="childProvider"
|
|
115
|
-
:editable="
|
|
120
|
+
:editable="effectiveEditable"
|
|
116
121
|
:breadcrumb-menu="breadcrumbMenu"
|
|
117
122
|
:class="resolvedClass"
|
|
118
123
|
/>
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
<script setup>
|
|
2
|
-
import { ref, computed, onBeforeUnmount } from "vue";
|
|
2
|
+
import { ref, computed, onBeforeUnmount, shallowRef, watch } from "vue";
|
|
3
3
|
import { useAbracadabra } from "../composables/useAbracadabra";
|
|
4
|
+
import { useSpaceConnections } from "../composables/useSpaceConnections";
|
|
4
5
|
import { useSyncedMap } from "../composables/useYDoc";
|
|
5
6
|
import { useAbraLocale } from "../composables/useAbraLocale";
|
|
6
7
|
import { resolveDocType, getAvailableDocTypes } from "../utils/docTypes";
|
|
@@ -20,7 +21,14 @@ const props = defineProps({
|
|
|
20
21
|
const emit = defineEmits(["update:modelValue", "select"]);
|
|
21
22
|
const locale = computed(() => useAbraLocale("nodePanel"));
|
|
22
23
|
const { doc, registry } = useAbracadabra();
|
|
23
|
-
const
|
|
24
|
+
const { connections, getDocForDoc } = useSpaceConnections();
|
|
25
|
+
const ownerDoc = shallowRef(
|
|
26
|
+
props.docId ? getDocForDoc(props.docId) ?? doc.value : doc.value
|
|
27
|
+
);
|
|
28
|
+
watch(() => [props.docId, doc.value, connections.size], () => {
|
|
29
|
+
ownerDoc.value = props.docId ? getDocForDoc(props.docId) ?? doc.value : doc.value;
|
|
30
|
+
}, { immediate: true });
|
|
31
|
+
const treeMap = useSyncedMap(ownerDoc, "doc-tree");
|
|
24
32
|
const docTypeDef = computed(() => resolveDocType(props.docType, registry));
|
|
25
33
|
const hasPageType = computed(() => !!(props.docType && props.docType !== "doc"));
|
|
26
34
|
const docTypeItems = computed(
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
<script setup>
|
|
2
2
|
import { ref, computed, nextTick, shallowRef, toRaw, watch } from "vue";
|
|
3
3
|
import { useVirtualizer } from "@tanstack/vue-virtual";
|
|
4
|
-
import { useAbracadabra, useTrash, useChat, useVoice, useToast, useAppConfig, useSyncedMap, useDocImport, useDocExport, useWindowManager, useAwareness } from "#imports";
|
|
4
|
+
import { useAbracadabra, useTrash, useChat, useVoice, useToast, useAppConfig, useSyncedMap, useDocImport, useDocExport, useWindowManager, useAwareness, useDocumentPermissions } from "#imports";
|
|
5
5
|
import { resolveDocType, getAvailableDocTypes } from "../utils/docTypes";
|
|
6
6
|
import { avatarBorderStyle } from "../utils/avatarStyle";
|
|
7
7
|
import { DOC_DRAG_MIME, isDocDrag, parseDocDragPayload, isDescendantInMap } from "../utils/docDragDrop";
|
|
@@ -17,7 +17,11 @@ const props = defineProps({
|
|
|
17
17
|
spaceId: { type: [String, null], required: false, default: null }
|
|
18
18
|
});
|
|
19
19
|
const emit = defineEmits(["navigate", "create"]);
|
|
20
|
-
const { doc, spaceDocId, isReady, provider, client, userName } = useAbracadabra();
|
|
20
|
+
const { doc, spaceDocId, isReady, provider, client, userName, effectiveRole } = useAbracadabra();
|
|
21
|
+
const { canWrite: treeCanWriteRole } = useDocumentPermissions(effectiveRole);
|
|
22
|
+
const canWrite = computed(
|
|
23
|
+
() => props.editable && (!effectiveRole.value || treeCanWriteRole.value)
|
|
24
|
+
);
|
|
21
25
|
const { trashMap, trashedCount, moveToTrash, restoreFromTrash, permanentlyDelete, emptyTrash } = useTrash();
|
|
22
26
|
const _chat = import.meta.client ? useChat() : null;
|
|
23
27
|
const chatChannels = computed(() => _chat?.channels.value ?? {});
|
|
@@ -811,13 +815,15 @@ function isInThisCall(item) {
|
|
|
811
815
|
}
|
|
812
816
|
const { floatWindowsAvailable } = useWindowManager();
|
|
813
817
|
function treeNodeMenuItems(item) {
|
|
814
|
-
const
|
|
818
|
+
const writable = canWrite.value;
|
|
819
|
+
const isMulti = multiSelected.value.size > 1 && multiSelected.value.has(item.id);
|
|
820
|
+
const multiDeleteSection = writable && isMulti ? [[{
|
|
815
821
|
label: `Move ${multiSelected.value.size} items to Trash`,
|
|
816
822
|
icon: "i-lucide-trash-2",
|
|
817
823
|
color: "error",
|
|
818
824
|
onSelect: deleteSelected
|
|
819
825
|
}]] : [];
|
|
820
|
-
const multiExportSection =
|
|
826
|
+
const multiExportSection = isMulti ? [[{
|
|
821
827
|
label: `Export ${multiSelected.value.size} items`,
|
|
822
828
|
icon: "i-lucide-download",
|
|
823
829
|
children: [
|
|
@@ -825,50 +831,68 @@ function treeNodeMenuItems(item) {
|
|
|
825
831
|
{ label: "HTML", icon: "i-lucide-file-code", onSelect: () => exportDocs([...multiSelected.value], "html") }
|
|
826
832
|
]
|
|
827
833
|
}]] : [];
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
834
|
+
const openItems = [
|
|
835
|
+
{
|
|
836
|
+
label: "Open",
|
|
837
|
+
icon: "i-lucide-external-link",
|
|
838
|
+
onSelect: () => emit("navigate", item.id)
|
|
839
|
+
},
|
|
840
|
+
{
|
|
841
|
+
label: "Open as overlay",
|
|
842
|
+
icon: "i-lucide-panel-right",
|
|
843
|
+
onSelect: () => openAsOverlay(item.id)
|
|
844
|
+
},
|
|
845
|
+
...floatWindowsAvailable.value ? [{
|
|
846
|
+
label: "Open as window",
|
|
847
|
+
icon: "i-lucide-picture-in-picture-2",
|
|
848
|
+
onSelect: () => openAsFloatingWindow(item.id)
|
|
849
|
+
}] : []
|
|
850
|
+
];
|
|
851
|
+
const editItems = writable ? [
|
|
852
|
+
{
|
|
853
|
+
label: "Rename",
|
|
854
|
+
icon: "i-lucide-pencil",
|
|
855
|
+
onSelect: () => startRename(item.id)
|
|
856
|
+
},
|
|
857
|
+
{
|
|
858
|
+
label: "Duplicate",
|
|
859
|
+
icon: "i-lucide-copy",
|
|
860
|
+
onSelect: () => duplicateDoc(item.id)
|
|
861
|
+
},
|
|
862
|
+
{
|
|
863
|
+
label: "Add child page",
|
|
864
|
+
icon: "i-lucide-file-plus",
|
|
865
|
+
onSelect: () => createDirectly(item.id)
|
|
866
|
+
},
|
|
867
|
+
{
|
|
868
|
+
label: "Move to\u2026",
|
|
869
|
+
icon: "i-lucide-corner-down-right",
|
|
870
|
+
onSelect: () => openMovePicker(item.id)
|
|
871
|
+
},
|
|
872
|
+
{
|
|
873
|
+
label: "Edit tags\u2026",
|
|
874
|
+
icon: "i-lucide-tags",
|
|
875
|
+
onSelect: () => openTagsEditor(item.id)
|
|
876
|
+
}
|
|
877
|
+
] : [];
|
|
878
|
+
const exportImportItems = [
|
|
879
|
+
{
|
|
880
|
+
label: "Export",
|
|
881
|
+
icon: "i-lucide-download",
|
|
882
|
+
children: [
|
|
883
|
+
{ label: "Markdown", icon: "i-lucide-file-text", onSelect: () => exportSingleDoc(item.id, "markdown") },
|
|
884
|
+
{ label: "HTML", icon: "i-lucide-file-code", onSelect: () => exportSingleDoc(item.id, "html") }
|
|
885
|
+
]
|
|
886
|
+
},
|
|
887
|
+
...writable ? [{
|
|
888
|
+
label: "Import into...",
|
|
889
|
+
icon: "i-lucide-file-up",
|
|
890
|
+
onSelect: () => importFiles(item.id)
|
|
891
|
+
}] : []
|
|
892
|
+
];
|
|
893
|
+
const groups = [[...openItems, ...editItems]];
|
|
894
|
+
if (writable) {
|
|
895
|
+
groups.push([
|
|
872
896
|
{
|
|
873
897
|
label: "Change type",
|
|
874
898
|
icon: "i-lucide-layers",
|
|
@@ -883,33 +907,21 @@ function treeNodeMenuItems(item) {
|
|
|
883
907
|
}
|
|
884
908
|
}))
|
|
885
909
|
}
|
|
886
|
-
]
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
children: [
|
|
892
|
-
{ label: "Markdown", icon: "i-lucide-file-text", onSelect: () => exportSingleDoc(item.id, "markdown") },
|
|
893
|
-
{ label: "HTML", icon: "i-lucide-file-code", onSelect: () => exportSingleDoc(item.id, "html") }
|
|
894
|
-
]
|
|
895
|
-
},
|
|
896
|
-
{
|
|
897
|
-
label: "Import into...",
|
|
898
|
-
icon: "i-lucide-file-up",
|
|
899
|
-
onSelect: () => importFiles(item.id)
|
|
900
|
-
}
|
|
901
|
-
],
|
|
902
|
-
[
|
|
910
|
+
]);
|
|
911
|
+
}
|
|
912
|
+
groups.push(exportImportItems);
|
|
913
|
+
if (writable) {
|
|
914
|
+
groups.push([
|
|
903
915
|
{
|
|
904
916
|
label: "Move to Trash",
|
|
905
917
|
icon: "i-lucide-trash-2",
|
|
906
918
|
color: "error",
|
|
907
919
|
onSelect: () => deleteDoc(item.id)
|
|
908
920
|
}
|
|
909
|
-
]
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
921
|
+
]);
|
|
922
|
+
}
|
|
923
|
+
groups.push(...multiExportSection, ...multiDeleteSection);
|
|
924
|
+
return groups;
|
|
913
925
|
}
|
|
914
926
|
function onRestoreItem(item) {
|
|
915
927
|
restoreFromTrash(item.id);
|
|
@@ -947,17 +959,19 @@ function trashRootMenuItems() {
|
|
|
947
959
|
];
|
|
948
960
|
}
|
|
949
961
|
function treeAreaMenuItems() {
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
[
|
|
962
|
+
const groups = [];
|
|
963
|
+
if (canWrite.value) {
|
|
964
|
+
groups.push([{ label: "New page", icon: "i-lucide-file-plus", onSelect: () => createDirectly(null) }]);
|
|
965
|
+
groups.push([
|
|
953
966
|
{ label: "Import files...", icon: "i-lucide-file-up", onSelect: () => importFiles(null) },
|
|
954
967
|
{ label: "Import folder...", icon: "i-lucide-folder-up", onSelect: () => importFolder(null) }
|
|
955
|
-
]
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
|
|
960
|
-
];
|
|
968
|
+
]);
|
|
969
|
+
}
|
|
970
|
+
groups.push([
|
|
971
|
+
{ label: "Export all as Markdown", icon: "i-lucide-download", onSelect: () => exportAll("md") },
|
|
972
|
+
{ label: "Export all as HTML", icon: "i-lucide-file-code", onSelect: () => exportAll("html") }
|
|
973
|
+
]);
|
|
974
|
+
return groups;
|
|
961
975
|
}
|
|
962
976
|
function nodeToFlatItem(node) {
|
|
963
977
|
return {
|
|
@@ -19,6 +19,7 @@ import { useDocLinkPick } from "../composables/useDocLinkPick";
|
|
|
19
19
|
import { makeDocSearch } from "../composables/useDocSuggest";
|
|
20
20
|
import { DocSuggest } from "../extensions/doc-suggest";
|
|
21
21
|
import { useNodeContextMenu } from "../composables/useNodeContextMenu";
|
|
22
|
+
import { useDocumentPermissions } from "../composables/useDocumentPermissions";
|
|
22
23
|
import { DOC_DRAG_MIME, isDocDrag, parseDocDragPayload, isDescendantInMap } from "../utils/docDragDrop";
|
|
23
24
|
import { useEditorToolbar } from "../composables/useEditorToolbar";
|
|
24
25
|
import { useEditorSuggestions } from "../composables/useEditorSuggestions";
|
|
@@ -51,7 +52,11 @@ const props = defineProps({
|
|
|
51
52
|
const viewMode = ref("rich");
|
|
52
53
|
const emit = defineEmits(["ready", "update", "rename", "updateMeta"]);
|
|
53
54
|
const model = defineModel({ type: null });
|
|
54
|
-
const { doc, provider, registry } = useNuxtApp().$abracadabra;
|
|
55
|
+
const { doc, provider, registry, effectiveRole } = useNuxtApp().$abracadabra;
|
|
56
|
+
const { canWrite: bcCanWriteRole } = useDocumentPermissions(effectiveRole);
|
|
57
|
+
const bcCanWrite = computed(
|
|
58
|
+
() => props.editable && (!effectiveRole.value || bcCanWriteRole.value)
|
|
59
|
+
);
|
|
55
60
|
const { connections, getProviderForDoc, getDocForDoc } = useSpaceConnections();
|
|
56
61
|
const ownerProvider = computed(() => getProviderForDoc(props.docId) ?? provider.value);
|
|
57
62
|
const ownerDoc = shallowRef(getDocForDoc(props.docId) ?? doc.value);
|
|
@@ -538,6 +543,7 @@ function bcMenuItems(a) {
|
|
|
538
543
|
type: a.type,
|
|
539
544
|
tree: bcTree,
|
|
540
545
|
registry,
|
|
546
|
+
canWrite: bcCanWrite.value,
|
|
541
547
|
favorites: { isFavorite, toggleFavorite },
|
|
542
548
|
onOpen: (id) => navigateTo(getDocUrl(id)),
|
|
543
549
|
onOpenInWindow: floatWindowsAvailable.value ? () => bcOpenAsWindow(a.id, a.label) : void 0,
|
|
@@ -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
|
-
controls: boolean;
|
|
16
15
|
total: boolean;
|
|
16
|
+
controls: 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
|
-
controls: boolean;
|
|
16
15
|
total: boolean;
|
|
16
|
+
controls: boolean;
|
|
17
17
|
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
18
18
|
declare const _default: typeof __VLS_export;
|
|
19
19
|
export default _default;
|
|
@@ -48,6 +48,7 @@ watch(() => savedDocMeta.value?.mediaRepeat, (v) => {
|
|
|
48
48
|
if (v && v !== repeatMode.value) repeatMode.value = v;
|
|
49
49
|
});
|
|
50
50
|
function setRepeatMode(v) {
|
|
51
|
+
if (props.editable === false) return;
|
|
51
52
|
repeatMode.value = v;
|
|
52
53
|
tree.updateMeta(props.docId, { mediaRepeat: v });
|
|
53
54
|
}
|
|
@@ -59,6 +60,7 @@ watch(() => savedDocMeta.value?.mediaShuffle, (v) => {
|
|
|
59
60
|
if (typeof v === "boolean" && v !== shuffleEnabled.value) shuffleEnabled.value = v;
|
|
60
61
|
});
|
|
61
62
|
function toggleShuffle() {
|
|
63
|
+
if (props.editable === false) return;
|
|
62
64
|
const next = !shuffleEnabled.value;
|
|
63
65
|
shuffleEnabled.value = next;
|
|
64
66
|
tree.updateMeta(props.docId, { mediaShuffle: next });
|
|
@@ -7,6 +7,12 @@ type __VLS_Props = {
|
|
|
7
7
|
canRename?: boolean;
|
|
8
8
|
canDelete?: boolean;
|
|
9
9
|
canDrag?: boolean;
|
|
10
|
+
/**
|
|
11
|
+
* Whether the viewer may mutate the column. Sort + resize write to the SHARED
|
|
12
|
+
* table meta (every peer sees them), so a read-only viewer must not trigger
|
|
13
|
+
* them. Defaults true for back-compat. Threaded from the renderer's canWrite.
|
|
14
|
+
*/
|
|
15
|
+
editable?: boolean;
|
|
10
16
|
};
|
|
11
17
|
declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
|
|
12
18
|
sort: (dir: "asc" | "desc" | "clear") => any;
|
|
@@ -8,7 +8,8 @@ const props = defineProps({
|
|
|
8
8
|
sortDir: { type: String, required: false },
|
|
9
9
|
canRename: { type: Boolean, required: false },
|
|
10
10
|
canDelete: { type: Boolean, required: false },
|
|
11
|
-
canDrag: { type: Boolean, required: false }
|
|
11
|
+
canDrag: { type: Boolean, required: false },
|
|
12
|
+
editable: { type: Boolean, required: false }
|
|
12
13
|
});
|
|
13
14
|
const emit = defineEmits(["rename", "delete", "sort", "resizeStart", "dragPointerDown"]);
|
|
14
15
|
const isEditing = ref(false);
|
|
@@ -27,26 +28,28 @@ function commitRename() {
|
|
|
27
28
|
const isSorted = computed(() => props.sortKey === props.columnId);
|
|
28
29
|
const menuItems = computed(() => {
|
|
29
30
|
const items = [];
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
31
|
+
if (props.editable !== false) {
|
|
32
|
+
const sortGroup = [
|
|
33
|
+
{
|
|
34
|
+
label: "Sort A \u2192 Z",
|
|
35
|
+
icon: "i-lucide-arrow-up-narrow-wide",
|
|
36
|
+
onSelect: () => emit("sort", "asc")
|
|
37
|
+
},
|
|
38
|
+
{
|
|
39
|
+
label: "Sort Z \u2192 A",
|
|
40
|
+
icon: "i-lucide-arrow-down-wide-narrow",
|
|
41
|
+
onSelect: () => emit("sort", "desc")
|
|
42
|
+
}
|
|
43
|
+
];
|
|
44
|
+
if (isSorted.value) {
|
|
45
|
+
sortGroup.push({
|
|
46
|
+
label: "Clear sort",
|
|
47
|
+
icon: "i-lucide-x",
|
|
48
|
+
onSelect: () => emit("sort", "clear")
|
|
49
|
+
});
|
|
40
50
|
}
|
|
41
|
-
|
|
42
|
-
if (isSorted.value) {
|
|
43
|
-
sortGroup.push({
|
|
44
|
-
label: "Clear sort",
|
|
45
|
-
icon: "i-lucide-x",
|
|
46
|
-
onSelect: () => emit("sort", "clear")
|
|
47
|
-
});
|
|
51
|
+
items.push(sortGroup);
|
|
48
52
|
}
|
|
49
|
-
items.push(sortGroup);
|
|
50
53
|
if (props.canRename) {
|
|
51
54
|
items.push([{
|
|
52
55
|
label: "Rename",
|
|
@@ -108,6 +111,7 @@ const menuItems = computed(() => {
|
|
|
108
111
|
/>
|
|
109
112
|
|
|
110
113
|
<UDropdownMenu
|
|
114
|
+
v-if="menuItems.length"
|
|
111
115
|
:items="menuItems"
|
|
112
116
|
:content="{ align: 'start' }"
|
|
113
117
|
>
|
|
@@ -122,6 +126,7 @@ const menuItems = computed(() => {
|
|
|
122
126
|
</div>
|
|
123
127
|
|
|
124
128
|
<div
|
|
129
|
+
v-if="editable !== false"
|
|
125
130
|
class="absolute top-0 right-0 w-1 h-full cursor-col-resize hover:bg-(--ui-primary)/30 transition-colors"
|
|
126
131
|
@pointerdown.stop.prevent="emit('resizeStart', $event)"
|
|
127
132
|
/>
|
|
@@ -7,6 +7,12 @@ type __VLS_Props = {
|
|
|
7
7
|
canRename?: boolean;
|
|
8
8
|
canDelete?: boolean;
|
|
9
9
|
canDrag?: boolean;
|
|
10
|
+
/**
|
|
11
|
+
* Whether the viewer may mutate the column. Sort + resize write to the SHARED
|
|
12
|
+
* table meta (every peer sees them), so a read-only viewer must not trigger
|
|
13
|
+
* them. Defaults true for back-compat. Threaded from the renderer's canWrite.
|
|
14
|
+
*/
|
|
15
|
+
editable?: boolean;
|
|
10
16
|
};
|
|
11
17
|
declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
|
|
12
18
|
sort: (dir: "asc" | "desc" | "clear") => any;
|
|
@@ -144,6 +144,7 @@ function renameColumn(col, label) {
|
|
|
144
144
|
props.tableView.renameColumn(col.id, label);
|
|
145
145
|
}
|
|
146
146
|
function onResizeStart(e, colId) {
|
|
147
|
+
if (props.editable === false) return;
|
|
147
148
|
const startX = e.clientX;
|
|
148
149
|
const col = allColumns.value.find((c) => c.id === colId);
|
|
149
150
|
const startWidth = getColumnWidth(col ?? { id: colId, type: "meta", label: "" });
|
|
@@ -364,6 +365,7 @@ defineExpose({ addMetaColumn, addRow });
|
|
|
364
365
|
:width="getColumnWidth(col)"
|
|
365
366
|
:sort-key="tableView.sortKey.value"
|
|
366
367
|
:sort-dir="tableView.sortDir.value"
|
|
368
|
+
:editable="editable !== false"
|
|
367
369
|
:can-rename="editable !== false && col.type !== 'label'"
|
|
368
370
|
:can-delete="editable !== false && col.type !== 'label'"
|
|
369
371
|
:can-drag="editable !== false"
|
|
@@ -453,6 +453,7 @@ defineExpose({ addColumn, addRow });
|
|
|
453
453
|
:width="getDocColumnWidth(col.id)"
|
|
454
454
|
:sort-key="tableView.sortKey.value"
|
|
455
455
|
:sort-dir="tableView.sortDir.value"
|
|
456
|
+
:editable="editable !== false"
|
|
456
457
|
:can-rename="editable !== false"
|
|
457
458
|
:can-delete="editable !== false"
|
|
458
459
|
:can-drag="editable !== false"
|
|
@@ -477,6 +478,7 @@ defineExpose({ addColumn, addRow });
|
|
|
477
478
|
:width="getMetaColumnWidth(mc)"
|
|
478
479
|
:sort-key="tableView.sortKey.value"
|
|
479
480
|
:sort-dir="tableView.sortDir.value"
|
|
481
|
+
:editable="editable !== false"
|
|
480
482
|
:can-rename="false"
|
|
481
483
|
:can-delete="editable !== false"
|
|
482
484
|
:can-drag="false"
|
|
@@ -52,7 +52,10 @@ const sortLabel = computed(() => {
|
|
|
52
52
|
{{ rowCount }} row{{ rowCount !== 1 ? "s" : "" }}
|
|
53
53
|
</span>
|
|
54
54
|
|
|
55
|
+
<!-- Table mode writes to shared meta — read-only viewers see a static
|
|
56
|
+
label instead of the mode dropdown. -->
|
|
55
57
|
<UDropdownMenu
|
|
58
|
+
v-if="editable !== false"
|
|
56
59
|
:items="modeItems"
|
|
57
60
|
:content="{ align: 'start' }"
|
|
58
61
|
>
|
|
@@ -64,17 +67,30 @@ const sortLabel = computed(() => {
|
|
|
64
67
|
:label="modeLabel"
|
|
65
68
|
/>
|
|
66
69
|
</UDropdownMenu>
|
|
70
|
+
<span
|
|
71
|
+
v-else
|
|
72
|
+
class="inline-flex items-center gap-1 text-xs text-(--ui-text-muted)"
|
|
73
|
+
>
|
|
74
|
+
<UIcon
|
|
75
|
+
:name="modeIcon"
|
|
76
|
+
class="size-3.5"
|
|
77
|
+
/>
|
|
78
|
+
{{ modeLabel }}
|
|
79
|
+
</span>
|
|
67
80
|
|
|
81
|
+
<!-- Sort badge: clearing sort mutates shared meta, so it's only clickable
|
|
82
|
+
for writers. Read-only viewers still see the active sort, statically. -->
|
|
68
83
|
<UBadge
|
|
69
84
|
v-if="sortLabel"
|
|
70
85
|
size="sm"
|
|
71
86
|
variant="subtle"
|
|
72
87
|
color="neutral"
|
|
73
|
-
class="cursor-pointer"
|
|
74
|
-
@click="tableView.setSort(void 0)"
|
|
88
|
+
:class="editable !== false ? 'cursor-pointer' : ''"
|
|
89
|
+
@click="editable !== false && tableView.setSort(void 0)"
|
|
75
90
|
>
|
|
76
91
|
Sort: {{ sortLabel }}
|
|
77
92
|
<UIcon
|
|
93
|
+
v-if="editable !== false"
|
|
78
94
|
name="i-lucide-x"
|
|
79
95
|
class="size-3 ml-1"
|
|
80
96
|
/>
|
|
@@ -22,24 +22,30 @@ export function useDocSeo(docId, options) {
|
|
|
22
22
|
() => resolvedId.value ? `/api/_abracadabra/render/${resolvedId.value}` : "/api/_abracadabra/render/_none",
|
|
23
23
|
{ key: `seo-${resolvedId.value}`, server: true, lazy: true, immediate: !!resolvedId.value }
|
|
24
24
|
);
|
|
25
|
-
const title = computed(
|
|
25
|
+
const title = computed(
|
|
26
|
+
() => entry.value?.label || renderData.value?.title || options?.siteName || "Untitled"
|
|
27
|
+
);
|
|
26
28
|
const description = computed(
|
|
27
|
-
() => entry.value?.meta?.note
|
|
29
|
+
() => entry.value?.meta?.note || entry.value?.meta?.description || renderData.value?.description || extractFirstParagraph(renderData.value?.html) || options?.fallbackDescription || options?.siteName || void 0
|
|
28
30
|
);
|
|
29
31
|
const ogImage = computed(
|
|
30
|
-
() => entry.value?.meta?.coverImage
|
|
32
|
+
() => entry.value?.meta?.coverImage || renderData.value?.ogImage || extractFirstImage(renderData.value?.html) || void 0
|
|
31
33
|
);
|
|
32
34
|
useHead({
|
|
33
35
|
title,
|
|
34
36
|
...options?.titleTemplate ? { titleTemplate: options.titleTemplate } : {}
|
|
35
37
|
});
|
|
36
38
|
useSeoMeta({
|
|
39
|
+
description,
|
|
37
40
|
ogTitle: title,
|
|
38
41
|
ogDescription: description,
|
|
39
|
-
|
|
42
|
+
ogSiteName: () => options?.siteName,
|
|
40
43
|
ogType: "article",
|
|
44
|
+
ogImage: () => ogImage.value,
|
|
41
45
|
twitterCard: "summary",
|
|
42
|
-
|
|
46
|
+
twitterTitle: title,
|
|
47
|
+
twitterDescription: description,
|
|
48
|
+
twitterImage: () => ogImage.value
|
|
43
49
|
});
|
|
44
50
|
return { title, description, ogImage };
|
|
45
51
|
}
|
|
@@ -16,8 +16,19 @@ interface NodeContextMenuOptions {
|
|
|
16
16
|
onChangeType?: (id: string, newType: string) => void;
|
|
17
17
|
/** Open the doc — renders an "Open" item (e.g. navigate to the full page). */
|
|
18
18
|
onOpen?: (id: string) => void;
|
|
19
|
+
/** Open the doc in a slide-over panel — renders "Open as slideover". */
|
|
20
|
+
onOpenOverlay?: (id: string) => void;
|
|
19
21
|
/** Open the doc in a floating window — renders "Open as window". */
|
|
20
22
|
onOpenInWindow?: (id: string) => void;
|
|
23
|
+
/**
|
|
24
|
+
* Whether the current user may mutate this doc. When false, every mutating
|
|
25
|
+
* group is dropped (rename / duplicate / change-type / add-child / move-to /
|
|
26
|
+
* edit-tags / color / move-to-trash), leaving only read-safe items: open /
|
|
27
|
+
* slideover / window, copy link, favorites, export. Defaults to true for
|
|
28
|
+
* back-compat — pass `useDocumentPermissions(effectiveRole).canWrite` (AND
|
|
29
|
+
* the host `editable` opt-in) so read-only viewers don't see dead actions.
|
|
30
|
+
*/
|
|
31
|
+
canWrite?: boolean;
|
|
21
32
|
/** Create a child page under this node — renders "Add child page". */
|
|
22
33
|
onAddChild?: (parentId: string) => void;
|
|
23
34
|
/** Reparent this node — renders "Move to…" (e.g. open an <ADocPickerModal>). */
|
|
@@ -2,6 +2,7 @@ import { getAvailableDocTypes } from "../utils/docTypes.js";
|
|
|
2
2
|
import { UI_COLORS } from "../types.js";
|
|
3
3
|
export function useNodeContextMenu(opts) {
|
|
4
4
|
const { nodeId, label: _label, type, tree, registry } = opts;
|
|
5
|
+
const canWrite = opts.canWrite !== false;
|
|
5
6
|
const docTypes = getAvailableDocTypes(registry);
|
|
6
7
|
const openGroup = [];
|
|
7
8
|
if (opts.onOpen) {
|
|
@@ -13,6 +14,15 @@ export function useNodeContextMenu(opts) {
|
|
|
13
14
|
}
|
|
14
15
|
});
|
|
15
16
|
}
|
|
17
|
+
if (opts.onOpenOverlay) {
|
|
18
|
+
openGroup.push({
|
|
19
|
+
label: "Open as slideover",
|
|
20
|
+
icon: "i-lucide-panel-right",
|
|
21
|
+
onSelect() {
|
|
22
|
+
opts.onOpenOverlay(nodeId);
|
|
23
|
+
}
|
|
24
|
+
});
|
|
25
|
+
}
|
|
16
26
|
if (opts.onOpenInWindow) {
|
|
17
27
|
openGroup.push({
|
|
18
28
|
label: "Open as window",
|
|
@@ -119,7 +129,7 @@ export function useNodeContextMenu(opts) {
|
|
|
119
129
|
}
|
|
120
130
|
});
|
|
121
131
|
}
|
|
122
|
-
if (opts.onEditTags) {
|
|
132
|
+
if (opts.onEditTags && canWrite) {
|
|
123
133
|
actionsGroup.push({
|
|
124
134
|
label: "Edit tags\u2026",
|
|
125
135
|
icon: "i-lucide-tags",
|
|
@@ -150,8 +160,8 @@ export function useNodeContextMenu(opts) {
|
|
|
150
160
|
];
|
|
151
161
|
const items = [];
|
|
152
162
|
if (openGroup.length > 0) items.push(openGroup);
|
|
153
|
-
items.push(editGroup, appearanceGroup);
|
|
163
|
+
if (canWrite) items.push(editGroup, appearanceGroup);
|
|
154
164
|
if (actionsGroup.length > 0) items.push(actionsGroup);
|
|
155
|
-
items.push(dangerGroup);
|
|
165
|
+
if (canWrite) items.push(dangerGroup);
|
|
156
166
|
return { items };
|
|
157
167
|
}
|
|
@@ -1,3 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* <DocLinkView> — NodeView for an inline link to another document.
|
|
3
|
+
*
|
|
4
|
+
* Renders a pill badge for the linked doc. Left-click opens it (plain →
|
|
5
|
+
* navigate to the full page, Cmd/Ctrl → slide-over panel, Alt → floating
|
|
6
|
+
* window). Right-click opens the same node context menu the breadcrumb and
|
|
7
|
+
* sidebar tree use (open / slideover / window / rename / duplicate / change
|
|
8
|
+
* type / copy link / favorite / trash), gated on write access so read-only
|
|
9
|
+
* viewers only see the read-safe items.
|
|
10
|
+
*
|
|
11
|
+
* Ported to match cou-sh/app/components/editor/DocLinkView.vue.
|
|
12
|
+
*/
|
|
1
13
|
import type { NodeViewProps } from '@tiptap/vue-3';
|
|
2
14
|
declare const __VLS_export: import("vue").DefineComponent<NodeViewProps, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<NodeViewProps> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
3
15
|
declare const _default: typeof __VLS_export;
|
|
@@ -1,11 +1,19 @@
|
|
|
1
1
|
<script setup>
|
|
2
2
|
import { NodeViewWrapper } from "@tiptap/vue-3";
|
|
3
|
-
import { computed } from "vue";
|
|
3
|
+
import { computed, ref, defineAsyncComponent } from "vue";
|
|
4
4
|
import { navigateTo } from "#imports";
|
|
5
5
|
import { useAbracadabra } from "../../composables/useAbracadabra";
|
|
6
|
-
import {
|
|
6
|
+
import { useChildTree } from "../../composables/useChildTree";
|
|
7
|
+
import { useFavorites } from "../../composables/useFavorites";
|
|
8
|
+
import { useWindowManager } from "../../composables/useWindowManager";
|
|
9
|
+
import { useNodePanel } from "../../composables/useNodePanel";
|
|
10
|
+
import { useNodeContextMenu } from "../../composables/useNodeContextMenu";
|
|
11
|
+
import { useDocumentPermissions } from "../../composables/useDocumentPermissions";
|
|
7
12
|
import { useDocSlugs } from "../../composables/useDocSlugs";
|
|
8
13
|
import { resolveDocType } from "../../utils/docTypes";
|
|
14
|
+
import ANodeContextMenu from "../../components/shell/ANodeContextMenu.vue";
|
|
15
|
+
import AModalShell from "../../components/AModalShell.vue";
|
|
16
|
+
const ANodePanel = defineAsyncComponent(() => import("../../components/ANodePanel.vue"));
|
|
9
17
|
const props = defineProps({
|
|
10
18
|
decorations: { type: Array, required: true },
|
|
11
19
|
selected: { type: Boolean, required: true },
|
|
@@ -19,23 +27,90 @@ const props = defineProps({
|
|
|
19
27
|
extension: { type: Object, required: true },
|
|
20
28
|
HTMLAttributes: { type: Object, required: true }
|
|
21
29
|
});
|
|
22
|
-
const { doc: rootDoc } = useAbracadabra();
|
|
30
|
+
const { doc: rootDoc, provider, registry, isReady, effectiveRole } = useAbracadabra();
|
|
23
31
|
const { getDocUrl } = useDocSlugs();
|
|
24
|
-
const treeMap = useSyncedMap(
|
|
25
|
-
rootDoc,
|
|
26
|
-
"doc-tree"
|
|
27
|
-
);
|
|
28
32
|
const docId = computed(() => props.node.attrs.docId);
|
|
33
|
+
const tree = useChildTree(rootDoc, docId.value);
|
|
34
|
+
const { treeMap } = tree;
|
|
35
|
+
const { isFavorite, toggleFavorite } = useFavorites(rootDoc);
|
|
36
|
+
const { floatWindowsAvailable } = useWindowManager();
|
|
37
|
+
const { canWrite: canWriteRole } = useDocumentPermissions(effectiveRole);
|
|
38
|
+
const canWrite = computed(() => !effectiveRole.value || canWriteRole.value);
|
|
29
39
|
const treeEntry = computed(() => treeMap.data[docId.value]);
|
|
30
40
|
const exists = computed(() => !!treeEntry.value);
|
|
31
|
-
const docType = computed(() => resolveDocType(treeEntry.value?.type));
|
|
41
|
+
const docType = computed(() => resolveDocType(treeEntry.value?.type, registry));
|
|
32
42
|
const label = computed(() => treeEntry.value?.label || "Untitled");
|
|
33
|
-
|
|
43
|
+
const { openNodeId, openNodeLabel, openNodeProvider, openNode, closePanel } = useNodePanel(provider);
|
|
44
|
+
async function openAsWindow(id, title) {
|
|
45
|
+
const wm = useWindowManager();
|
|
46
|
+
if (wm.windows.has(id)) {
|
|
47
|
+
wm.focusWindow(id);
|
|
48
|
+
return;
|
|
49
|
+
}
|
|
50
|
+
const childProv = await provider.value?.loadChild(id);
|
|
51
|
+
if (!childProv) return;
|
|
52
|
+
if (!childProv.isSynced) {
|
|
53
|
+
await new Promise((resolve) => {
|
|
54
|
+
const done = () => {
|
|
55
|
+
childProv.off("synced", done);
|
|
56
|
+
resolve();
|
|
57
|
+
};
|
|
58
|
+
childProv.on("synced", done);
|
|
59
|
+
setTimeout(resolve, 6e3);
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
const entry = treeMap.get(id);
|
|
63
|
+
wm.openWindow({ id, title, docId: id, docType: entry?.type, provider: childProv, initialTab: "editor" });
|
|
64
|
+
}
|
|
65
|
+
function onClick(e) {
|
|
66
|
+
if (!docId.value) return;
|
|
34
67
|
e.preventDefault();
|
|
35
68
|
e.stopPropagation();
|
|
36
|
-
if (!
|
|
69
|
+
if (!e.shiftKey && (e.metaKey || e.ctrlKey)) {
|
|
70
|
+
openNode(docId.value, label.value);
|
|
71
|
+
return;
|
|
72
|
+
}
|
|
73
|
+
if (!e.shiftKey && e.altKey && floatWindowsAvailable.value) {
|
|
74
|
+
void openAsWindow(docId.value, label.value);
|
|
75
|
+
return;
|
|
76
|
+
}
|
|
37
77
|
navigateTo(getDocUrl(docId.value));
|
|
38
78
|
}
|
|
79
|
+
const renameOpen = ref(false);
|
|
80
|
+
const renameValue = ref("");
|
|
81
|
+
function startRename() {
|
|
82
|
+
renameValue.value = label.value;
|
|
83
|
+
renameOpen.value = true;
|
|
84
|
+
}
|
|
85
|
+
function commitRename() {
|
|
86
|
+
const next = renameValue.value.trim();
|
|
87
|
+
if (next) tree.renameEntry(docId.value, next);
|
|
88
|
+
renameOpen.value = false;
|
|
89
|
+
}
|
|
90
|
+
const menuItems = computed(() => useNodeContextMenu({
|
|
91
|
+
nodeId: docId.value,
|
|
92
|
+
label: label.value,
|
|
93
|
+
type: treeEntry.value?.type,
|
|
94
|
+
meta: treeEntry.value?.meta,
|
|
95
|
+
tree,
|
|
96
|
+
registry,
|
|
97
|
+
canWrite: canWrite.value,
|
|
98
|
+
favorites: { isFavorite, toggleFavorite },
|
|
99
|
+
onOpen: (id) => navigateTo(getDocUrl(id)),
|
|
100
|
+
onOpenOverlay: (id) => openNode(id, label.value),
|
|
101
|
+
onOpenInWindow: floatWindowsAvailable.value ? (id) => void openAsWindow(id, label.value) : void 0,
|
|
102
|
+
onRename: () => startRename(),
|
|
103
|
+
onAddChild: (parentId) => {
|
|
104
|
+
if (!isReady.value) return;
|
|
105
|
+
const id = tree.createChild(parentId, "Untitled", "doc");
|
|
106
|
+
navigateTo(getDocUrl(id));
|
|
107
|
+
},
|
|
108
|
+
onCopyLink: (id) => {
|
|
109
|
+
if (!import.meta.client || !navigator?.clipboard) return;
|
|
110
|
+
navigator.clipboard.writeText(new URL(getDocUrl(id), location.origin).href).catch(() => {
|
|
111
|
+
});
|
|
112
|
+
}
|
|
113
|
+
}).items);
|
|
39
114
|
</script>
|
|
40
115
|
|
|
41
116
|
<template>
|
|
@@ -43,18 +118,22 @@ function navigate(e) {
|
|
|
43
118
|
as="span"
|
|
44
119
|
class="inline-flex align-baseline"
|
|
45
120
|
>
|
|
46
|
-
<
|
|
121
|
+
<ANodeContextMenu
|
|
47
122
|
v-if="exists"
|
|
48
|
-
:
|
|
49
|
-
color="neutral"
|
|
50
|
-
variant="subtle"
|
|
51
|
-
size="sm"
|
|
52
|
-
class="dl-badge rounded-full cursor-pointer"
|
|
53
|
-
:class="{ 'dl-badge-selected': props.selected }"
|
|
54
|
-
@click="navigate"
|
|
123
|
+
:items="menuItems"
|
|
55
124
|
>
|
|
56
|
-
|
|
57
|
-
|
|
125
|
+
<UBadge
|
|
126
|
+
:icon="docType.icon"
|
|
127
|
+
color="neutral"
|
|
128
|
+
variant="subtle"
|
|
129
|
+
size="sm"
|
|
130
|
+
class="dl-badge rounded-full cursor-pointer"
|
|
131
|
+
:class="{ 'dl-badge-selected': props.selected }"
|
|
132
|
+
@click="onClick"
|
|
133
|
+
>
|
|
134
|
+
{{ label }}
|
|
135
|
+
</UBadge>
|
|
136
|
+
</ANodeContextMenu>
|
|
58
137
|
<UBadge
|
|
59
138
|
v-else
|
|
60
139
|
icon="i-lucide-file-x"
|
|
@@ -65,6 +144,46 @@ function navigate(e) {
|
|
|
65
144
|
>
|
|
66
145
|
Missing document
|
|
67
146
|
</UBadge>
|
|
147
|
+
|
|
148
|
+
<!-- Slide-over host: heavy panel mounts only while a link is open -->
|
|
149
|
+
<ANodePanel
|
|
150
|
+
v-if="openNodeId"
|
|
151
|
+
:node-id="openNodeId"
|
|
152
|
+
:node-label="openNodeLabel"
|
|
153
|
+
:child-provider="openNodeProvider"
|
|
154
|
+
:doc-type="treeMap.data[openNodeId]?.type"
|
|
155
|
+
@close="closePanel"
|
|
156
|
+
/>
|
|
157
|
+
|
|
158
|
+
<!-- Rename modal -->
|
|
159
|
+
<AModalShell
|
|
160
|
+
:open="renameOpen"
|
|
161
|
+
title="Rename document"
|
|
162
|
+
max-width="sm:max-w-sm"
|
|
163
|
+
@update:open="renameOpen = $event"
|
|
164
|
+
>
|
|
165
|
+
<UInput
|
|
166
|
+
v-model="renameValue"
|
|
167
|
+
autofocus
|
|
168
|
+
placeholder="Document name"
|
|
169
|
+
class="w-full"
|
|
170
|
+
@keydown.enter="commitRename"
|
|
171
|
+
/>
|
|
172
|
+
<template #footer>
|
|
173
|
+
<div class="flex justify-end gap-2">
|
|
174
|
+
<UButton
|
|
175
|
+
label="Cancel"
|
|
176
|
+
color="neutral"
|
|
177
|
+
variant="ghost"
|
|
178
|
+
@click="renameOpen = false"
|
|
179
|
+
/>
|
|
180
|
+
<UButton
|
|
181
|
+
label="Rename"
|
|
182
|
+
@click="commitRename"
|
|
183
|
+
/>
|
|
184
|
+
</div>
|
|
185
|
+
</template>
|
|
186
|
+
</AModalShell>
|
|
68
187
|
</NodeViewWrapper>
|
|
69
188
|
</template>
|
|
70
189
|
|
|
@@ -1,3 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* <DocLinkView> — NodeView for an inline link to another document.
|
|
3
|
+
*
|
|
4
|
+
* Renders a pill badge for the linked doc. Left-click opens it (plain →
|
|
5
|
+
* navigate to the full page, Cmd/Ctrl → slide-over panel, Alt → floating
|
|
6
|
+
* window). Right-click opens the same node context menu the breadcrumb and
|
|
7
|
+
* sidebar tree use (open / slideover / window / rename / duplicate / change
|
|
8
|
+
* type / copy link / favorite / trash), gated on write access so read-only
|
|
9
|
+
* viewers only see the read-safe items.
|
|
10
|
+
*
|
|
11
|
+
* Ported to match cou-sh/app/components/editor/DocLinkView.vue.
|
|
12
|
+
*/
|
|
1
13
|
import type { NodeViewProps } from '@tiptap/vue-3';
|
|
2
14
|
declare const __VLS_export: import("vue").DefineComponent<NodeViewProps, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<NodeViewProps> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
3
15
|
declare const _default: typeof __VLS_export;
|
|
@@ -20,9 +20,8 @@ async function getServerDoc() {
|
|
|
20
20
|
}
|
|
21
21
|
export async function renderDocToHTML(ydoc) {
|
|
22
22
|
try {
|
|
23
|
-
const [{ getSchema }, {
|
|
23
|
+
const [{ getSchema }, { default: StarterKit }, { Node, DOMSerializer }, { coreServerSchemaStubs, pruneUnknownNodes, yFragmentToPmJSON }] = await Promise.all([
|
|
24
24
|
import("@tiptap/core"),
|
|
25
|
-
import("@tiptap/y-tiptap"),
|
|
26
25
|
import("@tiptap/starter-kit"),
|
|
27
26
|
import("prosemirror-model"),
|
|
28
27
|
import("./serverSchemaStubs.js")
|
|
@@ -32,7 +31,11 @@ export async function renderDocToHTML(ydoc) {
|
|
|
32
31
|
...coreServerSchemaStubs(_extensions),
|
|
33
32
|
..._extensions
|
|
34
33
|
]);
|
|
35
|
-
const json =
|
|
34
|
+
const { json: rawJson, dropped } = yFragmentToPmJSON(ydoc.getXmlFragment("default"));
|
|
35
|
+
if (dropped.length) {
|
|
36
|
+
console.warn(`[abracadabra:doc-cache] skipped ${dropped.length} unclassifiable node(s) while rendering:`, [...new Set(dropped)].join(", "));
|
|
37
|
+
}
|
|
38
|
+
const json = pruneUnknownNodes(rawJson, schema);
|
|
36
39
|
const node = Node.fromJSON(schema, json);
|
|
37
40
|
const serverDoc = await getServerDoc();
|
|
38
41
|
const container = serverDoc.createElement("div");
|
|
@@ -14,6 +14,15 @@ interface PmJsonNode {
|
|
|
14
14
|
}>;
|
|
15
15
|
[key: string]: unknown;
|
|
16
16
|
}
|
|
17
|
+
/**
|
|
18
|
+
* Convert a Y.XmlFragment to ProseMirror `{ type: 'doc', content }` JSON without
|
|
19
|
+
* relying on cross-module `instanceof`. Unclassifiable children are dropped and
|
|
20
|
+
* their type name collected in `dropped` for a single non-fatal warning.
|
|
21
|
+
*/
|
|
22
|
+
export declare function yFragmentToPmJSON(fragment: any): {
|
|
23
|
+
json: PmJsonNode;
|
|
24
|
+
dropped: string[];
|
|
25
|
+
};
|
|
17
26
|
/**
|
|
18
27
|
* Drop nodes whose type the schema doesn't know (and unknown marks), keeping
|
|
19
28
|
* everything else intact. Returns a structurally-cloned JSON tree that is
|
|
@@ -33,6 +33,47 @@ export function coreServerSchemaStubs(appExtensions = []) {
|
|
|
33
33
|
const taken = new Set(appExtensions.map((e) => e.name));
|
|
34
34
|
return [DocumentHeaderStub, DocumentMetaStub, CalloutStub, DividerStub, QuoteStub].filter((s) => !taken.has(s.name));
|
|
35
35
|
}
|
|
36
|
+
const HASHED_MARK_NAME = /(.*)--[a-z0-9+/=]{8}$/i;
|
|
37
|
+
function yAttrToMarkName(attrName) {
|
|
38
|
+
return HASHED_MARK_NAME.exec(attrName)?.[1] ?? attrName;
|
|
39
|
+
}
|
|
40
|
+
function isYText(item) {
|
|
41
|
+
return item != null && typeof item.toDelta === "function" && typeof item.nodeName !== "string";
|
|
42
|
+
}
|
|
43
|
+
function isYElement(item) {
|
|
44
|
+
return item != null && typeof item.nodeName === "string" && typeof item.getAttributes === "function" && typeof item.toArray === "function";
|
|
45
|
+
}
|
|
46
|
+
export function yFragmentToPmJSON(fragment) {
|
|
47
|
+
const dropped = [];
|
|
48
|
+
const serialize = (item) => {
|
|
49
|
+
if (isYText(item)) {
|
|
50
|
+
return item.toDelta().map((d) => {
|
|
51
|
+
const text = { type: "text", text: d.insert };
|
|
52
|
+
if (d.attributes) {
|
|
53
|
+
text.marks = Object.keys(d.attributes).map((key) => {
|
|
54
|
+
const mark = { type: yAttrToMarkName(key) };
|
|
55
|
+
const attrs = d.attributes[key];
|
|
56
|
+
if (attrs && Object.keys(attrs).length) mark.attrs = attrs;
|
|
57
|
+
return mark;
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
return text;
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
if (isYElement(item)) {
|
|
64
|
+
const node = { type: item.nodeName };
|
|
65
|
+
const attrs = item.getAttributes();
|
|
66
|
+
if (attrs && Object.keys(attrs).length) node.attrs = attrs;
|
|
67
|
+
const children = item.toArray().flatMap(serialize);
|
|
68
|
+
if (children.length) node.content = children;
|
|
69
|
+
return [node];
|
|
70
|
+
}
|
|
71
|
+
dropped.push(item?.constructor?.name ?? typeof item);
|
|
72
|
+
return [];
|
|
73
|
+
};
|
|
74
|
+
const content = fragment.toArray().flatMap(serialize);
|
|
75
|
+
return { json: { type: "doc", content }, dropped };
|
|
76
|
+
}
|
|
36
77
|
export function pruneUnknownNodes(json, schema) {
|
|
37
78
|
const knownNode = (t) => !!t && !!schema.nodes[t];
|
|
38
79
|
const knownMark = (t) => !!t && !!schema.marks[t];
|