From 0eeebeb6b1dcec1618caa74e6452c57cf151ac5e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=94=A6=E5=BF=83?= <41134017+Lhcfl@users.noreply.github.com> Date: Mon, 22 Jul 2024 15:53:30 +0800 Subject: [PATCH] DEV: add @submit hook for ace editor (#28010) * DEV: add @commit hook for ace editor Add @commit hook to AceEditor to handle "save and run" in Data Explorer --- .../javascripts/discourse/app/components/ace-editor.js | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/app/assets/javascripts/discourse/app/components/ace-editor.js b/app/assets/javascripts/discourse/app/components/ace-editor.js index ac40995d624..17fe7a6d193 100644 --- a/app/assets/javascripts/discourse/app/components/ace-editor.js +++ b/app/assets/javascripts/discourse/app/components/ace-editor.js @@ -136,6 +136,15 @@ export default class AceEditor extends Component { bindKey: { mac: "cmd-s", win: "ctrl-s" }, }); } + if (this.submit) { + editor.commands.addCommand({ + name: "submit", + exec: () => { + this.submit(); + }, + bindKey: { mac: "cmd-enter", win: "ctrl-enter" }, + }); + } editor.on("blur", () => { this.warnSCSSDeprecations();