Code Monkey home page Code Monkey logo

ckeditor5-custom-element's People

Contributors

centaur54dev avatar routhinator avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

ckeditor5-custom-element's Issues

Adding property attributes to custom-element produces an error

Hi,

I'm working on an Angular project in which I need to implement a html-text-editor. I'm using the CKEditor. I've created a custom build so I can use your plugin in my project. Everything works fine until I try to add the property 'attributes' to my custom tag. This gives the following error in my console:

ckeditor-ckeditor5-angular.js:326 ReferenceError: attributeToAttribute is not defined
    at Zg.init (ckeditor.js:5)
    at ZoneDelegate.push../node_modules/zone.js/dist/zone.js.ZoneDelegate.invoke (zone.js:391)
    at Zone.push../node_modules/zone.js/dist/zone.js.Zone.run (zone.js:150)
    at zone.js:889
    at ZoneDelegate.push../node_modules/zone.js/dist/zone.js.ZoneDelegate.invokeTask (zone.js:423)
    at Zone.push../node_modules/zone.js/dist/zone.js.Zone.runTask (zone.js:195)
    at drainMicroTaskQueue (zone.js:601)

My CustomElement implementation is like this:

ClassicEditor.defaultConfig = {
    toolbar: {
        items: [
            'custom-element-tagname1'
        ]
    },
    CustomElement:{
        items:[
            {tag: 'tagname1', placeholder: 'some text', attributes:{name:'foo'}, inline:true, editable:false}
        ]
    },
}

elements broken after editing a second time

I have created an element:

CustomElement:{
    items:[
        {tag: 'div', placeholder: 'placeholder text',
            attributes:{class: 'bg-light' },
            inline:true, editable:false},
    ]
},

The class bg-light is simply to test with a background color.

All works when inserting and when I save the first time. However, when I want to edit again, my element is removed and in return I get:

<p><br data-cke-filler="true"></p>
<p>placeholder text</p>
<p><br data-cke-filler="true"></p>

Building from Source?

Hello and thanks for the amazing package
im using ckeditor with laravel, and building it with webpack (i know, maybe im kinda masochistic) and im having problem of duplicate packages when configuring my ckeditor.js.

`CKEditorError: ckeditor-duplicated-modules: Some CKEditor 5 modules are duplicated. Read more: https://ckeditor.com/docs/ckeditor5/latest/framework/guides/support/error-codes.html#error-ckeditor-duplicated-modules

at Module.<anonymous> (https://localhost/0.js:97925:9)
at Module../node_modules/ckeditor5-custom-element/node_modules/@ckeditor/ckeditor5-utils/src/version.js (https://localhost/0.js:97929:30)
at __webpack_require__ (https://localhost/js/app.js:64:30)
at Module../node_modules/ckeditor5-custom-element/node_modules/@ckeditor/ckeditor5-utils/src/emittermixin.js (https://localhost/0.js:95406:66)
at __webpack_require__ (https://localhost/js/app.js:64:30)
at Module../node_modules/ckeditor5-custom-element/node_modules/@ckeditor/ckeditor5-utils/src/observablemixin.js (https://localhost/0.js:96739:71)
at __webpack_require__ (https://localhost/js/app.js:64:30)
at Module../node_modules/ckeditor5-custom-element/node_modules/@ckeditor/ckeditor5-core/src/plugin.js (https://localhost/0.js:89797:103)
at __webpack_require__ (https://localhost/js/app.js:64:30)
at Module../node_modules/ckeditor5-custom-element/src/customelement.js (https://localhost/0.js:98199:93)`

my ckeditor works if removing the custom plugin, the problem seems related on how node reference the ck-editor libs defined into the plugin.
any insight on this?

Tag attributes doesn't apply

@centaur54dev

At the moment you cannot add attributes to tags.

It is because you wrongly mapped attributes to tags

for (let a=0; a<attrkeys.length; a++){
	editor.conversion.for( 'downcast' ).attributeToAttribute( ( {
		model: attrkeys[a],
		view: attrkeys[a],
		converterPriority: 'low'
	}));
	editor.conversion.for( 'upcast' ).add(attributeToAttribute({
		view: attrkeys[a],
		model: attrkeys[a],
		converterPriority: 'low'
	}));
}

In order to make it work, you should change it to

for (let a=0; a<attrkeys.length; a++){
	editor.conversion.for( 'downcast' ).attributeToAttribute({
		model: attrkeys[a],
		view: attrkeys[a],
		converterPriority: 'low'
	});
	editor.conversion.for( 'upcast' ).attributeToAttribute({
		view: attrkeys[a],
		model: attrkeys[a],
		converterPriority: 'low'
	});
}

Cannot resolve 'ckeditor5-custom-element'

When compiling in my webpack project, I get the error Module not found: Error: Can't resolve 'ckeditor5-custom-element'

I am importing the same as any node_module:
import CustomElementPlugin from 'ckeditor5-custom-element'

I noticed that your package.json points to 'customelement.js' as your main. However, you don't have a top level customelement.js, it's in 'src/customelement.js'. When I manually change your package.json in node_modules to use 'src/customelement.js' for main, I can use your library as normal.
"main": "src/customelement.js",

allowedAttributes not working

Hi,

I tried yours, but I dont find any allowed attributes working.

items: [
                {
                    tag: 'tagname1', 
                    placeholder: 'some text', 
                    attributes: {
                        name:'ABCD',

                    }, 
                    inline: true , 
                    editable: false
                }, 
.....

and I try to insert text by

var viewFragment = editor.data.processor.toView( content );
var modelFragment = editor.data.toModel( viewFragment );
editor.model.insertContent( modelFragment );

the result is only :
image

Could you please help me, what is wrong?

Thanks

Support safeHtml placeholder

I'm trying to create a pagebreak element that has an html placeholder with an FA Icon to display nicely to the user. Unfortunately the plugin is designed to always treat the placeholder as unsafe and escape it.

I propose that there be a flag to indicate that the placeholder should be treated as safeHTML.

For reference, this is the output I need to achieve:

<pagebreak><p style="text-align:center">--- <i class="fa fa-file-text-o"></i> ---</p></pagebreak>

This is the config I'm using:

  public ckEditorConfig = {
    toolbar: [
      'bold', 'italic', 'link', 'bulletedList', 'numberedList', 'blockQuote', 'code', 'alignment', 'custom-element-pagebreak',
      '|', 'undo', 'redo',
      '|', 'removeFormat'
    ],
    placeholder: 'This is where you type the body of your writing. Use the controls above for formatting.',
    CustomElement: {
      items: [
        {
          tag: 'pagebreak',
          placeholder: '<p style="text-align:center">--- <i class="fa fa-file-text-o"></i> ---</p>',
          inline: false,
        }
      ]
    }
  };

And this is what I get in the output currently:

<pagebreak>&lt;p style="text-align:center"&gt;--- &lt;i class="fa fa-file-text-o"&gt;&lt;/i&gt; ---&lt;/p&gt;</pagebreak>

I'd propose a boolean for this like safePlaceholder that defaults to false.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.