2021-08-16 09:09:05 +00:00
|
|
|
import { TaskItem } from '@tiptap/extension-task-item';
|
2021-08-25 18:11:33 +00:00
|
|
|
import { PARSE_HTML_PRIORITY_HIGHEST } from '../constants';
|
2021-08-16 09:09:05 +00:00
|
|
|
|
|
|
|
export default TaskItem.extend({
|
2021-11-18 18:14:27 +00:00
|
|
|
addOptions() {
|
|
|
|
return {
|
|
|
|
nested: true,
|
|
|
|
HTMLAttributes: {},
|
|
|
|
};
|
2021-08-16 09:09:05 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
addAttributes() {
|
|
|
|
return {
|
|
|
|
checked: {
|
|
|
|
default: false,
|
|
|
|
parseHTML: (element) => {
|
|
|
|
const checkbox = element.querySelector('input[type=checkbox].task-list-item-checkbox');
|
2021-09-16 15:12:47 +00:00
|
|
|
|
|
|
|
return checkbox?.checked;
|
2021-08-16 09:09:05 +00:00
|
|
|
},
|
|
|
|
renderHTML: (attributes) => ({
|
|
|
|
'data-checked': attributes.checked,
|
|
|
|
}),
|
|
|
|
keepOnSplit: false,
|
|
|
|
},
|
|
|
|
};
|
|
|
|
},
|
|
|
|
|
|
|
|
parseHTML() {
|
|
|
|
return [
|
|
|
|
{
|
|
|
|
tag: 'li.task-list-item',
|
2021-08-25 18:11:33 +00:00
|
|
|
priority: PARSE_HTML_PRIORITY_HIGHEST,
|
2021-08-16 09:09:05 +00:00
|
|
|
},
|
|
|
|
];
|
|
|
|
},
|
|
|
|
});
|