Skip to content

Commit 95b99dd

Browse files
authored
Merge pull request #583 from awcodes/feat/link-protocols
Feat: allow link protocols for deep links
2 parents 7c401aa + fe5ed4d commit 95b99dd

File tree

5 files changed

+57
-34
lines changed

5 files changed

+57
-34
lines changed

config/filament-tiptap-editor.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,4 +113,15 @@
113113
|
114114
*/
115115
'preset_colors' => [],
116+
117+
/*
118+
|--------------------------------------------------------------------------
119+
| Protocols
120+
|--------------------------------------------------------------------------
121+
|
122+
| With newer versions of Tiptap, you need to define additional protocols
123+
| for the link extension. i.e. 'ftp', 'mailto', etc.
124+
|
125+
*/
126+
'link_protocols' => [],
116127
];

resources/dist/filament-tiptap-editor.js

Lines changed: 33 additions & 33 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

resources/js/plugin.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,7 @@ export default function tiptap({
175175
getSearchResultsUsing,
176176
mentionDebounce,
177177
mentionSearchStrategy,
178+
linkProtocols = [],
178179
}) {
179180
let editor = null;
180181

@@ -321,6 +322,14 @@ export default function tiptap({
321322
if (['ordered-list', 'bullet-list', 'checked-list'].includes(tool)) {
322323
extensions.push(e)
323324
if (!extensions.includes(ListItem)) extensions.push(ListItem);
325+
} else if (tool === 'link') {
326+
if (linkProtocols?.length) {
327+
extensions.push(e.configure({
328+
protocols: linkProtocols,
329+
}))
330+
} else {
331+
extensions.push(e)
332+
}
324333
} else {
325334
extensions.push(e)
326335
}

resources/views/tiptap-editor.blade.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ class="relative z-0 tiptap-wrapper rounded-md bg-white dark:bg-gray-900 focus-wi
7171
},
7272
mentionDebounce: @js($mentionDebounce),
7373
mentionSearchStrategy: @js($mentionSearchStrategy),
74+
linkProtocols: @js(config('filament-tiptap-editor.link_protocols')),
7475
})"
7576
x-init="$nextTick(() => { init() })"
7677
x-on:click.away="blur()"

src/TiptapConverter.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,9 @@ public function getExtensions(): array
8888
new Underline,
8989
new Superscript,
9090
new Subscript,
91-
new Marks\Link,
91+
new Marks\Link([
92+
'protocols' => config('filament-tiptap-editor.link_protocols', []),
93+
]),
9294
new Marks\Small,
9395
...$customExtensions,
9496
];

0 commit comments

Comments
 (0)