Skip to content

Commit

Permalink
fix(details): Don't sync open state of details nodes
Browse files Browse the repository at this point in the history
Signed-off-by: Jonas <[email protected]>
  • Loading branch information
mejo- committed Aug 27, 2024
1 parent 005e19d commit 9d73c45
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 6 deletions.
8 changes: 4 additions & 4 deletions src/nodes/Details.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ const Details = Node.create({

addAttributes() {
return {
open: {
openDetails: {
default: false,
},
}
Expand Down Expand Up @@ -123,7 +123,7 @@ const Details = Node.create({
}, {
type: this.name,
attrs: {
open: true,
openDetails: true,
},
content: [
{ type: 'detailsSummary' },
Expand Down Expand Up @@ -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)
Expand Down
36 changes: 34 additions & 2 deletions src/nodes/DetailsView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@
<template #icon>
<TriangleSmallDownIcon :size="20"
class="button-open"
:class="{ 'open': isOpen }"
:class="{ 'open': open }"
@click="toggleOpen" />
</template>
</NcButton>
<NodeViewContent :class="{ 'is-hidden': !isOpen }" />
<NodeViewContent :class="{ 'is-hidden': !open }" />
</NodeViewWrapper>
</template>

Expand All @@ -34,6 +34,12 @@ export default {
TriangleSmallDownIcon,
},
data() {
return {
open: false,
}
},
props: {

Check warning on line 43 in src/nodes/DetailsView.vue

View workflow job for this annotation

GitHub Actions / NPM lint

The "props" property should be above the "data" property on line 37
node: {
type: Object,
Expand All @@ -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

Check warning on line 66 in src/nodes/DetailsView.vue

View workflow job for this annotation

GitHub Actions / NPM lint

Missing trailing comma
})
}
},
watch: {

Check warning on line 71 in src/nodes/DetailsView.vue

View workflow job for this annotation

GitHub Actions / NPM lint

The "watch" property should be above the "beforeMount" property on line 62
'node.attrs.openDetails'(val) {
if (val) {
console.debug('watch node.attrs.openDetails')
this.open = true
this.updateAttributes({
openDetails: false

Check warning on line 77 in src/nodes/DetailsView.vue

View workflow job for this annotation

GitHub Actions / NPM lint

Missing trailing comma
})
}
}

Check warning on line 80 in src/nodes/DetailsView.vue

View workflow job for this annotation

GitHub Actions / NPM lint

Missing trailing comma
},
methods: {
toggleOpen() {
this.open = !this.open
/*
this.updateAttributes({
open: !this.isOpen,
})
*/
},
},
}
Expand Down

0 comments on commit 9d73c45

Please sign in to comment.