Add specific button in editor toolbar Grav CMS - content-management-system

How can I add a new button in the editor toolbar in Grav CMS?. For example, the toolbar now contains a bold button, italic button, list button...etc. What I want is to add a new button to this toolbar to do a specific task like "Adding to some text". Or something similar. Is that could be done?

you can add button to editor through js
(function($){
$(function(){
$('body').on('grav-editor-ready', function() {
var Instance = Grav.default.Forms.Fields.EditorField.Instance;
Instance.addButton({
// Your stuff
});
});
});
})(jQuery);
Plenty examples how to do it on github, for instance you can check how Grav Team Implement New editor button
here : https://github.com/getgrav/grav-plugin-editor-buttons
they use that method to add shortcodes buttons to editor

Related

Customizing properties dialog screen in IBM Content Navigator

I need to develop a functionality in IBM Content Navigator where after search for an item, right click it-> Properties, I need to either:
1 - add a button in properties dialog screen that will call a service and open another dialog;
2 - or extend the Save button functionality to also call a service and open another dialog;
What's quickest way to achieve that ?
Have a look # ecm.widget.dialog.EditPropertiesDialog and onSave() method. This might help you to extend save button functionality.
You can add your customized code by using aspect before/after:
(choose either depending on your functionality)
aspect.after(ecm.widget.dialog.EditPropertiesDialog.prototype,"onSave", function(event){
......
});
aspect.before(ecm.widget.dialog.EditPropertiesDialog.prototype,"onSave", function(event){
......
});

Tinymce capture click event when 'New Document' was clicked

setup : function(ed) {
ed.on("click", function(e) {});
};
Tried setting up like this.But this get triggered when I click inside the editor text-area. So How do I capture the click event when a user clicks on "New document" from "File".Using Tinymce v4
TinyMCE does not issue any specific event when New Document is selected from the Menu. You can do one of two things:
1 - Leverage the ExecCommand event and look to see what actual command was issued.
When you select File -> New Document the editor fires an ExecCommand event and the command property is set to the value mceNewDocument. You can add code to your TinyMCE configuration that looks for any ExecCommand event and then checks to see if the command property is set to mceNewDocument. For example you can put this in your TinyMCE configuration...
setup: function (editor) {
editor.on('ExecCommand', function (e) {
if("mceNewDocument" == e.command) {
console.log('New Document was run...");
}
});
}
2 - Build a custom New Document menu option.
You can create a custom menu option and stop using the default one. Then you can add your own custom logic to do whatever you need when this option is selected. You can learn more about custom menu items here:
https://www.tinymce.com/docs/demo/custom-toolbar-menu-item/
The default menu option is defined in the FormatControls.js file within TinyMCE so you can use that as a template for your own custom button.

Add text next to UI Form action icon in toolbar?

Is there a way to add text next to the action icon in the toolbar of an eclipse RCP UI Form? If you do not assign the Action an ImageDescriptor, the action will be displayed containing only text. If you do give it an ImageDescriptor, it displays only the image. I want to display both side by side, within one button - is there a way to do this?
This will have only the text "Description" in the button on the toolbar:
myAction = new Action("Description", SWT.PUSH) {
#Override
public void run() {}
};
myForm.getToolBarManager().add(myAction);
But adding an image will cause the the text to be replaced:
myAction.setImageDescriptor(newImage);
I was eventually able to find an answer to my issue, hopefully it's helpful to anyone else who runs into this problem. I found this in the Eclipse Rich Client Platform (2nd Ed.) book.
The Action must be converted to an ActionContributionItem with its mode set to MODE_FORCE_TEXT. This will display both the text and the image in the toolbar.
ActionContributionItem aCI = new ActionContributionItem(myAction);
aCI.setMode(ActionContributionItem.MODE_FORCE_TEXT);
myForm.getToolBarManager().add(aCI);

Open link on press of "sap.m.Button" instead of using "sap.m.Link" [duplicate]

This question already has an answer here:
SAPUI5 Open link on Button press
(1 answer)
Closed 1 year ago.
I am relatively new to UI5. My search for "[sapui5] icon link" brought no useful results. So here is my question.
I have the following sap.m.Link
<Link id="myLink" href="http://stackoverflow.com/" text="Stackoverflow" />
which displays the text "Stackoverflow" on the UI, and when I click on it, I will navigate to stackoverflow.com. That's the effect I want.
But how can I replace the text with an icon, for example "sap-icon://download"? According to the Link-API, it doesn't have an attribute icon. So is there a way to get the same effect using sap.m.Button that does have this attribute:
<Button icon="sap-icon://download" press=".onDataExport" />
What would the handler onDataExport look like? My idea is to use a (somehow) hidden sap.m.Link and a sap.m.Button containing the icon. The press-handler of the Button would then somehow trigger a 'link clicked' (not sure if that is possible).
My answer comes a bit late, but I hope that it will help others, as I searched for a ready-to-use Link including an Icon (although this does not seem to be the real need of StoneCrusher).
Button which triggers link navigation:
If you want a sap.m.Button to act like a classical link, then you can attach a press event and use window.open in that event, like:
myButton.attachPress(function () {
window.open(url,target);
});
Link with UI5 icon:
If you want to display a sap-icon in a sap.m.Link, then you have to extend the link, include an aggregation which contains the icon and then render the icon before you render the text of the link.
renderer : function(oRm, oControl) {
[...]
oRm.write("<a");
oRm.writeControlData(oControl);
oRm.addClass("sapMLnk sapMLnkMaxWidth touconLink");
oRm.writeClasses();
oRm.write("href=\"javascript:void(0);\" ");
oRm.write(">");
//Render icon
if (icon!="") {
oControl.getAggregation("_icon").setIcon(icon);
oRm.renderControl(oControl.getAggregation("_icon"));
}
oRm.writeEscaped(text);
oRm.write("</a>");
}
I was in need of both and published these and other custom UI5 convenience controls here: www.toucon.fr
Use the below code in your onDataExport function in controller:
sap.m.URLHelper.redirect("https://stackoverflow.com/", true);
Refer to the below link for info: ui5.sap.com/#/sample/sap.m.sample.Link/preview
sorry only got reply in JSON style, but you see what is missing in your code:
jQuery.sap.require("sap.ui.core.IconPool");
var sBack = sap.ui.core.IconPool.getIconURI("nav-back");
var button = new sap.ui.commons.Button({
icon : sBack,
});

Add a popup Pane to crossrider add-on icon and bliking icons to the add-on icon

I wanted to migrate my existing add-on for firefox and chrome to crossrider in order to have it also with safari and IE, but i've a few doubts that mayble Schlomo (or any Crossrider developercan) can help me to solve them.
Questions :
Can i add a popup pane when someone clicks on the add-on button showing some kind of options inside it?
Can i add a blinking icon to the actual icon showing some kind of event happened like incoming chat or so?
Is there a way to add the red text box like in chrome showing at the bottom right of the icon some kind of text?
Thanks a lot!
When you pose the question like that, I can only hope the following answers will serve to allay your doubts and enlighten :)
First off, I would recommend familiarizing yourself with How to add a browser button to your Crossrider extension in general and the button popup feature specifically.
In answer to your specific questions:
You can use the button popup feature and build the required options in there. Take a look at the Button Popup Menu demo extension to get you started.
Whilst you can't make the button blink, you can alternate the button icon to make it look like blinking (see example).
In short, yes. Simply use the appAPI.browserAction.setBadgeText and appAPI.browserAction.setBadgeBackgroundColor methods (see example).
The following example bring together the key elements in the background.js code required to achieve the solutions mentioned. Look at the popup.html file in the Button Popup Menu for an example of how to build the options page.
appAPI.ready(function() {
var sid, // Blink interval id
alt=0, // Blink alternation state
icon = { // Blink icons
0: 'icons/icon0.png',
1: 'icons/icon1.png'
};
// Set the initial icon for the button
appAPI.browserAction.setResourceIcon(icon[0]);
// Sets the popup for the button
appAPI.browserAction.setPopup({
resourcePath:'html/popup.html',
height: 300,
width: 300
});
if (true) { // blink condition, set to true for this example
// Blink icon
sid = appAPI.setInterval(function() {
alt = 1 - alt;
appAPI.browserAction.setResourceIcon(icon[alt]);
}, 1 * 1000);
} else {
appAPI.clearInterval(sid);
}
if (true) { // show button text condition, set to true for this example
// Add red text box to icon
appAPI.browserAction.setBadgeText('ext', [255,0,0,255]);
}
});
[Disclosure: I am a crossrider employee]