Implemented: plugin CSS

RainLoop still had a TODO for implementing plugin CSS
This is now used by the CKEditor plugin
This commit is contained in:
djmaze 2021-04-01 21:01:35 +02:00
parent 94abf288ba
commit d2534b5ed9
4 changed files with 260 additions and 84 deletions

View file

@ -0,0 +1,213 @@
/*.cke_button__sourcedialog_label {
display: none !important;
}*/
.cke_chrome {
border: 1px solid #ccc !important;
}
.cke_toolgroup {
padding-right: 0 !important;
background: #FBFBFB !important;
}
.cke_toolgroup, .cke_combo_button {
border: 1px solid #A6A6A6 !important;
}
.cke_top {
padding: 2px;
box-shadow: none !important;
border-bottom: 1px solid #b6b6b6 !important;
background: #F0F0F0 !important;
}
.cke_combo_on a.cke_combo_button,
.cke_combo_off a.cke_combo_button:hover,
.cke_combo_off a.cke_combo_button:focus,
.cke_combo_off a.cke_combo_button:active {
padding: 1px !important;
margin-left: 0 !important;
}
.cke_toolgroup a.cke_button:last-child:after,
.cke_toolgroup a.cke_button.cke_button_disabled:hover:last-child:after {
border: none !important;
height: 0 !important;
width: 0 !important;
margin: 0 !important;
padding: 0 !important;
}
.cke_button_on {
background: #ddd !important;
}
.cke_combo {
margin-top: 1px !important;
}
.cke_combo__fontsize {
margin-left: 3px !important;
.cke_combo_text {
width: 40px !important;
}
}
.cke_combo_text {
line-height: 24px !important;
padding-left: 8px !important;
}
.cke_combo_button {
background: #FBFBFB !important;
}
.cke_source {
font-family: var(--fontMono) !important;
padding: 10px !important;
padding-right: 0 !important;
box-shadow: none !important;
}
.cke_plain {
background-color: #fff;
outline: none;
overflow: auto;
z-index: 1;
margin: 0;
border: 0;
padding: 10px;
padding-right: 0;
white-space: pre-wrap;
font-family: var(--fontMono), monospace;
font-size: 13px;
line-height: 16px;
color: #333;
resize: none;
border-radius: 0;
box-shadow: none;
box-sizing: border-box;
}
.cke_plain:focus, .cke_source:focus {
border: 0;
}
.b-compose .cke_chrome {
border-right: 0;
border-left: 0;
border-bottom: 0;
box-shadow: none;
}
.cke_wysiwyg_div {
padding: 10px !important;
font-family: var(--fontSans);
font-size: 13px;
line-height: 16px;
color: #333;
ul {
padding-left: 40px;
li {
list-style-type: disc !important;
}
}
ol {
padding-left: 40px;
li {
list-style-type: decimal !important;
}
}
pre, code {
margin: 0;
padding: 0;
background: #fff;
border: none;
border-radius: 0;
font-family: var(--fontMono);
display: block;
word-break: normal;
word-wrap: break-word;
background-color: #f9f9f9;
}
code {
display: inline;
padding: 2px 5px;
}
pre {
padding: 5px 10px;
border-radius: 5px;
background-color: #f9f9f9;
}
pre > code {
padding: 0;
}
blockquote {
border: 0;
border-left: solid 2px #444;
margin: 5px 0 5px 5px;
padding-left: 5px;
}
blockquote p {
margin: 0 0 10px;
font-size: 14px;
line-height: 20px;
}
img {
vertical-align: bottom;
}
a {
color: blue;
text-decoration: underline;
&:visited {
color: #609;
}
&:active {
color: red;
}
}
}
.cke_dialog {
a:hover {
text-decoration: none;
}
.cke_dialog_ui_labeled_content {
margin-top: 5px;
margin-bottom: 5px;
}
.cke_dialog_ui_input_select, .cke_dialog_ui_input_text, .cke_dialog_ui_input_textarea {
box-shadow: none;
border-radius: 2px;
&:focus {
outline: 0;
border: 1px solid #999;
}
}
.cke_dialog_ui_input_select, .cke_dialog_ui_input_text {
height: 25px;
line-height: 25px;
}
}

View file

@ -4,9 +4,9 @@ class CKEditorPlugin extends \RainLoop\Plugins\AbstractPlugin
{
const
NAME = 'CKEditor',
VERSION = '2.0',
RELEASE = '2021-03-25',
REQUIRED = '2.4.2',
VERSION = '2.1',
RELEASE = '2021-04-01',
REQUIRED = '2.4.4',
DESCRIPTION = 'Use CKEditor instead of Squire as WYSIWYG';
public function Init() : void
@ -32,6 +32,7 @@ class CKEditorPlugin extends \RainLoop\Plugins\AbstractPlugin
}
if (\is_file("{$path}/ckeditor.js")) {
$this->addCss('ckeditor.less');
$this->addJs('ckeditor.js');
}
}

View file

@ -172,6 +172,16 @@ abstract class AbstractPlugin
return $this;
}
protected function addCss(string $sFile, bool $bAdminScope = false) : self
{
if ($this->oPluginManager)
{
$this->oPluginManager->AddCss($this->sPath.'/'.$sFile, $bAdminScope);
}
return $this;
}
protected function addJs(string $sFile, bool $bAdminScope = false) : self
{
if ($this->oPluginManager)

View file

@ -9,50 +9,16 @@ class Manager
*/
private $oActions;
/**
* @var array
*/
private $aHooks;
/**
* @var array
*/
private $aJs;
/**
* @var array
*/
private $aAdminJs;
/**
* @var array
*/
private $aTemplates;
/**
* @var array
*/
private $aAdminTemplates;
/**
* @var array
*/
private $aProcessTemplate;
/**
* @var array
*/
private $aAdditionalParts;
/**
* @var array
*/
private $aAdditionalJson;
/**
* @var array
*/
private $aPlugins;
private
$aHooks = array(),
$aCss = array([], []),
$aJs = array([], []),
$aTemplates = array(),
$aAdminTemplates = array(),
$aProcessTemplate = array(),
$aAdditionalParts = array(),
$aAdditionalJson = array(),
$aPlugins = array();
/**
* @var bool
@ -68,17 +34,6 @@ class Manager
{
$this->oLogger = null;
$this->oActions = $oActions;
$this->aPlugins = array();
$this->aHooks = array();
$this->aJs = array();
$this->aAdminJs = array();
$this->aTemplates = array();
$this->aAdminTemplates = array();
$this->aJsonFilters = array();
$this->aAdditionalJson = array();
$this->aProcessTemplate = array();
$oConfig = $this->oActions->Config();
$this->bIsEnabled = (bool) $oConfig->Get('plugins', 'enable', false);
@ -216,14 +171,20 @@ class Manager
public function HaveJs(bool $bAdminScope = false) : bool
{
$bResult = false;
return $this->bIsEnabled && 0 < \count($this->aJs[$bAdminScope ? 1 : 0]);
}
if ($this->bIsEnabled)
{
$bResult = $bAdminScope ? 0 < \count($this->aAdminJs) : 0 < \count($this->aJs);
public function CompileCss(bool $bAdminScope = false) : string
{
$aResult = array();
if ($this->bIsEnabled) {
foreach ($this->aCss[$bAdminScope ? 1 : 0] as $sFile) {
if (\is_readable($sFile)) {
$aResult[] = \file_get_contents($sFile);
}
}
}
return $bResult;
return \implode("\n", $aResult);
}
public function CompileJs(bool $bAdminScope = false) : string
@ -231,8 +192,7 @@ class Manager
$aResult = array();
if ($this->bIsEnabled)
{
$aJs = $bAdminScope ? $this->aAdminJs : $this->aJs;
foreach ($aJs as $sFile)
foreach ($this->aJs[$bAdminScope ? 1 : 0] as $sFile)
{
if (\is_readable($sFile))
{
@ -244,14 +204,6 @@ class Manager
return \implode("\n", $aResult);
}
/**
* @todo
*/
public function CompileCss(bool $bAdminScope = false) : string
{
return '';
}
public function CompileTemplate(array &$aList, bool $bAdminScope = false) : void
{
if ($this->bIsEnabled)
@ -326,18 +278,18 @@ class Manager
return $this;
}
public function AddCss(string $sFile, bool $bAdminScope = false) : self
{
if ($this->bIsEnabled) {
$this->aCss[$bAdminScope ? 1 : 0] = $sFile;
}
return $this;
}
public function AddJs(string $sFile, bool $bAdminScope = false) : self
{
if ($this->bIsEnabled)
{
if ($bAdminScope)
{
$this->aAdminJs[$sFile] = $sFile;
}
else
{
$this->aJs[$sFile] = $sFile;
}
if ($this->bIsEnabled) {
$this->aJs[$bAdminScope ? 1 : 0][$sFile] = $sFile;
}
return $this;