File tree Expand file tree Collapse file tree 1 file changed +16
-0
lines changed
src/LiveDevelopment/BrowserScripts Expand file tree Collapse file tree 1 file changed +16
-0
lines changed Original file line number Diff line number Diff line change @@ -2027,6 +2027,19 @@ function RemoteFunctions(config) {
20272027 return dismissed ;
20282028 }
20292029
2030+ /**
2031+ * This function is responsible to move the cursor to the end of the text content when we start editing
2032+ * @param {DOMElement } element
2033+ */
2034+ function moveCursorToEnd ( element ) {
2035+ const selection = window . getSelection ( ) ;
2036+ const range = document . createRange ( ) ;
2037+ range . selectNodeContents ( element ) ;
2038+ range . collapse ( false ) ;
2039+ selection . removeAllRanges ( ) ;
2040+ selection . addRange ( range ) ;
2041+ }
2042+
20302043 // Function to handle direct editing of elements in the live preview
20312044 function startEditing ( element ) {
20322045 if ( ! element ) {
@@ -2036,6 +2049,8 @@ function RemoteFunctions(config) {
20362049 // Make the element editable
20372050 element . setAttribute ( "contenteditable" , "true" ) ;
20382051 element . focus ( ) ;
2052+
2053+ moveCursorToEnd ( element ) ;
20392054 dismissMoreOptionsBox ( ) ;
20402055
20412056 element . _originalContent = cleanupElementProperties ( element ) ;
@@ -2137,6 +2152,7 @@ function RemoteFunctions(config) {
21372152
21382153 // Remove contenteditable attribute
21392154 element . removeAttribute ( "contenteditable" ) ;
2155+ dismissMoreOptionsBox ( ) ;
21402156
21412157 // Remove event listeners
21422158 if ( element . _editListeners ) {
You can’t perform that action at this time.
0 commit comments