Why is TinyMCE removing my custom MPDF HTML elements?

I have a Vue application with a Symfony backend. I am using TinyMCE to edit documents that are generated by mpdf. In the mpdf twig content, I need to add a page footer on certain pages and exclude it on others. To achieve this, I have created custom HTML tags for enabling or disabling the footer. The structure of my custom tags is as follows:

    <pagefooter
            name="NotLastPageFooter"
            content-left=""
            content-center="{PAGENO}/{nbpg}"
            content-right=""
            footer-style="font-size:10px">

    </pagefooter>

    <pagefooter
            name="lastPageFooter"
            content-left=""
            content-center="{PAGENO}/{nbpg}"
            content-right=""
            footer-style="font-size:10px">

    </pagefooter>

    <setpagefooter
            name="lastPageFooter"
            value="off"
    />

    <setpagefooter
            name="NotLastPageFooter"
            value="on"
    />

However, when I edit a generated document via TinyMCE, it removes these html blocks provided by mpdf, resulting in edited documents without a page footer. Below is my TinyMCE configuration:

<editor
    @onKeyUp="onDocumentUpdate(document, index, $event)"
    :value="editor"
    entity_encoding="raw"
    output-format="html"
    :init="{
        allow_conditional_comments: false,
        allow_unsafe_link_target: true,
        convert_fonts_to_spans : false,
        keep_styles: true,
        custom_elements: 'pagefooter,setpagefooter',
        extended_valid_elements :'setpagefooter[name],setpagefooter[value],pagefooter[name],pagefooter[content-center],pagefooter[content-right],pagefooter[footer-style]',
        height: 600,
        menubar: false,
        plugins: [
            'advlist autolink lists link image charmap print preview anchor code',
            'searchreplace visualblocks code fullscreen',
            'insertdatetime media table paste code help wordcount'
        ],
        toolbar:
            'undo redo | formatselect | bold italic backcolor | \
            alignleft aligncenter alignright alignjustify | \
            bullist numlist outdent indent | removeformat | help code',

}"
/>

Answer №1

It seems like the issue may stem from improperly using extended_valid_elements. Make sure you are not repeating the tag multiple times in the configuration. The documentation provides useful working examples:

For instance:

extended_valid_elements : 'img[class|src|border=0|alt|title]'

...or...

extended_valid_elements :'setpagefooter[name|value],pagefooter[name|content-center|content-right|footer-style]',

Remember to include all attributes in one set of brackets. To better understand, here is an example that might work for your content:

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

What is the best way to implement a dropdown menu with sub-menus using Vuetify?

Is it possible to create a menu with icon buttons that open sub-menus when clicked? I have a structure of buttons data like this: buttons: [ { id: 'options', title: 'More Options', icon: 'fas fa-bars', action: '& ...

When the bounds are adjusted, removing markers in Vue Cookbook's Google Map

I've encountered an issue with clearing markers after updating new bounds on a map. Whenever I post a request with new bounds, new markers get added to the map while the old ones remain in place. This situation becomes quite awkward for me because the ...

Node.js vulnerability labeled as CVE-2021-38628

Description: Enhance security measures by disabling the use of TLSv1.0 protocol and transitioning to a more secure option like TLSv1.2. To perform a manual test, utilize the following openssl commands: openssl s_client -connect ip:port -tls1. If succes ...

The Laravel error should occur within the context of a chat application

Encountering an issue with my code. I am using the following event: https://github.com/musonza/chat/blob/master/src/Messages/MessageWasSent.php In the controller: public function sendMessage(Conversation $conversation, Request $request) { $v = Valida ...

Apply a red border to any form inputs that contain incorrect information when the submit

How can I add red borders to my form inputs only when they are invalid after submission, without displaying the red borders from the start? Currently, I am using the input:invalid selectors in CSS, but this causes the red borders to appear immediately. I ...

Vue-Router fails to function when a route is activated

Check out the following routes: /form/1 /form/2 /form/3 While on the / address, clicking on /form/1 causes VueRouter to load my component inside router-view. However, when I'm already on /form/1, clicking on /form/2 does nothing! ...

Troubleshooting a problem with arrays in Vue.js and axios

Hey everyone, I recently received a response from an axios call that looks like this: axios.post('/api/hr_employee/days/'+ this.period_data.year +'/'+ this.period_data.month +'?page='+this.currentPage+'&api_token=&apo ...

A guide on implementing Google reCAPTCHA in a Nuxt.js website

Trying to implement the recaptcha-module from nuxt-community in my Nuxt project but struggling with verifying if the user has passed the check. The documentation and example provided are not clear enough for me (https://github.com/nuxt-community/recaptch ...

Passing a custom Vue component as a property to a parent component

Struggling to find answers to my unique question, I'm attempting to create an interface where users can drag or input images using Vue. I've developed a component called Card, which combines Vue and Bulma to create card-like objects with props fo ...

Unexpected state being returned by Vuex

I am encountering an issue with a pop-up modal that is not behaving as expected. The condition for the pop-up to appear is if the user has no transactions, which is determined by checking the length of the depositHistory array. If the length is greater tha ...

Symfony 2 can be configured to add a "data-*" attribute to each radio input field in a form entity

Within my form, I have a field named "membership" that displays radio buttons. Here is the code snippet: ->add( 'membership', 'entity', array( 'class' => 'Comit ...

When retrieving information regarding related objects in a Twig template, consider making extra database requests

Every time I write code like this: controller: public function listAction() { $actions = $this->getDoctrine()->getRepository('AcmeDemoBundle:Action')->findAll(); return $this->render('AcmeDemoBundle:Admin:action/list.h ...

Issues with utilizing Jquery datepicker within a Vue.js component's v-for loop in Laravel

I am facing an issue with the Jquery date picker inside a v-for loop in my vue.js component. The date picker works fine outside of the loop, but inside the loop it does not behave as expected. Here is a snippet of code where the date picker is working cor ...

Struggling to concatenate array dynamically in Vue using ajax request

I am working on a Vue instance that fetches objects from a REST endpoint and showcases them on a web page. Most parts of the functionality work smoothly like filtering, however, there is an issue when attempting to add new objects by requesting a new "page ...

Vue.js is unable to render the template using Object

During this demonstration at https://jsfiddle.net/ccforward/fa35a2cc/, I encountered an issue where the template could not render and the data in resultWrong remained empty with a value of {} At https://jsfiddle.net/ccforward/zoo6xzc ...

Generate random floating numbers at intervals and calculate their sum

I've been given a task to complete. Upon page load, there should be 10 fields labeled as A, B, C, D ... each with the initial value of 3. After the page has loaded, every 2 seconds all field values should change randomly. The change will be a rand ...

Setting up Stylelint in a Vue 3 app with VSCode to automatically lint on save

I am looking to perform linting on my scss files and scss scope within .vue components. Here is what my configuration looks like in stylelint.config: module.exports = { extends: [ 'stylelint-config-standard', 'stylelint-config-rece ...

unable to install npm package on Azure cloud platform

My attempt to deploy my website to Azure has hit a roadblock as npm install is failing with the following error: 2498 silly fetchPackageMetaData error for interactjs@git+https://github.com/taye/interact.js.git#v1.3.0-alpha.4 Command failed: D:\Prog ...

Ensure you have the correct loader specified for Laravel Mix

After compiling my assets import './bootstrap'; import './components'; const app = new Vue({ el: '#app' }); This is the content of my package.json file: { "private": true, "scripts": { "dev": "node node_module ...

Unable to bring in Vuex store into the request file

My goal is to trigger a mutation when a request is sent and a response is received. Here is my request file: import axios from 'axios' import router from '@/router' import _ from 'lodash' const instance = axios.create({ ...