Skip to content

Commit 1dfa1d3

Browse files
authored
Merge pull request #5696 from christianbeeznest/ofaj-21876-1
Internal: Add CSS reset for TinyMCE editor content - refs BT#21876
2 parents fc9886d + a6f8faf commit 1dfa1d3

File tree

3 files changed

+69
-31
lines changed

3 files changed

+69
-31
lines changed

assets/css/app.scss

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
//@import '~jquery-ui/themes/base/all.css';
1010

1111
@import "tinymce/skins/ui/oxide/skin.css";
12+
@import './editor_content.css';
1213

1314
@layer utilities {
1415
.border-gray-300 {

assets/css/editor_content.css

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,44 @@
22
Stylesheet for HTML blocks created with CKEditor to embed in Chamilo pages.
33
*/
44

5+
/* Reset styles */
6+
.tiny-content {
7+
all: initial;
8+
display: block;
9+
width: 100%;
10+
}
11+
12+
.tiny-content * {
13+
box-sizing: border-box;
14+
}
15+
16+
/* Specific styles for TinyMCE content */
17+
.tiny-content img {
18+
display: block !important;
19+
margin-left: auto !important;
20+
margin-right: auto !important;
21+
}
22+
23+
.tiny-content table {
24+
margin: auto !important;
25+
border-collapse: collapse !important;
26+
}
27+
28+
.tiny-content td, .tiny-content th {
29+
padding: 5px !important;
30+
}
31+
32+
.tiny-content a {
33+
color: blue !important;
34+
text-decoration: underline !important;
35+
}
36+
37+
.tiny-content caption {
38+
caption-side: top !important;
39+
text-align: center !important;
40+
font-weight: bold !important;
41+
}
42+
543
/* Hack for show Bootstrap alerts in CKEditor' style select */
644
.cke_panel_listItem a > :first-child {
745
margin-bottom: 0;

assets/vue/components/basecomponents/BaseTinyEditor.vue

Lines changed: 30 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -21,17 +21,14 @@
2121
</template>
2222

2323
<script setup>
24-
import { computed, ref } from "vue"
24+
import { computed, ref, watch } from "vue"
2525
import TinyEditor from "../../components/Editor"
2626
import { useRoute, useRouter } from "vue-router"
2727
import { useCidReqStore } from "../../store/cidReq"
2828
import { storeToRefs } from "pinia"
2929
import { useSecurityStore } from "../../store/securityStore"
3030
import FloatLabel from "primevue/floatlabel"
3131
32-
//import contentUiCss from "css-loader!tinymce/skins/ui/oxide/content.css"
33-
//import contentCss from "css-loader!tinymce/skins/content/default/content.css"
34-
3532
const modelValue = defineModel({
3633
type: String,
3734
required: true,
@@ -104,7 +101,6 @@ const toolbarTextDirection = "ltr rtl"
104101
const defaultEditorConfig = {
105102
skin: false,
106103
content_css: false,
107-
//content_style: contentUiCss.toString() + "\n" + contentCss.toString(),
108104
branding: false,
109105
relative_urls: false,
110106
height: 500,
@@ -136,33 +132,30 @@ const defaultEditorConfig = {
136132
"visualblocks",
137133
"wordcount",
138134
],
139-
toolbar:
140-
toolbarUndo +
141-
" | " +
142-
toolbarFormatText +
143-
" | " +
144-
toolbarInsertMedia +
145-
" | " +
146-
toolbarFontConfig +
147-
" | " +
148-
toolbarAlign +
149-
" | " +
150-
toolbarIndent +
151-
" | " +
152-
toolbarList +
153-
" | " +
154-
toolbarColor +
155-
" | " +
156-
toolbarPageBreak +
157-
" | " +
158-
toolbarSpecialSymbols +
159-
" | " +
160-
toolbarOther +
161-
" | " +
162-
toolbarCode +
163-
" | " +
164-
toolbarTextDirection,
135+
toolbar: [
136+
toolbarUndo,
137+
toolbarFormatText,
138+
toolbarInsertMedia,
139+
toolbarFontConfig,
140+
toolbarAlign,
141+
toolbarIndent,
142+
toolbarList,
143+
toolbarColor,
144+
toolbarPageBreak,
145+
toolbarSpecialSymbols,
146+
toolbarOther,
147+
toolbarCode,
148+
toolbarTextDirection
149+
].join(" | "),
165150
file_picker_callback: filePickerCallback,
151+
content_style: ".tiny-content { font-family: Arial, sans-serif; font-size: 14px; }",
152+
body_class: 'tiny-content',
153+
setup: (editor) => {
154+
editor.on('init', () => {
155+
const body = editor.getBody();
156+
body.classList.add('tiny-content');
157+
});
158+
}
166159
}
167160
168161
if (props.fullPage) {
@@ -175,6 +168,12 @@ const editorConfig = computed(() => ({
175168
...props.editorConfig,
176169
}))
177170
171+
watch(modelValue, (newValue) => {
172+
if (newValue && !newValue.includes('tiny-content')) {
173+
modelValue.value = `<div class="tiny-content">${newValue}</div>`
174+
}
175+
})
176+
178177
async function filePickerCallback(callback, value, meta) {
179178
let url = getUrlForTinyEditor()
180179
if ("image" === meta.filetype) {

0 commit comments

Comments
 (0)