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),
getCollaborationCursorExtension(provider, user),
],
editorProps: {
// @ts-ignore
taskItemClickable: true,
},
});
const [loading, toggleLoading] = useToggle(true);

View File

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