Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The link rel attribute should be handled as a token list to allow mixing manual link decorators for the same attribute #17461

Open
wants to merge 54 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
54 commits
Select commit Hold shift + click to select a range
cdf9b8d
Refactoring of view styles and classes to more generic solution.
niegowski Nov 4, 2024
5e6a334
Fixed unwrapping.
niegowski Nov 5, 2024
5310c3f
Updated tests.
niegowski Nov 5, 2024
8cd520d
Added fast-access private properties.
niegowski Nov 5, 2024
60c7c58
Fixed tests.
niegowski Nov 5, 2024
3daf3b3
Merge branch 'refs/heads/master' into ck/13985
niegowski Nov 6, 2024
1b142c1
Using getter for easier usage and marginal performance difference.
niegowski Nov 6, 2024
6437f0e
Bring back original method signature.
niegowski Nov 6, 2024
9685665
Merge branch 'refs/heads/master' into ck/13985
niegowski Nov 6, 2024
a7ac306
Unified setAttribute for both tokenized, styles map and plain string …
niegowski Nov 8, 2024
cc84584
Reduced usage of addClass, removeClass, addStyle, removeStyle in Down…
niegowski Nov 8, 2024
f2b5543
Wrap/unwrap AttributeElement delegated to the view Elements.
niegowski Nov 13, 2024
4665f8f
Added tests.
niegowski Nov 13, 2024
7d04816
Added hasAttribute with expected value handling.
niegowski Nov 14, 2024
ece3d94
Fixed mention upcast conversion (all attributes must be consumed).
niegowski Nov 14, 2024
72c6449
Removed not used property from type declaration.
niegowski Nov 14, 2024
6ffcbb7
Part of the Matcher internal logic split into the view Element.
niegowski Nov 14, 2024
dd0b292
Code simplification.
niegowski Nov 15, 2024
47af99d
WiP.
niegowski Nov 15, 2024
ad48a11
Adjusting matcher logic.
niegowski Nov 18, 2024
6cae667
Fixed failing tests.
niegowski Nov 19, 2024
a2e01fe
Unified pattern match check.
niegowski Nov 19, 2024
419cc23
Added test for attribute name match without a value match.
niegowski Nov 19, 2024
467d497
Split matching back to helpers.
niegowski Nov 20, 2024
8afae7f
Added tests for backward compatibility and fixed pattern normalizatio…
niegowski Nov 20, 2024
b56d2ae
Removed de-dup.
niegowski Nov 20, 2024
a3a9f33
Merge branch 'master' into ck/13985
niegowski Nov 22, 2024
e111c07
Merge branch 'master' into ck/13985
niegowski Nov 26, 2024
9f6eea0
Merge branch 'master' into ck/13985
niegowski Dec 5, 2024
3c92676
The ViewConsumable should not be aware how to handle different kinds …
niegowski Dec 6, 2024
a09ee9e
Updated GHS to the new matcher output format.
niegowski Dec 6, 2024
cca2cd6
Normalized output of MatcherFunctionPattern match.
niegowski Dec 6, 2024
e80aa7f
Updated MatcherFunctionPattern handling so it accepts boolean return …
niegowski Dec 6, 2024
8aa73c1
Delegated consuming of related styles.
niegowski Dec 9, 2024
3dde209
Update test.
niegowski Dec 9, 2024
fb4c515
Reorder methods.
niegowski Dec 9, 2024
9feeacb
Simplified collecting of matching attributes.
niegowski Dec 9, 2024
36c3a98
Avoid double normalization.
niegowski Dec 9, 2024
3119882
Code cleaning.
niegowski Dec 9, 2024
ff24ea0
Code cleaning.
niegowski Dec 10, 2024
1e719ef
Empty style and class attribute should be possible.
niegowski Dec 10, 2024
0d3328e
Updating docs.
niegowski Dec 10, 2024
775c7b7
Updating docs.
niegowski Dec 10, 2024
40b2075
Added iterator to getClassNames() for backward compatibility.
niegowski Dec 11, 2024
4d7d7a2
Updating docs.
niegowski Dec 11, 2024
261c526
Merge branch 'master' into ck/13985
niegowski Dec 12, 2024
d2d5aac
Added tests.
niegowski Dec 13, 2024
be6969a
Added tests.
niegowski Dec 16, 2024
d210c85
Added tests.
niegowski Dec 16, 2024
dd9f070
Added tests.
niegowski Dec 16, 2024
17c67ab
Added tests.
niegowski Dec 16, 2024
d671264
Merge branch 'master' into ck/13985
niegowski Dec 16, 2024
08e7d87
Fix doclet.
niegowski Dec 17, 2024
0c4253d
Apply suggestions from code review.
niegowski Jan 9, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
63 changes: 19 additions & 44 deletions packages/ckeditor5-engine/src/conversion/downcasthelpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1664,60 +1664,35 @@ function changeAttribute( attributeCreator: AttributeCreatorFunction ) {

// First remove the old attribute if there was one.
if ( data.attributeOldValue !== null && oldAttribute ) {
if ( oldAttribute.key == 'class' ) {
const classes = typeof oldAttribute.value == 'string' ? oldAttribute.value.split( /\s+/ ) : oldAttribute.value;
let value = oldAttribute.value;

for ( const className of classes ) {
viewWriter.removeClass( className, viewElement );
}
} else if ( oldAttribute.key == 'style' ) {
if ( oldAttribute.key == 'style' ) {
if ( typeof oldAttribute.value == 'string' ) {
const styles = new StylesMap( viewWriter.document.stylesProcessor );

styles.setTo( oldAttribute.value );

for ( const [ key ] of styles.getStylesEntries() ) {
viewWriter.removeStyle( key, viewElement );
}
value = new StylesMap( viewWriter.document.stylesProcessor )
.setTo( oldAttribute.value )
.getStylesEntries()
.map( ( [ key ] ) => key );
} else {
const keys = Object.keys( oldAttribute.value );

for ( const key of keys ) {
viewWriter.removeStyle( key, viewElement );
}
value = Object.keys( oldAttribute.value );
}
} else {
viewWriter.removeAttribute( oldAttribute.key, viewElement );
}

viewWriter.removeAttribute( oldAttribute.key, value as ArrayOrItem<string>, viewElement );
}

// Then set the new attribute.
if ( data.attributeNewValue !== null && newAttribute ) {
if ( newAttribute.key == 'class' ) {
const classes = typeof newAttribute.value == 'string' ? newAttribute.value.split( /\s+/ ) : newAttribute.value;

for ( const className of classes ) {
viewWriter.addClass( className, viewElement );
}
} else if ( newAttribute.key == 'style' ) {
if ( typeof newAttribute.value == 'string' ) {
const styles = new StylesMap( viewWriter.document.stylesProcessor );

styles.setTo( newAttribute.value );

for ( const [ key, value ] of styles.getStylesEntries() ) {
viewWriter.setStyle( key, value, viewElement );
}
} else {
const keys = Object.keys( newAttribute.value );

for ( const key of keys ) {
viewWriter.setStyle( key, ( newAttribute.value as Record<string, string> )[ key ], viewElement );
}
}
} else {
viewWriter.setAttribute( newAttribute.key, newAttribute.value as string, viewElement );
let value = newAttribute.value;

if ( newAttribute.key == 'style' && typeof newAttribute.value == 'string' ) {
value = Object.fromEntries(
new StylesMap( viewWriter.document.stylesProcessor )
.setTo( newAttribute.value )
.getStylesEntries()
);
}

viewWriter.setAttribute( newAttribute.key, value, false, viewElement );
}
};
}
Expand Down
Loading
Loading