tiptap: support just disable edit

This commit is contained in:
fantasticit 2022-04-27 16:39:31 +08:00
parent 2ad45a880e
commit 775172a61c
4 changed files with 28 additions and 8 deletions

View File

@ -134,8 +134,9 @@ export const MindWrapper = ({ editor, node, updateAttributes }) => {
minder.execCommand('zoom', parseInt(zoom));
if (!isEditable) {
minder.disable();
minder.preventEdit = true;
} else {
minder.preventEdit = false;
minder.enable();
}
@ -172,8 +173,9 @@ export const MindWrapper = ({ editor, node, updateAttributes }) => {
if (!minder) return;
if (!isEditable) {
minder.disable();
minder.preventEdit = true;
} else {
minder.preventEdit = false;
minder.enable();
}
}, [isEditable]);

View File

@ -26,7 +26,7 @@ define(function (require, exports, module) {
return {
useTemplate: function (name, duration) {
this.setTemplate(name);
this.refresh(duration || 500);
this.refresh(duration || 800);
},
getTemplate: function () {
@ -68,7 +68,6 @@ define(function (require, exports, module) {
};
})()
);
let timer = null;
Module.register('TemplateModule', {
/**
@ -86,10 +85,7 @@ define(function (require, exports, module) {
execute: function (minder, name) {
minder.useTemplate(name);
clearTimeout(timer);
timer = setTimeout(() => {
minder.execCommand('camera');
}, 550);
},
queryValue: function (minder) {

View File

@ -14,9 +14,18 @@ define(function (require, exports, module) {
var minder = this.minder;
var receiver = this.receiver;
var container = this.container;
if (minder.preventEdit) {
return;
}
var hotbox = new Hotbox(container);
hotbox.setParentFSM(fsm);
fsm.when('normal -> hotbox', function (exit, enter, reason) {
if (minder.preventEdit) {
return;
}
var node = minder.getSelectedNode();
var position;
if (node) {

View File

@ -19,6 +19,11 @@ define(function (require, exports, module) {
var receiver = this.receiver;
var receiverElement = receiver.element;
var isGecko = window.kity.Browser.gecko;
if (minder.disableEdit) {
return;
}
// setup everything to go
setupReciverElement();
setupFsm();
@ -91,6 +96,10 @@ define(function (require, exports, module) {
*/
// edit for the selected node
function editText() {
if (minder.preventEdit) {
return;
}
var node = minder.getSelectedNode();
if (!node) {
return;
@ -120,6 +129,10 @@ define(function (require, exports, module) {
* @Date 2015-12-2
*/
function enterInputMode() {
if (minder.preventEdit) {
return;
}
var node = minder.getSelectedNode();
if (node) {
var fontSize = node.getData('font-size') || node.getStyle('font-size');