From 60771b2deddd4f54a0272ca2a2778580b9f67744 Mon Sep 17 00:00:00 2001 From: Matias Arriola Date: Mon, 20 Dec 2021 21:21:39 +0000 Subject: [PATCH] Merged in bugfix/undo-delete-and-tooltips (pull request #12) Bugfix/undo delete and tooltips * Fix undo delete: restore NodeModel original-like implementation * Fix empty tooltips (no text) Approved-by: Paulo Veiga --- packages/mindplot/src/components/model/NodeModel.js | 11 ++++++++++- .../src/components/widget/KeyboardShortcutTooltip.js | 9 ++++----- 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/packages/mindplot/src/components/model/NodeModel.js b/packages/mindplot/src/components/model/NodeModel.js index 363674bb..7744cf24 100644 --- a/packages/mindplot/src/components/model/NodeModel.js +++ b/packages/mindplot/src/components/model/NodeModel.js @@ -122,7 +122,16 @@ class NodeModel extends INodeModel { * @return {mindplot.model.NodeModel} an identical clone of the NodeModel */ clone() { - return cloneDeep(this); + const result = new NodeModel(this.getType(), this._mindmap); + result._children = this._children.map((node) => { + const cnode = node.clone(); + cnode._parent = result; + return cnode; + }); + + result._properties = cloneDeep(this._properties); + result._feature = cloneDeep(this._feature); + return result; } /** diff --git a/packages/mindplot/src/components/widget/KeyboardShortcutTooltip.js b/packages/mindplot/src/components/widget/KeyboardShortcutTooltip.js index 589ead51..aa016c14 100644 --- a/packages/mindplot/src/components/widget/KeyboardShortcutTooltip.js +++ b/packages/mindplot/src/components/widget/KeyboardShortcutTooltip.js @@ -31,20 +31,19 @@ class KeyboardShortcutTooltip extends FloatingTip { buttonElem.append(tipDiv); super(tipDiv, { - // Content can also be a function of the target element! - content: KeyboardShortcutTooltip._buildContent(), + // content can be a function or string + content: KeyboardShortcutTooltip._buildContent(text), html: true, placement: 'bottom', className: 'keyboardShortcutTip', template: '', }); - this._text = text; tipDiv.on('click', (e) => { tipDiv.trigger('mouseleave', e); }); } - static _buildContent() { + static _buildContent(text) { const result = $('
'); result.css({ padding: '3px 0px', @@ -52,7 +51,7 @@ class KeyboardShortcutTooltip extends FloatingTip { color: 'white', }); - const textContainer = $('
').text(this._text); + const textContainer = $('
').text(text); textContainer.css({ width: '100%', 'font-size': '90%',