File tree Expand file tree Collapse file tree 4 files changed +24
-1
lines changed
dialtone-vue2/components/rich_text_editor
dialtone-vue3/components/rich_text_editor Expand file tree Collapse file tree 4 files changed +24
-1
lines changed Original file line number Diff line number Diff line change @@ -155,5 +155,6 @@ export const WithCustomExtensions = {
155155 allowUnderline : false ,
156156 allowCode : false ,
157157 allowCodeblock : false ,
158+ link : false ,
158159 } ,
159160} ;
Original file line number Diff line number Diff line change @@ -655,7 +655,6 @@ export default {
655655 },
656656
657657 methods: {
658-
659658 createEditor () {
660659 // For all available options, see https://tiptap.dev/api/editor#settings
661660 this .editor = new Editor ({
@@ -669,6 +668,17 @@ export default {
669668 class: this .inputClass ,
670669 },
671670
671+ handlePaste : (_ , event ) => {
672+ // When having link and customLink props we should maintain default paste behavior
673+ if (! this .link && ! this .customLink ) {
674+ const pastedContent = event .clipboardData .getData (' text' );
675+ this .editor .chain ().focus ().insertContent (pastedContent).run ();
676+ return true ; // Prevent the default paste behavior
677+ }
678+
679+ return false ; // Allow the default paste behavior
680+ },
681+
672682 // Moves the <br /> tags inside the previous closing tag to avoid
673683 // Prosemirror wrapping them within another </p> tag.
674684 transformPastedHTML (html ) {
Original file line number Diff line number Diff line change @@ -162,5 +162,6 @@ export const WithCustomExtensions = {
162162 allowUnderline : false ,
163163 allowCode : false ,
164164 allowCodeblock : false ,
165+ link : false ,
165166 } ,
166167} ;
Original file line number Diff line number Diff line change @@ -670,6 +670,17 @@ export default {
670670 class: this .inputClass ,
671671 },
672672
673+ handlePaste : (_ , event ) => {
674+ // When having link and customLink props we should maintain default paste behavior
675+ if (! this .link && ! this .customLink ) {
676+ const pastedContent = event .clipboardData .getData (' text' );
677+ this .editor .chain ().focus ().insertContent (pastedContent).run ();
678+ return true ; // Prevent the default paste behavior
679+ }
680+
681+ return false ; // Allow the default paste behavior
682+ },
683+
673684 // Moves the <br /> tags inside the previous closing tag to avoid
674685 // Prosemirror wrapping them within another </p> tag.
675686 transformPastedHTML (html ) {
You can’t perform that action at this time.
0 commit comments