Internal: Add CSS reset for TinyMCE editor content - refs BT#21876

pull/5696/head
christianbeeznst 1 year ago
parent c6ec538631
commit 91171a2a47
  1. 1
      assets/css/app.scss
  2. 27
      assets/css/editor_content.css
  3. 61
      assets/vue/components/basecomponents/BaseTinyEditor.vue

@ -9,6 +9,7 @@
//@import '~jquery-ui/themes/base/all.css'; //@import '~jquery-ui/themes/base/all.css';
@import "tinymce/skins/ui/oxide/skin.css"; @import "tinymce/skins/ui/oxide/skin.css";
@import './editor_content.css';
@layer utilities { @layer utilities {
.border-gray-300 { .border-gray-300 {

@ -2,6 +2,33 @@
Stylesheet for HTML blocks created with CKEditor to embed in Chamilo pages. Stylesheet for HTML blocks created with CKEditor to embed in Chamilo pages.
*/ */
/* Reset styles */
.tiny-content {
all: initial;
display: block;
width: 100%;
}
.tiny-content * {
all: revert;
box-sizing: border-box;
}
/* Specific styles for TinyMCE content */
.tiny-content img {
display: block !important;
margin-left: auto !important;
margin-right: auto !important;
width: auto !important;
height: auto !important;
}
.tiny-content table {
margin: auto !important;
width: auto !important;
}
/* Hack for show Bootstrap alerts in CKEditor' style select */ /* Hack for show Bootstrap alerts in CKEditor' style select */
.cke_panel_listItem a > :first-child { .cke_panel_listItem a > :first-child {
margin-bottom: 0; margin-bottom: 0;

@ -21,7 +21,7 @@
</template> </template>
<script setup> <script setup>
import { computed, ref } from "vue" import { computed, ref, watch } from "vue"
import TinyEditor from "../../components/Editor" import TinyEditor from "../../components/Editor"
import { useRoute, useRouter } from "vue-router" import { useRoute, useRouter } from "vue-router"
import { useCidReqStore } from "../../store/cidReq" import { useCidReqStore } from "../../store/cidReq"
@ -29,9 +29,6 @@ import { storeToRefs } from "pinia"
import { useSecurityStore } from "../../store/securityStore" import { useSecurityStore } from "../../store/securityStore"
import FloatLabel from "primevue/floatlabel" import FloatLabel from "primevue/floatlabel"
//import contentUiCss from "css-loader!tinymce/skins/ui/oxide/content.css"
//import contentCss from "css-loader!tinymce/skins/content/default/content.css"
const modelValue = defineModel({ const modelValue = defineModel({
type: String, type: String,
required: true, required: true,
@ -104,7 +101,6 @@ const toolbarTextDirection = "ltr rtl"
const defaultEditorConfig = { const defaultEditorConfig = {
skin: false, skin: false,
content_css: false, content_css: false,
//content_style: contentUiCss.toString() + "\n" + contentCss.toString(),
branding: false, branding: false,
relative_urls: false, relative_urls: false,
height: 500, height: 500,
@ -136,33 +132,30 @@ const defaultEditorConfig = {
"visualblocks", "visualblocks",
"wordcount", "wordcount",
], ],
toolbar: toolbar: [
toolbarUndo + toolbarUndo,
" | " + toolbarFormatText,
toolbarFormatText + toolbarInsertMedia,
" | " + toolbarFontConfig,
toolbarInsertMedia + toolbarAlign,
" | " + toolbarIndent,
toolbarFontConfig + toolbarList,
" | " + toolbarColor,
toolbarAlign + toolbarPageBreak,
" | " + toolbarSpecialSymbols,
toolbarIndent + toolbarOther,
" | " + toolbarCode,
toolbarList + toolbarTextDirection
" | " + ].join(" | "),
toolbarColor +
" | " +
toolbarPageBreak +
" | " +
toolbarSpecialSymbols +
" | " +
toolbarOther +
" | " +
toolbarCode +
" | " +
toolbarTextDirection,
file_picker_callback: filePickerCallback, file_picker_callback: filePickerCallback,
content_style: ".tiny-content { font-family: Arial, sans-serif; font-size: 14px; }",
body_class: 'tiny-content',
setup: (editor) => {
editor.on('init', () => {
const body = editor.getBody();
body.classList.add('tiny-content');
});
}
} }
if (props.fullPage) { if (props.fullPage) {
@ -175,6 +168,12 @@ const editorConfig = computed(() => ({
...props.editorConfig, ...props.editorConfig,
})) }))
watch(modelValue, (newValue) => {
if (newValue && !newValue.includes('tiny-content')) {
modelValue.value = `<div class="tiny-content">${newValue}</div>`
}
})
async function filePickerCallback(callback, value, meta) { async function filePickerCallback(callback, value, meta) {
let url = getUrlForTinyEditor() let url = getUrlForTinyEditor()
if ("image" === meta.filetype) { if ("image" === meta.filetype) {

Loading…
Cancel
Save