From: Alexander Ebert Date: Mon, 6 Jun 2022 12:17:51 +0000 (+0200) Subject: Inconsistent behavior of text formatting on iPadOS X-Git-Tag: 5.5.0_RC_1~5 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=34fa4555d121e10e96918267ba13e40b5f0da339;p=GitHub%2FWoltLab%2FWCF.git Inconsistent behavior of text formatting on iPadOS See https://www.woltlab.com/community/thread/295811-schriftfarbe-schriftart-oder-schriftgr%C3%B6%C3%9Fe-%C3%A4ndern-auf-ipad/ --- diff --git a/wcfsetup/install/files/js/3rdParty/redactor2/plugins/WoltLabColor.js b/wcfsetup/install/files/js/3rdParty/redactor2/plugins/WoltLabColor.js index 7a681fc9ec..6bd8afd620 100644 --- a/wcfsetup/install/files/js/3rdParty/redactor2/plugins/WoltLabColor.js +++ b/wcfsetup/install/files/js/3rdParty/redactor2/plugins/WoltLabColor.js @@ -1,5 +1,7 @@ $.Redactor.prototype.WoltLabColor = function() { "use strict"; + + let uiRedactorFormat; // these are hex values, but the '#' was left out for convenience var _defaultColors = [ @@ -41,36 +43,28 @@ $.Redactor.prototype.WoltLabColor = function() { }); $('').insertBefore(dropdownMenu.children('li').last()); + + require(['WoltLabSuite/Core/Ui/Redactor/Format'], (UiRedactorFormat) => { + uiRedactorFormat = UiRedactorFormat; + }); }, - setColor: function(key) { + setColor(key) { key = key.replace(/^color_/, ''); + + if ($.browser.iOS && !this.detect.isIpad()) { + this.selection.restore(); + } - this.selection.save(); - - require(['WoltLabSuite/Core/Ui/Redactor/Format'], (function(UiRedactorFormat) { - this.buffer.set(); - - UiRedactorFormat.format(this.$editor[0], 'color', '#' + key); - - this.buffer.set(); - }).bind(this)); + this.buffer.set(); - this.selection.restore(); + uiRedactorFormat.format(this.$editor[0], 'color', '#' + key); }, - removeColor: function() { - this.selection.save(); - - require(['WoltLabSuite/Core/Ui/Redactor/Format'], (function(UiRedactorFormat) { - this.buffer.set(); - - UiRedactorFormat.removeFormat(this.$editor[0], 'color'); - - this.buffer.set(); - }).bind(this)); + removeColor() { + this.buffer.set(); - this.selection.restore(); + uiRedactorFormat.removeFormat(this.$editor[0], 'color'); } }; }; diff --git a/wcfsetup/install/files/js/3rdParty/redactor2/plugins/WoltLabFont.js b/wcfsetup/install/files/js/3rdParty/redactor2/plugins/WoltLabFont.js index 52c414ace7..08e2a435dc 100644 --- a/wcfsetup/install/files/js/3rdParty/redactor2/plugins/WoltLabFont.js +++ b/wcfsetup/install/files/js/3rdParty/redactor2/plugins/WoltLabFont.js @@ -1,5 +1,7 @@ $.Redactor.prototype.WoltLabFont = function() { "use strict"; + + let uiRedactorFormat; return { _fonts: [ @@ -42,36 +44,28 @@ $.Redactor.prototype.WoltLabFont = function() { }).bind(this)); $('').insertBefore(dropdownMenu.children('li').last()); + + require(["WoltLabSuite/Core/Ui/Redactor/Format"], (UiRedactorFormat) => { + uiRedactorFormat = UiRedactorFormat; + }); }, - setFont: function(key) { + setFont(key) { key = key.replace(/^fontFamily_/, ''); - - this.selection.save(); - - require(['WoltLabSuite/Core/Ui/Redactor/Format'], (function(UiRedactorFormat) { - this.buffer.set(); - - UiRedactorFormat.format(this.$editor[0], 'font-family', this.WoltLabFont._fonts[key]); - - this.buffer.set(); - }).bind(this)); - - this.selection.restore(); + + if ($.browser.iOS && !this.detect.isIpad()) { + this.selection.restore(); + } + + this.buffer.set(); + + uiRedactorFormat.format(this.$editor[0], 'font-family', this.WoltLabFont._fonts[key]); }, - removeFont: function() { - this.selection.save(); - - require(['WoltLabSuite/Core/Ui/Redactor/Format'], (function(UiRedactorFormat) { - this.buffer.set(); - - UiRedactorFormat.removeFormat(this.$editor[0], 'font-family'); - - this.buffer.set(); - }).bind(this)); + removeFont() { + this.buffer.set(); - this.selection.restore(); + uiRedactorFormat.removeFormat(this.$editor[0], 'font-family'); } }; }; diff --git a/wcfsetup/install/files/js/3rdParty/redactor2/plugins/WoltLabSize.js b/wcfsetup/install/files/js/3rdParty/redactor2/plugins/WoltLabSize.js index f95c4dc314..a8f8a40fbc 100644 --- a/wcfsetup/install/files/js/3rdParty/redactor2/plugins/WoltLabSize.js +++ b/wcfsetup/install/files/js/3rdParty/redactor2/plugins/WoltLabSize.js @@ -1,5 +1,7 @@ $.Redactor.prototype.WoltLabSize = function() { "use strict"; + + let uiRedactorFormat; return { init: function() { @@ -34,34 +36,26 @@ $.Redactor.prototype.WoltLabSize = function() { }); $('').insertBefore(dropdownMenu.children('li').last()); + + require(['WoltLabSuite/Core/Ui/Redactor/Format'], (UiRedactorFormat) => { + uiRedactorFormat = UiRedactorFormat; + }); }, - setSize: function(key) { - this.selection.save(); - - require(['WoltLabSuite/Core/Ui/Redactor/Format'], (function(UiRedactorFormat) { - this.buffer.set(); - - UiRedactorFormat.format(this.$editor[0], 'font-size', key.replace(/^size_/, '') + 'pt'); - - this.buffer.set(); - }).bind(this)); + setSize(key) { + this.buffer.set(); + + if ($.browser.iOS && !this.detect.isIpad()) { + this.selection.restore(); + } - this.selection.restore(); + uiRedactorFormat.format(this.$editor[0], 'font-size', key.replace(/^size_/, '') + 'pt'); }, - removeSize: function() { - this.selection.save(); - - require(['WoltLabSuite/Core/Ui/Redactor/Format'], (function(UiRedactorFormat) { - this.buffer.set(); - - UiRedactorFormat.removeFormat(this.$editor[0], 'font-size'); - - this.buffer.set(); - }).bind(this)); + removeSize() { + this.buffer.set(); - this.selection.restore(); + uiRedactorFormat.removeFormat(this.$editor[0], 'font-size'); } }; };