improve details experiment
This commit is contained in:
@@ -1,5 +1,4 @@
|
|||||||
import { Node, mergeAttributes } from '@tiptap/core'
|
import { Node, mergeAttributes } from '@tiptap/core'
|
||||||
// import { update } from 'cypress/types/lodash'
|
|
||||||
|
|
||||||
export interface DetailsOptions {
|
export interface DetailsOptions {
|
||||||
HTMLAttributes: {
|
HTMLAttributes: {
|
||||||
@@ -33,7 +32,9 @@ export default Node.create({
|
|||||||
HTMLAttributes,
|
HTMLAttributes,
|
||||||
}) => {
|
}) => {
|
||||||
const item = document.createElement('details')
|
const item = document.createElement('details')
|
||||||
let open = false
|
|
||||||
|
// TODO: Why does that have to be true?
|
||||||
|
let open = true
|
||||||
|
|
||||||
item.addEventListener('click', event => {
|
item.addEventListener('click', event => {
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
@@ -58,24 +59,8 @@ export default Node.create({
|
|||||||
dom: item,
|
dom: item,
|
||||||
contentDOM: item,
|
contentDOM: item,
|
||||||
ignoreMutation: (updatedNode: MutationRecord) => {
|
ignoreMutation: (updatedNode: MutationRecord) => {
|
||||||
// @ts-ignore
|
|
||||||
console.log({ updatedNode }, 'ignoreMutation', updatedNode.attributeName === 'open')
|
|
||||||
|
|
||||||
return updatedNode.attributeName === 'open'
|
return updatedNode.attributeName === 'open'
|
||||||
},
|
},
|
||||||
// update: updatedNode => {
|
|
||||||
// if (updatedNode.type !== this.type) {
|
|
||||||
// return false
|
|
||||||
// }
|
|
||||||
|
|
||||||
// if (updatedNode.attrs.open) {
|
|
||||||
// item.setAttribute('open', 'open')
|
|
||||||
// } else {
|
|
||||||
// item.removeAttribute('open')
|
|
||||||
// }
|
|
||||||
|
|
||||||
// return true
|
|
||||||
// },
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -31,7 +31,7 @@ export default {
|
|||||||
],
|
],
|
||||||
content: `
|
content: `
|
||||||
<p>Here is a details list:</p>
|
<p>Here is a details list:</p>
|
||||||
<details open>
|
<details>
|
||||||
<summary>An open details tag</summary>
|
<summary>An open details tag</summary>
|
||||||
<p>More info about the details.</p>
|
<p>More info about the details.</p>
|
||||||
</details>
|
</details>
|
||||||
|
|||||||
Reference in New Issue
Block a user