mirror of https://github.com/fantasticit/think.git
feat: add taskItemClickable options
This commit is contained in:
parent
ffd3f80284
commit
253e07e6db
|
@ -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);
|
||||||
|
|
||||||
|
|
|
@ -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;
|
||||||
|
|
Loading…
Reference in New Issue