How to use the tinymce/tinymce.Env function in tinymce

To help you get started, we’ve selected a few tinymce examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github Automattic / wp-calypso / client / components / tinymce / index.jsx View on Github external
focusEditor = () => {
		if ( this.props.mode === 'html' ) {
			const textNode = this.textInput.current;

			// Collapse selection to avoid scrolling to the bottom of the textarea
			if ( this.state.selection ) {
				this.selectTextInTextArea( this.state.selection );
			} else {
				textNode.setSelectionRange( 0, 0 );
			}

			// Browser is not Internet Explorer 11
			if ( 11 !== tinymce.Env.ie ) {
				textNode.focus();
			}
		} else if ( this._editor ) {
			this._editor.focus();
		}
	};
github Automattic / wp-calypso / client / components / tinymce / plugins / wpeditimage / plugin.js View on Github external
} else if ( node.nodeName === 'IMG' || node.nodeName === 'DT' || node.nodeName === 'A' ) {
				wrap = dom.getParent( node, 'div.mceTemp' );
			}

			if ( wrap ) {
				dom.events.cancel( event );
				removeImage( node );
				return false;
			}
		}
	} );

	// After undo/redo FF seems to set the image height very slowly when it is set to 'auto' in the CSS.
	// This causes image.getBoundingClientRect() to return wrong values and the resize handles are shown in wrong places.
	// Collapse the selection to remove the resize handles.
	if ( tinymce.Env.gecko ) {
		editor.on( 'undo redo', function() {
			if ( editor.selection.getNode().nodeName === 'IMG' ) {
				editor.selection.collapse();
			}
		} );
	}

	editor.wpSetImgCaption = function( content ) {
		return parseShortcode( content );
	};

	editor.wpGetImgCaption = function( content ) {
		return getShortcode( content );
	};

	editor.on( 'BeforeSetContent', function( event ) {
github Automattic / wp-calypso / client / components / tinymce / plugins / wpcom / plugin.js View on Github external
editor.on( 'init', function() {
		var env = tinymce.Env,
			bodyClass = [ 'mceContentBody' ], // back-compat for themes that use this in editor-style.css...
			doc = editor.getDoc(),
			dom = editor.dom;

		if ( tinymce.Env.iOS ) {
			dom.addClass( doc.documentElement, 'ios' );
		}

		if ( editor.getParam( 'directionality' ) === 'rtl' ) {
			bodyClass.push( 'rtl' );
			dom.setAttrib( doc.documentElement, 'dir', 'rtl' );
		}

		if ( env.ie ) {
			if ( parseInt( env.ie, 10 ) === 9 ) {
				bodyClass.push( 'ie9' );
			} else if ( parseInt( env.ie, 10 ) === 8 ) {
				bodyClass.push( 'ie8' );
			} else if ( env.ie < 8 ) {
				bodyClass.push( 'ie7' );
			}
github Automattic / wp-calypso / client / components / tinymce / plugins / wpcom-autoresize / plugin.js View on Github external
parseInt( marginTop, 10 ) +
			parseInt( marginBottom, 10 ) +
			parseInt( paddingTop, 10 ) +
			parseInt( paddingBottom, 10 ) +
			parseInt( borderTop, 10 ) +
			parseInt( borderBottom, 10 );

		// IE < 11, other?
		if ( myHeight && myHeight < docElm.offsetHeight ) {
			myHeight = docElm.offsetHeight;
		}

		// Make sure we have a valid height
		if ( isNaN( myHeight ) || myHeight <= 0 ) {
			// Get height differently depending on the browser used
			if ( tinymce.Env.ie ) {
				myHeight = body.scrollHeight;
			} else if ( tinymce.Env.webkit && body.clientHeight === 0 ) {
				myHeight = 0;
			} else {
				myHeight = body.offsetHeight;
			}
		}

		// Don't make it smaller than the minimum height
		if ( myHeight > settings.autoresize_min_height ) {
			resizeHeight = myHeight;
		}

		// If a maximum height has been defined don't exceed this height
		if ( settings.autoresize_max_height && myHeight > settings.autoresize_max_height ) {
			resizeHeight = settings.autoresize_max_height;
github Automattic / wp-calypso / client / components / tinymce / plugins / wpcom-autoresize / plugin.js View on Github external
parseInt( paddingTop, 10 ) +
			parseInt( paddingBottom, 10 ) +
			parseInt( borderTop, 10 ) +
			parseInt( borderBottom, 10 );

		// IE < 11, other?
		if ( myHeight && myHeight < docElm.offsetHeight ) {
			myHeight = docElm.offsetHeight;
		}

		// Make sure we have a valid height
		if ( isNaN( myHeight ) || myHeight <= 0 ) {
			// Get height differently depending on the browser used
			if ( tinymce.Env.ie ) {
				myHeight = body.scrollHeight;
			} else if ( tinymce.Env.webkit && body.clientHeight === 0 ) {
				myHeight = 0;
			} else {
				myHeight = body.offsetHeight;
			}
		}

		// Don't make it smaller than the minimum height
		if ( myHeight > settings.autoresize_min_height ) {
			resizeHeight = myHeight;
		}

		// If a maximum height has been defined don't exceed this height
		if ( settings.autoresize_max_height && myHeight > settings.autoresize_max_height ) {
			resizeHeight = settings.autoresize_max_height;
			body.style.overflowY = 'auto';
			docElm.style.overflowY = 'auto'; // Old IE
github Automattic / wp-calypso / client / components / tinymce / plugins / wpcom / plugin.js View on Github external
editor.on( 'PastePreProcess', function( event ) {
				// Remove trailing <br> added by WebKit browsers to the clipboard
				event.content = event.content.replace( /<br class="?Apple-interchange-newline">/gi, '' );

				// In WebKit this is handled by removeWebKitStyles()
				if ( ! tinymce.Env.webkit ) {
					// Remove all inline styles
					event.content = event.content.replace( /(&lt;[^&gt;]+) style="[^"]*"([^&gt;]*&gt;)/gi, '$1$2' );

					// Put back the internal styles
					event.content = event.content.replace(
						/(&lt;[^&gt;]+) data-mce-style=([^&gt;]+&gt;)/gi,
						'$1 style=$2'
					);
				}
			} );
github Automattic / wp-calypso / client / components / tinymce / plugins / wpcom / plugin.js View on Github external
editor.on( 'init', function() {
		var env = tinymce.Env,
			bodyClass = [ 'mceContentBody' ], // back-compat for themes that use this in editor-style.css...
			doc = editor.getDoc(),
			dom = editor.dom;

		if ( tinymce.Env.iOS ) {
			dom.addClass( doc.documentElement, 'ios' );
		}

		if ( editor.getParam( 'directionality' ) === 'rtl' ) {
			bodyClass.push( 'rtl' );
			dom.setAttrib( doc.documentElement, 'dir', 'rtl' );
		}

		if ( env.ie ) {
			if ( parseInt( env.ie, 10 ) === 9 ) {
				bodyClass.push( 'ie9' );
github Automattic / wp-calypso / client / components / tinymce / plugins / wpcom-view / plugin.js View on Github external
function wpview( editor ) {
	let $ = editor.$,
		selected,
		Env = tinymce.Env,
		VK = tinymce.util.VK,
		TreeWalker = tinymce.dom.TreeWalker,
		toRemove = false,
		firstFocus = true,
		isios = /iPad|iPod|iPhone/.test( navigator.userAgent ),
		cursorInterval,
		lastKeyDownNode,
		setViewCursorTries,
		focus,
		execCommandView,
		execCommandBefore,
		toolbar;

	/**
	 * Replaces all marker nodes tied to this view instance.
	 *
github Automattic / wp-calypso / client / components / tinymce / plugins / wpcom / plugin.js View on Github external
editor.on( 'ExecCommand', function( e ) {
		if (
			tinymce.Env.webkit &&
			style &&
			( 'InsertUnorderedList' === e.command || 'InsertOrderedList' === e.command )
		) {
			editor.dom.remove( style );
		}
	} );
github Automattic / wp-calypso / client / components / tinymce / plugins / wpcom / plugin.js View on Github external
moretext +
						'" ' +
						'class="wp-more-tag mce-wp-more" title="' +
						title +
						'" data-mce-resize="false" data-mce-placeholder="1" /&gt;'
					);
				} );
			}

			if ( event.content.indexOf( '' ) !== -1 ) {
				title = translate( 'Page break' );

				event.content = event.content.replace(
					//g,
					'<img data-mce-placeholder="1" data-mce-resize="false" class="wp-more-tag mce-wp-nextpage" data-wp-more="nextpage" src="' +
						tinymce.Env.transparentSrc +
						'">'
				);
			}

			if ( event.load &amp;&amp; event.format !== 'raw' ) {
				event.content = wpautop( event.content );
			}
		}
	} );