File tree Expand file tree Collapse file tree 2 files changed +1
-24
lines changed Expand file tree Collapse file tree 2 files changed +1
-24
lines changed Original file line number Diff line number Diff line change 11/* global code_snippets_editor_atts */
22
33window . code_snippets_editor = ( function ( CodeMirror , editor_atts ) {
4- const snippet_form = document . getElementById ( 'snippet-form' ) ;
5-
64 const save_snippet_cb = ( cm ) => document . getElementById ( 'save_snippet' ) . click ( ) ;
75
86 editor_atts [ 'extraKeys' ] = window . navigator . platform . match ( 'Mac' ) ?
@@ -13,21 +11,6 @@ window.code_snippets_editor = (function (CodeMirror, editor_atts) {
1311 document . querySelector ( '.editor-help-text' ) . className += ' platform-mac' ;
1412 }
1513
16- const editor = CodeMirror . fromTextArea ( document . getElementById ( 'snippet_code' ) , editor_atts ) ;
17-
18- // set the cursor to the previous position
19- let matches = window . location . href . match ( / [ ? & ] c u r s o r _ l i n e = ( \d + ) & c u r s o r _ c h = ( \d + ) / ) ;
20- if ( matches ) {
21- editor . focus ( ) ;
22- editor . setCursor ( { line : matches [ 1 ] , ch : matches [ 2 ] } ) ;
23- }
24-
25- // send the current cursor position to the next page
26- snippet_form . addEventListener ( 'submit' , ( ) => {
27- const cursor = editor . getCursor ( ) ;
28- snippet_form . insertAdjacentHTML ( 'beforeend' , `<input type="hidden" name="snippet_editor_cursor_line" value="${ cursor . line } ">` ) ;
29- snippet_form . insertAdjacentHTML ( 'beforeend' , `<input type="hidden" name="snippet_editor_cursor_ch" value="${ cursor . ch } ">` ) ;
30- } ) ;
14+ return CodeMirror . fromTextArea ( document . getElementById ( 'snippet_code' ) , editor_atts ) ;
3115
32- return editor ;
3316} ) ( window . Code_Snippets_CodeMirror , code_snippets_editor_atts ) ;
Original file line number Diff line number Diff line change @@ -288,12 +288,6 @@ private function save_posted_snippet() {
288288 code_snippets ()->get_menu_url ( 'edit ' )
289289 );
290290
291- if ( isset ( $ _POST ['snippet_editor_cursor_line ' ], $ _POST ['snippet_editor_cursor_ch ' ] ) &&
292- is_numeric ( $ _POST ['snippet_editor_cursor_line ' ] ) && is_numeric ( $ _POST ['snippet_editor_cursor_ch ' ] ) ) {
293- $ redirect_uri = add_query_arg ( 'cursor_line ' , intval ( $ _POST ['snippet_editor_cursor_line ' ] ), $ redirect_uri );
294- $ redirect_uri = add_query_arg ( 'cursor_ch ' , intval ( $ _POST ['snippet_editor_cursor_ch ' ] ), $ redirect_uri );
295- }
296-
297291 wp_redirect ( esc_url_raw ( $ redirect_uri ) );
298292 exit ;
299293 }
You can’t perform that action at this time.
0 commit comments