first commit
This commit is contained in:
95
components/com_jce/editor/tiny_mce/plugins/fontselect/config.php
vendored
Normal file
95
components/com_jce/editor/tiny_mce/plugins/fontselect/config.php
vendored
Normal file
@@ -0,0 +1,95 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @copyright Copyright (c) 2009-2022 Ryan Demmer. All rights reserved
|
||||
* @license GNU/GPL 2 or later - http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
||||
* JCE is free software. This version may have been modified pursuant
|
||||
* to the GNU General Public License, and as distributed it includes or
|
||||
* is derivative of works licensed under the GNU General Public License or
|
||||
* other free or open source software licenses
|
||||
*/
|
||||
class WFFontselectPluginConfig
|
||||
{
|
||||
protected static $fonts = array('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');
|
||||
|
||||
public static function getConfig(&$settings)
|
||||
{
|
||||
$wf = WFApplication::getInstance();
|
||||
|
||||
$settings['fontselect_fonts'] = self::getFonts();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a list of editor font families.
|
||||
*
|
||||
* @return string font family list
|
||||
*
|
||||
* @param string $add Font family to add
|
||||
* @param string $remove Font family to remove
|
||||
*/
|
||||
protected static function getFonts()
|
||||
{
|
||||
$wf = WFApplication::getInstance();
|
||||
|
||||
$fonts = $wf->getParam('fontselect.fonts');
|
||||
|
||||
// decode string
|
||||
if (is_string($fonts)) {
|
||||
$fonts = htmlspecialchars_decode($fonts);
|
||||
}
|
||||
|
||||
// map for new format, where fonts are saved as an array of an associative array, eg: [['Andale Mono' => 'andale mono,times', 'Arial' => 'arial,helvetica,sans-serif']]
|
||||
if (is_array($fonts)) {
|
||||
$values = $fonts;
|
||||
|
||||
// reset array
|
||||
$fonts = array();
|
||||
|
||||
// map associative array to array of key value pairs
|
||||
foreach ($values as $key => $value) {
|
||||
if (is_numeric($key) && is_array($value)) {
|
||||
$fonts = array_merge($fonts, $value);
|
||||
} else {
|
||||
$fonts = array_merge($fonts, array($key => $value));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// get fonts using legacy parameters
|
||||
if (empty($fonts)) {
|
||||
$fonts = self::$fonts;
|
||||
|
||||
$add = $wf->getParam('editor.theme_advanced_fonts_add');
|
||||
$remove = $wf->getParam('editor.theme_advanced_fonts_remove');
|
||||
|
||||
if (empty($remove) && empty($add)) {
|
||||
return '';
|
||||
}
|
||||
|
||||
$remove = preg_split('/[;,]+/', $remove);
|
||||
|
||||
if (count($remove)) {
|
||||
foreach ($fonts as $key => $value) {
|
||||
foreach ($remove as $gone) {
|
||||
if ($gone && preg_match('/^'.$gone.'=/i', $value)) {
|
||||
// Remove family
|
||||
unset($fonts[$key]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
foreach (explode(';', $add) as $new) {
|
||||
// Add new font family
|
||||
if (preg_match('/([^\=]+)(\=)([^\=]+)/', trim($new)) && !in_array($new, $fonts)) {
|
||||
$fonts[] = $new;
|
||||
}
|
||||
}
|
||||
|
||||
natcasesort($fonts);
|
||||
$fonts = implode(';', $fonts);
|
||||
}
|
||||
|
||||
return $fonts;
|
||||
}
|
||||
}
|
||||
2
components/com_jce/editor/tiny_mce/plugins/fontselect/editor_plugin.js
vendored
Normal file
2
components/com_jce/editor/tiny_mce/plugins/fontselect/editor_plugin.js
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
/* jce - 2.9.32 | 2022-11-01 | https://www.joomlacontenteditor.net | Copyright (C) 2006 - 2022 Ryan Demmer. All rights reserved | GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html */
|
||||
!function(){var each=tinymce.each;tinymce.create("tinymce.plugins.FontSelectPlugin",{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",init:function(ed,url){this.editor=ed,ed.onNodeChange.add(function(ed,cm,n,collapsed,o){var fv,c=cm.get("fontselect");c&&n&&each(o.parents,function(n){if(n.style&&(fv=n.style.fontFamily||ed.dom.getStyle(n,"fontFamily"),fv=fv.replace(/[\"\']+/g,"").replace(/^([^,]+).*/,"$1").toLowerCase(),c.select(function(v){return v.replace(/^([^,]+).*/,"$1").toLowerCase()===fv}),fv))return!1})})},createControl:function(n,cf){if("fontselect"===n)return this._createFontSelect()},_createFontSelect:function(){var ctrl,self=this,ed=self.editor;return ctrl=ed.controlManager.createListBox("fontselect",{title:"advanced.fontdefault",max_height:384,onselect:function(v){var cur=ctrl.items[ctrl.selectedIndex];return!v&&cur?void ed.execCommand("FontName",!1,cur.value):(ed.execCommand("FontName",!1,v),ctrl.select(function(sv){return v==sv}),void(cur&&cur.value==v&&ctrl.select(null)))}}),each(ed.getParam("fontselect_fonts",self.fonts,"hash"),function(v,k){/\d/.test(v)&&(v="'"+v+"'"),ctrl.add(ed.translate(k),v,{style:v.indexOf("dings")==-1?"font-family:"+v:""})}),ctrl}}),tinymce.PluginManager.add("fontselect",tinymce.plugins.FontSelectPlugin)}();
|
||||
20
components/com_jce/editor/tiny_mce/plugins/fontselect/fontselect.xml
vendored
Normal file
20
components/com_jce/editor/tiny_mce/plugins/fontselect/fontselect.xml
vendored
Normal file
@@ -0,0 +1,20 @@
|
||||
<?xml version="1.0" ?>
|
||||
<extension version="3.4" type="plugin" group="jce" method="upgrade">
|
||||
<name>WF_FONTSELECT_TITLE</name>
|
||||
<version>2.9.32</version>
|
||||
<creationDate>01-11-2022</creationDate>
|
||||
<author>Ryan Demmer</author>
|
||||
<authorEmail>info@joomlacontenteditor.net</authorEmail>
|
||||
<authorUrl>https://www.joomlacontenteditor.net/</authorUrl>
|
||||
<copyright>Ryan Demmer</copyright>
|
||||
<license>GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html</license>
|
||||
<description>WF_FONTSELECT_DESC</description>
|
||||
<icon>fontselect</icon>
|
||||
<fields name="fontselect">
|
||||
<fieldset name="config">
|
||||
<field name="fonts" type="fonts" default="" label="WF_PARAM_FONTS" description="WF_PARAM_FONTS_DESC" />
|
||||
</fieldset>
|
||||
</fields>
|
||||
<help></help>
|
||||
<languages></languages>
|
||||
</extension>
|
||||
1
components/com_jce/editor/tiny_mce/plugins/fontselect/index.html
vendored
Normal file
1
components/com_jce/editor/tiny_mce/plugins/fontselect/index.html
vendored
Normal file
@@ -0,0 +1 @@
|
||||
<html><body bgcolor="#FFFFFF"></body></html>
|
||||
Reference in New Issue
Block a user