feat: add taskItemClickable options

pull/24/head
fantasticit 2022-03-30 14:24:53 +08:00
parent ffd3f80284
commit 253e07e6db
2 changed files with 12 additions and 0 deletions

View File

@ -50,6 +50,10 @@ export const Editor: React.FC<IProps> = ({ user, documentId, document }) => {
getCollaborationExtension(provider), getCollaborationExtension(provider),
getCollaborationCursorExtension(provider, user), getCollaborationCursorExtension(provider, user),
], ],
editorProps: {
// @ts-ignore
taskItemClickable: true,
},
}); });
const [loading, toggleLoading] = useToggle(true); const [loading, toggleLoading] = useToggle(true);

View File

@ -64,6 +64,8 @@ const CustomTaskItem = BuiltInTaskItem.extend({
}, },
addProseMirrorPlugins() { addProseMirrorPlugins() {
const extensionThis = this;
return [ return [
new Plugin({ new Plugin({
props: { props: {
@ -86,6 +88,12 @@ const CustomTaskItem = BuiltInTaskItem.extend({
if (view.editable) { if (view.editable) {
const target = event.target as HTMLElement; const target = event.target as HTMLElement;
if (target.tagName.toLowerCase() !== 'span') return false; if (target.tagName.toLowerCase() !== 'span') return false;
} else {
// 非编辑模式,仅支持配置 taskItemClickable 可点击
// @ts-ignore
if (!extensionThis.editor.options.editorProps.taskItemClickable) {
return;
}
} }
const parentElement = element.parentElement; const parentElement = element.parentElement;