Improved styling of the label dialog editor, so that the appearance is closer to the Label result

This commit is contained in:
Jan Böhmer 2022-09-21 21:49:09 +02:00
parent 9c87202509
commit ab8be58c0d
6 changed files with 33 additions and 4 deletions

View file

@ -188,6 +188,8 @@ Editor.defaultConfig = {
'fontSize': { 'fontSize': {
options: [ options: [
'default', 'default',
6,
7,
8, 8,
9, 9,
10, 10,
@ -222,7 +224,7 @@ Editor.defaultConfig = {
'tableCellProperties', 'tableCellProperties',
'tableProperties' 'tableProperties'
] ]
} },
}; };
export default { Editor, EditorWatchdog }; export default { Editor, EditorWatchdog };

View file

@ -6,6 +6,7 @@ import { default as HTMLLabelEditor } from "../../ckeditor/html_label";
import EditorWatchdog from '@ckeditor/ckeditor5-watchdog/src/editorwatchdog'; import EditorWatchdog from '@ckeditor/ckeditor5-watchdog/src/editorwatchdog';
import "../../css/ckeditor.css";
/* stimulusFetch: 'lazy' */ /* stimulusFetch: 'lazy' */
export default class extends Controller { export default class extends Controller {
@ -43,6 +44,13 @@ export default class extends Controller {
editor.enableReadOnlyMode("readonly"); editor.enableReadOnlyMode("readonly");
} }
//Apply additional styles
const editor_div = editor.ui.view.element;
const new_classes = this.element.dataset.ckClass;
if (editor_div && new_classes) {
editor_div.classList.add(...new_classes.split(","));
}
console.log(editor); console.log(editor);
}) })
.catch(error => { .catch(error => {

19
assets/css/ckeditor.css Normal file
View file

@ -0,0 +1,19 @@
/********************************************************************
* HTML Label style override
*********************************************************************/
/** Should be the same settings, as in label_style.css */
.ck-html-label .ck-content {
font-family: "DejaVu Sans Mono", monospace;
font-size: 12px;
line-height: 1.0;
font-size-adjust: 1.5;
}
.ck-html-label .ck-content p {
margin: 0;
}
.ck-html-label .ck-content hr {
margin: 2px;
}

View file

@ -106,6 +106,7 @@ class LabelOptionsType extends AbstractType
'mode' => 'html-label', 'mode' => 'html-label',
'attr' => [ 'attr' => [
'rows' => 4, 'rows' => 4,
'data-ck-class' => 'ck-html-label'
], ],
]); ]);

View file

@ -3,7 +3,7 @@
{{ element.lines | raw }} {{ element.lines | raw }}
</div> </div>
<div class="C39-container" style=""> <div class="C39-container" style="">
<img class="C39" src="{{ element.barcode | data_uri(mime='image/svg+xml') }}" height="30px"> <img class="C39" src="{{ element.barcode | data_uri(mime='image/svg+xml') }}" height="30px"><br>
<span class="C39-text">{{ element.barcode_content }}</span> <span class="C39-text">{{ element.barcode_content }}</span>
</div> </div>
</div> </div>

View file

@ -4,7 +4,7 @@
body { body {
font-family: "DejaVu Sans Mono"; font-family: "DejaVu Sans Mono";
font-size: 9pt; font-size: 12px;
line-height: 1.0; line-height: 1.0;
} }
@ -38,7 +38,6 @@ hr {
.C39-text { .C39-text {
display: block; display: block;
margin-top: -6px;
font-size: 6pt; font-size: 6pt;
} }