From f6548d4f97bf36e89d92c5119c8c1a1ada81d393 Mon Sep 17 00:00:00 2001 From: Hans Pagel Date: Wed, 17 Mar 2021 23:21:36 +0100 Subject: [PATCH] docs: update content --- .../Examples/InteractiveNodeViews/index.vue | 11 --- .../demos/Guide/NodeViews/JavaScript/index.js | 62 +++++++++++++++ .../Guide/NodeViews/JavaScript/index.vue | 77 +++++++++++++++++++ .../Guide/NodeViews/VueComponent/index.vue | 11 --- .../NodeViews/VueComponentContent/index.vue | 11 --- docs/src/docPages/guide/node-views/js.md | 18 ++++- 6 files changed, 156 insertions(+), 34 deletions(-) create mode 100644 docs/src/demos/Guide/NodeViews/JavaScript/index.js create mode 100644 docs/src/demos/Guide/NodeViews/JavaScript/index.vue diff --git a/docs/src/demos/Examples/InteractiveNodeViews/index.vue b/docs/src/demos/Examples/InteractiveNodeViews/index.vue index 2fcafcd9..51b8fc0c 100644 --- a/docs/src/demos/Examples/InteractiveNodeViews/index.vue +++ b/docs/src/demos/Examples/InteractiveNodeViews/index.vue @@ -49,15 +49,4 @@ export default { margin-top: 0.75em; } } - -.output { - background-color: #0D0D0D; - color: #fff; - padding: 1rem; - font-family: monospace; - font-size: 1.1rem; - border-radius: 0.5rem; - margin: 1rem 0; - position: relative; -} diff --git a/docs/src/demos/Guide/NodeViews/JavaScript/index.js b/docs/src/demos/Guide/NodeViews/JavaScript/index.js new file mode 100644 index 00000000..61d9ddfe --- /dev/null +++ b/docs/src/demos/Guide/NodeViews/JavaScript/index.js @@ -0,0 +1,62 @@ +import { Node, mergeAttributes } from '@tiptap/core' + +export default Node.create({ + name: 'nodeView', + + group: 'block', + + atom: true, + + addAttributes() { + return { + count: { + default: 0, + }, + } + }, + + parseHTML() { + return [ + { + tag: 'node-view', + }, + ] + }, + + renderHTML({ HTMLAttributes }) { + return ['node-view', mergeAttributes(HTMLAttributes)] + }, + + addNodeView() { + return ({ + editor, node, getPos, HTMLAttributes, decorations, extension, + }) => { + const dom = document.createElement('div') + dom.classList.add('node-view') + + const label = document.createElement('span') + label.classList.add('label') + label.innerHTML = 'Node View' + + const content = document.createElement('div') + content.classList.add('content') + content.innerHTML = 'I’m rendered with JavaScript.' + + dom.append(label, content) + + return { + dom, + } + } + }, +}) + +// +// Vue Component + +//
+// +//
+//
diff --git a/docs/src/demos/Guide/NodeViews/JavaScript/index.vue b/docs/src/demos/Guide/NodeViews/JavaScript/index.vue new file mode 100644 index 00000000..e2474ee1 --- /dev/null +++ b/docs/src/demos/Guide/NodeViews/JavaScript/index.vue @@ -0,0 +1,77 @@ + + + + + diff --git a/docs/src/demos/Guide/NodeViews/VueComponent/index.vue b/docs/src/demos/Guide/NodeViews/VueComponent/index.vue index 2fcafcd9..51b8fc0c 100644 --- a/docs/src/demos/Guide/NodeViews/VueComponent/index.vue +++ b/docs/src/demos/Guide/NodeViews/VueComponent/index.vue @@ -49,15 +49,4 @@ export default { margin-top: 0.75em; } } - -.output { - background-color: #0D0D0D; - color: #fff; - padding: 1rem; - font-family: monospace; - font-size: 1.1rem; - border-radius: 0.5rem; - margin: 1rem 0; - position: relative; -} diff --git a/docs/src/demos/Guide/NodeViews/VueComponentContent/index.vue b/docs/src/demos/Guide/NodeViews/VueComponentContent/index.vue index c8d2e072..50929663 100644 --- a/docs/src/demos/Guide/NodeViews/VueComponentContent/index.vue +++ b/docs/src/demos/Guide/NodeViews/VueComponentContent/index.vue @@ -51,15 +51,4 @@ export default { margin-top: 0.75em; } } - -.output { - background-color: #0D0D0D; - color: #fff; - padding: 1rem; - font-family: monospace; - font-size: 1.1rem; - border-radius: 0.5rem; - margin: 1rem 0; - position: relative; -} diff --git a/docs/src/docPages/guide/node-views/js.md b/docs/src/docPages/guide/node-views/js.md index 7352a12a..6aaa6da2 100644 --- a/docs/src/docPages/guide/node-views/js.md +++ b/docs/src/docPages/guide/node-views/js.md @@ -5,6 +5,7 @@ ## Introduction TODO +## Code snippet ```js import { Node } from '@tiptap/core' import { VueNodeViewRenderer } from '@tiptap/vue-2' @@ -20,7 +21,22 @@ export default Node.create({ return { dom, } - }) + } }, }) ``` + +## Render markup + + +## Access node attributes +TODO + +## Update node attributes +TODO + +## Adding a content editable +TODO + +## All available props +TODO