How to use the tinymce/tinymce.init 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 oroinc / platform / src / Oro / Bundle / FormBundle / Resources / public / js / app / views / wysiwig-editor / wysiwyg-editor-view.js View on Github external
}
            }
            this._deferredRender();
            const options = this.options;
            if ($(this.$el).prop('disabled') || $(this.$el).prop('readonly')) {
                options.readonly = true;
            }

            _.each(this.options.pluginsMap, function(url, name) {
                url = location.origin + '/' + this.options.assets_base_url + url;
                if (this.options.plugins.indexOf(name) !== -1) {
                    tinyMCE.PluginManager.load(name, url);
                }
            }, this);

            tinyMCE.init(_.extend({
                target: this.el,
                setup: function(editor) {
                    editor.on('keydown', function(e) {
                        if (e.keyCode === 27) {
                            _.defer(function() {
                                // action is deferred to give time for tinymce to process the event by itself first
                                self.$el.trigger(e);
                            });
                        }
                    });
                    editor.on('change', function() {
                        editor.save({no_events: true});
                    });
                    editor.on('SetContent', function() {
                        editor.save({no_events: true});
                    });
github rinvex / cortex / resources / js / app.js View on Github external
});

    $('.sidebar').animate({ scrollTop: sidebarScrolPosition }, 0);

    // This is a workaround to handle the SPA nature of turbolinks
    window.BookableRangeReady = true;
    $(document).trigger('bookablerange.ready');

    // Persist page scroll position
    if (Turbolinks.scroll.top) {
        document.documentElement.scrollTop = Turbolinks.scroll.top;
        Turbolinks.scroll = {};
    }

    // Initialize the tinymce
    TinyMCE.init({
        selector: '.tinymce',
        skin_url: '/tinymce/ui/oxide',
        plugins: "image imagetools",
        toolbar: "undo redo | styleselect | bold italic | alignleft aligncenter alignright alignjustify | outdent indent | image",
        content_css: '/tinymce/ui/oxide/content.css'
    });

    // Initialize dropzone(s)
    $('.dropzone').dropzone({
        parallelUploads: 1,
        init: function() {
            this.on('queuecomplete', function(file) {
                window.location = routes.route(
                    window.Accessarea + '.' + window.location.pathname.split('/')[2] + '.index'
                );
            });
github onespacemedia / project-template / {{cookiecutter.repo_name}} / {{cookiecutter.package_name}} / assets / js / frontend-editing / wysiwyg.js View on Github external
export default function ({ selector }) {
  tinymce.baseURL = '/static/tinymce'
  const settings = JSON.parse(document.querySelector(selector).dataset.wysSettings)
  settings.selector = selector

  tinymce.init(settings)
}
github Automattic / wp-calypso / client / components / tinymce / index.jsx View on Github external
if ( store ) {
			const state = store.getState();

			localeSlug = getCurrentLocaleSlug( state );
			isRtl = isLocaleRtl( localeSlug );
			colorScheme = getPreference( state, 'colorScheme' );
		}

		this.localize( isRtl, localeSlug );

		const ltrButton = isRtl ? 'ltr,' : '';
		const gutenbergClassName = isGutenbergClassicBlock ? ' is-gutenberg' : '';
		const spellchecker = isVipSite ? ',spellchecker' : '';

		tinymce.init( {
			selector: '#' + this._id,
			skin_url: '/calypso/tinymce/skins/lightgray',
			skin: 'lightgray',
			content_css: CONTENT_CSS,
			language: localeSlug,
			language_url: DUMMY_LANG_URL,
			directionality: isRtl ? 'rtl' : 'ltr',
			formats: {
				alignleft: [
					{
						selector: 'p,h1,h2,h3,h4,h5,h6,td,th,div,ul,ol,li',
						styles: { textAlign: 'left' },
					},
					{
						selector: 'img,table,dl.wp-caption',
						classes: 'alignleft',
github DMPRoadmap / roadmap / app / javascript / utils / tinymce.js View on Github external
init(options = {}) {
    if (isObject(options)) {
      tinymce.init($.extend(true, defaultOptions, options)).then(resizeEditors);
    } else {
      tinymce.init(defaultOptions).then(resizeEditors);
    }
  },
  /*
github keystonejs / keystone / packages / fields-wysiwyg-tinymce / src / views / Editor.js View on Github external
auto_focus: autoFocus,
      plugins: plugins || defaultPlugins,
      readonly: isDisabled,
      target: elementRef.current,
      toolbar: toolbar || defaultToolbar,
      setup: editor => {
        editorRef.current = editor;
        editor.on('init', () => {
          if (typeof value === 'string') {
            editor.setContent(value);
          }
          editor.on('change keyup setcontent', handleChange);
        });
      },
    };
    tinymce.init(options);

    return () => {
      tinymce.remove(editorRef.current);
    };
  }, [plugins, toolbar]);
github ia-toki / judgels / judgels-frontends / raphael / src / components / forms / FormRichTextArea / TinyMCETextArea.tsx View on Github external
componentDidMount() {
    if (tinymce) {
      tinymce.init({
        selector: '.tinymce',
        skin_url: '/skins/lightgray',
        content_css: '/skins/raphael/content.css',
        branding: false,
        menubar: false,
        plugins: 'code image link lists table',
        toolbar:
          'bold italic underline strikethrough subscript superscript blockquote removeformat | ' +
          'bullist numlist | outdent indent | ' +
          'alignleft aligncenter alignright alignjustify | ' +
          'image link table | ' +
          'styleselect formatselect | ' +
          'code',
        setup: editor => {
          editor.on('change', () => {
            this.props.onChange(editor.getContent());
github Automattic / wp-calypso / client / extensions / woocommerce / components / compact-tinymce / index.js View on Github external
};

		const store = this.reduxStore;
		let isRtl = false;
		let localeSlug = 'en';

		if ( store ) {
			const state = store.getState();

			localeSlug = getCurrentLocaleSlug( state );
			isRtl = isLocaleRtl( localeSlug );
		}

		this.localize( isRtl, localeSlug );

		tinymce.init( {
			selector: '#' + this._id,
			skin_url: '/calypso/tinymce/skins/lightgray',
			skin: 'lightgray',
			body_class: 'description',
			content_css: '/calypso/tinymce/skins/woocommerce/content.css',
			language: localeSlug,
			language_url: this.DUMMY_LANG_URL,
			directionality: isRtl ? 'rtl' : 'ltr',
			relative_urls: false,
			remove_script_host: false,
			convert_urls: false,
			browser_spellcheck: true,
			fix_list_elements: true,
			keep_styles: false,
			textarea: this.textarea,
			preview_styles: 'font-family font-size font-weight font-style text-decoration text-transform',