Skip to content

Commit

Permalink
Merge pull request #14406 from ckeditor/ck/9888-preserving-inline-emp…
Browse files Browse the repository at this point in the history
…ty-elements

Feature (html-support): Introduced configuration option to allow empty inline elements. Closes #9888.

Other (engine): The `DomConverter` should allow registering custom matchers to detect inline object elements. See #9888.

Other (source-editing): Fixed formatting of `<br>` elements in source editing. Whitespaces before `<br>` element should not be added.
  • Loading branch information
niegowski authored Jul 13, 2023
2 parents 0175879 + b910260 commit 899250e
Show file tree
Hide file tree
Showing 25 changed files with 1,344 additions and 311 deletions.
9 changes: 7 additions & 2 deletions packages/ckeditor5-engine/src/model/documentselection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1135,8 +1135,10 @@ class LiveSelection extends Selection {

// ...look for a first character node in that range and take attributes from it.
for ( const value of range ) {
// If the item is an object, we don't want to get attributes from its children.
// If the item is an object, we don't want to get attributes from its children...
if ( value.item.is( 'element' ) && schema.isObject( value.item ) ) {
// ...but collect attributes from inline object.
attrs = getTextAttributes( value.item, schema );
break;
}

Expand Down Expand Up @@ -1237,7 +1239,10 @@ function getTextAttributes( node: Item | null, schema: Schema ): Iterable<[strin

// Collect all attributes that can be applied to the text node.
for ( const [ key, value ] of node.getAttributes() ) {
if ( schema.checkAttribute( '$text', key ) ) {
if (
schema.checkAttribute( '$text', key ) &&
schema.getAttributeProperties( key ).copyFromObject !== false
) {
attributes.push( [ key, value ] );
}
}
Expand Down
12 changes: 12 additions & 0 deletions packages/ckeditor5-engine/src/model/schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1764,6 +1764,18 @@ export interface AttributeProperties {
*/
copyOnEnter?: boolean;

/**
* Indicates that given attribute should be preserved while replacing the element.
*/
copyOnReplace?: boolean;

/**
* Indicates that given text attribute should be copied from an inline object to the next inserted inline content.
*
* @default true
*/
copyFromObject?: boolean;

[ name: string ]: unknown;
}

Expand Down
Loading

0 comments on commit 899250e

Please sign in to comment.