Fix: 修复图形块转代码时中文变量和函数名未编码
This commit is contained in:
@@ -181,6 +181,10 @@ class EditorBlockly extends EditorBase {
|
|||||||
return $xml[0].outerHTML;
|
return $xml[0].outerHTML;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this.getRawCode = (workspace, generator) => {
|
||||||
|
return generator?.workspaceToCode(workspace) || '';
|
||||||
|
}
|
||||||
|
|
||||||
this.getCode = (workspace, generator) => {
|
this.getCode = (workspace, generator) => {
|
||||||
let code = generator?.workspaceToCode(workspace) || '';
|
let code = generator?.workspaceToCode(workspace) || '';
|
||||||
code = code.replace(/(_E[0-9A-F]{1}_[0-9A-F]{2}_[0-9A-F]{2})+/g, function (s) {
|
code = code.replace(/(_E[0-9A-F]{1}_[0-9A-F]{2}_[0-9A-F]{2})+/g, function (s) {
|
||||||
@@ -327,6 +331,11 @@ class EditorBlockly extends EditorBase {
|
|||||||
return EditorBlockly.getXML(workspace);
|
return EditorBlockly.getXML(workspace);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
getRawCode() {
|
||||||
|
const workspace = this.#getTargetWorkspace_();
|
||||||
|
return EditorBlockly.getRawCode(workspace, Blockly.generator);
|
||||||
|
}
|
||||||
|
|
||||||
getCode() {
|
getCode() {
|
||||||
const workspace = this.#getTargetWorkspace_();
|
const workspace = this.#getTargetWorkspace_();
|
||||||
return EditorBlockly.getCode(workspace, Blockly.generator);
|
return EditorBlockly.getCode(workspace, Blockly.generator);
|
||||||
|
|||||||
@@ -458,8 +458,8 @@ class EditorMix extends EditorBase {
|
|||||||
getCode() {
|
getCode() {
|
||||||
const blockPage = this.getPage('block');
|
const blockPage = this.getPage('block');
|
||||||
const codePage = this.getPage('code');
|
const codePage = this.getPage('code');
|
||||||
if (this.drag.shown === Drag.Extend.POSITIVE) {
|
if (this.drag.shown !== Drag.Extend.NEGATIVE) {
|
||||||
return blockPage.getCode();
|
return blockPage.getRawCode();
|
||||||
} else {
|
} else {
|
||||||
return codePage.getCode();
|
return codePage.getCode();
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user