Skip to content

πŸ”₯ πŸ”₯ πŸ”₯ A Free & Self-hostable Airtable Alternative

fix(nc-gui): use extension config provider

Ramesh Mane0fd2e54afef6
diff --git a/packages/nc-gui/components/cell/TextArea.vue b/packages/nc-gui/components/cell/TextArea.vue
index 590e8a93e0..bb55c7c02f 100644
--- a/packages/nc-gui/components/cell/TextArea.vue
+++ b/packages/nc-gui/components/cell/TextArea.vue
@@ -42,7 +42,7 @@ const cellEventHook = inject(CellEventHookInj, null)
const active = inject(ActiveCellInj, null)
-const activeExtensionId = inject(ActiveExtensionIdInj, readonly(ref('')))
+const extensionConfig = inject(ExtensionConfigInj, ref({ isPageDesignerPreviewPanel: false }))
const readOnly = computed(() => readOnlyInj.value || column.value.readonly)
@@ -110,12 +110,12 @@ const localRowHeight = computed(() => {
return rowHeight.value
})
-const isPageDesignerExtensionActive = computed(() => {
- return activeExtensionId.value === 'page-designer-ee'
+const isPageDesignerPreviewPanel = computed(() => {
+ return extensionConfig.value.isPageDesignerPreviewPanel
})
const isFullHeight = computed(() => {
- return isForm.value || isPageDesignerExtensionActive.value
+ return isForm.value || isPageDesignerPreviewPanel.value
})
const isVisible = ref(false)
@@ -194,7 +194,7 @@ const richTextContent = computedAsync(async () => {
enableMention: true,
users: unref(baseUsers.value),
currentUser: unref(user.value),
- ...(isExpandedFormOpen.value || isPageDesignerExtensionActive.value
+ ...(isExpandedFormOpen.value || isPageDesignerPreviewPanel.value
? { maxBlockTokens: undefined }
: { maxBlockTokens: rowHeight.value }),
},
@@ -492,7 +492,7 @@ useResizeObserver(inputWrapperRef, () => {
{
'nc-readonly-rich-text-grid ': !isExpandedFormOpen && !isForm,
'nc-readonly-rich-text-sort-height':
- localRowHeight === 1 && !isExpandedFormOpen && !isForm && !isPageDesignerExtensionActive,
+ localRowHeight === 1 && !isExpandedFormOpen && !isForm && !isPageDesignerPreviewPanel,
},
]"
:style="{
@@ -514,7 +514,7 @@ useResizeObserver(inputWrapperRef, () => {
<div
class="nc-cell-field nc-rich-text-content nc-rich-text-content-grid"
:class="
- !isExpandedFormOpen && !isPageDesignerExtensionActive
+ !isExpandedFormOpen && !isPageDesignerPreviewPanel
? `line-clamp-${rowHeightTruncateLines(localRowHeight, true)}`
: 'py-2'
"
@@ -650,7 +650,7 @@ useResizeObserver(inputWrapperRef, () => {
<span v-else>{{ vModel }}</span>
<div
- v-if="!isPageDesignerExtensionActive"
+ v-if="!isPageDesignerPreviewPanel"
class="!absolute !hidden nc-text-area-expand-btn group-hover:block z-3 items-center gap-1"
:class="{
'active': active && isCanvasInjected,
diff --git a/packages/nc-gui/components/cell/User/Readonly.vue b/packages/nc-gui/components/cell/User/Readonly.vue
index 052bccfd9e..7dbb47ed5e 100644
--- a/packages/nc-gui/components/cell/User/Readonly.vue
+++ b/packages/nc-gui/components/cell/User/Readonly.vue
@@ -39,6 +39,12 @@ const rowHeight = inject(RowHeightInj, ref(isInFilter.value ? 1 : undefined))
const isKanban = inject(IsKanbanInj, ref(false))
+const extensionConfig = inject(ExtensionConfigInj, ref({ isPageDesignerPreviewPanel: false }))
+
+const isPageDesignerPreviewPanel = computed(() => {
+ return extensionConfig.value.isPageDesignerPreviewPanel
+})
+
const options = computed(() => {
const currentUserField: any[] = []
if (isEeUI && isInFilter.value) {
@@ -136,6 +142,9 @@ const isCollaborator = (userIdOrEmail) => {
<div
v-else
class="flex overflow-hidden gap-y-1"
+ :class="{
+ 'flex-wrap': isPageDesignerPreviewPanel,
+ }"
:style="{
'flex-wrap': !isInFilter,
'max-width': '100%',
diff --git a/packages/nc-gui/components/extensions/Extension.vue b/packages/nc-gui/components/extensions/Extension.vue
index 1f59aba1e3..9f0ce1d9b3 100644
--- a/packages/nc-gui/components/extensions/Extension.vue
+++ b/packages/nc-gui/components/extensions/Extension.vue
@@ -32,7 +32,7 @@ const extensionManifest = computed<ExtensionManifest | undefined>(() => {
const activeExtensionId = computed(() => extensionManifest.value?.id ?? '')
-provide(ActiveExtensionIdInj, readonly(activeExtensionId))
+provide(ExtensionConfigInj, ref({ activeExtensionId }))
const {
fullscreen,
diff --git a/packages/nc-gui/components/virtual-cell/Lookup.vue b/packages/nc-gui/components/virtual-cell/Lookup.vue
index 965418af1b..2c5285caac 100644
--- a/packages/nc-gui/components/virtual-cell/Lookup.vue
+++ b/packages/nc-gui/components/virtual-cell/Lookup.vue
@@ -287,13 +287,17 @@ const handleCloseDropdown = (e: MouseEvent) => {
const badgedVirtualColumns = [UITypes.Rollup, UITypes.Formula]
const isBadgedVirtualColumn = computed(() => badgedVirtualColumns.includes(lookupColumn.value?.uidt as UITypes))
-const isPageDesignerLookup = inject(IsPageDesignerExtensionActiveInj, false)
+const extensionConfig = inject(ExtensionConfigInj, ref({ isPageDesignerPreviewPanel: false }))
const { getPossibleAttachmentSrc } = useAttachment()
const attachmentUrl = computed(() => getPossibleAttachmentSrc(arrValue.value[0])?.[0] ?? '')
</script>
<template>
- <img v-if="isPageDesignerLookup && attachmentUrl" :src="attachmentUrl" class="object-contain h-full w-full" />
+ <img
+ v-if="extensionConfig.isPageDesignerPreviewPanel && attachmentUrl"
+ :src="attachmentUrl"
+ class="object-contain h-full w-full"
+ />
<NcDropdown
v-else
:disabled="disableDropdown"
diff --git a/packages/nc-gui/context/index.ts b/packages/nc-gui/context/index.ts
index 8440901d5b..c46da464fc 100644
--- a/packages/nc-gui/context/index.ts
+++ b/packages/nc-gui/context/index.ts
@@ -138,11 +138,16 @@ export const CanvasCellEventDataInj: InjectionKey<
// triggering this hook from within an editable cell will turn it into "selection state"
export const CanvasSelectCellInj: InjectionKey<EventHook | undefined> = Symbol('canvas-select-cell-inj')
-export const IsPageDesignerExtensionActiveInj: InjectionKey<boolean> = Symbol('is-page-designer-extension-active')
export const IsLinkRecordDropdownInj: InjectionKey<Ref<boolean>> = Symbol('is-link-record-dropdown-injection')
export const PlanUpgraderClickHookInj: InjectionKey<EventHook<void>> = Symbol('plan-upgrader-click-hook-injection')
export const IsMiniSidebarInj: InjectionKey<Ref<boolean>> = Symbol('is-mini-sidebar-injection')
-export const ActiveExtensionIdInj: InjectionKey<ComputedRef<string> | Ref<string>> = Symbol('active-extension-id-injection')
+export const ExtensionConfigInj: InjectionKey<
+ Ref<{
+ activeExtensionId?: string
+ isPageDesignerPreviewPanel?: boolean
+ [key: string]: any
+ }>
+> = Symbol('extension-config-injection')