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.
Related
I've googled and found nothing, so here I am. If this is in the CKEditor documentation, I haven't found it there either.
The powers that be want a user to be able to double-click on a piece of text (say, a word) in CKEditor, and have that be able to open up a new HTML element outside of CKEditor (such as a Bootstrap Modal). Is this even possible, and if so, how do I go about it?
For example, I've written a separate "Agenda Builder" which is really just where you pick some stuff from drop downs like the name of a meeting room, how many seats you'll need, etc, and enter some dates and times. That all gets saved to the database. But in the text in CKEditor, they want to be able to double-click on [[agenda]] and have it then open up that feature for the user to create their agenda and save it (an entirely separate thing from CKEditor), and then later I will "insert" the agenda into the document in place of the [[agenda]] tag. Make sense?
Thanks!
I think I manage to find the answers to these after posting the question... here's what I came up with:
editor.on('doubleclick', function(e) {
var element = e.data.element.$.innerText;
if (element =='[[agenda]]' ) {
alert("clicked on agenda");
}
});
We solved this exact scenario by creating a CKEditor Plugin(for our own use). When you highlight a word and select a drop down from the plugin, it edits the element highlighted.
In our scenario we used an Angular directive for the navigation.
I'm using the ck-editor(4.4.6). In Ck-editor's textarea I want to update my text, for that I use setData("hai"); that text updating correctly but some plugin functionality not working after use this setData(); (eg. restrict multiple enter if I reload the page it's working correctly).
editorInstance.setData("test text");
Anyway first time and after reload the page it working fine.
ruby on rails with jquery things are I'm using.
How can I solve this?
I don't know about ck-editor(4.4.6) but i can give you a way to solve it. You have to use based on your parent class. First time it works because it was same but after that it did't find the class/your specific term/attribute. So you have to use by calling parent class/id and under your activity.
You will need to call the update element function after setting the data, this will actually set the value in the field.
And, also you will need to specify the id of the textarea as given below.
CKEDITOR.instances.id_of_textarea.setData('hai');
CKEDITOR.instances.id_of_textarea.updateElement();
Finally, I got the answer instead of set data I just add my content to CKEditor text area as link this its working fine:
$('#cke_editor1 iframe').contents().find('body').html("Your text");
We have a widget in our Magento page which allows us to show some featured products. But what our main goal is, is that we want to change the featured products when an element is clicked, here is what the widget looks like in code:
{{widget type="slideshow/slideshow" slideshow_ids="16,17,18,19,20" template="ma2_slideshow/slideshownews.phtml"}}
The id's which the widget uses, needs to be changed when an element is clicked.
I've already searched and fiddled with some variables but it doesn't work unfortunately...
I am also wondering what type of language the widget is...
Any more information needed? Any suggestions?
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.
I want to populate the format-box in CKEditor toolbar dynamically (depending on what the user selects in another select box).
Is it possible to change the options of the format-combo box dynamically , without reloading the whole CKEditor ?
The shortest answer is: no. However...
The plugin responsible for this box is the format plugin. It gathers all the data during the init function called when editor is being initialized. If you want to have this thing dynamically populated, you need to change some logic of this plugin on your own.
You might be interested in onRender callback for rich combos which is used by the plugin to dynamically change the value of the combo. Another handful thing might be add() method of rich combo used by format plugin. I'm pretty sure you got to extend the richcombo plugin to remove items.
Good luck anyway!