wp/wp-admin/js/editor.js
changeset 16 a86126ab1dd4
parent 9 177826044cd9
child 18 be944660c56a
--- a/wp/wp-admin/js/editor.js	Tue Oct 22 16:11:46 2019 +0200
+++ b/wp/wp-admin/js/editor.js	Tue Dec 15 13:49:49 2020 +0100
@@ -26,7 +26,7 @@
 				 *
 				 * @since 4.3.0
 				 *
-				 * @returns {void}
+				 * @return {void}
 				 */
 				$$( document ).on( 'click', function( event ) {
 					var id, mode,
@@ -47,7 +47,7 @@
 		 * @since 3.9.0
 		 *
 		 * @param {Object} editor The TinyMCE editor.
-		 * @returns {number} If the height is between 10 and 200 return the height,
+		 * @return {number} If the height is between 10 and 200 return the height,
 		 * else return 30.
 		 */
 		function getToolbarHeight( editor ) {
@@ -70,7 +70,7 @@
 		 *
 		 * @param {string} id The id of the editor you want to change the editor mode for. Default: `content`.
 		 * @param {string} mode The mode you want to switch to. Default: `toggle`.
-		 * @returns {void}
+		 * @return {void}
 		 */
 		function switchEditor( id, mode ) {
 			id = id || 'content';
@@ -112,7 +112,7 @@
 				}
 
 				if ( keepSelection ) {
-					// Save the selection
+					// Save the selection.
 					addHTMLBookmarkInTextAreaContent( $textarea );
 				}
 
@@ -131,7 +131,7 @@
 					}
 
 					if ( editor.getParam( 'wp_keep_scroll_position' ) ) {
-						// Restore the selection
+						// Restore the selection.
 						focusHTMLBookmarkInVisualEditor( editor );
 					}
 				} else {
@@ -149,7 +149,8 @@
 				}
 
 				if ( editor ) {
-					// Don't resize the textarea in iOS. The iframe is forced to 100% height there, we shouldn't match it.
+					// Don't resize the textarea in iOS.
+					// The iframe is forced to 100% height there, we shouldn't match it.
 					if ( ! tinymce.Env.iOS ) {
 						iframe = editor.iframeElement;
 						editorHeight = iframe ? parseInt( iframe.style.height, 10 ) : 0;
@@ -177,7 +178,8 @@
 						selectTextInTextArea( editor, selectionRange );
 					}
 				} else {
-					// There is probably a JS error on the page. The TinyMCE editor instance doesn't exist. Show the textarea.
+					// There is probably a JS error on the page.
+					// The TinyMCE editor instance doesn't exist. Show the textarea.
 					$textarea.css({ 'display': '', 'visibility': '' });
 				}
 
@@ -202,14 +204,14 @@
 		 * @param {string} content The test content where the cursor is.
 		 * @param {number} cursorPosition The cursor position inside the content.
 		 *
-		 * @returns {(null|Object)} Null if cursor is not in a tag, Object if the cursor is inside a tag.
+		 * @return {(null|Object)} Null if cursor is not in a tag, Object if the cursor is inside a tag.
 		 */
 		function getContainingTagInfo( content, cursorPosition ) {
 			var lastLtPos = content.lastIndexOf( '<', cursorPosition - 1 ),
 				lastGtPos = content.lastIndexOf( '>', cursorPosition );
 
 			if ( lastLtPos > lastGtPos || content.substr( cursorPosition, 1 ) === '>' ) {
-				// find what the tag is
+				// Find what the tag is.
 				var tagContent = content.substr( lastLtPos ),
 					tagMatch = tagContent.match( /<\s*(\/)?(\w+|\!-{2}.*-{2})/ );
 
@@ -222,7 +224,7 @@
 
 				return {
 					ltPos: lastLtPos,
-					gtPos: lastLtPos + closingGt + 1, // offset by one to get the position _after_ the character,
+					gtPos: lastLtPos + closingGt + 1, // Offset by one to get the position _after_ the character.
 					tagType: tagType,
 					isClosingTag: !! tagMatch[1]
 				};
@@ -248,7 +250,7 @@
 		 * @param {number} cursorPosition    The cursor position to check.
 		 *
 		 * @return {(undefined|Object)} Undefined if the cursor is not wrapped in a shortcode tag.
-		 *                                Information about the wrapping shortcode tag if it's wrapped in one.
+		 *                              Information about the wrapping shortcode tag if it's wrapped in one.
 		 */
 		function getShortcodeWrapperInfo( content, cursorPosition ) {
 			var contentShortcodes = getShortCodePositionsInText( content );
@@ -403,7 +405,7 @@
 
 			var cursorStart = cursorPositions.cursorStart,
 				cursorEnd = cursorPositions.cursorEnd,
-				// check if the cursor is in a tag and if so, adjust it
+				// Check if the cursor is in a tag and if so, adjust it.
 				isCursorStartInTag = getContainingTagInfo( content, cursorStart );
 
 			if ( isCursorStartInTag ) {
@@ -471,7 +473,7 @@
 		 * The method directly manipulates the `textarea` content, to allow TinyMCE plugins
 		 * to run after the markers are added.
 		 *
-		 * @param {object} $textarea TinyMCE's textarea wrapped as a DomQuery object
+		 * @param {Object} $textarea TinyMCE's textarea wrapped as a DomQuery object
 		 */
 		function addHTMLBookmarkInTextAreaContent( $textarea ) {
 			if ( ! $textarea || ! $textarea.length ) {
@@ -506,11 +508,11 @@
 			}
 
 			textArea.value = [
-				textArea.value.slice( 0, htmlModeCursorStartPosition ), // text until the cursor/selection position
-				cursorMarkerSkeleton.clone()							// cursor/selection start marker
+				textArea.value.slice( 0, htmlModeCursorStartPosition ), // Text until the cursor/selection position.
+				cursorMarkerSkeleton.clone()							// Cursor/selection start marker.
 					.addClass( 'mce_SELRES_start' )[0].outerHTML,
-				selectedText, 											// selected text with end cursor/position marker
-				textArea.value.slice( htmlModeCursorEndPosition )		// text from last cursor/selection position to end
+				selectedText, 											// Selected text with end cursor/position marker.
+				textArea.value.slice( htmlModeCursorEndPosition )		// Text from last cursor/selection position to end.
 			].join( '' );
 		}
 
@@ -559,7 +561,7 @@
 		 * By default TinyMCE wraps loose inline tags in a `<p>`.
 		 * When removing selection markers an empty `<p>` may be left behind, remove it.
 		 *
-		 * @param {object} $marker The marker to be removed from the editor DOM, wrapped in an instnce of `editor.$`
+		 * @param {Object} $marker The marker to be removed from the editor DOM, wrapped in an instnce of `editor.$`
 		 */
 		function removeSelectionMarker( $marker ) {
 			var $markerParent = $marker.parent();
@@ -658,8 +660,8 @@
 		 * Check the notes in the comments in the code below for more information on some gotchas
 		 * and why this solution was chosen.
 		 *
-		 * @param {Object} editor The editor where we must find the selection
-		 * @returns {(null|Object)} The selection range position in the editor
+		 * @param {Object} editor The editor where we must find the selection.
+		 * @return {(null|Object)} The selection range position in the editor.
 		 */
 		function findBookmarkedPosition( editor ) {
 			// Get the TinyMCE `window` reference, since we need to access the raw selection.
@@ -804,7 +806,7 @@
 					endMatchIndex -= endMatch[1].length;
 				}
 
-				// We need to adjust the end position to discard the length of the range start marker
+				// We need to adjust the end position to discard the length of the range start marker.
 				endIndex = endMatchIndex - startMatchLength;
 			}
 
@@ -826,7 +828,7 @@
 		 * @param {Object} selection Selection data.
 		 */
 		function selectTextInTextArea( editor, selection ) {
-			// only valid in the text area mode and if we have selection
+			// Only valid in the text area mode and if we have selection.
 			if ( ! selection ) {
 				return;
 			}
@@ -836,11 +838,11 @@
 				end = selection.end || selection.start;
 
 			if ( textArea.focus ) {
-				// Wait for the Visual editor to be hidden, then focus and scroll to the position
+				// Wait for the Visual editor to be hidden, then focus and scroll to the position.
 				setTimeout( function() {
 					textArea.setSelectionRange( start, end );
 					if ( textArea.blur ) {
-						// defocus before focusing
+						// Defocus before focusing.
 						textArea.blur();
 					}
 					textArea.focus();
@@ -1004,7 +1006,7 @@
 		 * @memberof switchEditors
 		 *
 		 * @param {string} text The text input.
-		 * @returns {string} The formatted text.
+		 * @return {string} The formatted text.
 		 */
 		function autop( text ) {
 			var preserve_linebreaks = false,
@@ -1130,8 +1132,8 @@
 		 *
 		 * @memberof switchEditors
 		 *
-		 * @param {String} html The content from the visual editor.
-		 * @returns {String} the filtered content.
+		 * @param {string} html The content from the visual editor.
+		 * @return {string} the filtered content.
 		 */
 		function pre_wpautop( html ) {
 			var obj = { o: exports, data: html, unfiltered: html };
@@ -1156,8 +1158,8 @@
 		 *
 		 * @memberof switchEditors
 		 *
-		 * @param {String} text The content from the text editor.
-		 * @returns {String} filtered content.
+		 * @param {string} text The content from the text editor.
+		 * @return {string} filtered content.
 		 */
 		function wpautop( text ) {
 			var obj = { o: exports, data: text, unfiltered: text };
@@ -1223,7 +1225,7 @@
 	 *
 	 * @param {string} id The HTML id of the textarea that is used for the editor.
 	 *                    Has to be jQuery compliant. No brackets, special chars, etc.
-	 * @param {object} settings Example:
+	 * @param {Object} settings Example:
 	 * settings = {
 	 *    // See https://www.tinymce.com/docs/configure/integration-and-setup/.
 	 *    // Alternatively set to `true` to use the defaults.
@@ -1249,7 +1251,7 @@
 
 		defaults = wp.editor.getDefaultSettings();
 
-		// Initialize TinyMCE by default
+		// Initialize TinyMCE by default.
 		if ( ! settings ) {
 			settings = {
 				tinymce: true