Skip to content

Commit

Permalink
#17 Fontawesome Pro solution update
Browse files Browse the repository at this point in the history
code improvements
  • Loading branch information
DirkPersky committed Mar 19, 2022
1 parent 9c1b716 commit aa93309
Show file tree
Hide file tree
Showing 9 changed files with 69 additions and 37 deletions.
7 changes: 3 additions & 4 deletions Configuration/RTE/FullFA5Pro.yaml
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
imports:
- { resource: "EXT:rte_ckeditor/Configuration/RTE/Full.yaml" }
- { resource: "EXT:rte_ckeditor_fontawesome/Configuration/RTE/PluginFA5.yaml" }
- { resource: "EXT:rte_ckeditor_fontawesome/Configuration/RTE/PluginFA5Pro.yaml" }

# Add configuration for the editor
editor:
config:
# css definitions for the editor
contentsCss:
- "EXT:rte_ckeditor/Resources/Public/Css/contents.css"
fontAwesome:
- "https://use.fontawesome.com/releases/v5.14.0/css/all.css"
5 changes: 4 additions & 1 deletion Configuration/RTE/PluginFA5.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,12 @@
editor:
externalPlugins:
ckeditor_fa5:
resource: "EXT:rte_ckeditor_fontawesome/Resources/Public/JavaScript/Plugins/ckeditor_fa5/plugin.js?v=11.5.3"
resource: "EXT:rte_ckeditor_fontawesome/Resources/Public/JavaScript/Plugins/ckeditor_fa5/plugin.js?v=11.5.4"

config:
fontAwesome:
- "https://use.fontawesome.com/releases/v5.15.4/css/all.css"

coreStyles_italic:
element: 'i'
overrides: 'span'
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.3"
resource: "EXT:rte_ckeditor_fontawesome/Resources/Public/JavaScript/Plugins/ckeditor_fa5pro/plugin.js?v=11.5.4"

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

config:
fontAwesome:
- "https://use.fontawesome.com/releases/v6.0.0/css/all.css"

coreStyles_italic:
element: 'i'
overrides: 'span'
Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,16 +53,16 @@ At the next step you need to extend your individual Toolbar-Config to add the Cl
## Use Fontawesome Pro, or Custom Config:
first create the file `/fileadmin/rte_ckeditor_fontawesome/FA5Pro.yaml`.
Copy the content from below and replace your `fontawesome pro` link.

![Update YAML](https://img.shields.io/badge/UPDATE-FA5%20PRO%20YAML-green?style=for-the-badge)
```
imports:
- { resource: "EXT:rte_ckeditor/Configuration/RTE/Full.yaml" }
- { resource: "EXT:rte_ckeditor_fontawesome/Configuration/RTE/PluginFA5Pro.yaml" }
# Add configuration for the editor
editor:
config:
# css definitions for the editor
contentsCss:
- "EXT:rte_ckeditor/Resources/Public/Css/contents.css"
fontAwesome:
- "LINK TO FONTAWESOME PRO"
```

Expand Down
15 changes: 9 additions & 6 deletions Resources/Public/JavaScript/Plugins/ckeditor_fa5/plugin.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
(function ($) {
var CKEDITOR_FA = {
cdn: 'https://use.fontawesome.com/releases/v5.15.4/css/all.css',
version: '11.5.3'
version: '11.5.4'
};

CKEDITOR.dtd.$removeEmpty.span = 0;
Expand All @@ -22,9 +21,13 @@
});
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);

editor.addContentsCss(CKEDITOR_FA.cdn);
loadCSS(CKEDITOR_FA.cdn);
// add styles
if(typeof editor.config.fontAwesome != 'undefined'){
editor.config.fontAwesome.map(function (css_file) {
editor.addContentsCss(css_file);
loadCSS(css_file);
});
}
}
});

Expand All @@ -36,7 +39,7 @@
var headID = document.getElementsByTagName('head')[0];
var cssLink = document.createElement("link");
cssLink.rel = "stylesheet";
cssLink.type = "text/css";
cssLink.type = "text/css";
cssLink.href = href;
// add to dom
headID.appendChild(cssLink);
Expand Down
51 changes: 36 additions & 15 deletions Resources/Public/JavaScript/Plugins/ckeditor_fa5pro/plugin.js
Original file line number Diff line number Diff line change
@@ -1,26 +1,47 @@
(function ($) {
var CKEDITOR_FA = {
version: '11.5.3'
version: '11.5.4'
};

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

CKEDITOR.plugins.add('ckeditor_fa5pro', {
icons: 'ckeditor-fa',
init: function (editor) {
editor.addCommand('ckeditor_fa5pro', new CKEDITOR.dialogCommand('ckeditorFaDialog', {
allowedContent: 'i(!fa-*)',
}));
editor.ui.addButton('ckeditor_fa5pro', {
label: 'Insert FontAwesome icon',
command: 'ckeditor_fa5pro',
toolbar: 'insert',
icon: this.path + 'icons/ckeditor-fa.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);
icons: 'ckeditor-fa',
init: function (editor) {
editor.addCommand('ckeditor_fa5pro', new CKEDITOR.dialogCommand('ckeditorFaDialog', {
allowedContent: 'i(!fa-*)',
}));
editor.ui.addButton('ckeditor_fa5pro', {
label: 'Insert FontAwesome icon',
command: 'ckeditor_fa5pro',
toolbar: 'insert',
icon: this.path + 'icons/ckeditor-fa.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);
13 changes: 8 additions & 5 deletions Resources/Public/JavaScript/Plugins/ckeditor_fa6/plugin.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
(function ($) {
var CKEDITOR_FA = {
cdn: 'https://use.fontawesome.com/releases/v6.0.0/css/all.css',
version: '11.5.3'
version: '11.5.4'
};

CKEDITOR.dtd.$removeEmpty.span = 0;
Expand All @@ -22,9 +21,13 @@
});
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);

editor.addContentsCss(CKEDITOR_FA.cdn);
loadCSS(CKEDITOR_FA.cdn);
// add styles
if(typeof editor.config.fontAwesome != 'undefined'){
editor.config.fontAwesome.map(function (css_file) {
editor.addContentsCss(css_file);
loadCSS(css_file);
});
}
}
});

Expand Down
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.3',
'version' => '11.5.4',
'constraints' => [
'depends' => [
'typo3' => '10.4.0-11.5.99',
Expand Down

0 comments on commit aa93309

Please sign in to comment.