function test_setHtmlContents() { const quillEditor = new Quill('#editor'); const html = "<b>this is a bold text</b>"; const delta = quillEditor.clipboard.convert(html); quillEditor.setContents(delta); quillEditor.clipboard.convert(); }
function test_formatLine3() { const quillEditor = new Quill('#editor'); quillEditor.formatLine(1, 3, { align: 'right', bold: false, }); }
function test_formatText2() { const quillEditor = new Quill('#editor'); quillEditor.formatText(0, 5, { bold: false, color: 'rgb(0, 0, 255)' }); }
function test_setContents() { const quillEditor = new Quill('#editor'); quillEditor.setContents(new Delta({ ops: [ { insert: 'Hello ' }, { insert: 'World!', attributes: { bold: true } }, { insert: '\n' } ]})); }
function test_formatText4() { const quillEditor = new Quill('#editor'); const range = {index: 0, length: 5}; quillEditor.formatText(range, { bold: false, color: 'rgb(0, 0, 255)' }); }
function test_updateContents() { const quillEditor = new Quill('#editor'); quillEditor.updateContents(new Delta({ ops: [ { retain: 6 }, // Keep 'Hello ' { delete: 5 }, // 'World' is deleted { insert: 'Quill' }, // Insert 'Quill' { retain: 1, attributes: { bold: true } } // Apply bold to exclamation mark ] })); }
function test_getSelection() { const quillEditor = new Quill('#editor'); const range = quillEditor.getSelection(); if (range) { if (range.index === range.length) { console.log('User cursor is at index', range.index); } else { const text = quillEditor.getText(range.index, range.length); console.log('User has highlighted: ', text); } } else { console.log('User cursor is not in editor'); } }
function test_on_Events() { const textChangeHandler = (newDelta: DeltaStatic, oldDelta: DeltaStatic, source: string) => { }; const selectionChangeHandler = (newRange: RangeStatic, oldRange: RangeStatic, source: string) => { }; const editorChangeHandler = (name: string, ...args: any[]) => { }; const quillEditor = new Quill('#editor'); quillEditor .on('text-change', textChangeHandler) .off('text-change', textChangeHandler) .once('text-change', textChangeHandler) .on('selection-change', selectionChangeHandler) .off('selection-change', selectionChangeHandler) .once('selection-change', selectionChangeHandler) .on('editor-change', editorChangeHandler) .off('editor-change', editorChangeHandler) .once('editor-change', editorChangeHandler); }
function test_formatText() { const quillEditor = new Quill('#editor'); quillEditor.formatText(0, 5, 'bold', true); }
function test_insertText() { const quillEditor = new Quill('#editor'); quillEditor.insertText(0, "Hello World"); }