Reputation: 22442
I am using the Froala editor in my solution to create html that is to be sent to a PDF writer. The PDF writer does not support clickable links. This means that the full url must show as text.
So what I want is to disable the possibility to add links with custom text in the editor. I want it to be generated as a clickable anchor link (<a href="url">url</a>
) but I want the full url to show in the text. Reason I want this to be inserted as link rather than disabling the link plugin altogether, is that it will then be visually formatted as a link by css.
I have found the setting linkText: false
for the Froala editor, which hides the text field inside the insert link popup. This is basically what I want - so far so good.
The issue is that the user can "work around" this by selecting a text in the editor before clicking the link button. The text is still not shown in the link popup, but the link you create is applied to the selected text, and the link url is not shown in the text.
Is there some way I can disable this behaviour in the link plugin so that if the user has selected a text before adding the link, the text will be ignored, and the link with url as text will just be inserted after the pre-selected text?
FroalaEditor version is 4.0.11
Upvotes: 0
Views: 790
Reputation: 5
One possible solution to your question is turning off the Froala URL plugin.
The developer can use the pluginsEnabled option to turn off that plugin. This may seem counterintuitive.
By default, there is no option to mention the plugins you want to disable. If the plugin name is not in the pluginsEnabled, it is now disabled.
For example: pluginsEnabled: [‘image,’ ‘link,’ ‘URL,’ ‘align’]
This code only enables image, link, URL, and align plugins. Other plugins will be disabled.
You can check the detailed code about the question in this blog post on the Froala site.
Upvotes: 0
Reputation: 22442
I ended up removing the possibility to open the link popup. I removed the insertLink
from toolbarButtons
and quickInsertButtons
. I also removed linkEdit
and linkRemove
from linkEditButtons
.
I also have the url
plugin active, so that whenever I insert a text in the editor that the Froala url plugin recognizes as a valid url, it is wrapped in an <a>
tag which provides the styling for links as I want. I still have the link plugin active but with only with linkEditButtons: ['linkOpen', 'linkStyle']
to be able to open the link from the editor and select from a couple of link styles I have set up.
Upvotes: 0