improve details experiment

This commit is contained in:
Hans Pagel 2021-02-11 00:15:35 +01:00
parent a6c1e2e20f
commit bd6233a1a1
2 changed files with 4 additions and 19 deletions

View File

@ -1,5 +1,4 @@
import { Node, mergeAttributes } from '@tiptap/core'
// import { update } from 'cypress/types/lodash'
export interface DetailsOptions {
HTMLAttributes: {
@ -33,7 +32,9 @@ export default Node.create({
HTMLAttributes,
}) => {
const item = document.createElement('details')
let open = false
// TODO: Why does that have to be true?
let open = true
item.addEventListener('click', event => {
// @ts-ignore
@ -58,24 +59,8 @@ export default Node.create({
dom: item,
contentDOM: item,
ignoreMutation: (updatedNode: MutationRecord) => {
// @ts-ignore
console.log({ updatedNode }, 'ignoreMutation', 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
// },
}
}
},

View File

@ -31,7 +31,7 @@ export default {
],
content: `
<p>Here is a details list:</p>
<details open>
<details>
<summary>An open details tag</summary>
<p>More info about the details.</p>
</details>