|
@@ -44,13 +44,18 @@
|
|
|
import { defer } from 'utils/hueUtils';
|
|
import { defer } from 'utils/hueUtils';
|
|
|
import I18n from 'utils/i18n';
|
|
import I18n from 'utils/i18n';
|
|
|
|
|
|
|
|
|
|
+ //taken from https://www.cs.tut.fi/~jkorpela/chars/spaces.html
|
|
|
|
|
+ const UNICODES_TO_REMOVE = /[\u1680\u180E\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200A\u200B\u202F\u205F\u3000\uFEFF]/gi;
|
|
|
|
|
+
|
|
|
|
|
+ const removeUnicodes = (value: string) => value.replace(UNICODES_TO_REMOVE, ' ');
|
|
|
|
|
+
|
|
|
@Component({
|
|
@Component({
|
|
|
components: { AceAutocomplete },
|
|
components: { AceAutocomplete },
|
|
|
methods: { I18n }
|
|
methods: { I18n }
|
|
|
})
|
|
})
|
|
|
export default class AceEditor extends Vue {
|
|
export default class AceEditor extends Vue {
|
|
|
@Prop()
|
|
@Prop()
|
|
|
- value!: string;
|
|
|
|
|
|
|
+ initialValue!: string;
|
|
|
@Prop()
|
|
@Prop()
|
|
|
id!: string;
|
|
id!: string;
|
|
|
@Prop()
|
|
@Prop()
|
|
@@ -71,7 +76,7 @@
|
|
|
if (!editorElement) {
|
|
if (!editorElement) {
|
|
|
return;
|
|
return;
|
|
|
}
|
|
}
|
|
|
- editorElement.textContent = this.value;
|
|
|
|
|
|
|
+ editorElement.textContent = this.initialValue;
|
|
|
const editor = <Ace.Editor>ace.edit(editorElement);
|
|
const editor = <Ace.Editor>ace.edit(editorElement);
|
|
|
|
|
|
|
|
const resizeAce = () => {
|
|
const resizeAce = () => {
|
|
@@ -298,6 +303,10 @@
|
|
|
// processErrorsAndWarnings('error', newErrors);
|
|
// processErrorsAndWarnings('error', newErrors);
|
|
|
// });
|
|
// });
|
|
|
|
|
|
|
|
|
|
+ const triggerChange = () => {
|
|
|
|
|
+ this.$emit('value-changed', removeUnicodes(editor.getValue()));
|
|
|
|
|
+ };
|
|
|
|
|
+
|
|
|
editor.commands.addCommand({
|
|
editor.commands.addCommand({
|
|
|
name: 'execute',
|
|
name: 'execute',
|
|
|
bindKey: { win: 'Ctrl-Enter', mac: 'Command-Enter|Ctrl-Enter' },
|
|
bindKey: { win: 'Ctrl-Enter', mac: 'Command-Enter|Ctrl-Enter' },
|
|
@@ -306,12 +315,16 @@
|
|
|
this.aceLocationHandler.refreshStatementLocations();
|
|
this.aceLocationHandler.refreshStatementLocations();
|
|
|
}
|
|
}
|
|
|
if (this.editor && this.executor.activeExecutable) {
|
|
if (this.editor && this.executor.activeExecutable) {
|
|
|
|
|
+ triggerChange();
|
|
|
await this.executor.activeExecutable.reset();
|
|
await this.executor.activeExecutable.reset();
|
|
|
await this.executor.activeExecutable.execute();
|
|
await this.executor.activeExecutable.execute();
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
});
|
|
});
|
|
|
|
|
|
|
|
|
|
+ editor.on('change', triggerChange);
|
|
|
|
|
+ editor.on('blur', triggerChange);
|
|
|
|
|
+
|
|
|
window.setTimeout(() => {
|
|
window.setTimeout(() => {
|
|
|
this.$emit('ace-created', editor);
|
|
this.$emit('ace-created', editor);
|
|
|
}, 3000);
|
|
}, 3000);
|