Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

In Ckeditor how to copy/get all formatting from a selected text

I am using CKEditor ver.3.6 in my Asp.net MVC 3 Application.

My requirement is to create Paint format option in the Google doc.I need to implement Paint format option in a ckeditor.

In Ckeditor how to copy/get all formatting such as font, font effects, centered paragraph alignment from a selected text(source) to a newly selected text (destination).

Please suggest a proper solution.

like image 509
amexn Avatar asked Jan 10 '12 05:01

amexn


People also ask

What is the output of CKEditor?

CKEditor 4 offers a flexible output formatting system that gives developers full control over what the HTML code produced by the editor will look like. It is possible to define: When to indent tags (each tag may have a different configuration) and which indentation method to use (tabs, spaces).

Where is CKEditor config file?

CKEditor 4 comes with a rich set of configuration options that make it possible to customize its appearance, features, and behavior. The main configuration file is named config. js . This file can be found in the root of the CKEditor 4 installation folder.

How do I delete a style in CKEditor?

Enable the RemoveFormatLinks plugin in the configuration and run the editor: ClassicEditor . create( ..., { plugins: [ RemoveFormat, RemoveFormatLinks, // ... ], toolbar: [ 'removeFormat', // ... ] } ) From now on, the the “Remove Format” button should also remove links in the content.


1 Answers

Use this function to replace the content of a selected html with the text in one field. On a button click, call this function:

function Replace()
 {  
     var sel = editor.getSelection();   
     var ele=sel.getStartElement();
     if(ele.hasAttributes())
     {
        var insertele= editor.document.createElement('span');
        ele.copyAttributes(insertele,{type:1,value:1})
        insertele.setHtml($("#repTxt").val());
        editor.insertElement(insertele);        
     }  

 }
like image 50
Sunil Raj Avatar answered Oct 13 '22 10:10

Sunil Raj