logo
down
shadow

Altering CKEditor HTML content after instanceReady and paste


Altering CKEditor HTML content after instanceReady and paste

By : Jingshu Fang
Date : November 16 2020, 06:23 AM
Does that help You should use CKEditor's dataProcessor.dataFilter. This is the standard mechanism used by the editor to filter input (JSFiddle). It handles data set with editor.setData, data pasted by the user and, of course, initial HTML from textarea or any element to which CKEditor is attached.
code :
CKEDITOR.replace( 'my-editor', {
    // See http://stackoverflow.com/a/15659962/1485219
    extraAllowedContent: 'span(readonly)',

    // Just to make the interface clear.
    toolbarGroups: [
        {"name":"document","groups":["mode"]},
        {"name":"basicstyles","groups":["basicstyles"]}
    ],
    on: {
        // When all plugins were loaded but editor data is not yet processed.
        pluginsLoaded: function( evt ) {
            // Add custom rule to dataFilter (when data comes *into* editor).
            this.dataProcessor.dataFilter.addRules( {
                elements: {
                    // Check all elements. Rules can be specific, i.e. for img or h2.
                    $: function( element ) {
                        if ( element.hasClass( 'readonly' ) ) {
                            element.attributes.contenteditable = "false";
                        }
                    }
                }
            } );
        }
    }
} );
// This plugin brings a widget into editor.
CKEDITOR.plugins.add( 'myFirstWidget', {
    // Widget plugin must be loaded (must be present in the build of CKEditor).
    requires: 'widget',

    init: function( editor ) {
        editor.widgets.add( 'myFirstWidget', {        
            button: 'My First Widget Button',

            // http://stackoverflow.com/a/15659962/1485219
            allowedContent: 'span(readonly)',                            
            requiredContent: 'span(readonly)',

            // Make all <span class="readonly"> a non-editable widget. 
            upcast: function( element ) {
                return element.name == 'span' && element.hasClass( 'readonly' );
            }
        } );        
    }
} );

CKEDITOR.replace( 'my-editor', {
    // Use the plugin.
    extraPlugins: 'myFirstWidget',

    // Just to make the interface clear.
    toolbar: [ [ 'Source', '-', 'MyFirstWidget' ] ]
} );


Share : facebook icon twitter icon
CKEditor on('paste') event doesn't have evt.data.html defined

CKEditor on('paste') event doesn't have evt.data.html defined


By : user3894424
Date : March 29 2020, 07:55 AM
I wish did fix the issue. Make sure that your config does not have CKEDITOR.config.forcePasteAsPlainText= true; as that effectively removes evt.data.html property leaving you only with evt.data.text to work with.
CKeditor remove all html tag except div,span on paste event

CKeditor remove all html tag except div,span on paste event


By : Ali Haidar
Date : March 29 2020, 07:55 AM
will help you I want to remove all html tags from CKeditor when user uses Ctrl+v to paste the content. Following is the code I've written. Not working as I expected. , Try this:
code :
function strip_tags(html, keepTags) {

    var ptn = new RegExp('<(?!\/?(' + keepTags.join('|') + '))[^>]+>', 'g');
    return html.replace(ptn, '');
}
Inject content/HTML without altering the DOM

Inject content/HTML without altering the DOM


By : Muhammad Zahid
Date : March 29 2020, 07:55 AM
wish help you to fix your issue After searching for a long time I finally found this page from Google Support themselves: Can Google Site Search index JavaScript content on my pages?
This is exactly what they say in that page... short answer: No, it cannot index content inside JavaScript:
CKEditor .focus() in instanceReady event is not working

CKEditor .focus() in instanceReady event is not working


By : niranjan niru
Date : March 29 2020, 07:55 AM
this one helps. I am having problems in setting the focus in instanceReady event of CKEditor 3.4.1. I have already tried the following two ways but both of them are not always working. , or maybe try this, this is much simpler:
use startupFocus : true
setReadOnly causes error when called on instanceReady of CKEditor

setReadOnly causes error when called on instanceReady of CKEditor


By : Disho
Date : March 29 2020, 07:55 AM
Does that help Two years later, but here is my solution. Maybe someone else will find it useful. As stated above, the event is appearantly triggered before the editable() function is fully set up, and therefore one solution is to simply wait for it to finish before setting it to readonly. This may be an ugly way to do it, but it works.
Related Posts Related Posts :
  • Looking for simplest option to render Razor cshtml pages in a console application without any web server
  • Evaluating variables at a specific time in Modelica
  • When I run the Application, only "web" engine is running in GlassFish. "webservices" is not started
  • How To Set MIME Type Of Google Drive File
  • Remove Missing Values in Weka
  • Reloading a UICollectionView using reloadData method returns immediately before reloading data
  • carrot2 - can I cluster documents from a folder?
  • StreamSocket has no Close Implementation in C#
  • Rails, Foundation 4, Respond.js not working properly in IE8
  • How can i create imagesurface from cairo xlib's Graphics Context using cairo and x11 Api's?
  • CKEditor "overflow: scroll" on parent causes toolbar to freeze at initial position
  • Differences between components and controls in ENYO
  • Photoshop making isometric?
  • Does Intel IPP 8.0 support in-place operations?
  • What is Object dictionary in CANOpen?
  • Example of orbBasic Indexed User Variables
  • convert to ABSOLUTE in logback
  • How to conditionally download file using p:fileDownload
  • Error on pod install
  • Set HTTP GET Parameters in Finagle
  • different attack that uses sql injection
  • How can I change my xampp username not as 'root'
  • AMQP Content header payload structure
  • Apache POI formula evaluation not working for Excel IF
  • How can I trace RESTEasy's dispatch?
  • Map Freezes on iOS 7 with Google Maps SDK 1.4
  • Comparing lists, is the subset list within the first list
  • Non-ascii character highlight in Sublime Text 2
  • Installing Magit in Aquamacs
  • Receiving error - System.Net.Mail.SmtpException: 4.3.2 try again later
  • Coreaudio render callback in monotouch
  • The command 'yarn --v' also initiates 'yarn install' and installs packages automatically. Why is this happening?
  • save multiple matches in a list (grep or awk)
  • Can a number register be used in a groff request?
  • Mapping FAQ with RASA for large dataset (2000+)
  • Fragment not receiving LiveData updates after remove + add
  • FitText.js makes text bigger rather than smaller
  • ARM - Implementing stack with load/store multiple register values
  • How to check if a ChromeCast Session is already in progress
  • ngForm inside a Carousel Slide in UI Bootstrap not working
  • Clearing attributes in Tritium
  • "vagrant up" failing: Vagrant VM failed to remain in the running state
  • ftsearch returning empty docs
  • What are the advantages of setting "hive.exec.parallel" to false in Hive ?
  • Creating a root certificate in FiddlerCore
  • How to access app.config in a blueprint?
  • DB2 RECORDSET table name converted to uppercase
  • Resizing the superview according to the subviews
  • IExpress - Disable Compression
  • Getting InvalidProtocolBufferException while running oozie job
  • What are the differences between Play run and start?
  • How can I share props in ReasonReact?
  • Task.Delay is skipped
  • Parsley.js Password Confirm doesn‘t work
  • How to get all registred 'browser:resource' in Plone
  • Overriding page_list controller inside a package in Concrete5.6.1.2
  • Robolectric 2.x - dependent jars are downloading while running the tests
  • Setting Flyout to Main Frame Navigation(Windows 8.1 app store)
  • Build project - Nuget Error
  • How to recover admin password for SonarQube
  • shadow
    Privacy Policy - Terms - Contact Us © ourworld-yourmove.org