Skip to content

Commit

Permalink
Merge pull request #28 from aschmutt/fontawesome-6pro
Browse files Browse the repository at this point in the history
Fontawesome 6pro
  • Loading branch information
DirkPersky authored May 7, 2022
2 parents 7724d76 + fcb8c9c commit 9bf703b
Show file tree
Hide file tree
Showing 15 changed files with 406 additions and 7 deletions.
2 changes: 1 addition & 1 deletion Configuration/RTE/PluginFA5.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
editor:
externalPlugins:
ckeditor_fa5:
resource: "EXT:rte_ckeditor_fontawesome/Resources/Public/JavaScript/Plugins/ckeditor_fa5/plugin.js?v=11.5.4"
resource: "EXT:rte_ckeditor_fontawesome/Resources/Public/JavaScript/Plugins/ckeditor_fa5/plugin.js?v=11.5.5"

config:
fontAwesome:
Expand Down
2 changes: 1 addition & 1 deletion Configuration/RTE/PluginFA5Pro.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
editor:
externalPlugins:
ckeditor_fa5pro:
resource: "EXT:rte_ckeditor_fontawesome/Resources/Public/JavaScript/Plugins/ckeditor_fa5pro/plugin.js?v=11.5.4"
resource: "EXT:rte_ckeditor_fontawesome/Resources/Public/JavaScript/Plugins/ckeditor_fa5pro/plugin.js?v=11.5.5"

config:
coreStyles_italic:
Expand Down
2 changes: 1 addition & 1 deletion Configuration/RTE/PluginFA6.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
editor:
externalPlugins:
ckeditor_fa:
resource: "EXT:rte_ckeditor_fontawesome/Resources/Public/JavaScript/Plugins/ckeditor_fa6/plugin.js?v=11.5.4"
resource: "EXT:rte_ckeditor_fontawesome/Resources/Public/JavaScript/Plugins/ckeditor_fa6/plugin.js?v=11.5.5"

config:
fontAwesome:
Expand Down
16 changes: 16 additions & 0 deletions Configuration/RTE/PluginFA6Pro.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# Register wordcount plugin for ckeditor
editor:
externalPlugins:
ckeditor_fa:
resource: "EXT:rte_ckeditor_fontawesome/Resources/Public/JavaScript/Plugins/ckeditor_fa6pro/plugin.js?v=11.5.5"

config:

coreStyles_italic:
element: 'i'
overrides: 'span'

extraAllowedContent:
- i(*)[*]
- span(*)[*]
- em(*)[*]
44 changes: 44 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,50 @@ Add to your constant or clear this:
plugin.tx_ckeditor_fontawesome.css = "LINK TO FONTAWESOME PRO"
```

## Fontawesome 6 Pro

Usually you have a RTE config in your sitepackage, if not create a new file.
* add PluginFA6Pro.yaml to imports
* add fontAwesome URL or path to CSS
* if icons are still missing: check webfonts path in the css and change if necessary

```
imports:
- { resource: "EXT:rte_ckeditor/Configuration/RTE/Processing.yaml" }
- { resource: "EXT:rte_ckeditor/Configuration/RTE/Editor/Base.yaml" }
- { resource: "EXT:rte_ckeditor/Configuration/RTE/Editor/Plugins.yaml" }
- { resource: "EXT:rte_ckeditor_fontawesome/Configuration/RTE/PluginFA6Pro.yaml" }
editor:
config:
fontAwesome:
- "EXT:sitepackage/Resources/Public/Fonts/Css/fa6pro-all.css"
```

## TCA Selector for Fontawesome Icons

You can use the Fontawesome SVG folder as source for a TCA Select field.
Change "fileFolder" to the path where your SVGs are located:

```
'icon' => [
'exclude' => 1,
'label' => 'Icon',
'config' => [
'type' => 'select',
'renderType' => 'selectMultipleSideBySide',
'fileFolder' => 'EXT:sitepackage/Resources/Public/Icons/Fontawesome/',
'fileFolder_extList' => 'svg',
'fileFolder_recursions' => 0,
'size' => 5,
'minitems' => 0,
'maxitems' => 1,
],
],
```

With npm installation, the SVGs are located in `node_modules/@fortawesome/fontawesome-pro/svgs/light`

## ToDo:
- Add FA-Icon in Content Headline Definition.

Expand Down
2 changes: 1 addition & 1 deletion Resources/Public/JavaScript/Plugins/ckeditor_fa5/plugin.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
(function ($) {
var CKEDITOR_FA = {
version: '11.5.4'
version: '11.5.5'
};

CKEDITOR.dtd.$removeEmpty.span = 0;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
(function ($) {
var CKEDITOR_FA = {
version: '11.5.4'
version: '11.5.5'
};

CKEDITOR.dtd.$removeEmpty.span = 0;
Expand Down
2 changes: 1 addition & 1 deletion Resources/Public/JavaScript/Plugins/ckeditor_fa6/plugin.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
(function ($) {
var CKEDITOR_FA = {
version: '11.5.4'
version: '11.5.5'
};

CKEDITOR.dtd.$removeEmpty.span = 0;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@

#ckeditor-fa-icons {
text-align: center;
white-space: normal;
width: 100%;
height: 350px;
overflow: auto
}

#ckeditor-fa-icons a {
display: inline-block;
width: 72px;
padding: 5px 0;
text-align: center;
vertical-align: top
}

#ckeditor-fa-icons a span {
font-size: 28px;
display: block;
text-align: center
}

#ckeditor-fa-icons a.active {
background-color: rgba(0, 0, 0, .1)
}

.faSelect {
width: 100%
}

div[name="font-awesome"] .cke_dialog_ui_input_select {
width: 100%;
}

div[name="font-awesome"] .cke_dialog_ui_input_text {
min-width: 100px;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
Update Icons https://cdpn.io/MarkBoots/fullpage/LYyeGzo

```javascript
fetch("https://raw.githubusercontent.com/FortAwesome/Font-Awesome/6.x/metadata/icons.json")
.then(response =>response.json()).then(jsondata => {
var solid = [], regular = [], brand = [];

Object.entries(jsondata).forEach(([key, value]) => {
if(typeof value.free != 'undefined') {
if(value.free.indexOf('brands') >= 0) brand.push(`"${key}"`);
if(value.free.indexOf('solid') >= 0) solid.push(`"${key}"`);
if(value.free.indexOf('regular') >= 0) regular.push(`"${key}"`);
}
});

console.warn('%cSOLID', "font-size:3rem"); console.log(solid.join(','));
console.warn('%cREGULAR', "font-size:3rem"); console.log(regular.join(','));
console.warn('%cBRAND', "font-size:3rem"); console.log(brand.join(','));
});
```

### Update Icons with bash

When loading with npm, there is a folder with SVGs:

`node_modules/@fortawesome/fontawesome-pro/svgs/light`

Bash script to get the list of icons:

```bash
#!/bin/bash

filelist=""
for file in *.svg
do
filename="${file%.svg}"
filelist+=\"$filename\",
done
echo $filelist
```

=> copy output, remove last `,` and paste into ckeditor-fa.js => `var faLight = [`

Large diffs are not rendered by default.

Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
47 changes: 47 additions & 0 deletions Resources/Public/JavaScript/Plugins/ckeditor_fa6pro/plugin.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
(function ($) {
var CKEDITOR_FA = {
version: '11.5.5'
};

CKEDITOR.dtd.$removeEmpty.span = 0;
CKEDITOR.dtd.$removeEmpty.em = 0;
CKEDITOR.dtd.$removeEmpty.i = 0;

CKEDITOR.plugins.add('ckeditor_fa', {
icons: 'ckeditor-fa',
init: function (editor) {
editor.addCommand('ckeditor_fa', new CKEDITOR.dialogCommand('ckeditorFaDialog', {
allowedContent: 'i(!fa-*)',
}));
editor.ui.addButton('ckeditor_fa', {
label: 'Insert FontAwesome icon',
command: 'ckeditor_fa',
toolbar: 'insert',
icon: this.path + 'icons/fa32x32.png',
});
CKEDITOR.dialog.add('ckeditorFaDialog', this.path + 'dialogs/ckeditor-fa.js?v=' + CKEDITOR_FA.version);
CKEDITOR.document.appendStyleSheet(this.path + 'css/ckeditor-fa.css?v=' + CKEDITOR_FA.version);
// add styles
if(typeof editor.config.fontAwesome != 'undefined'){
editor.config.fontAwesome.map(function (css_file) {
editor.addContentsCss(css_file);
loadCSS(css_file);
});
}
}
});

/**
* Load Fontawesome
* @param href
*/
function loadCSS(href) {
var headID = document.getElementsByTagName('head')[0];
var cssLink = document.createElement("link");
cssLink.rel = "stylesheet";
cssLink.type = "text/css";
cssLink.href = href;
// add to dom
headID.appendChild(cssLink);
}
})(TYPO3.jQuery);
2 changes: 1 addition & 1 deletion ext_emconf.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
'clearCacheOnLoad' => 0,
'author' => 'Dirk Persky',
'author_email' => '[email protected]',
'version' => '11.5.4',
'version' => '11.5.5',
'constraints' => [
'depends' => [
'typo3' => '10.4.0-11.5.99',
Expand Down
1 change: 1 addition & 0 deletions ext_localconf.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,6 @@
$GLOBALS['TYPO3_CONF_VARS']['RTE']['Presets']['default'] = 'EXT:rte_ckeditor_fontawesome/Configuration/RTE/DefaultFA6.yaml';
$GLOBALS['TYPO3_CONF_VARS']['RTE']['Presets']['full'] = 'EXT:rte_ckeditor_fontawesome/Configuration/RTE/FullFA6.yaml';
$GLOBALS['TYPO3_CONF_VARS']['RTE']['Presets']['minimal'] = 'EXT:rte_ckeditor_fontawesome/Configuration/RTE/MinimalFA6.yaml';
$GLOBALS['TYPO3_CONF_VARS']['RTE']['Presets']['fa6pro'] = 'EXT:rte_ckeditor_fontawesome/Configuration/RTE/PluginFa6Pro.yaml';
})();

0 comments on commit 9bf703b

Please sign in to comment.