diff --git a/src/nodes/Details.js b/src/nodes/Details.js index 66109d21f17..cd305a50fc1 100644 --- a/src/nodes/Details.js +++ b/src/nodes/Details.js @@ -71,7 +71,7 @@ const Details = Node.create({ addAttributes() { return { - open: { + openDetails: { default: false, }, } @@ -123,7 +123,7 @@ const Details = Node.create({ }, { type: this.name, attrs: { - open: true, + openDetails: true, }, content: [ { type: 'detailsSummary' }, @@ -176,8 +176,8 @@ const Details = Node.create({ } const details = detailsParentInfo($from, schema) - if (!details.node.attrs.open) { - editor.commands.updateAttributes('details', { open: true }) + if (!details.node.attrs.openDetails) { + editor.commands.updateAttributes('details', { openDetails: true }) } const detailsContent = detailsContentNode(details.node, schema) diff --git a/src/nodes/DetailsView.vue b/src/nodes/DetailsView.vue index 07573147c2b..ccfb236c65f 100644 --- a/src/nodes/DetailsView.vue +++ b/src/nodes/DetailsView.vue @@ -11,11 +11,11 @@ - + @@ -34,6 +34,12 @@ export default { TriangleSmallDownIcon, }, + data() { + return { + open: false, + } + }, + props: { node: { type: Object, @@ -45,17 +51,43 @@ export default { }, }, + /* computed: { isOpen() { return this.node.attrs.open }, }, + */ + + beforeMount() { + if (this.node.attrs.openDetails) { + this.open = true + this.updateAttributes({ + openDetails: false + }) + } + }, + + watch: { + 'node.attrs.openDetails'(val) { + if (val) { + console.debug('watch node.attrs.openDetails') + this.open = true + this.updateAttributes({ + openDetails: false + }) + } + } + }, methods: { toggleOpen() { + this.open = !this.open + /* this.updateAttributes({ open: !this.isOpen, }) + */ }, }, }