1
0
mirror of https://github.com/processwire/processwire.git synced 2025-08-10 16:54:44 +02:00

Fix issue processwire/processwire-issues#1335 - inserting <figure><img> nodes in Safari deleting content after the <figure>

This commit is contained in:
Ryan Cramer
2021-08-25 13:46:41 -04:00
parent 212406b173
commit e6e08ad3fb
3 changed files with 23 additions and 4 deletions

View File

@@ -3,10 +3,10 @@
/** /**
* ProcessWire Inputfield for CKEditor * ProcessWire Inputfield for CKEditor
* *
* CKEditor Copyright (C) 2003-2019, CKSource - Frederico Knabben * CKEditor Copyright (C) 2003-2021, CKSource - Frederico Knabben
* http://ckeditor.com * http://ckeditor.com
* *
* ProcessWire 3.x, Copyright 2019 by Ryan Cramer * ProcessWire 3.x, Copyright 2021 by Ryan Cramer
* https://processwire.com * https://processwire.com
* *
* FIELD CONFIGURATION * FIELD CONFIGURATION
@@ -40,7 +40,7 @@ class InputfieldCKEditor extends InputfieldTextarea implements ConfigModule {
public static function getModuleInfo() { public static function getModuleInfo() {
return array( return array(
'title' => 'CKEditor', 'title' => 'CKEditor',
'version' => 167, 'version' => 168,
'summary' => __('CKEditor textarea rich text editor.', __FILE__), 'summary' => __('CKEditor textarea rich text editor.', __FILE__),
'installs' => array('MarkupHTMLPurifier'), 'installs' => array('MarkupHTMLPurifier'),
); );

View File

@@ -103,6 +103,24 @@
var $figureCaption = null; var $figureCaption = null;
var nodeParentName = nodeParent.$.nodeName.toUpperCase(); var nodeParentName = nodeParent.$.nodeName.toUpperCase();
var nodeGrandparentName = nodeGrandparent ? nodeGrandparent.$.nodeName.toUpperCase() : ''; var nodeGrandparentName = nodeGrandparent ? nodeGrandparent.$.nodeName.toUpperCase() : '';
var figureNodeSafari = null;
if(selection.getType() == CKEDITOR.SELECTION_TEXT) {
// Safari doesnt support independent selection of figure elements without display:block,
// so restart selection after changing display property of <figure> to block which then
// makes it selectable in Safari
if(nodeParentName == 'FIGURE') {
figureNodeSafari = nodeParent;
} else if(nodeGrandparentName == 'FIGURE') {
figureNodeSafari = nodeGrandparent;
}
if(figureNodeSafari) {
selection.reset();
selection.removeAllRanges();
figureNodeSafari.$.style.display = 'block';
selection.selectElement(figureNodeSafari);
}
}
if(typeof ckeGetProcessWireConfig != "undefined") { if(typeof ckeGetProcessWireConfig != "undefined") {
// note: ckeGetProcessWireConfig not yet present in front-end editor // note: ckeGetProcessWireConfig not yet present in front-end editor
@@ -263,6 +281,7 @@
} }
var html = $insertHTML[0].outerHTML; var html = $insertHTML[0].outerHTML;
if(figureNodeSafari) figureNodeSafari.remove(); // Safari inserts an extra <figure>, so remove the original
editor.insertHtml(html); editor.insertHtml(html);
editor.fire('change'); editor.fire('change');
$iframe.dialog("close"); $iframe.dialog("close");

File diff suppressed because one or more lines are too long