Ошибка «Literal содержит неэкранированный разрыв строки» при установке текста для TinyMCE из базы данных - PullRequest
0 голосов
/ 28 сентября 2019

Я пытаюсь вставить текст из базы данных в TinyMCEeditor, чтобы пользователь мог редактировать текст, но я получаю "" строковый литерал содержит неэкранированный разрыв строки ошибка в консоли.

Вот как я вставляю текст в TinyMCE

tinymce.init({
    selector:'textarea',
    automatic_uploads: false,
    browser_spellcheck: true,
    invalid_elements : "script, img, link, style, form, input, textarea, select, option",
    setup: function (ed) {
        ed.on("init", function (ed) {
            tinymce.get('content').setContent("{!! $content->content !!}");
            tinymce.execCommand('mceRepaint');
        });
    }
});

Вот как это выглядит в браузере

    tinymce.init({
        selector:'textarea',
        automatic_uploads: false,
        browser_spellcheck: true,
        invalid_elements : "script, img, link, style, form, input, textarea, select, option",
        setup: function (ed) {
            ed.on("init", function (ed) {
                tinymce.get('content').setContent("<h1>Alright, let's mafia things up a bit. Joey, burn down the ship. Clamps, burn down the crew.</h1>
<p>Uh, is the puppy mechanical in any way? The alien mothership is in orbit here. If we can hit that bullseye, the rest of the dominoes will fall like a house of cards. Checkmate. Bender! Ship! Stop bickering or I'm going to come back there and change your opinions manually!</p>
<p>That could be 'my' beautiful soul sitting naked on a couch. If I could just learn to play this stupid thing. Guess again. In our darkest hour, we can stand erect, with proud upthrust bosoms. <strong> Oh no!</strong> <em> The professor will hit me!</em> But if Zoidberg 'fixes' it&hellip; then perhaps gifts!</p>
<h2>I could if you hadn't turned on the light and shut off my stereo.</h2>
<p>Okay, it's 500 dollars, you have no choice of carrier, the battery can't hold the charge and the reception isn't very&hellip; We're also Santa Claus! This is the worst part. The calm before the battle.</p>
<ol>
<li>Ummm&hellip;to eBay?</li>
<li>No, just a regular mistake.</li>
<li>Can we have Bender Burgers again?</li>
</ol>");
                tinymce.execCommand('mceRepaint');
            });
        }
    });

Как исправить строковый литерал "", содержащийнеэкранированный разрыв строки ошибка?

1 Ответ

0 голосов
/ 29 сентября 2019

Исправлено с помощью функции PHP addlashes ().

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...