ckeditor5
ckeditor5 copied to clipboard
upcast 'p' element with attribute/class (?)
📝 Provide detailed reproduction steps (if any)
I created conversion for upcast element to element
editor.conversion.for('upcast').elementToElement({
view: { name: 'p', attributes: ['abcd']},
model: .....
}
then i insert html <p abcd>aaa</p>
(allowed attributes in schema 'paragraph')
and debug the code, its no go through the upcasting
i checked it with div/ other elements and its works, just with 'p' isnt working... checked also with classes instead of attributes
✔️ Expected result
elementToElement function called and do the job
❌ Actual result
elementToElement function not called
📃 Other details
- Browser: …
- OS: …
- First affected CKEditor version: …
- Installed CKEditor plugins: …
If you'd like to see this fixed sooner, add a 👍 reaction to this post.
I'm also having the same issue. I have a model element that is block element type which basically gets downcasted to a paragraph with a special class attribute. I've found that the upcast process in filtering for p-tag elements with that special class to convert back to my model element does not work. I've tried setting priority to the highest, and still does not work.
Instead of downcasting/upcasting using paragraphs, I've tried "div" elements, but still, for some reason these just get automatically converted to paragraphs without any attributes at all. I've tried setting breakpoints in the upcast handler, and looks like it is never hit.
Any news about this bug resolution?
I'm not able to reproduce this issue. The following code works:
editor.model.schema.register( 'xyz', {
inheritAllFrom: '$block',
allowAttributes: [ 'foo' ]
} );
editor.conversion.for( 'upcast' ).elementToElement( {
view: {
name: 'p',
attributes: [ 'abcd' ]
},
model: ( viewElement, { writer } ) => {
return writer.createElement( 'xyz', {
foo: viewElement.getAttribute( 'abcd' )
} );
},
converterPriority: 'high'
} );
editor.conversion.for( 'downcast' ).elementToElement( {
model: {
name: 'xyz',
attributes: [ 'foo' ]
},
view: ( modelElement, { writer } ) => {
return writer.createContainerElement( 'p', {
abcd: modelElement.getAttribute( 'foo' )
} );
}
} );