How to change the theme in an Ace editor? - ace-editor

I've been trying to add syntax highlighting to my web app and found ace. However, after working at the solution provided in the documentation, I am still unable to change the editor theme. Does anyone know how to go about this?
So far I've just initialized the element with the following code
var editor = ace.edit("editor");
editor.getSession().setUseWrapMode(true);
editor.setHighlightActiveLine(true);
editor.setShowPrintMargin(false);
editor.setTheme('ace-builds-master/theme/tomorrow_night.css');
editor.getSession().setMode("ace/mode/javascript");

In the build mode argument to setTheme() is not a path but an id of the theme so you need to call
.setTheme('ace/theme/tomorrow_night') instead
Note that you also can set all the options in one call using
editor.setOptions({
useWrapMode: true,
highlightActiveLine: true,
showPrintMargin: false,
theme: 'ace/theme/tomorrow_night',
mode: 'ace/mode/javascript'
})
or in newer version of ace pass object with options to ace.edit
var editor = ace.edit("editor"{
useWrapMode: true,
...
})

Related

DJANGO-CMS PlaholderFields CKEDITOR TEXT_HTML_SANITIZE

I've implemented a PlaceholderField outside my CMS and it works fine but Text copied from MS-Word keeps all dirty markup (like <font face="Times New Roman, serif"><font size="3">) which I want to get rid of. When I copy the same Text in a normal CKEditor field it works as explained in djangocms-text-ckeditor source (settings.TEXT_HTML_SANITIZE using html5lib).
Is there a parameter I can add to settings.CMS_PLACEHOLDER_CONF in order to make it work? Or any idea to implement it?
You may ask "Why not using directly HTMLField with djangocms-text-ckeditor?" Because I want to have access to Filer-File and Filer-Image plugins available in PlaceholderField.
The following setting is not part of the placeholder config, they are separate settings in the settings.py file:
TEXT_HTML_SANITIZE = True
CKEDITOR_SETTINGS = {
...
'basicEntities': True,
'entities': True,
...
}
Taken from: https://github.com/django-cms/djangocms-text-ckeditor#configurable-sanitizer

Change sapui5 fileuploader browse button text

I'm looking for a way to change sapui5 language at runtime based on the loggedin user language. I have the i18n properties file in place. The challenge that I'm facing is to change the text on the FileUploader button. This text is not being picked up from the properties file. It is always 'Browse'
I'm using sap.ui.commons.FileUploader()
var FileUploader = new sap.ui.commons.FileUploader({
id: "fileUploader_id",
fileType: "zip",
uploadOnChange: false,
buttonText: oBundle.getText(FILEUPLOADER_BUTTON_TEXT),
tooltip: oBundle.getText(FILEUPLOADER_BUTTON_TIP),
});
Similar problem with the table when there is no data. The table displays 'No data' in english instead I want it to be in a user specific language.
The "buttonText" property from sap.ui.unified.FileUploader is not working?
I just gave it a try to see and the button's label changed accordingly.
<u:FileUploader buttonText="{i18n>browseText}"></u:FileUploader>
In older versions of SAPUI5 (using commons library), the button Text can be changed by overwriting the standard buttonText parameter. i.e., in this case the standard "FILEUPLOAD_BROWSE" has to be overwritten in the local i18n.properties file. We cannot use the name that suites us (like FILEUPLOADER_BUTTON_TEXT).

ckeditor stylesheet parser in fullpage mode

Is it possible to use the stylesheet parser in full page mode? I can get either of these features to work, but not both. For example, the following settings result in an empty styles combo box.
var editor1 = CKEDITOR.replace('editor1', {
contentsCss: ['myStyles.css'],
stylesSet: [],
fullPage: true,
allowedContent: true
});
If I comment out the "styleSet: []" line, then the combo box gets populated with the default styles, and mine don't get added. On the other hand, if I comment out "fullPage: true", then my styles get added, but I'm not in full page mode.
I'm using the latest version of ckeditor (4.4.7). Thanks for any help ...

Inserting a link into CKEditor

I'm trying to insert a link into an instance of CKEditor using the following line: -
CKEDITOR.instances.CKInstance.insertHtml('My Text');
All that happens though is that 'MyText' is inserted without the link. Anyone know how to insert the link properly?
PS. I know that CKEditor comes with a plugin to insert links but I'm doing my own one
Thanks
Shazoo
I guess that you're using CKEditor 4.1 or newer. And since you don't use the official link plugin, your editor discards all <a> tags. You need to properly configure Allowed Content Filter so your editor accepts <a> tags back again.
You can do it when defining your command, like this:
// Assuming you want a dialog-driven command...
editor.addCommand( 'yourCommand', new CKEDITOR.dialogCommand( 'link', {
allowedContent: 'a[!href]', // Allow <a> in the editor with mandatory href attr.
requiredContent: 'a[href]' // This command requires <a> with href to be enabled.
} ) );
Or in editor's config with config.extraAllowedContent = 'a[!href]'. This is not recommended though as you develop a plugin (right?), which should bring a custom command.

ck editor forcefully removing my html and body tags

I am trying to edit an entire html using fck editor. So that should contain tags like html, body ,DOCTYPE etc. But my problem is when I submit the data, fckeditor forcefully remove the above tags from the content. I want to avoid this. Is there any configuration issue there.
-Arun
look at this config option. CKEDITOR.config.fullPage. I believe it will permit you to edit the full page (and will preserve the contents) (i haven't used it.)
'ckEditor' (as it's now known) shouldn't allow html/script tags directly within the content. However if you have the latest version there is a 'source' view which allows all the source to be edited directly and may give you what you want.
Arun User this one .This is best solution for you.
var CKcontent = false ;
$(document).ready(function(){
// setup ckeditor and its configurtion
CKEDITOR.replace( 'content1',
{
//fullPage : true,
customConfig : 'config.js' ,
toolbar : 'BasicToolbar' ,
height : "300"
});
});
Set only fullpage : false if not show HTML content otherwise set true
Note: it implemented by me in our development

Resources