Remove unnecessary elements from insert link menu: TinyMCE - javascript

I use TinyMCE for content editing. I allow people to enter links in their HTML. So when the user clicks on add link, he sees the following popup:
But none of the users is actually using any of the fields except of URL. Is there a way to remove all these fields and leave only URL, but when the user click on the link in created html - to open this link in the new tab/window?
I tried to look at their documentation, but was not able to find how to achieve this.

Well, you can clone the tinymce core plugin rename it and remove the parts you don't need.
Don't forget to include the new name in your tinymce plugin and button config.

Related

Target this anchor link via JS entered into href

Is it possible to target anchor link via JS entered into href? I need to kill the cursor style on a SPECIFIC link. I cannot do it any other way - so no css, jQuery, etc. It has to go into a CMS via an insert js link on a link.
Example of input: javascript:void(0);targetThisLink.style.cursor='default'
Example of output inserted into the page/DOM: Link
I tried this.style.cursor='default'. It failed. I am not sure this is possible, but if it is let me know.
Try this
Link
Note two things:
Style is only applied after user clicks on the link
You have to have a way to target that specific link via querySelector. Class or ID would be ideal. I used a tag but that would apply same style to all other links on the page. If nothing else possible try using a[href^=javascript:]
Are you able to use mouseover in your CMS?
See example below:
Click Me

AngularJS Summernote insert link always open in new tab by default

I have a Summernote editor in an ng-dialog and I'm trying to make all links that are inserted open in a new tab by default. I added a CSS class to the editor to hide the checkbox for that option but I can't figure out a way to check that checkbox.
Is there an insertLink or dialogOpen event that I can place my code for checking the checkbox? Thank you!
Go to the summernote.js file and find
$openInNewWindow.prop('checked', linkInfo.isNewWindow);
Set this forcefully true by replacing linkInfo.isNewWindow
$openInNewWindow.prop('checked', true);
Hopefully it will resolve your issue.

Getting specific content from TinyMCE editor

I have a plugin im building for wordpress that injects a shortcode with content inside it after the user selects options for that plugin. What im having trouble with is tinyMCE.get('content').getContent() this is called when a user wants to update those options but using this pulls everything thats in tinymce, I need it limited to the content inside the shortcode open and close tags. For example: after a user selects options of the plugin, a shortcode of [plugin]---HTML OPTIONS---[/plugin] will be created but when tinyMCE.get('content').getContent() is called I need it to grab everything inside of said plugin tags and nothing else like so: [plugin]---GET THIS CODE----[/plugin] any help would be grateful. Let me know if you need clarification on anything.
If I understand what you are attempting then what you are looking for is the
tinymce.dom.Selection class (doc)
More specifically:
// Sets some contents to the current selection in the editor
tinymce.activeEditor.selection.setContent('Some contents');
// Gets the current selection
alert(tinymce.activeEditor.selection.getContent());
You might take a look at code in some of the available plugins. The link plugin in particular works with text selections.

Call Equation Editor plugin when custom button is clicked

I have a very basic text editor that uses CKEditor. The default CKEditor toolbar is hidden because for editing I need only image upload (which is completely custom) and Equation Editor plugin for formulas.
My goal is to use a custom button for the Equation Editor and call the plugin on click. So, somewhere in the UI of the editor, I would have this:
Insert formula
Clicking on the button should open the Equation Editor.
How do I achieve this?
Note: I have multiple CKEditor instances on the page.
You should use CKEDITOR.editor.execCommand() like this
CKEDITOR.instances.myEditorInstance.execCommand( 'mathjax' )
And this is where you'll find how to do this.
You can list available commands of the CKEditor instance by browsing CKEDITOR.instances.myEditorInstance.commands object.

Make TinyMCE follow anchors within textarea

I am trying to find a method of making TinyMCE follow anchor links within the textarea. I am trying to make a table of contents, and would like the ability for users to skip the the desired section in the editor. Is this possible?
Thanks.
You will need to write an own plugin for that setting the cursor position using methods from the tinymce class Selection. The newest tinymce version contains the method setCursorLocation which may be used for example.

Categories