Files
edx-platform/xmodule/js/src/html/edit.js
Arunmozhi 54507c1e08 feat: allow overriding TinyMCE config using settings
The TinyMCE configuration can be overridden by adding a
`TINYMCE_CONFIG_OVERRIDES` dict to the `JS_ENV_EXTRA_CONFIG`.
2022-11-23 19:55:28 +01:00

1452 lines
56 KiB
JavaScript

// Once generated by CoffeeScript 1.9.3, but now lives as pure JS
/* eslint-disable */
(function() {
var bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; };
this.HTMLEditingDescriptor = (function() {
/*
custom fonts are prepended to font selection dropdown
*/
var CUSTOM_FONTS, STANDARD_FONTS, _getFonts;
CUSTOM_FONTS = "Default='Open Sans', Verdana, Arial, Helvetica, sans-serif;";
/*
list of standard tinyMCE fonts: http://www.tinymce.com/wiki.php/Configuration:font_formats
*/
STANDARD_FONTS = "Andale Mono=andale mono,times;" +
"Arial=arial,helvetica,sans-serif;" +
"Arial Black=arial black,avant garde;" +
"Book Antiqua=book antiqua,palatino;" +
"Comic Sans MS=comic sans ms,sans-serif;" +
"Courier New=courier new,courier;" +
"Georgia=georgia,palatino;" +
"Helvetica=helvetica;" +
"Impact=impact,chicago;" +
"Symbol=symbol;" +
"Tahoma=tahoma,arial,helvetica,sans-serif;" +
"Terminal=terminal,monaco;" +
"Times New Roman=times new roman,times;" +
"Trebuchet MS=trebuchet ms,geneva;" +
"Verdana=verdana,geneva;" +
"Webdings=webdings;" +
"Wingdings=wingdings,zapf dingbats";
_getFonts = function() {
return CUSTOM_FONTS + STANDARD_FONTS;
};
function HTMLEditingDescriptor(element) {
this.initInstanceCallback = bind(this.initInstanceCallback, this);
this.saveCodeEditor = bind(this.saveCodeEditor, this);
this.showCodeEditor = bind(this.showCodeEditor, this);
this.saveLink = bind(this.saveLink, this);
this.editLink = bind(this.editLink, this);
this.editImageSubmit = bind(this.editImageSubmit, this);
this.saveImageFromModal = bind(this.saveImageFromModal, this);
this.closeImageModal = bind(this.closeImageModal, this);
this.openImageModal = bind(this.openImageModal, this);
this.saveImage = bind(this.saveImage, this);
this.editImage = bind(this.editImage, this);
this.setupTinyMCE = bind(this.setupTinyMCE, this);
this.cancelButton = bind(this.cancelButton, this);
var tiny_mce_css_links;
this.element = element;
this.base_asset_url = this.element.find("#editor-tab").data('base-asset-url');
this.editor_choice = this.element.find("#editor-tab").data('editor');
this.new_image_modal = window.STUDIO_FRONTEND_IN_CONTEXT_IMAGE_SELECTION;
if (this.base_asset_url === void 0) {
this.base_asset_url = null;
}
/*
We always create the "raw editor" so we can get the text out of it if necessary on save.
*/
this.advanced_editor = CodeMirror.fromTextArea($(".edit-box", this.element)[0], {
mode: "text/html",
lineNumbers: true,
lineWrapping: true
});
if (this.editor_choice === 'visual') {
this.$advancedEditorWrapper = $(this.advanced_editor.getWrapperElement());
this.$advancedEditorWrapper.addClass('is-inactive');
/*
Create an array of all content CSS links to use in and pass to Tiny MCE.
We create this dynamically in order to support hashed files from our Django pipeline.
CSS files that are to be used by Tiny MCE should contain the string "tinymce" so
they can be found by the search below.
We filter for only those files that are "content" files (as opposed to "skin" files).
*/
tiny_mce_css_links = [];
$("link[rel=stylesheet][href*='tinymce']").filter("[href*='content']").each(function() {
tiny_mce_css_links.push($(this).attr("href"));
});
/*
This is a workaround for the fact that tinyMCE's baseURL property is not getting correctly set on AWS
instances (like sandbox). It is not necessary to explicitly set baseURL when running locally.
*/
tinyMCE.baseURL = baseUrl + "js/vendor/tinymce/js/tinymce";
/*
This is necessary for the LMS bulk e-mail acceptance test. In that particular scenario,
tinyMCE incorrectly decides that the suffix should be "", which means it fails to load files.
*/
tinyMCE.suffix = ".min";
var tinyMceConfig = {
script_url: baseUrl + "js/vendor/tinymce/js/tinymce/tinymce.full.min.js",
font_formats: _getFonts(),
theme: "silver",
skin: "studio-tmce5",
schema: "html5",
entity_encoding: "raw",
/*
Necessary to preserve relative URLs to our images.
*/
convert_urls: false,
/*
Sniff UI direction from `.wrapper-view` in studio or `.window-wrap` in LMS
*/
directionality: $(".wrapper-view, .window-wrap").prop('dir'),
content_css: tiny_mce_css_links.join(", "),
formats: {
// tinyMCE does block level for code by default
code: {
inline: 'code'
}
},
/*
Disable visual aid on borderless table.
*/
visual: false,
plugins: "lists, link, image, codemirror",
codemirror: {
path: baseUrl + "js/vendor",
disableFilesMerge: true,
jsFiles: ["codemirror-compressed.js"],
cssFiles: ["CodeMirror/codemirror.css"]
},
image_advtab: true,
/*
We may want to add "styleselect" when we collect all styles used throughout the LMS
*/
toolbar: "formatselect fontselect bold italic underline forecolor wrapAsCode " +
"alignleft aligncenter alignright alignjustify " +
"bullist numlist outdent indent blockquote link unlink " +
((this.new_image_modal ? 'insertImage' : 'image') + " code"),
block_formats: edx.StringUtils.interpolate(
gettext("{paragraph}=p;{preformatted}=pre;{heading3}=h3;{heading4}=h4;{heading5}=h5;{heading6}=h6"),
{
paragraph: gettext("Paragraph"),
preformatted: gettext("Preformatted"),
heading3: gettext("Heading 3"),
heading4: gettext("Heading 4"),
heading5: gettext("Heading 5"),
heading6: gettext("Heading 6")
}),
width: '100%',
height: '435px',
menubar: false,
statusbar: false,
/*
Necessary to avoid stripping of style tags.
*/
valid_children: "+body[style]",
/*
Allow any elements to be used, e.g. link, script, math
*/
valid_elements: "*[*]",
extended_valid_elements: "*[*]",
invalid_elements: "",
setup: this.setupTinyMCE,
/*
Cannot get access to tinyMCE Editor instance (for focusing) until after it is rendered.
The tinyMCE callback passes in the editor as a parameter.
*/
init_instance_callback: this.initInstanceCallback,
browser_spellcheck: true
};
if (typeof process != "undefined" && process.env.JS_ENV_EXTRA_CONFIG) {
var tinyMceAdditionalPlugins = process.env.JS_ENV_EXTRA_CONFIG.TINYMCE_ADDITIONAL_PLUGINS;
// check if we have any additional plugins passed
if (tinyMceAdditionalPlugins) {
// go over each plugin
tinyMceAdditionalPlugins.forEach(function (tinyMcePlugin) {
// check if plugins is not empty (ie there are existing plugins)
if (tinyMceConfig.plugins.trim()) {
tinyMceConfig.plugins += ', ';
}
// add the plugin to the list of plugins
tinyMceConfig.plugins += tinyMcePlugin.name;
// check if the plugin should be included in the toolbar
if (tinyMcePlugin.toolbar) {
// check if toolbar is not empty (ie there are already items in the toolbar)
if (tinyMceConfig.toolbar.trim()) {
tinyMceConfig.toolbar += ' | ';
}
tinyMceConfig.toolbar += tinyMcePlugin.name;
}
// add the additional settings for each plugin (if there is any)
if (tinyMcePlugin.extra_settings) {
tinyMceConfig[tinyMcePlugin.name] = tinyMcePlugin.extra_settings;
}
});
}
// apply configuration overrides if have been defined
var tinyMceConfigOverrides = process.env.JS_ENV_EXTRA_CONFIG.TINYMCE_CONFIG_OVERRIDES;
if (tinyMceConfigOverrides) {
Object.assign(tinyMceConfig, tinyMceConfigOverrides);
}
}
this.tiny_mce_textarea = $(".tiny-mce", this.element).tinymce(tinyMceConfig);
tinymce.addI18n('en', {
/*
Translators: this is a message from the raw HTML editor displayed in the browser when a user needs to edit HTML
*/
"Add to Dictionary": gettext("Add to Dictionary"),
/*
Translators: this is a message from the raw HTML editor displayed in the browser when a user needs to edit HTML
*/
"Advanced": gettext("Advanced"),
/*
Translators: this is a message from the raw HTML editor displayed in the browser when a user needs to edit HTML
*/
"Align center": gettext("Align center"),
/*
Translators: this is a message from the raw HTML editor displayed in the browser when a user needs to edit HTML
*/
"Align left": gettext("Align left"),
/*
Translators: this is a message from the raw HTML editor displayed in the browser when a user needs to edit HTML
*/
"Align right": gettext("Align right"),
/*
Translators: this is a message from the raw HTML editor displayed in the browser when a user needs to edit HTML
*/
"Alignment": gettext("Alignment"),
/*
Translators: this is a message from the raw HTML editor displayed in the browser when a user needs to edit HTML
*/
"Alternative source": gettext("Alternative source"),
/*
Translators: this is a message from the raw HTML editor displayed in the browser when a user needs to edit HTML
*/
"Anchor": gettext("Anchor"),
/*
Translators: this is a message from the raw HTML editor displayed in the browser when a user needs to edit HTML
*/
"Anchors": gettext("Anchors"),
/*
Translators: this is a message from the raw HTML editor displayed in the browser when a user needs to edit HTML
*/
"Author": gettext("Author"),
/*
Translators: this is a message from the raw HTML editor displayed in the browser when a user needs to edit HTML
*/
"Background color": gettext("Background color"),
/*
Translators: this is a message from the raw HTML editor displayed in the browser when a user needs to edit HTML
*/
"Blockquote": gettext("Blockquote"),
/*
Translators: this is a message from the raw HTML editor displayed in the browser when a user needs to edit HTML
*/
"Blocks": gettext("Blocks"),
/*
Translators: this is a message from the raw HTML editor displayed in the browser when a user needs to edit HTML
*/
"Body": gettext("Body"),
/*
Translators: this is a message from the raw HTML editor displayed in the browser when a user needs to edit HTML
*/
"Bold": gettext("Bold"),
/*
Translators: this is a message from the raw HTML editor displayed in the browser when a user needs to edit HTML
*/
"Border color": gettext("Border color"),
/*
Translators: this is a message from the raw HTML editor displayed in the browser when a user needs to edit HTML
*/
"Border": gettext("Border"),
/*
Translators: this is a message from the raw HTML editor displayed in the browser when a user needs to edit HTML
*/
"Bottom": gettext("Bottom"),
/*
Translators: this is a message from the raw HTML editor displayed in the browser when a user needs to edit HTML
*/
"Bullet list": gettext("Bullet list"),
/*
Translators: this is a message from the raw HTML editor displayed in the browser when a user needs to edit HTML
*/
"Cancel": gettext("Cancel"),
/*
Translators: this is a message from the raw HTML editor displayed in the browser when a user needs to edit HTML
*/
"Caption": gettext("Caption"),
/*
Translators: this is a message from the raw HTML editor displayed in the browser when a user needs to edit HTML
*/
"Cell padding": gettext("Cell padding"),
/*
Translators: this is a message from the raw HTML editor displayed in the browser when a user needs to edit HTML
*/
"Cell properties": gettext("Cell properties"),
/*
Translators: this is a message from the raw HTML editor displayed in the browser when a user needs to edit HTML
*/
"Cell spacing": gettext("Cell spacing"),
/*
Translators: this is a message from the raw HTML editor displayed in the browser when a user needs to edit HTML
*/
"Cell type": gettext("Cell type"),
/*
Translators: this is a message from the raw HTML editor displayed in the browser when a user needs to edit HTML
*/
"Cell": gettext("Cell"),
/*
Translators: this is a message from the raw HTML editor displayed in the browser when a user needs to edit HTML
*/
"Center": gettext("Center"),
/*
Translators: this is a message from the raw HTML editor displayed in the browser when a user needs to edit HTML
*/
"Circle": gettext("Circle"),
/*
Translators: this is a message from the raw HTML editor displayed in the browser when a user needs to edit HTML
*/
"Clear formatting": gettext("Clear formatting"),
/*
Translators: this is a message from the raw HTML editor displayed in the browser when a user needs to edit HTML
*/
"Close": gettext("Close"),
/*
Translators: this is a message from the raw HTML editor displayed in the browser when a user needs to edit HTML
*/
"Code block": gettext("Code block"),
/*
Translators: this is a message from the raw HTML editor displayed in the browser when a user needs to edit HTML
*/
"Code": gettext("Code"),
/*
Translators: this is a message from the raw HTML editor displayed in the browser when a user needs to edit HTML
*/
"Color": gettext("Color"),
/*
Translators: this is a message from the raw HTML editor displayed in the browser when a user needs to edit HTML
*/
"Cols": gettext("Cols"),
/*
Translators: this is a message from the raw HTML editor displayed in the browser when a user needs to edit HTML
*/
"Column group": gettext("Column group"),
/*
Translators: this is a message from the raw HTML editor displayed in the browser when a user needs to edit HTML
*/
"Column": gettext("Column"),
/*
Translators: this is a message from the raw HTML editor displayed in the browser when a user needs to edit HTML
*/
"Constrain proportions": gettext("Constrain proportions"),
/*
Translators: this is a message from the raw HTML editor displayed in the browser when a user needs to edit HTML
*/
"Copy row": gettext("Copy row"),
/*
Translators: this is a message from the raw HTML editor displayed in the browser when a user needs to edit HTML
*/
"Copy": gettext("Copy"),
/*
Translators: this is a message from the raw HTML editor displayed in the browser when a user needs to edit HTML
*/
"Could not find the specified string.": gettext("Could not find the specified string."),
/*
Translators: this is a message from the raw HTML editor displayed in the browser when a user needs to edit HTML
*/
"Custom color": gettext("Custom color"),
/*
Translators: this is a message from the raw HTML editor displayed in the browser when a user needs to edit HTML
*/
"Custom...": gettext("Custom..."),
/*
Translators: this is a message from the raw HTML editor displayed in the browser when a user needs to edit HTML
*/
"Cut row": gettext("Cut row"),
/*
Translators: this is a message from the raw HTML editor displayed in the browser when a user needs to edit HTML
*/
"Cut": gettext("Cut"),
/*
Translators: this is a message from the raw HTML editor displayed in the browser when a user needs to edit HTML
*/
"Decrease indent": gettext("Decrease indent"),
/*
Translators: this is a message from the raw HTML editor displayed in the browser when a user needs to edit HTML
*/
"Default": gettext("Default"),
/*
Translators: this is a message from the raw HTML editor displayed in the browser when a user needs to edit HTML
*/
"Delete column": gettext("Delete column"),
/*
Translators: this is a message from the raw HTML editor displayed in the browser when a user needs to edit HTML
*/
"Delete row": gettext("Delete row"),
/*
Translators: this is a message from the raw HTML editor displayed in the browser when a user needs to edit HTML
*/
"Delete table": gettext("Delete table"),
/*
Translators: this is a message from the raw HTML editor displayed in the browser when a user needs to edit HTML
*/
"Description": gettext("Description"),
/*
Translators: this is a message from the raw HTML editor displayed in the browser when a user needs to edit HTML
*/
"Dimensions": gettext("Dimensions"),
/*
Translators: this is a message from the raw HTML editor displayed in the browser when a user needs to edit HTML
*/
"Disc": gettext("Disc"),
/*
Translators: this is a message from the raw HTML editor displayed in the browser when a user needs to edit HTML
*/
"Div": gettext("Div"),
/*
Translators: this is a message from the raw HTML editor displayed in the browser when a user needs to edit HTML
*/
"Document properties": gettext("Document properties"),
/*
Translators: this is a message from the raw HTML editor displayed in the browser when a user needs to edit HTML
*/
"Edit HTML": gettext("Edit HTML"),
/*
Translators: this is a message from the raw HTML editor displayed in the browser when a user needs to edit HTML
*/
"Edit": gettext("Edit"),
/*
Translators: this is a message from the raw HTML editor displayed in the browser when a user needs to edit HTML
*/
"Embed": gettext("Embed"),
/*
Translators: this is a message from the raw HTML editor displayed in the browser when a user needs to edit HTML
*/
"Emoticons": gettext("Emoticons"),
/*
Translators: this is a message from the raw HTML editor displayed in the browser when a user needs to edit HTML
*/
"Encoding": gettext("Encoding"),
/*
Translators: this is a message from the raw HTML editor displayed in the browser when a user needs to edit HTML
*/
"File": gettext("File"),
/*
Translators: this is a message from the raw HTML editor displayed in the browser when a user needs to edit HTML
*/
"Find and replace": gettext("Find and replace"),
/*
Translators: this is a message from the raw HTML editor displayed in the browser when a user needs to edit HTML
*/
"Find next": gettext("Find next"),
/*
Translators: this is a message from the raw HTML editor displayed in the browser when a user needs to edit HTML
*/
"Find previous": gettext("Find previous"),
/*
Translators: this is a message from the raw HTML editor displayed in the browser when a user needs to edit HTML
*/
"Find": gettext("Find"),
/*
Translators: this is a message from the raw HTML editor displayed in the browser when a user needs to edit HTML
*/
"Finish": gettext("Finish"),
/*
Translators: this is a message from the raw HTML editor displayed in the browser when a user needs to edit HTML
*/
"Font Family": gettext("Font Family"),
/*
Translators: this is a message from the raw HTML editor displayed in the browser when a user needs to edit HTML
*/
"Font Sizes": gettext("Font Sizes"),
/*
Translators: this is a message from the raw HTML editor displayed in the browser when a user needs to edit HTML
*/
"Footer": gettext("Footer"),
/*
Translators: this is a message from the raw HTML editor displayed in the browser when a user needs to edit HTML
*/
"Format": gettext("Format"),
/*
Translators: this is a message from the raw HTML editor displayed in the browser when a user needs to edit HTML
*/
"Formats": gettext("Formats"),
/*
Translators: this is a message from the raw HTML editor displayed in the browser when a user needs to edit HTML
*/
"Fullscreen": gettext("Fullscreen"),
/*
Translators: this is a message from the raw HTML editor displayed in the browser when a user needs to edit HTML
*/
"General": gettext("General"),
/*
Translators: this is a message from the raw HTML editor displayed in the browser when a user needs to edit HTML
*/
"H Align": gettext("H Align"),
/*
Translators: this is a message from the raw HTML editor displayed in the browser when a user needs to edit HTML
*/
"Header 1": gettext("Header 1"),
/*
Translators: this is a message from the raw HTML editor displayed in the browser when a user needs to edit HTML
*/
"Header 2": gettext("Header 2"),
/*
Translators: this is a message from the raw HTML editor displayed in the browser when a user needs to edit HTML
*/
"Header 3": gettext("Header 3"),
/*
Translators: this is a message from the raw HTML editor displayed in the browser when a user needs to edit HTML
*/
"Header 4": gettext("Header 4"),
/*
Translators: this is a message from the raw HTML editor displayed in the browser when a user needs to edit HTML
*/
"Header 5": gettext("Header 5"),
/*
Translators: this is a message from the raw HTML editor displayed in the browser when a user needs to edit HTML
*/
"Header 6": gettext("Header 6"),
/*
Translators: this is a message from the raw HTML editor displayed in the browser when a user needs to edit HTML
*/
"Header cell": gettext("Header cell"),
/*
Translators: this is a message from the raw HTML editor displayed in the browser when a user needs to edit HTML
*/
"Header": gettext("Header"),
/*
Translators: this is a message from the raw HTML editor displayed in the browser when a user needs to edit HTML
*/
"Headers": gettext("Headers"),
/*
Translators: this is a message from the raw HTML editor displayed in the browser when a user needs to edit HTML
*/
"Heading 1": gettext("Heading 1"),
/*
Translators: this is a message from the raw HTML editor displayed in the browser when a user needs to edit HTML
*/
"Heading 2": gettext("Heading 2"),
/*
Translators: this is a message from the raw HTML editor displayed in the browser when a user needs to edit HTML
*/
"Heading 3": gettext("Heading 3"),
/*
Translators: this is a message from the raw HTML editor displayed in the browser when a user needs to edit HTML
*/
"Heading 4": gettext("Heading 4"),
/*
Translators: this is a message from the raw HTML editor displayed in the browser when a user needs to edit HTML
*/
"Heading 5": gettext("Heading 5"),
/*
Translators: this is a message from the raw HTML editor displayed in the browser when a user needs to edit HTML
*/
"Heading 6": gettext("Heading 6"),
/*
Translators: this is a message from the raw HTML editor displayed in the browser when a user needs to edit HTML
*/
"Headings": gettext("Headings"),
/*
Translators: this is a message from the raw HTML editor displayed in the browser when a user needs to edit HTML
*/
"Height": gettext("Height"),
/*
Translators: this is a message from the raw HTML editor displayed in the browser when a user needs to edit HTML
*/
"Horizontal line": gettext("Horizontal line"),
/*
Translators: this is a message from the raw HTML editor displayed in the browser when a user needs to edit HTML
*/
"Horizontal space": gettext("Horizontal space"),
/*
Translators: this is a message from the raw HTML editor displayed in the browser when a user needs to edit HTML
*/
"HTML source code": gettext("HTML source code"),
/*
Translators: this is a message from the raw HTML editor displayed in the browser when a user needs to edit HTML
*/
"Ignore all": gettext("Ignore all"),
/*
Translators: this is a message from the raw HTML editor displayed in the browser when a user needs to edit HTML
*/
"Ignore": gettext("Ignore"),
/*
Translators: this is a message from the raw HTML editor displayed in the browser when a user needs to edit HTML
*/
"Image description": gettext("Image description"),
/*
Translators: this is a message from the raw HTML editor displayed in the browser when a user needs to edit HTML
*/
"Increase indent": gettext("Increase indent"),
/*
Translators: this is a message from the raw HTML editor displayed in the browser when a user needs to edit HTML
*/
"Inline": gettext("Inline"),
/*
Translators: this is a message from the raw HTML editor displayed in the browser when a user needs to edit HTML
*/
"Insert column after": gettext("Insert column after"),
/*
Translators: this is a message from the raw HTML editor displayed in the browser when a user needs to edit HTML
*/
"Insert column before": gettext("Insert column before"),
/*
Translators: this is a message from the raw HTML editor displayed in the browser when a user needs to edit HTML
*/
"Insert date/time": gettext("Insert date/time"),
/*
Translators: this is a message from the raw HTML editor displayed in the browser when a user needs to edit HTML
*/
"Insert image": gettext("Insert image"),
/*
Translators: this is a message from the raw HTML editor displayed in the browser when a user needs to edit HTML
*/
"Insert link": gettext("Insert link"),
/*
Translators: this is a message from the raw HTML editor displayed in the browser when a user needs to edit HTML
*/
"Insert row after": gettext("Insert row after"),
/*
Translators: this is a message from the raw HTML editor displayed in the browser when a user needs to edit HTML
*/
"Insert row before": gettext("Insert row before"),
/*
Translators: this is a message from the raw HTML editor displayed in the browser when a user needs to edit HTML
*/
"Insert table": gettext("Insert table"),
/*
Translators: this is a message from the raw HTML editor displayed in the browser when a user needs to edit HTML
*/
"Insert template": gettext("Insert template"),
/*
Translators: this is a message from the raw HTML editor displayed in the browser when a user needs to edit HTML
*/
"Insert video": gettext("Insert video"),
/*
Translators: this is a message from the raw HTML editor displayed in the browser when a user needs to edit HTML
*/
"Insert": gettext("Insert"),
/*
Translators: this is a message from the raw HTML editor displayed in the browser when a user needs to edit HTML
*/
"Insert/edit image": gettext("Insert/edit image"),
/*
Translators: this is a message from the raw HTML editor displayed in the browser when a user needs to edit HTML
*/
"Insert/edit link": gettext("Insert/edit link"),
/*
Translators: this is a message from the raw HTML editor displayed in the browser when a user needs to edit HTML
*/
"Insert/edit video": gettext("Insert/edit video"),
/*
Translators: this is a message from the raw HTML editor displayed in the browser when a user needs to edit HTML
*/
"Italic": gettext("Italic"),
/*
Translators: this is a message from the raw HTML editor displayed in the browser when a user needs to edit HTML
*/
"Justify": gettext("Justify"),
/*
Translators: this is a message from the raw HTML editor displayed in the browser when a user needs to edit HTML
*/
"Keywords": gettext("Keywords"),
/*
Translators: this is a message from the raw HTML editor displayed in the browser when a user needs to edit HTML
*/
"Left to right": gettext("Left to right"),
/*
Translators: this is a message from the raw HTML editor displayed in the browser when a user needs to edit HTML
*/
"Left": gettext("Left"),
/*
Translators: this is a message from the raw HTML editor displayed in the browser when a user needs to edit HTML
*/
"Lower Alpha": gettext("Lower Alpha"),
/*
Translators: this is a message from the raw HTML editor displayed in the browser when a user needs to edit HTML
*/
"Lower Greek": gettext("Lower Greek"),
/*
Translators: this is a message from the raw HTML editor displayed in the browser when a user needs to edit HTML
*/
"Lower Roman": gettext("Lower Roman"),
/*
Translators: this is a message from the raw HTML editor displayed in the browser when a user needs to edit HTML
*/
"Match case": gettext("Match case"),
/*
Translators: this is a message from the raw HTML editor displayed in the browser when a user needs to edit HTML
*/
"Merge cells": gettext("Merge cells"),
/*
Translators: this is a message from the raw HTML editor displayed in the browser when a user needs to edit HTML
*/
"Middle": gettext("Middle"),
/*
Translators: this is a message from the raw HTML editor displayed in the browser when a user needs to edit HTML
*/
"Name": gettext("Name"),
/*
Translators: this is a message from the raw HTML editor displayed in the browser when a user needs to edit HTML
*/
"New document": gettext("New document"),
/*
Translators: this is a message from the raw HTML editor displayed in the browser when a user needs to edit HTML
*/
"New window": gettext("New window"),
/*
Translators: this is a message from the raw HTML editor displayed in the browser when a user needs to edit HTML
*/
"Next": gettext("Next"),
/*
Translators: this is a message from the raw HTML editor displayed in the browser when a user needs to edit HTML
*/
"No color": gettext("No color"),
/*
Translators: this is a message from the raw HTML editor displayed in the browser when a user needs to edit HTML
*/
"Nonbreaking space": gettext("Nonbreaking space"),
/*
Translators: this is a message from the raw HTML editor displayed in the browser when a user needs to edit HTML
*/
"None": gettext("None"),
/*
Translators: this is a message from the raw HTML editor displayed in the browser when a user needs to edit HTML
*/
"Numbered list": gettext("Numbered list"),
/*
Translators: this is a message from the raw HTML editor displayed in the browser when a user needs to edit HTML
*/
"Ok": gettext("Ok"),
/*
Translators: this is a message from the raw HTML editor displayed in the browser when a user needs to edit HTML
*/
"OK": gettext("OK"),
/*
Translators: this is a message from the raw HTML editor displayed in the browser when a user needs to edit HTML
*/
"Page break": gettext("Page break"),
/*
Translators: this is a message from the raw HTML editor displayed in the browser when a user needs to edit HTML
*/
"Paragraph": gettext("Paragraph"),
/*
Translators: this is a message from the raw HTML editor displayed in the browser when a user needs to edit HTML
*/
"Paste as text": gettext("Paste as text"),
/*
Translators: this is a message from the raw HTML editor displayed in the browser when a user needs to edit HTML
*/
"Paste is now in plain text mode. Contents will now be pasted as plain text until you toggle this option off.": gettext("Paste is now in plain text mode. Contents will now be pasted as plain text until you toggle this option off."),
/*
Translators: this is a message from the raw HTML editor displayed in the browser when a user needs to edit HTML
*/
"Paste row after": gettext("Paste row after"),
/*
Translators: this is a message from the raw HTML editor displayed in the browser when a user needs to edit HTML
*/
"Paste row before": gettext("Paste row before"),
/*
Translators: this is a message from the raw HTML editor displayed in the browser when a user needs to edit HTML
*/
"Paste your embed code below:": gettext("Paste your embed code below:"),
/*
Translators: this is a message from the raw HTML editor displayed in the browser when a user needs to edit HTML
*/
"Paste": gettext("Paste"),
/*
Translators: this is a message from the raw HTML editor displayed in the browser when a user needs to edit HTML
*/
"Poster": gettext("Poster"),
/*
Translators: this is a message from the raw HTML editor displayed in the browser when a user needs to edit HTML
*/
"Pre": gettext("Pre"),
/*
Translators: this is a message from the raw HTML editor displayed in the browser when a user needs to edit HTML
*/
"Prev": gettext("Prev"),
/*
Translators: this is a message from the raw HTML editor displayed in the browser when a user needs to edit HTML
*/
"Preview": gettext("Preview"),
/*
Translators: this is a message from the raw HTML editor displayed in the browser when a user needs to edit HTML
*/
"Print": gettext("Print"),
/*
Translators: this is a message from the raw HTML editor displayed in the browser when a user needs to edit HTML
*/
"Redo": gettext("Redo"),
/*
Translators: this is a message from the raw HTML editor displayed in the browser when a user needs to edit HTML
*/
"Remove link": gettext("Remove link"),
/*
Translators: this is a message from the raw HTML editor displayed in the browser when a user needs to edit HTML
*/
"Replace all": gettext("Replace all"),
/*
Translators: this is a message from the raw HTML editor displayed in the browser when a user needs to edit HTML
*/
"Replace all": gettext("Replace all"),
/*
Translators: this is a message from the raw HTML editor displayed in the browser when a user needs to edit HTML
*/
"Replace with": gettext("Replace with"),
/*
Translators: this is a message from the raw HTML editor displayed in the browser when a user needs to edit HTML
*/
"Replace": gettext("Replace"),
/*
Translators: this is a message from the raw HTML editor displayed in the browser when a user needs to edit HTML
*/
"Replace": gettext("Replace"),
/*
Translators: this is a message from the raw HTML editor displayed in the browser when a user needs to edit HTML
*/
"Restore last draft": gettext("Restore last draft"),
/*
Translators: this is a message from the raw HTML editor displayed in the browser when a user needs to edit HTML
*/
"Rich Text Area. Press ALT-F9 for menu. Press ALT-F10 for toolbar. Press ALT-0 for help": gettext("Rich Text Area. Press ALT-F9 for menu. Press ALT-F10 for toolbar. Press ALT-0 for help"),
/*
Translators: this is a message from the raw HTML editor displayed in the browser when a user needs to edit HTML
*/
"Right to left": gettext("Right to left"),
/*
Translators: this is a message from the raw HTML editor displayed in the browser when a user needs to edit HTML
*/
"Right": gettext("Right"),
/*
Translators: this is a message from the raw HTML editor displayed in the browser when a user needs to edit HTML
*/
"Robots": gettext("Robots"),
/*
Translators: this is a message from the raw HTML editor displayed in the browser when a user needs to edit HTML
*/
"Row group": gettext("Row group"),
/*
Translators: this is a message from the raw HTML editor displayed in the browser when a user needs to edit HTML
*/
"Row properties": gettext("Row properties"),
/*
Translators: this is a message from the raw HTML editor displayed in the browser when a user needs to edit HTML
*/
"Row type": gettext("Row type"),
/*
Translators: this is a message from the raw HTML editor displayed in the browser when a user needs to edit HTML
*/
"Row": gettext("Row"),
/*
Translators: this is a message from the raw HTML editor displayed in the browser when a user needs to edit HTML
*/
"Rows": gettext("Rows"),
/*
Translators: this is a message from the raw HTML editor displayed in the browser when a user needs to edit HTML
*/
"Save": gettext("Save"),
/*
Translators: this is a message from the raw HTML editor displayed in the browser when a user needs to edit HTML
*/
"Scope": gettext("Scope"),
/*
Translators: this is a message from the raw HTML editor displayed in the browser when a user needs to edit HTML
*/
"Select all": gettext("Select all"),
/*
Translators: this is a message from the raw HTML editor displayed in the browser when a user needs to edit HTML
*/
"Show blocks": gettext("Show blocks"),
/*
Translators: this is a message from the raw HTML editor displayed in the browser when a user needs to edit HTML
*/
"Show invisible characters": gettext("Show invisible characters"),
/*
Translators: this is a message from the raw HTML editor displayed in the browser when a user needs to edit HTML
*/
"Source code": gettext("Source code"),
/*
Translators: this is a message from the raw HTML editor displayed in the browser when a user needs to edit HTML
*/
"Source": gettext("Source"),
/*
Translators: this is a message from the raw HTML editor displayed in the browser when a user needs to edit HTML
*/
"Special character": gettext("Special character"),
/*
Translators: this is a message from the raw HTML editor displayed in the browser when a user needs to edit HTML
*/
"Spellcheck": gettext("Spellcheck"),
/*
Translators: this is a message from the raw HTML editor displayed in the browser when a user needs to edit HTML
*/
"Split cell": gettext("Split cell"),
/*
Translators: this is a message from the raw HTML editor displayed in the browser when a user needs to edit HTML
*/
"Square": gettext("Square"),
/*
Translators: this is a message from the raw HTML editor displayed in the browser when a user needs to edit HTML
*/
"Start search": gettext("Start search"),
/*
Translators: this is a message from the raw HTML editor displayed in the browser when a user needs to edit HTML
*/
"Strikethrough": gettext("Strikethrough"),
/*
Translators: this is a message from the raw HTML editor displayed in the browser when a user needs to edit HTML
*/
"Style": gettext("Style"),
/*
Translators: this is a message from the raw HTML editor displayed in the browser when a user needs to edit HTML
*/
"Subscript": gettext("Subscript"),
/*
Translators: this is a message from the raw HTML editor displayed in the browser when a user needs to edit HTML
*/
"Superscript": gettext("Superscript"),
/*
Translators: this is a message from the raw HTML editor displayed in the browser when a user needs to edit HTML
*/
"Table properties": gettext("Table properties"),
/*
Translators: this is a message from the raw HTML editor displayed in the browser when a user needs to edit HTML
*/
"Table": gettext("Table"),
/*
Translators: this is a message from the raw HTML editor displayed in the browser when a user needs to edit HTML
*/
"Target": gettext("Target"),
/*
Translators: this is a message from the raw HTML editor displayed in the browser when a user needs to edit HTML
*/
"Templates": gettext("Templates"),
/*
Translators: this is a message from the raw HTML editor displayed in the browser when a user needs to edit HTML
*/
"Text color": gettext("Text color"),
/*
Translators: this is a message from the raw HTML editor displayed in the browser when a user needs to edit HTML
*/
"Text to display": gettext("Text to display"),
/*
Translators: this is a message from the raw HTML editor displayed in the browser when a user needs to edit HTML
*/
"The URL you entered seems to be an email address. Do you want to add the required mailto: prefix?": gettext("The URL you entered seems to be an email address. Do you want to add the required mailto: prefix?"),
/*
Translators: this is a message from the raw HTML editor displayed in the browser when a user needs to edit HTML
*/
"The URL you entered seems to be an external link. Do you want to add the required http:// prefix?": gettext("The URL you entered seems to be an external link. Do you want to add the required http:// prefix?"),
/*
Translators: this is a message from the raw HTML editor displayed in the browser when a user needs to edit HTML
*/
"Title": gettext("Title"),
/*
Translators: this is a message from the raw HTML editor displayed in the browser when a user needs to edit HTML
*/
"Tools": gettext("Tools"),
/*
Translators: this is a message from the raw HTML editor displayed in the browser when a user needs to edit HTML
*/
"Top": gettext("Top"),
/*
Translators: this is a message from the raw HTML editor displayed in the browser when a user needs to edit HTML
*/
"Underline": gettext("Underline"),
/*
Translators: this is a message from the raw HTML editor displayed in the browser when a user needs to edit HTML
*/
"Undo": gettext("Undo"),
/*
Translators: this is a message from the raw HTML editor displayed in the browser when a user needs to edit HTML
*/
"Upper Alpha": gettext("Upper Alpha"),
/*
Translators: this is a message from the raw HTML editor displayed in the browser when a user needs to edit HTML
*/
"Upper Roman": gettext("Upper Roman"),
/*
Translators: this is a message from the raw HTML editor displayed in the browser when a user needs to edit HTML
*/
"Url": gettext("Url"),
/*
Translators: this is a message from the raw HTML editor displayed in the browser when a user needs to edit HTML
*/
"V Align": gettext("V Align"),
/*
Translators: this is a message from the raw HTML editor displayed in the browser when a user needs to edit HTML
*/
"Vertical space": gettext("Vertical space"),
/*
Translators: this is a message from the raw HTML editor displayed in the browser when a user needs to edit HTML
*/
"View": gettext("View"),
/*
Translators: this is a message from the raw HTML editor displayed in the browser when a user needs to edit HTML
*/
"Visual aids": gettext("Visual aids"),
/*
Translators: this is a message from the raw HTML editor displayed in the browser when a user needs to edit HTML
*/
"Whole words": gettext("Whole words"),
/*
Translators: this is a message from the raw HTML editor displayed in the browser when a user needs to edit HTML
*/
"Width": gettext("Width"),
/*
Translators: this is a message from the raw HTML editor displayed in the browser when a user needs to edit HTML
*/
"Words: {0}": gettext("Words: {0}"),
/*
Translators: this is a message from the raw HTML editor displayed in the browser when a user needs to edit HTML
*/
"You have unsaved changes are you sure you want to navigate away?": gettext("You have unsaved changes are you sure you want to navigate away?"),
/*
Translators: this is a message from the raw HTML editor displayed in the browser when a user needs to edit HTML
*/
"Your browser doesn't support direct access to the clipboard. Please use the Ctrl+X/C/V keyboard shortcuts instead.": gettext("Your browser doesn't support direct access to the clipboard. Please use the Ctrl+X/C/V keyboard shortcuts instead.")
});
}
}
HTMLEditingDescriptor.prototype.setupTinyMCE = function(ed) {
ed.ui.registry.addButton('wrapAsCode', {
/*
Translators: this is a toolbar button tooltip from the raw HTML editor displayed in the browser when a user needs to edit HTML
*/
tooltip: gettext('Code block'),
icon: 'code-sample',
onAction: function() {
return ed.formatter.toggle('code');
}
});
ed.ui.registry.addButton('insertImage', {
/*
Translators: this is a toolbar button tooltip from the raw HTML editor displayed in the browser when a user needs to edit HTML
*/
tooltip: gettext('Insert/Edit Image'),
icon: 'image',
onAction: this.openImageModal
});
this.visualEditor = ed;
this.imageModal = $('#edit-image-modal #modalWrapper');
/*
These events were added to the plugin code as the TinyMCE PluginManager
does not fire any events when plugins are opened or closed.
*/
ed.on('SaveImage', this.saveImage);
ed.on('EditImage', this.editImage);
ed.on('SaveLink', this.saveLink);
ed.on('EditLink', this.editLink);
ed.on('ShowCodeEditor', this.showCodeEditor);
ed.on('SaveCodeEditor', this.saveCodeEditor);
$(".action-cancel").on('click', this.cancelButton);
this.imageModal.on('closeModal', this.closeImageModal);
return this.imageModal.on('submitForm', this.editImageSubmit);
};
HTMLEditingDescriptor.prototype.editImage = function(data) {
/*
Called when the image plugin will be shown. Input arg is the JSON version of the image data.
*/
if (data['src']) {
return data['src'] = rewriteStaticLinks(data['src'], this.base_asset_url, '/static/');
}
};
HTMLEditingDescriptor.prototype.saveImage = function(data) {
/*
Called when the image plugin is saved. Input arg is the JSON version of the image data.
*/
if (data['src']) {
return data['src'] = rewriteStaticLinks(data['src'], '/static/', this.base_asset_url);
}
};
HTMLEditingDescriptor.prototype.openImageModal = function() {
var img, imgAttrs;
img = $(this.visualEditor.selection.getNode());
imgAttrs = {
baseAssetUrl: this.base_asset_url
};
if (img && img.is('img')) {
imgAttrs['src'] = rewriteStaticLinks(img.attr('src'), this.base_asset_url, '/static/');
imgAttrs['alt'] = img.attr('alt');
imgAttrs['width'] = parseInt(img.attr('width'), 10) || img[0].naturalWidth;
imgAttrs['height'] = parseInt(img.attr('height'), 10) || img[0].naturalHeight;
imgAttrs['style'] = img.attr('style');
}
$('body').addClass('modal-open'); // prevents background from scrolling while modal is open
return this.imageModal[0].dispatchEvent(new CustomEvent('openModal', {
bubbles: true,
detail: imgAttrs
}));
};
HTMLEditingDescriptor.prototype.closeImageModal = function() {
$('body').removeClass('modal-open');
};
HTMLEditingDescriptor.prototype.saveImageFromModal = function(data) {
/*
Insert img node from studio-frontend modal form data passed as a javascript object
*/
if (data['src']) {
data['src'] = rewriteStaticLinks(data['src'], '/static/', this.base_asset_url);
}
return this.visualEditor.insertContent(this.visualEditor.dom.createHTML('img', data));
};
HTMLEditingDescriptor.prototype.editImageSubmit = function(event) {
if (event.detail) {
this.saveImageFromModal(event.detail);
}
return this.closeImageModal();
};
HTMLEditingDescriptor.prototype.editLink = function(data) {
/*
Called when the link plugin will be shown. Input arg is the JSON version of the link data.
*/
if (data['href']) {
return data['href'] = rewriteStaticLinks(data['href'], this.base_asset_url, '/static/');
}
};
HTMLEditingDescriptor.prototype.saveLink = function(data) {
/*
Called when the link plugin is saved. Input arg is the JSON version of the link data.
*/
if (data['href']) {
return data['href'] = rewriteStaticLinks(data['href'], '/static/', this.base_asset_url);
}
};
HTMLEditingDescriptor.prototype.showCodeEditor = function(source) {
/*
Called when the CodeMirror Editor is displayed to convert links to show static prefix.
The input argument is a dict with the text content.
*/
var content;
content = rewriteStaticLinks(source.content, this.base_asset_url, '/static/');
return source.content = content;
};
HTMLEditingDescriptor.prototype.saveCodeEditor = function(source) {
/*
Called when the CodeMirror Editor is saved to convert links back to the full form.
The input argument is a dict with the text content.
*/
var content;
content = rewriteStaticLinks(source.content, '/static/', this.base_asset_url);
return source.content = content;
};
HTMLEditingDescriptor.prototype.initInstanceCallback = function(visualEditor) {
visualEditor.setContent(rewriteStaticLinks(visualEditor.getContent({
no_events: 1
}), '/static/', this.base_asset_url));
/*
Unfortunately, just setting visualEditor.isNortDirty = true is not enough to convince TinyMCE we
haven't dirtied the Editor. Store the raw content so we can compare it later.
*/
this.starting_content = visualEditor.getContent({
format: "raw",
no_events: 1
});
return visualEditor.focus();
};
HTMLEditingDescriptor.prototype.getVisualEditor = function() {
/*
Returns the instance of TinyMCE.
Pulled out as a helper method for unit test.
*/
return this.visualEditor;
};
HTMLEditingDescriptor.prototype.save = function() {
var raw_content, text, visualEditor;
text = void 0;
if (this.editor_choice === 'visual') {
visualEditor = this.getVisualEditor();
raw_content = visualEditor.getContent({
format: "raw",
no_events: 1
});
if (this.starting_content !== raw_content) {
text = rewriteStaticLinks(visualEditor.getContent({
no_events: 1
}), this.base_asset_url, '/static/');
}
}
if (text === void 0) {
text = this.advanced_editor.getValue();
}
this.unbindSubmitEventFromImageEditor()
return {
data: text
};
};
HTMLEditingDescriptor.prototype.cancelButton = function () {
this.unbindSubmitEventFromImageEditor()
};
HTMLEditingDescriptor.prototype.unbindSubmitEventFromImageEditor = function () {
/*
Unbinds events on cancel/save button of image editor.
*/
if (this.imageModal) this.imageModal.off('submitForm')
};
return HTMLEditingDescriptor;
})();
}).call(this);