mirror of
https://github.com/processwire/processwire.git
synced 2025-08-13 02:04:35 +02:00
Minor TinyMCE updates plus make a method hookable for more configuration options
This commit is contained in:
@@ -135,7 +135,7 @@ class InputfieldTinyMCE extends InputfieldTextarea implements ConfigurableModule
|
|||||||
*
|
*
|
||||||
* field: setting names populated by init().
|
* field: setting names populated by init().
|
||||||
* module: setting names populated by __construct().
|
* module: setting names populated by __construct().
|
||||||
* defult: setting names that had the value 'default' set prior to init().
|
* default: setting names that had the value 'default' set prior to init().
|
||||||
* tinymce: setting names are those native to TinyMCE.
|
* tinymce: setting names are those native to TinyMCE.
|
||||||
* optionals: settings that can be configured with module OR field.
|
* optionals: settings that can be configured with module OR field.
|
||||||
*
|
*
|
||||||
|
@@ -7,6 +7,8 @@
|
|||||||
*
|
*
|
||||||
* ProcessWire 3.x, Copyright 2022 by Ryan Cramer
|
* ProcessWire 3.x, Copyright 2022 by Ryan Cramer
|
||||||
* https://processwire.com
|
* https://processwire.com
|
||||||
|
*
|
||||||
|
* @property InputfieldTinyMCE $inputfield
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
abstract class InputfieldTinyMCEClass extends Wire {
|
abstract class InputfieldTinyMCEClass extends Wire {
|
||||||
@@ -38,6 +40,7 @@ abstract class InputfieldTinyMCEClass extends Wire {
|
|||||||
*/
|
*/
|
||||||
public function __get($name) {
|
public function __get($name) {
|
||||||
switch($name) {
|
switch($name) {
|
||||||
|
case 'inputfield': return $this->inputfield;
|
||||||
case 'tools':
|
case 'tools':
|
||||||
case 'settings':
|
case 'settings':
|
||||||
case 'configs':
|
case 'configs':
|
||||||
@@ -78,4 +81,4 @@ abstract class InputfieldTinyMCEClass extends Wire {
|
|||||||
public function formats() {
|
public function formats() {
|
||||||
return $this->inputfield->helper('formats');
|
return $this->inputfield->helper('formats');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -7,6 +7,8 @@
|
|||||||
*
|
*
|
||||||
* ProcessWire 3.x, Copyright 2023 by Ryan Cramer
|
* ProcessWire 3.x, Copyright 2023 by Ryan Cramer
|
||||||
* https://processwire.com
|
* https://processwire.com
|
||||||
|
*
|
||||||
|
* @method array prepareSettingsForOutput(array $settings)
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
class InputfieldTinyMCESettings extends InputfieldTinyMCEClass {
|
class InputfieldTinyMCESettings extends InputfieldTinyMCEClass {
|
||||||
@@ -68,6 +70,7 @@ class InputfieldTinyMCESettings extends InputfieldTinyMCEClass {
|
|||||||
$value = $inputfield->get('content_css_url');
|
$value = $inputfield->get('content_css_url');
|
||||||
if(empty($value)) continue;
|
if(empty($value)) continue;
|
||||||
}
|
}
|
||||||
|
$value = $this->getContentCssUrl($value);
|
||||||
} else if($name === 'directionality') {
|
} else if($name === 'directionality') {
|
||||||
$value = $inputfield->getDirectionality();
|
$value = $inputfield->getDirectionality();
|
||||||
} else if($name === 'style_formats') {
|
} else if($name === 'style_formats') {
|
||||||
@@ -379,7 +382,12 @@ class InputfieldTinyMCESettings extends InputfieldTinyMCEClass {
|
|||||||
|
|
||||||
} else if(strpos($content_css, '/') !== false) {
|
} else if(strpos($content_css, '/') !== false) {
|
||||||
// custom file
|
// custom file
|
||||||
$url = $rootUrl . ltrim($content_css, '/');
|
if(strpos($content_css, $rootUrl) === 0) {
|
||||||
|
$url = $content_css;
|
||||||
|
} else {
|
||||||
|
$url = $rootUrl . ltrim($content_css, '/');
|
||||||
|
}
|
||||||
|
// $url = $rootUrl . ltrim($content_css, '/');
|
||||||
|
|
||||||
} else if($content_css === 'custom') {
|
} else if($content_css === 'custom') {
|
||||||
// custom file (alternate/fallback)
|
// custom file (alternate/fallback)
|
||||||
@@ -398,6 +406,10 @@ class InputfieldTinyMCESettings extends InputfieldTinyMCEClass {
|
|||||||
} else {
|
} else {
|
||||||
$url = $defaultUrl;
|
$url = $defaultUrl;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(strpos($url, '.css') === false) {
|
||||||
|
$url = rtrim($url, '/') . '/content.css';
|
||||||
|
}
|
||||||
|
|
||||||
return $url;
|
return $url;
|
||||||
}
|
}
|
||||||
@@ -411,7 +423,7 @@ class InputfieldTinyMCESettings extends InputfieldTinyMCEClass {
|
|||||||
* @return array
|
* @return array
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public function prepareSettingsForOutput(array $settings) {
|
public function ___prepareSettingsForOutput(array $settings) {
|
||||||
$config = $this->wire()->config;
|
$config = $this->wire()->config;
|
||||||
$rootUrl = $config->urls->root;
|
$rootUrl = $config->urls->root;
|
||||||
//$inline = $this->inputfield->inlineMode > 0;
|
//$inline = $this->inputfield->inlineMode > 0;
|
||||||
@@ -721,6 +733,7 @@ class InputfieldTinyMCESettings extends InputfieldTinyMCEClass {
|
|||||||
// remove settings that cannot be set for field/template context
|
// remove settings that cannot be set for field/template context
|
||||||
unset($mergedSettings['style_formats'], $mergedSettings['content_style'], $mergedSettings['content_css']);
|
unset($mergedSettings['style_formats'], $mergedSettings['content_style'], $mergedSettings['content_css']);
|
||||||
$dataSettings = $this->getSettings($mergedSettings);
|
$dataSettings = $this->getSettings($mergedSettings);
|
||||||
|
$this->applySkin($dataSettings, $defaults);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
// no configName in use, data-settings attribute will hold all non-default settings
|
// no configName in use, data-settings attribute will hold all non-default settings
|
||||||
|
Reference in New Issue
Block a user