From 9c30ab8a12dcaa0330b1b5e5d5711b44f5ec5981 Mon Sep 17 00:00:00 2001 From: Zhigang Zhang Date: Tue, 30 May 2023 20:40:03 +0800 Subject: [PATCH] relocate options of plugin (#474) --- example/2_features.html | 12 +++++++++--- src/jsmind.js | 2 +- src/jsmind.option.js | 1 + src/plugins/jsmind.draggable-node.js | 6 +++++- 4 files changed, 16 insertions(+), 5 deletions(-) diff --git a/example/2_features.html b/example/2_features.html index aed53a9c..6bd4b0d7 100644 --- a/example/2_features.html +++ b/example/2_features.html @@ -190,9 +190,15 @@ - - - + + + diff --git a/src/jsmind.js b/src/jsmind.js index ab580153..dfbe0c9e 100644 --- a/src/jsmind.js +++ b/src/jsmind.js @@ -78,7 +78,7 @@ export default class jsMind { this._event_bind(); - apply_plugins(this, this.options); + apply_plugins(this, this.options.plugin); } get_editable() { return this.options.editable; diff --git a/src/jsmind.option.js b/src/jsmind.option.js index f61ed59e..6b1653bf 100644 --- a/src/jsmind.option.js +++ b/src/jsmind.option.js @@ -58,6 +58,7 @@ const default_options = { down: 40, // Down }, }, + plugin: {}, }; export function merge_option(options) { diff --git a/src/plugins/jsmind.draggable-node.js b/src/plugins/jsmind.draggable-node.js index 47d5b9d0..5e71ed34 100644 --- a/src/plugins/jsmind.draggable-node.js +++ b/src/plugins/jsmind.draggable-node.js @@ -32,8 +32,12 @@ const DEFAULT_OPTIONS = { class DraggableNode { constructor(jm, options) { + var opts = {}; + jsMind.util.json.merge(opts, DEFAULT_OPTIONS); + jsMind.util.json.merge(opts, options); + this.jm = jm; - this.options = jsMind.util.json.merge(options || {}, DEFAULT_OPTIONS); + this.options = opts; this.e_canvas = null; this.canvas_ctx = null; this.shadow = null;