How to use the tinymce.PluginManager 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 cwrc / CWRC-WriterBase / src / js / tinymce_plugins / schematags.js View on Github external
'use strict';

var $ = require('jquery');
var tinymce = require('tinymce');
require('jquery-watermark');


tinymce.PluginManager.add('schematags', function(editor) {
    
    // re-implementing tinymce.ui.Menu to use dialogWrapper and so that we can set autohide
    tinymce.ui.Factory.add('cwrcmenu', tinymce.ui.FloatPanel.extend({
        Defaults: {
            defaultType: 'menuitem',
            border: 1,
            layout: 'stack',
            role: 'application',
            bodyRole: 'menu',
            ariaRoot: true
        },

        init: function(settings) {
            var self = this;

            settings.autohide = settings.autohide == undefined ? true : settings.autohide;
github cwrc / CWRC-WriterBase / src / js / tinymce_plugins / treepaste.js View on Github external
// defaults to "combined"
                    // Convert single line breaks to <br> and double line breaks to <p>...</p>
                    process([
                        [/\n\n/g, "<p></p><p>"],
                        [/^(.*&lt;\/p&gt;)(</p><p>)$/, '</p><p>$1'],
                        [/\n/g, "<br>"]
                    ]);
                }

                ed.execCommand('mceInsertContent', false, content);
            }
        }
    });

    // Register plugin
    tinymce.PluginManager.add("treepaste", tinymce.plugins.TreePastePlugin);
})();
</p>
github cwrc / CWRC-WriterBase / src / js / tinymce_plugins / prevent_delete.js View on Github external
function deleteConfirm(editor, element) {
    editor.writer.dialogManager.confirm({
        title: 'Warning',
        msg: `<p>Delete "${element.getAttribute('_tag')}" element?</p>`,
        showConfirmKey: 'confirm-delete-tag',
        type: 'info',
        callback: function(doIt) {
            if (doIt) {
                editor.writer.tagger.removeStructureTag(element.getAttribute('id'), false);
            }
        }
    })
}

tinymce.PluginManager.add('preventdelete', function(ed) {
    ed.on('keydown', function(evt) {
        if (keyWillDelete(evt)) {
            var range = ed.selection.getRng()

            // deleting individual characters
            if (range.collapsed &amp;&amp; range.commonAncestorContainer.nodeType === Node.TEXT_NODE) {
                // backspace
                if (evt.keyCode === 8) {
                    // start of element
                    if (range.startOffset === 0) {
                        deleteConfirm(ed, range.commonAncestorContainer.parentElement);
                        return cancelKey(evt)
                    }
                    
                    if (range.startOffset === 1 &amp;&amp; range.commonAncestorContainer.textContent.length === 1) {
                        if (range.commonAncestorContainer.textContent.charCodeAt(0) === 65279) {
github jirokun / survey-designer-js / lib / editor / tinymce_plugins / form.js View on Github external
/* eslint-env browser */
import React from 'react';
import { render } from 'react-dom';
import tinymce from 'tinymce';
import S from 'string';
import FormEditor from './FormEditor';

tinymce.PluginManager.add('form_editor', (editor) => {
  editor.addButton('form_editor', {
    text: 'Form',
    icon: false,
    onclick: () => {
      function selectElement(e) {
        e.preventDefault();
        e.stopPropagation();
        e.target.ownerDocument.removeEventListener('click', selectElement, true);
        const nodeName = e.target.nodeName;
        switch (nodeName) {
          case 'INPUT':
          case 'TEXTAREA':
          case 'SELECT':
            break;
          default:
            alert('選択した要素はフォームの要素ではありません');
github jirokun / survey-designer-js / lib / editor / tinymce_plugins / reference.js View on Github external
import tinymce from 'tinymce';
import S from 'string';
import '../../constants/tinymce_ja';

tinymce.PluginManager.add('reference_answer', (editor) => {
  editor.addButton('reference_answer', {
    text: '再掲',
    icon: false,
    onclick: () => {
      const survey = editor.settings.survey;
      const outputDefinitions = editor.settings.outputDefinitions;
      const outputDefinitionIdValues = outputDefinitions
        .map(od => ({ text: od.getLabelWithOutputNo(), value: od.getId() })).toArray();
      editor.windowManager.open({
        title: '再掲',
        // bodyの作り方は次のURLを参照
        // https://makina-corpus.com/blog/metier/2016/how-to-create-a-custom-dialog-in-tinymce-4
        body: [
          { type: 'listbox', name: 'outputDefinitionId', label: '参照する設問', values: outputDefinitionIdValues },
        ],
        onsubmit: (e) => {
github cwrc / CWRC-WriterBase / src / js / tinymce_plugins / cwrc_contextmenu.js View on Github external
'use strict';

var tinymce = require('tinymce');
var $ = require('jquery');

tinymce.PluginManager.add('cwrc_contextmenu', function(editor) {
    var menu, items, contextmenuNeverUseNative = editor.settings.contextmenu_never_use_native;
    
    var isNativeOverrideKeyEvent = function (e) {
        return e.ctrlKey && !contextmenuNeverUseNative;
    };

    var isMacWebKit = function () {
        return tinymce.Env.mac && tinymce.Env.webkit;
    };

    /**
     * This takes care of a os x native issue where it expands the selection
     * to the word at the caret position to do "lookups". Since we are overriding
     * the context menu we also need to override this expanding so the behavior becomes
     * normalized. Firefox on os x doesn't expand to the word when using the context menu.
     */
github joostory / tistory-editor / src / renderer / components / editor / tinymce / plugins / file-upload / index.js View on Github external
import tinymce from 'tinymce'
import plugin from './plugin'

tinymce.PluginManager.add('file-upload', plugin)
github cwrc / DEPRECATED-CWRC-Writer / src / js / tinymce_plugins / cwrc_path.js View on Github external
'use strict';

var tinymce = require('tinymce');

tinymce.PluginManager.add('cwrcpath', function(editor) {
    tinymce.ui.CWRCPath = tinymce.ui.Path.extend({
        postRender: function() {
            var self = this;

            function isHidden(elm) {
                if (elm.nodeType === 1) {
                    if (elm.nodeName == "BR" || !!elm.getAttribute('data-mce-bogus')) {
                        return true;
                    }

                    if (elm.getAttribute('data-mce-type') === 'bookmark') {
                        return true;
                    }
                }

                return false;
github cwrc / CWRC-WriterBase / src / js / tinymce_plugins / cwrc_path.js View on Github external
'use strict';

var tinymce = require('tinymce');

tinymce.PluginManager.add('cwrcpath', function(editor) {
    tinymce.ui.CWRCPath = tinymce.ui.Path.extend({
        postRender: function() {
            var self = this;

            function isHidden(elm) {
                if (elm.nodeType === 1) {
                    if (elm.nodeName == "BR" || !!elm.getAttribute('data-mce-bogus')) {
                        return true;
                    }

                    if (elm.getAttribute('data-mce-type') === 'bookmark') {
                        return true;
                    }
                }

                return false;
github cwrc / CWRC-WriterBase / src / js / tinymce_plugins / viewsource.js View on Github external
'use strict';

var $ = require('jquery');
var tinymce = require('tinymce');
    
tinymce.PluginManager.add('viewsource', function(editor) {
    
    function htmlEncode(str) {
        return str.replace(/[&amp;&lt;&gt;"']/g, function($0) {
            return "&amp;" + {"&amp;":"amp", "&lt;":"lt", "&gt;":"gt", '"':"quot", "'":"#39"}[$0] + ";";
        });
    }
    
    $(document.body).append(''+
        '<div id="viewSourceDialog">'+
        '</div>'
    );
        
    var d = $('#viewSourceDialog');
    d.dialog({
        title: 'View Source',
        modal: true,