execute(command, options = {}) {
        const { silent = false, undoable = true } = options;

        if (this.isExecuting) return;
        this.isExecuting = true;

        try {
            if (typeof command === 'string') {
                const factory = this.commandFactories.get(command);
                if (!factory) throw new Error(`Unknown command: ${command}`);
                command = factory();
            }

            // Check if there's an active transaction
            if (this.transactionStack.length > 0) {
                // If there is, add the command to the current transaction
                this.transactionStack[this.transactionStack.length - 1].push(command);
                return; // Don't execute the command yet
            }

            const result = command.execute();

            if (undoable) {
                const currentTime = Date.now();
                if (this.undoStack.length > 0 && 
                    currentTime - this.lastExecutionTime < this.mergeWindow &&
                    command.canMerge && 
                    command.canMerge(this.undoStack[this.undoStack.length - 1])) {
                    const mergedCommand = command.merge(this.undoStack.pop());
                    this.undoStack.push(mergedCommand);
                } else {
                    this.undoStack.push(command);
                }

                this.lastExecutionTime = currentTime;
                this.redoStack = [];

                if (this.undoStack.length > this.maxStackSize) {
                    this.undoStack.shift();
                }

                if (this.undoStack.length % this.snapshotInterval === 0) {
                    this.createSnapshot();
                }

                if (this.undoStack.length > this.compressThreshold) {
                    this.compressHistory();
                }
            }

            if (!silent) this.notifyListeners();

            return result;
        } catch (error) {
            console.error("Error executing command:", error);
            throw error;
        } finally {
            this.isExecuting = false;
        }
    }
Executes a command and optionally adds it to the undo stack.

@param {Command|string} command - The command to execute. Can be a Command object or a string identifier for a registered command.
@param {Object} [options={}] - Execution options.
@param {boolean} [options.silent=false] - If true, suppresses notification to listeners after execution.
@param {boolean} [options.undoable=true] - If false, the command will not be added to the undo stack.
@returns {*} The result of the command execution, if any.
@throws {Error} If an unknown command string is provided or if command execution fails.

@description
This method performs the following steps:
1. Checks if a command is already being executed to prevent recursion.
2. If the command is a string, it looks up and instantiates the corresponding Command object.
3. Executes the command and captures its result.
4. If undoable, attempts to merge the command with the previous one if conditions are met.
5. If undoable, adds the command to the undo stack and clears the redo stack.
6. If undoable, manages the undo stack size, creates snapshots, and compresses history if necessary.
7. Notifies listeners of the state change unless silent mode is enabled.

@example
// Execute a command object (undoable by default)
undoRedoManager.execute(new SomeCommand());

// Execute a registered command by name (undoable by default)
undoRedoManager.execute('someRegisteredCommand');

// Execute silently (without notifying listeners)
undoRedoManager.execute(someCommand, { silent: true });

// Execute non-undoable command
undoRedoManager.execute(someCommand, { undoable: false });