Tui.editor: Errors When Using CDN

Created on 13 Dec 2020  路  5Comments  路  Source: nhn/tui.editor

Code:

<!DOCTYPE html>
<html>
<head>
    <script src="https://uicdn.toast.com/editor/latest/toastui-editor-all.min.js"></script>
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.48.4/codemirror.min.css" />
    <link rel="stylesheet" href="https://uicdn.toast.com/editor/latest/toastui-editor.min.css" />
</head>
<body>
    <div id="editor"></div>
    <script>
        const editor = new toastui.Editor({
            el: document.querySelector('#editor'),
            height: '600px',
            initialEditType: 'markdown',
            previewStyle: 'vertical'
        });
    </script>
</body>
</html>

Errors:

Uncaught TypeError: Cannot read property 'appendChild' of null

Uncaught TypeError: toastui.Editor is not a constructor

OS: Windows 10
Browser: Chrome (latest version)

Bug

Most helpful comment

FWIW, same issue and above note was very helpful https://jsfiddle.net/rrjanbiah/9ytodkbx/

All 5 comments

Seems to work in JSFiddle though.

if I move everything to the body it works

Closing this issue, as even though the docs don't work, no response, and I found a solution

FWIW, same issue and above note was very helpful https://jsfiddle.net/rrjanbiah/9ytodkbx/

The cdn script should be placen inside your body tag, better at the end of your page and problem solved

Was this page helpful?
0 / 5 - 0 ratings

Related issues

existme picture existme  路  3Comments

Rorke76753 picture Rorke76753  路  4Comments

Yeongjae-Shin picture Yeongjae-Shin  路  3Comments

koliyo picture koliyo  路  4Comments

gincheong picture gincheong  路  4Comments