I am trying to customize the default Link modal that pops up on TinyMCE when attempting to hyperlink text. This refers to the Internal Link tab. The behavior that I want to add is having a dropdown with preset rootPaths to restrict the search to. This way users can quickly define up front which folder to search within. I know the tree provides it, but my use case wants a 1-click path for a number of preset folders that we know.
So first I set out to customize the Related Items pattern using this concept: https://training.plone.org/5/javascript/exercises/8.html#add-your-pattern-file
To extend: https://github.com/plone/mockup/blob/2.1.x/mockup/patterns/relateditems/pattern.js
The problem is that I do not necessarily want every interface that uses the pat-relateditems to implement the new behavior.
I also saw that I might want to extend the LinkModal pattern, but when I attempted to do that, I found that the extended version did not call the extended show function when the user taps to insert a link from TinyMCE.
require([
'jquery',
'tinymce',
'mockup-patterns-tinymce-url/js/links',
'pat-registry'
], function($, tinymce, LinkModal, registry) {
'use strict';
// first, unregister existing pattern
delete registry.patterns.linkmodal;
delete $.fn.patLinkmodal;
// creating new pattern automatically registers it
LinkModal.extend({
name: 'linkmodal',
trigger: '.pat-linkmodal',
parser: 'mockup',
init: function() {
var that = this;
LinkModal.prototype.init.call(that);
},
show: function() {
var that = this;
LinkModal.prototype.show.call(that);
// customizations here
}
});
});
So my question is, does anybody have any good docs on how to customize the LinkModal?
Thank you in advance for any insights!