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 1
1
/* global code_snippets_editor_atts */
2
2
3
3
window . code_snippets_editor = ( function ( CodeMirror , editor_atts ) {
4
- const snippet_form = document . getElementById ( 'snippet-form' ) ;
5
-
6
4
const save_snippet_cb = ( cm ) => document . getElementById ( 'save_snippet' ) . click ( ) ;
7
5
8
6
editor_atts [ 'extraKeys' ] = window . navigator . platform . match ( 'Mac' ) ?
@@ -13,21 +11,6 @@ window.code_snippets_editor = (function (CodeMirror, editor_atts) {
13
11
document . querySelector ( '.editor-help-text' ) . className += ' platform-mac' ;
14
12
}
15
13
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 ) ;
31
15
32
- return editor ;
33
16
} ) ( 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() {
288
288
code_snippets ()->get_menu_url ( 'edit ' )
289
289
);
290
290
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
-
297
291
wp_redirect ( esc_url_raw ( $ redirect_uri ) );
298
292
exit ;
299
293
}
You can’t perform that action at this time.
0 commit comments