Commit 5e0677af authored by Chris Graham's avatar Chris Graham
Browse files

Fixed MANTIS-4579 (Various CKEditor integration improvements)

parent a85051df
Loading
Loading
Loading
Loading
+69 −61
Original line number Diff line number Diff line
@@ -4,25 +4,26 @@ Spellcheck toggle button. Works on Chrome/Firefox/Safari/IE10

(function() {
	CKEDITOR.plugins.add('spellchecktoggle', {
        enableSpellChecker: function(editor) {
		enableSpellChecker: function(editor, showMessage) {
			editor.commands.spellchecktoggle.setState(CKEDITOR.TRISTATE_ON);

			editor.config.disableNativeSpellChecker = false;
			editor.element.$.spellcheck = true;
            editor.window.$.document.body.spellcheck=true;
			document.body.spellcheck = true;

			var oldData = editor.getData();
            if (!oldData.match(/<br( \/)?>\s*$/))
            {
			if (!oldData.match(/<br( \/)?>\s*$/)) {
				oldData += '<br /><br />'; // Aids the editor in deciding to do a spellcheck (CKEditor needs 2 for some reason)
			}
			editor.setData(oldData); // Needed to force spellchecker reset

			if (showMessage) {
				fauxmodal_alert(window.lang_SPELLCHECKER_ENABLED,function() {
					 editor.focus();
				},window.lang_SPELLCHECKER_LABEL);
			}

            editor.window.$.document.body.oncontextmenu=function(event) { // Runs before CKEditor handler
			document.body.oncontextmenu = function(event) { // Runs before CKEditor handler
				if (!event) event = window.event;
				// Do not let CKEditor handler happen
				if (typeof event.stopImmediatePropagation != 'undefined') event.stopImmediatePropagation();
@@ -30,24 +31,24 @@ Spellcheck toggle button. Works on Chrome/Firefox/Safari/IE10
			};
		},

        disableSpellChecker: function(editor) {
		disableSpellChecker: function(editor, showMessage) {
			editor.commands.spellchecktoggle.setState(CKEDITOR.TRISTATE_OFF);

			editor.config.disableNativeSpellChecker = true;
			editor.element.$.spellcheck = false;
            if (editor.window) // If not initial load (not needed/wanted for that anyway)
            {
                editor.window.$.document.body.spellcheck=false;

			document.body.spellcheck = false;

			editor.setData(editor.getData()); // Needed to force spellchecker reset

			if (showMessage) {
				fauxmodal_alert(window.lang_SPELLCHECKER_DISABLED,null,window.lang_SPELLCHECKER_LABEL);
			}

                editor.window.$.document.body.oncontextmenu=function() { // Runs before CKEditor handler
			document.body.oncontextmenu = function() { // Runs before CKEditor handler
				// Let CKEditor handler happen
				return null;
			};
            }
		},

		hidpi: true,
@@ -59,10 +60,10 @@ Spellcheck toggle button. Works on Chrome/Firefox/Safari/IE10

					  if (doSpellcheckNow)
					  {
                        editor.plugins['spellchecktoggle'].enableSpellChecker(editor);
							editor.plugins['spellchecktoggle'].enableSpellChecker(editor, true);
					  } else
					  {
                        editor.plugins['spellchecktoggle'].disableSpellChecker(editor);
							editor.plugins['spellchecktoggle'].disableSpellChecker(editor, true);
					  }
				 }
			};
@@ -76,7 +77,14 @@ Spellcheck toggle button. Works on Chrome/Firefox/Safari/IE10
				command: 'spellchecktoggle'
			});

            this.disableSpellChecker(editor);
			var _this = this;
			editor.on('instanceReady', function() {
				if (editor.config.wysiwygSpellcheckerDefault) {
					_this.enableSpellChecker(editor, false);
				} else {
					_this.disableSpellChecker(editor, false);
				}
			});
		}
	});
})();
+4 −1
Original line number Diff line number Diff line
@@ -586,6 +586,10 @@ We have the following which are either unlikely to be useful, or potentially uns
  - [tt]textmate[/tt] -- set this to '1' if you are developing on a local machine and use the Apple Mac TextMate editor. It will cause TextMate editing links to come up in stack traces
  - [tt]allow_php_in_templates[/tt] -- set this to '1' to enable the undocumented Tempcode 'PHP' directive, and its short-hand syntax (written like normal PHP long-tags). This allows you to write PHP code inside templates, but please aware there are strong risks associated with this. It means that themes you install may contain PHP code, or people submitting Comcode content may put in PHP code which you could accidentally unwittingly activate when validating content (as it would be validated against your own security credentials). Note this option is not designed to work from Comcode, because Comcode will add HTML formatting around your PHP code, corrupting it (from a security point of view you need to be aware though, as that could be avoided with some care by a hacker) 
  - [tt]git_autopull[/tt] -- set this to '1' if git changes should automatically be pulled every minute (less frequently if the CRON interval is longer). Assumes a suEXEC-like server and a git deployment and working [tt]shell_exec[/tt]
 - WYSIWYG editor
  - [tt]commercial_spellchecker[/tt] -- set this to '1' if you want to enable the WYSIWYG editor's spellcheck.net spellchecker
  - [tt]wysiwyg_normal_font_sizes[/tt] -- set this to '1' if you want to have normal font sizes rather than relative font sizes (relative sizes allow context-adaptive markup)
  - [tt]wysiwyg_spellchecker_default[/tt] -- set this to '1' if you want to allow the browser's spellcheck to be available by default (otherwise a button must be pressed)
 - Low-level tuning
  - [tt]no_forum_moderate[/tt] -- set this to '1' to hide the staff checklist mention of moderating the forum
  - [tt]show_menu_items_as_url[/tt] -- set this to '1' if you want the menu editor to show URLs instead of page-links (they will then be converted back)
@@ -604,7 +608,6 @@ We have the following which are either unlikely to be useful, or potentially uns
  - [tt]pagination_when_not_needed[/tt] -- set this to '1' if you want the pagination wrapper template to load even if there is no pagination (useful for collecting result metadata via Tempcode)
  - [tt]catalogue_seo_source_map__<catalogue-name>[/tt] -- a comma-separated list of field IDs to use for SEO keyword generation (if not set, uses all fields). If all keywords in the field should be used, put an exclamation mark after the field ID
  - [tt]disable_password_change_notifications_for_staff[/tt] -- set this to '1' if you want staff password edits to not result in notifications to users
  - [tt]commercial_spellchecker[/tt] -- set this to '1' if you want to enable the WYSIWYG editor's spellcheck.net spellchecker
  - [tt]filtercode_protected_fields[/tt] -- a comma-separated list of fields Filtercode cannot work on (above the ones hard-coded as forbidden)
  - [tt]memory_limit[/tt] -- set this to a memory limit to override Composr's built-in one (e.g. "128M"). This will make memory bugs on your server more dangerous, so use at your own risk (a memory usage problem can take down a whole server) -- although memory bugs are unlikely given that Composr users report if they ever see this error
  - [tt]canonical_keep_params[/tt] -- set this to a comma-separated list of keep_ parameters that should be allowed to propagate within search engines
+6 −0
Original line number Diff line number Diff line
@@ -767,6 +767,12 @@ span.validated_checkbox+input[name="validated"].input_tick {
	margin-bottom: 0;
}

/* Stop large images creating scrolling */
.cke_image_resizer {
	right: 0 !important;
	bottom: 0 !important;
}

.cke_widget_inline {
	line-height: 1em !important;
}
+7 −2
Original line number Diff line number Diff line
@@ -16,7 +16,7 @@ toolbar.push([precision_editing?'composr_image':null,'Table']);
if (precision_editing)
	toolbar.push('/');
toolbar.push(['Format','Font','FontSize']);
toolbar.push(['TextColor']);
toolbar.push(['TextColor','BGColor']);
if (precision_editing)
	toolbar.push(['Maximize', 'ShowBlocks']);
if (precision_editing)
@@ -30,7 +30,9 @@ var editor_settings={
	enterMode : window.CKEDITOR.ENTER_BR,
	uiColor : wysiwyg_color,
	ocpTheme : '{$THEME;^}',
	{+START,IF,{$NOT,{$VALUE_OPTION,wysiwyg_normal_font_sizes}}}
		fontSize_sizes : '0.6em;0.85em;1em;1.1em;1.2em;1.3em;1.4em;1.5em;1.6em;1.7em;1.8em;2em',
	{+END}
	removePlugins: '{+START,IF,{$NOT,{$CONFIG_OPTION,autogrow}}}autogrow{+END}',
	extraPlugins: 'showcomcodeblocks,imagepaste,spellchecktoggle'+(use_composr_toolbar?',composr':''),
	{+START,IF,{$NEQ,{$CKEDITOR_PATH},data_custom/ckeditor}}
@@ -59,6 +61,9 @@ var editor_settings={
	{+START,IF,{$CONFIG_OPTION,autogrow}}
		autoGrow_onStartup: true,
	{+END}
	{+START,IF,{$VALUE_OPTION,wysiwyg_spellchecker_default}}
		wysiwygSpellcheckerDefault: true,
	{+END}
	magicline_everywhere: true
};