function createSerializationListener(workspace, textAreaId) {
  const textArea = document.getElementById(textAreaId);
  return (e) => {
    if (workspace.isDragging()) return;
    textArea.value = JSON.stringify(
      Blockly.serialization.workspaces.save(workspace),
      undefined,
      2,
    );
  };
}
Returns an event listener that serializes the given workspace to JSON and
outputs it to the text area with the given ID.
@param {!Blockly.Workspace} workspace The workspace to serialize.
@param {string} textAreaId The ID of the text area to output to.
@returns {function(Blockly.Events.Abstract)} The listener.