My First Playground

This is a playground to test JavaScript. It runs a completely standard copy of Node.js on a virtual server created just for you. Every one of npm’s 300,000+ packages are pre-installed, so try it out:
var jsdom = require("jsdom"); jsdom.env({ html: '<div id="editor-container"></div>', scripts: [ 'https://cdnjs.cloudflare.com/ajax/libs/webcomponentsjs/0.7.22/MutationObserver.js', 'https://cdn.quilljs.com/1.0.4/quill.js'], onload: function (window) { var document = window.document; // fake getSelection // https://github.com/tmpvar/jsdom/issues/317 document.getSelection = function() { return { getRangeAt: function() {} }; }; var container = window.document.getElementById("editor-container"); var quill = new window.Quill(container, {}); var delta = { ops: [ { insert: 'Gandalf', attributes: { bold: true } }, { insert: ' the ' }, { insert: 'Grey', attributes: { color: '#ccc' } } ] }; quill.setContents(delta); console.log(document.querySelector(".ql-editor").innerHTML); } });
Loading…

no comments

    sign in to comment