Browse Source

fix: Improved autofilling network protocol prefix logic for rich link popup

pull/7046/head
Muhammed Mustafa 1 year ago
parent
commit
18f3ab169d
  1. 15
      packages/nc-gui/components/cell/RichText/LinkOptions.vue

15
packages/nc-gui/components/cell/RichText/LinkOptions.vue

@ -58,10 +58,23 @@ const checkLinkMark = (editor: Editor) => {
return showLinkOptions return showLinkOptions
} }
function notStartingWithNetworkProtocol(inputString: string) {
const pattern = /^(?![^:]+:\/\/).*/
const isMatch = pattern.test(inputString)
return isMatch
}
const onChange = () => { const onChange = () => {
const isLinkMarkedStoredInEditor = editor.value.state?.storedMarks?.some((mark: Mark) => mark.type.name === 'link') const isLinkMarkedStoredInEditor = editor.value.state?.storedMarks?.some((mark: Mark) => mark.type.name === 'link')
let formatedHref = href.value let formatedHref = href.value
if (isValidURL(href.value) && href.value.length > 0 && !href.value.startsWith('/') && !href.value.startsWith('http')) { if (
isValidURL(href.value) &&
href.value.length > 0 &&
!href.value.startsWith('/') &&
notStartingWithNetworkProtocol(href.value)
) {
formatedHref = `https://${href.value}` formatedHref = `https://${href.value}`
} }

Loading…
Cancel
Save