-
Notifications
You must be signed in to change notification settings - Fork 74
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3777 from 3scale/fix_codemirror_save
Fix codemirror save shortcut
- Loading branch information
Showing
3 changed files
with
15 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,20 @@ | ||
import CodeMirror from 'codemirror' | ||
import CodeMirror, { commands } from 'codemirror' | ||
import 'codemirror/addon/mode/overlay'// Seems to solve https://github.com/3scale/porta/blob/25fa9bc53bdd3eeb8f2a9c8e882f771c85c3c3cb/app/views/provider/admin/cms/_codemirror.html.erb#L34 | ||
import 'codemirror/mode/css/css' // Formats and styles for CSS; Used in CMS | ||
import 'codemirror/mode/htmlmixed/htmlmixed' // Formats and syles for HTML and Liquid; Used in CMS | ||
import 'codemirror/mode/javascript/javascript' // Formats and syles for JSON; Used in ActiveDocs and in CMS | ||
import 'codemirror/mode/xml/xml' // Formats and syles for XML | ||
|
||
/** | ||
* Adds a shortcut to "save" the codemirror editor. When Ctrl-S or Cmd-S is pressed, click Save | ||
* button. More info at https://codemirror.net/5/doc/manual.html#commands | ||
* TODO: the save button should really be disabled unless Codemirror has unsaved changes. | ||
*/ | ||
// @ts-expect-error -- Add a custom callback to "save" command. | ||
commands.save = () => { | ||
document | ||
.querySelector<HTMLInputElement>('#edit_cms_template #codemirror_save_button') | ||
?.click() | ||
} | ||
|
||
window.CodeMirror = CodeMirror |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
<div class="button-bar"> | ||
<%= f.actions :style => 'position:absolute' do %> | ||
<%= disable_sending_button %> | ||
<%= f.commit_button "#{@page.new_record? ? 'Create Email Template' : 'Save'}" %> | ||
<%= f.commit_button "#{@page.new_record? ? 'Create Email Template' : 'Save'}", button_html: { id: 'codemirror_save_button' } %> | ||
<% end %> | ||
</div> |