-
-
Notifications
You must be signed in to change notification settings - Fork 3.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'origin/master' into ck/10294/reconversion
- Loading branch information
Showing
19 changed files
with
424 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
/** | ||
* @license Copyright (c) 2003-2022, CKSource Holding sp. z o.o. All rights reserved. | ||
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license | ||
*/ | ||
|
||
/** | ||
* @module html-support/integrations/style | ||
*/ | ||
|
||
import { Plugin } from 'ckeditor5/src/core'; | ||
import { | ||
createObjectView, | ||
modelToViewBlockAttributeConverter, | ||
viewToModelBlockAttributeConverter, | ||
viewToModelObjectConverter | ||
} from '../converters.js'; | ||
|
||
import DataFilter from '../datafilter'; | ||
|
||
/** | ||
* Provides the General HTML Support for `style` elements. | ||
* | ||
* @extends module:core/plugin~Plugin | ||
*/ | ||
export default class StyleElementSupport extends Plugin { | ||
/** | ||
* @inheritDoc | ||
*/ | ||
static get requires() { | ||
return [ DataFilter ]; | ||
} | ||
|
||
/** | ||
* @inheritDoc | ||
*/ | ||
init() { | ||
const dataFilter = this.editor.plugins.get( DataFilter ); | ||
|
||
dataFilter.on( 'register:style', ( evt, definition ) => { | ||
const editor = this.editor; | ||
const schema = editor.model.schema; | ||
const conversion = editor.conversion; | ||
|
||
schema.register( 'htmlStyle', definition.modelSchema ); | ||
|
||
schema.extend( 'htmlStyle', { | ||
allowAttributes: [ 'htmlAttributes', 'htmlContent' ] | ||
} ); | ||
|
||
editor.data.registerRawContentMatcher( { | ||
name: 'style' | ||
} ); | ||
|
||
conversion.for( 'upcast' ).elementToElement( { | ||
view: 'style', | ||
model: viewToModelObjectConverter( definition ) | ||
} ); | ||
|
||
conversion.for( 'upcast' ).add( viewToModelBlockAttributeConverter( definition, dataFilter ) ); | ||
|
||
conversion.for( 'downcast' ).elementToElement( { | ||
model: 'htmlStyle', | ||
view: ( modelElement, { writer } ) => { | ||
return createObjectView( 'style', modelElement, writer ); | ||
} | ||
} ); | ||
|
||
conversion.for( 'downcast' ).add( modelToViewBlockAttributeConverter( definition ) ); | ||
|
||
evt.stop(); | ||
} ); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.