π₯ π₯ π₯ A Free & Self-hostable Airtable Alternative
TypeScript airtableairtable-alternativeautomatic-apihacktoberfestlow-codeno-codeno-code-databaseno-code-platformpostgresqlrest-apirestful-apispreadsheetsqliteswagger
fix: dompurify issue
mertmite754b88d5b99
diff --git a/packages/nc-gui/components/cell/TextArea.vue b/packages/nc-gui/components/cell/TextArea.vueindex 47184381f6..f321253339 100644--- a/packages/nc-gui/components/cell/TextArea.vue+++ b/packages/nc-gui/components/cell/TextArea.vue@@ -524,13 +524,14 @@ useResizeObserver(inputWrapperRef, () => {@keydown.enter="onExpand"><div+ v-dompurify-html="richTextContent"class="nc-cell-field nc-rich-text-content nc-rich-text-content-grid":class="!isExpandedFormOpen && !isPageDesignerPreviewPanel? `line-clamp-${rowHeightTruncateLines(localRowHeight, true)}`: 'py-2'"- v-dompurify-html="richTextContent"+ @click="handleDompurifyLinkClick"></div></div><!-- eslint-disable vue/use-v-on-exact -->diff --git a/packages/nc-gui/components/smartsheet/expanded-form/Sidebar/Audits.vue b/packages/nc-gui/components/smartsheet/expanded-form/Sidebar/Audits.vueindex 623dcb04b2..3b976bb677 100644--- a/packages/nc-gui/components/smartsheet/expanded-form/Sidebar/Audits.vue+++ b/packages/nc-gui/components/smartsheet/expanded-form/Sidebar/Audits.vue@@ -161,6 +161,7 @@ function isV0Audit(audit: AuditType) {v-if="audit.details"v-dompurify-html="audit.details"class="rounded-lg border-1 border-nc-border-gray-medium bg-nc-bg-gray-extralight divide-y py-2 px-3"+ @click="handleDompurifyLinkClick"></div><div v-else class="rounded-lg border-1 border-nc-border-gray-medium bg-nc-bg-gray-extralight divide-y py-2 px-3">{{ audit.description }}diff --git a/packages/nc-gui/components/smartsheet/expanded-form/Sidebar/Comments.vue b/packages/nc-gui/components/smartsheet/expanded-form/Sidebar/Comments.vueindex 4a31d41e59..acaa7f8bb7 100644--- a/packages/nc-gui/components/smartsheet/expanded-form/Sidebar/Comments.vue+++ b/packages/nc-gui/components/smartsheet/expanded-form/Sidebar/Comments.vue@@ -499,8 +499,9 @@ onBeforeUnmount(() => {<div v-else class="space-y-1 pl-9"><div- class="nc-rich-text-content !text-small !leading-18px !text-nc-content-gray"v-dompurify-html="parsedHtmlComments[commentItem.id]"+ class="nc-rich-text-content !text-small !leading-18px !text-nc-content-gray"+ @click="handleDompurifyLinkClick"></div></div></div>diff --git a/packages/nc-gui/components/smartsheet/grid/canvas/components/ExpandedText.vue b/packages/nc-gui/components/smartsheet/grid/canvas/components/ExpandedText.vueindex f5014a582c..a0292f117a 100644--- a/packages/nc-gui/components/smartsheet/grid/canvas/components/ExpandedText.vue+++ b/packages/nc-gui/components/smartsheet/grid/canvas/components/ExpandedText.vue@@ -226,13 +226,14 @@ const urls = replaceUrlsWithLink(result)<divv-if="urls"ref="inputRef"+ v-dompurify-html="urls":style="{resize: 'both',maxHeight: 'min(795px, 100vh - 170px)',width: 'min(1256px, 100vw - 124px)',}"class="nc-long-text-expanded-textarea border-1 border-nc-border-gray-medium bg-nc-bg-gray-extralight !py-1 !px-3 !text-nc-content-gray-extreme !transition-none !cursor-text !min-h-[210px] !rounded-lg focus:border-nc-border-brand disabled:!bg-nc-bg-gray-extralight nc-longtext-scrollbar"- v-dompurify-html="urls"+ @click="handleDompurifyLinkClick"></div><a-textareadiff --git a/packages/nc-gui/components/virtual-cell/Formula.vue b/packages/nc-gui/components/virtual-cell/Formula.vueindex 1767891efb..9f54ade4a9 100644--- a/packages/nc-gui/components/virtual-cell/Formula.vue+++ b/packages/nc-gui/components/virtual-cell/Formula.vue@@ -40,8 +40,11 @@ const openLongText = (event: MouseEvent) => {if (!isStringDataType.value) returnconst target = event.target as HTMLElement- if (target.tagName === 'A') {+ const anchor = target.closest('a') as HTMLAnchorElement | null+ if (anchor?.href) {+ event.preventDefault()event.stopPropagation()+ confirmPageLeavingRedirect(anchor.href, '_blank')return}diff --git a/packages/nc-gui/helpers/tiptap-markdown/extensions/marks/link.ts b/packages/nc-gui/helpers/tiptap-markdown/extensions/marks/link.tsindex 9bb37eabdc..ddd546a27e 100644--- a/packages/nc-gui/helpers/tiptap-markdown/extensions/marks/link.ts+++ b/packages/nc-gui/helpers/tiptap-markdown/extensions/marks/link.ts@@ -39,14 +39,7 @@ export const Link = TiptapLink.extend<LinkOptions>({const attr = mergeAttributes(this.options.HTMLAttributes, HTMLAttributes)if (isValidURL(attr.href)) {- return [- 'a',- {- ...attr,- onclick: '(function(event) { window.tiptapLinkHandler?.(event);})(event)', // Global handler- },- 0,- ]+ return ['a', attr, 0]}// We use this as a workaround to show a tooltip on the contentdiff --git a/packages/nc-gui/helpers/tiptap/functionality/markdown/md-link-rule-setup.ts b/packages/nc-gui/helpers/tiptap/functionality/markdown/md-link-rule-setup.tsindex 7a296e0a11..b5d5ee514c 100644--- a/packages/nc-gui/helpers/tiptap/functionality/markdown/md-link-rule-setup.ts+++ b/packages/nc-gui/helpers/tiptap/functionality/markdown/md-link-rule-setup.ts@@ -35,15 +35,6 @@ function mdLinkRuleSetupExt(md: MarkdownIt, { openLinkOnClick = false }: { openLif (relIndex < 0) {tokens[idx]!.attrPush(['rel', 'noopener noreferrer nofollow'])}- const onClickIndex = tokens[idx]!.attrIndex('onmousedown')- if (onClickIndex < 0) {- tokens[idx]!.attrPush(['onmousedown', '(function(event) { event.preventDefault();})(event)'])- }-- const clickIndex = tokens[idx]!.attrIndex('onclick')- if (clickIndex < 0) {- tokens[idx]!.attrPush(['onclick', '(function(event) { window.tiptapLinkHandler?.(event);})(event)'])- }}return self.renderToken(tokens, idx, options)diff --git a/packages/nc-gui/utils/urlUtils.ts b/packages/nc-gui/utils/urlUtils.tsindex fa93588213..35926cf813 100644--- a/packages/nc-gui/utils/urlUtils.ts+++ b/packages/nc-gui/utils/urlUtils.ts@@ -62,7 +62,6 @@ const _replaceUrlsWithLink = (text: string, plainCellValue = false): boolean | sa.setAttribute('class', 'nc-cell-field-link')a.setAttribute('target', '_blank')a.setAttribute('rel', 'noopener noreferrer')- a.setAttribute('onClick', 'window.tiptapLinkHandler(event)')return a.outerHTML},)@@ -245,6 +244,15 @@ export const confirmPageLeavingRedirect = (url: string, target?: '_blank', allow}}+export const handleDompurifyLinkClick = (event: MouseEvent) => {+ const target = (event.target as HTMLElement)?.closest('a') as HTMLAnchorElement | null+ if (!target?.href) return++ event.preventDefault()+ event.stopPropagation()+ confirmPageLeavingRedirect(target.href, '_blank')+}+export const addConfirmPageLeavingRedirectToWindow = (remove = false) => {if (typeof window === 'undefined') return@@ -254,14 +262,6 @@ export const addConfirmPageLeavingRedirectToWindow = (remove = false) => {}sessionStorage.setItem('ncIsSharedViewOrBase', 'true')-- window.tiptapLinkHandler = (event) => {- event.preventDefault()-- if (event?.target?.href) {- confirmPageLeavingRedirect(event?.target?.href, '_blank')- }- }}export const isLinkExpired = async (url: string) => {