tiptap: support just disable edit

pull/31/head
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)); minder.execCommand('zoom', parseInt(zoom));
if (!isEditable) { if (!isEditable) {
minder.disable(); minder.preventEdit = true;
} else { } else {
minder.preventEdit = false;
minder.enable(); minder.enable();
} }
@ -172,8 +173,9 @@ export const MindWrapper = ({ editor, node, updateAttributes }) => {
if (!minder) return; if (!minder) return;
if (!isEditable) { if (!isEditable) {
minder.disable(); minder.preventEdit = true;
} else { } else {
minder.preventEdit = false;
minder.enable(); minder.enable();
} }
}, [isEditable]); }, [isEditable]);

View File

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

View File

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

View File

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