Skip to content

Commit

Permalink
feat: allow providing custom link dialog component (#209)
Browse files Browse the repository at this point in the history
  • Loading branch information
mimpushkarev authored Dec 1, 2023
1 parent 735da40 commit 07d5445
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions src/plugins/link-dialog/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,11 @@ type EditLinkDialog = {
rectangle: RectData
}

type LinkDialogPluginParamsType = {
LinkDialog?: () => JSX.Element
linkAutocompleteSuggestions?: string[]
}

function getLinkNodeInSelection(selection: RangeSelection | null) {
if (!selection) {
return null
Expand Down Expand Up @@ -296,10 +301,10 @@ export const [
id: 'link-dialog',
dependencies: ['link'],
systemSpec: linkDialogSystem,
applyParamsToSystem(r, params: { linkAutocompleteSuggestions?: string[] } = {}) {
applyParamsToSystem(r, params: LinkDialogPluginParamsType = {}) {
r.pubKey('linkAutocompleteSuggestions', params.linkAutocompleteSuggestions || [])
},
init(r) {
r.pubKey('addComposerChild', LinkDialog)
init(r, params) {
r.pubKey('addComposerChild', params?.LinkDialog || LinkDialog)
}
})

0 comments on commit 07d5445

Please sign in to comment.