Created
November 30, 2022 11:34
-
-
Save jams2/7ca60aa56ad7e75dc994c21447abfadd to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
document.addEventListener('DOMContentLoaded', () => { | |
window.draftail.LinkModalWorkflowSource.prototype.getChooserConfig = function (entity, selectedText) { | |
let url = window.chooserUrls.pageChooser; | |
const urlParams = { | |
page_type: 'home.VoidPage', // this is the important line | |
allow_external_link: true, | |
allow_email_link: true, | |
allow_phone_link: true, | |
allow_anchor_link: true, | |
link_text: selectedText, | |
}; | |
if (entity) { | |
const data = entity.getData(); | |
if (data.id) { | |
if (data.parentId !== null) { | |
url = `${window.chooserUrls.pageChooser}${data.parentId}/`; | |
} else { | |
url = window.chooserUrls.pageChooser; | |
} | |
} else if (data.url.startsWith('mailto:')) { | |
url = window.chooserUrls.emailLinkChooser; | |
urlParams.link_url = data.url.replace('mailto:', ''); | |
} else if (data.url.startsWith('tel:')) { | |
url = window.chooserUrls.phoneLinkChooser; | |
urlParams.link_url = data.url.replace('tel:', ''); | |
} else if (data.url.startsWith('#')) { | |
url = window.chooserUrls.anchorLinkChooser; | |
urlParams.link_url = data.url.replace('#', ''); | |
} else { | |
url = window.chooserUrls.externalLinkChooser; | |
urlParams.link_url = data.url; | |
} | |
} | |
console.log(urlParams); | |
return { | |
url, | |
urlParams, | |
onload: window.PAGE_CHOOSER_MODAL_ONLOAD_HANDLERS, | |
responses: { | |
pageChosen: this.onChosen, | |
}, | |
}; | |
}; | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment