Block an element within the textarea

0

I need to block a part of a text that is inside ckeditor so that the user does not delete and does not change that part of the text, but it can complement the text only can not change that part

<p>Essa parte nao pode ser alterada</p> <p>Essa aqui pode</p>

Could it be some code css or javascript that blocks this change? Or would they have other shapes?

    
asked by anonymous 18.04.2018 / 17:12

1 answer

1

CKEditor is not <textarea> , it is contentEditable (or docMode ), anyway I think it is impossible to prevent the user from interacting with the element, because the control is all user contentEditable

What I recommend is to add the element later, for example when sending the form or saving the form data somewhere, assuming you use PHP, then just insert it when you got the data on the server, something like: p>

if (isset($_POST['dados'])) {
    $dados = $_POST['dados']; //Dados do textarea

    $dados .= '<div>Assinatura etc</div>'; //Adiciona uma assinatura
}

This is an example only to understand, in case of injecting into a specific place you can use DOMDocument::loadHTML to make HTML work with PHP and then use one of the following functions to select the exact location you want to inject a specific tag:

  • DOMDocument::getElementsByTagNameNS
  • DOMDocument::getElementsByTagName
  • DOMDocument::getElementById

Or use the DomXpath class to select (which is much more advanced and can simplify the job depending on the complexity of the selection type):

And then with one of the following functions:

Depends heavily on the need between these two.

    
18.04.2018 / 17:32