From 18b6365308d63ef5aab49df7003eab5ed07849be Mon Sep 17 00:00:00 2001 From: ryanbliss Date: Mon, 6 Jan 2020 15:04:55 -0700 Subject: [PATCH 1/2] render(h) function support for TodoItem --- .../tiptap-extensions/src/nodes/TodoItem.js | 33 +++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/packages/tiptap-extensions/src/nodes/TodoItem.js b/packages/tiptap-extensions/src/nodes/TodoItem.js index ed9b47a54..4eb4f0e16 100644 --- a/packages/tiptap-extensions/src/nodes/TodoItem.js +++ b/packages/tiptap-extensions/src/nodes/TodoItem.js @@ -29,6 +29,39 @@ export default class TodoItem extends Node {
`, + /* + The render function enables TodoItem to work in `runtimeonly` builds, + which is required for frameworks requiring strict CSP policies. For + example, doing this is required in Chrome Extensions. Having both + the template and the render function ensures there are no issues + converting the node to JSON and rendering the component. + */ + render(h) { + return h('li', { + attrs: { + 'data-type': this.node.type.name, + 'data-done': this.node.attrs.done.toString(), + 'data-drag-handle': '', + }, + }, [ + h('span', { + class: 'todo-checkbox', + attrs: { + contenteditable: false, + }, + on: { + click: this.onChange, + }, + }), + h('div', { + class: 'todo-content', + attrs: { + contenteditable: this.view.editable.toString(), + }, + ref: 'content', + }), + ]); + }, } } From 8ed2de71cd6a3d017c24b7b3507485a4d5b82669 Mon Sep 17 00:00:00 2001 From: ryanbliss Date: Mon, 6 Jan 2020 15:13:20 -0700 Subject: [PATCH 2/2] removed a semicolon that was causing a lint error --- packages/tiptap-extensions/src/nodes/TodoItem.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/tiptap-extensions/src/nodes/TodoItem.js b/packages/tiptap-extensions/src/nodes/TodoItem.js index 4eb4f0e16..caa05cfca 100644 --- a/packages/tiptap-extensions/src/nodes/TodoItem.js +++ b/packages/tiptap-extensions/src/nodes/TodoItem.js @@ -60,7 +60,7 @@ export default class TodoItem extends Node { }, ref: 'content', }), - ]); + ]) }, } }