Data exchange of docx files


My requirement is to click the button to copy all the contents of file A on the right to the cursor of file B on the left. How should it be implemented?

This is a partial code block that I have implemented

insertElement() {
      var projectEditorConnector = this.projectEditor.createConnector();
      var elementEditorConnector = this.elementEditor.createConnector();
      elementEditorConnector.callCommand(
        function () {
          sessionStorage.removeItem("elementTemp");
          var oDocument = Api.GetDocument();
          sessionStorage.setItem(
            "elementTemp",
            oDocument.ToJSON(true, true, true, true, true, true)
          );
        },
        function () {
          console.log("callback command");
        }
      );
      projectEditorConnector.callCommand(
        function () {
          var oDocument = Api.GetDocument();
          var json = Api.FromJSON(sessionStorage.getItem("elementTemp"));
          oDocument.InsertContent(json);
        },
        function () {
          console.log("callback command");
        }
      );
    }

I have reviewed the document introducing the global variable GlobalVariable, but I may report an error stating that GlobalVariable is not defined, so I used sessionStorage. Is there a better solution to implement it?

Even so, if I configure config. type=“embedded”, the above method cannot be implemented, and callCommand will not execute

Please do not create additional posts on the same question: Js代码怎么执行宏代码,或者调用宏呢?
If you have additional information, you can provide it to original topic.