diff --git a/index.html b/index.html
index dc222f3..ff7efae 100644
--- a/index.html
+++ b/index.html
@@ -327,7 +327,7 @@
-
+
@@ -347,7 +347,7 @@
src="js/ui/floating/history.js?v=fc92d14"
type="text/javascript">
diff --git a/js/lib/commands.d.js b/js/lib/commands.d.js
index 5ac16a8..a5d5c91 100644
--- a/js/lib/commands.d.js
+++ b/js/lib/commands.d.js
@@ -9,12 +9,21 @@
* @property {{[key: string]: any}} state The state of the current command instance
*/
+/**
+ * Extra command information
+ *
+ * @typedef CommandExtraParams
+ * @property {boolean} recordHistory The title passed to the command being run
+ * @property {Record} extra Extra information to be stored in the history entry
+ */
+
/**
* A command, which is run, then returns a CommandEntry object that can be used to manually undo/redo it
*
* @callback Command
* @param {string} title The title passed to the command being run
- * @param {*} options A options object for the command
+ * @param {any} options A options object for the command
+ * @param {CommandExtraParams} extra A options object for the command
* @returns {Promise}
*/
diff --git a/js/lib/commands.js b/js/lib/commands.js
index f665d1e..c805d38 100644
--- a/js/lib/commands.js
+++ b/js/lib/commands.js
@@ -74,10 +74,15 @@ const commands = makeReadOnly(
* @param {string} name Command identifier (name)
* @param {CommandDoCallback} run A method that performs the action for the first time
* @param {CommandUndoCallback} undo A method that reverses what the run method did
- * @param {CommandDoCallback} redo A method that redoes the action after undone (default: run)
+ * @param {object} options Extra options
+ * @param {CommandDoCallback} options.redo A method that redoes the action after undone (default: run)
* @returns {Command}
*/
- createCommand(name, run, undo, redo = run) {
+ createCommand(name, run, undo, options = {}) {
+ defaultOpt(options, {
+ redo: run,
+ });
+
const command = async function runWrapper(title, options, extra) {
// Create copy of options and state object
const copy = {};
@@ -89,6 +94,7 @@ const commands = makeReadOnly(
id: guid(),
title,
state,
+ extra: extra.extra,
};
// Attempt to run command
@@ -176,11 +182,13 @@ const commands = makeReadOnly(
* @param {string} name The name of the command to run
* @param {string} title The display name of the command on the history panel view
* @param {any} options The options to be sent to the command to be run
+ * @param {CommandExtraParams} extra Extra running options
* @return {Promise<{undo: () => void, redo: () => void}>} The command's return value
*/
async runCommand(name, title, options = null, extra = {}) {
defaultOpt(extra, {
recordHistory: true,
+ extra: {},
});
if (!this._types[name])
throw new ReferenceError(`[commands] Command '${name}' does not exist`);
diff --git a/js/ui/floating/layers.js b/js/ui/floating/layers.js
index 6682453..4f1bddb 100644
--- a/js/ui/floating/layers.js
+++ b/js/ui/floating/layers.js
@@ -531,9 +531,11 @@ commands.createCommand(
state.drawCommand.undo();
state.delCommand.undo();
},
- (title, options, state) => {
- state.drawCommand.redo();
- state.delCommand.redo();
+ {
+ redo: (title, options, state) => {
+ state.drawCommand.redo();
+ state.delCommand.redo();
+ },
}
);
diff --git a/pages/embed.test.html b/pages/embed.test.html
index 94fce93..729eacd 100644
--- a/pages/embed.test.html
+++ b/pages/embed.test.html
@@ -8,8 +8,8 @@