-
Notifications
You must be signed in to change notification settings - Fork 3.6k
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
Various merge tags related improvements and adjustments. #16096
Draft
Dumluregn
wants to merge
17
commits into
master
Choose a base branch
from
cc/5988-merge-tags
base: master
Could not load branches
Branch not found: {{ refName }}
Could not load tags
Nothing to show
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
d1fe075
Add an exception in the DomConverter handling the text after merge tags.
Dumluregn 9794fbd
Merge branch 'cc/5988-merge-tags' into cc/5988-merge-tags-conversion
Dumluregn 775af56
Add ui components.
Dumluregn f084570
Make resetting the search view also reset the list scroll.
Dumluregn f5c5678
Extract filter function.
Dumluregn 10e27a4
Extract the filter function.
Dumluregn d61345a
Merge branch 'cc/5988-merge-tags' into cc/5988-merge-tags-dropdown
Dumluregn cd78399
Simplify the solution.
Dumluregn b2ce564
Fix whitespace.
Dumluregn 95c51ed
Merge pull request #16014 from ckeditor/cc/5988-merge-tags-conversion
Dumluregn 45e1994
Merge pull request #16043 from ckeditor/cc/5988-merge-tags-dropdown
Dumluregn 2327062
Merge branch 'master' into cc/5988-merge-tags
Dumluregn 03447e6
Add menu bar components to the default menu bar config.
Dumluregn a2c0bf6
Merge pull request #16285 from ckeditor/cc/5988-merge-tags-menu-bar
Dumluregn 4e2a153
Merge branch 'master' into cc/5988-merge-tags
Dumluregn 7590c11
Merge branch 'master' into HEAD
Dumluregn c00eef6
Rename mergeTagsPreview -> previewMergeTags.
Dumluregn File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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
56 changes: 56 additions & 0 deletions
56
packages/ckeditor5-ui/src/highlightedtext/buttonlabelwithhighlightview.ts
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,56 @@ | ||
/** | ||
* @license Copyright (c) 2003-2024, CKSource Holding sp. z o.o. All rights reserved. | ||
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license | ||
*/ | ||
|
||
/** | ||
* @module ui/highlightedtext/buttonlabelwithhighlightview | ||
*/ | ||
|
||
import type ButtonLabel from '../button/buttonlabel.js'; | ||
import HighlightedTextView from './highlightedtextview.js'; | ||
|
||
/** | ||
* A button label view that can highlight a text fragment. | ||
*/ | ||
export default class ButtonLabelWithHighlightView extends HighlightedTextView implements ButtonLabel { | ||
/** | ||
* @inheritDoc | ||
*/ | ||
declare public style: string | undefined; | ||
|
||
/** | ||
* @inheritDoc | ||
*/ | ||
declare public text: string | undefined; | ||
|
||
/** | ||
* @inheritDoc | ||
*/ | ||
declare public id: string | undefined; | ||
|
||
/** | ||
* @inheritDoc | ||
*/ | ||
constructor() { | ||
super(); | ||
|
||
this.set( { | ||
style: undefined, | ||
text: undefined, | ||
id: undefined | ||
} ); | ||
|
||
const bind = this.bindTemplate; | ||
|
||
this.extendTemplate( { | ||
attributes: { | ||
class: [ | ||
'ck-button__label' | ||
], | ||
style: bind.to( 'style' ), | ||
id: bind.to( 'id' ) | ||
} | ||
} ); | ||
} | ||
} |
51 changes: 51 additions & 0 deletions
51
packages/ckeditor5-ui/src/highlightedtext/labelwithhighlightview.ts
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,51 @@ | ||
/** | ||
* @license Copyright (c) 2003-2024, CKSource Holding sp. z o.o. All rights reserved. | ||
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license | ||
*/ | ||
|
||
/** | ||
* @module ui/highlightedtext/labelwithhighlightview | ||
*/ | ||
|
||
import HighlightedTextView from './highlightedtextview.js'; | ||
import type LabelView from '../label/labelview.js'; | ||
import { uid } from '@ckeditor/ckeditor5-utils'; | ||
|
||
/** | ||
* A label view that can highlight a text fragment. | ||
*/ | ||
export default class LabelWithHighlightView extends HighlightedTextView implements LabelView { | ||
/** | ||
* @inheritDoc | ||
*/ | ||
public readonly id: string; | ||
|
||
/** | ||
* @inheritDoc | ||
*/ | ||
declare public for: string | undefined; | ||
|
||
/** | ||
* @inheritDoc | ||
*/ | ||
constructor() { | ||
super(); | ||
|
||
this.set( 'for', undefined ); | ||
|
||
const bind = this.bindTemplate; | ||
|
||
this.id = `ck-editor__label_${ uid() }`; | ||
|
||
this.extendTemplate( { | ||
attributes: { | ||
class: [ | ||
'ck', | ||
'ck-label' | ||
], | ||
id: this.id, | ||
for: bind.to( 'for' ) | ||
} | ||
} ); | ||
} | ||
} |
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
65 changes: 65 additions & 0 deletions
65
packages/ckeditor5-ui/src/search/filtergroupanditemnames.ts
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,65 @@ | ||
/** | ||
* @license Copyright (c) 2003-2024, CKSource Holding sp. z o.o. All rights reserved. | ||
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license | ||
*/ | ||
|
||
/** | ||
* @module ui/search/filtergroupanditemnames | ||
*/ | ||
|
||
import type ButtonView from '../button/buttonview.js'; | ||
import type ButtonLabelWithHighlightView from '../highlightedtext/buttonlabelwithhighlightview.js'; | ||
import type LabelWithHighlightView from '../highlightedtext/labelwithhighlightview.js'; | ||
import type ViewCollection from '../viewcollection.js'; | ||
import type ListItemGroupView from '../list/listitemgroupview.js'; | ||
import type ListItemView from '../list/listitemview.js'; | ||
import type ListSeparatorView from '../list/listseparatorview.js'; | ||
|
||
/** | ||
* A filter function that returns matching item and group names in the list view. | ||
*/ | ||
export default function filterGroupAndItemNames( | ||
regExp: RegExp | null, | ||
items: ViewCollection<ListItemGroupView | ListItemView | ListSeparatorView> | ||
): { | ||
resultsCount: number; | ||
totalItemsCount: number; | ||
} { | ||
let totalItemsCount = 0; | ||
let resultsCount = 0; | ||
|
||
for ( const groupView of items ) { | ||
const group = groupView as ListItemGroupView; | ||
const groupItems = group.items as ViewCollection<ListItemView>; | ||
const isGroupLabelMatching = regExp && !!group.label.match( regExp ); | ||
|
||
( group.labelView as LabelWithHighlightView ).highlightText( isGroupLabelMatching ? regExp : null ); | ||
|
||
for ( const listItemView of groupItems ) { | ||
const buttonView = listItemView.children.first as ButtonView; | ||
const labelView = buttonView.labelView as ButtonLabelWithHighlightView; | ||
|
||
if ( !regExp ) { | ||
listItemView.isVisible = true; | ||
labelView.highlightText( null ); | ||
} else { | ||
const isItemLabelMatching = !!buttonView.label!.match( regExp ); | ||
|
||
labelView.highlightText( isItemLabelMatching ? regExp : null ); | ||
|
||
listItemView.isVisible = isGroupLabelMatching || isItemLabelMatching; | ||
} | ||
} | ||
|
||
const visibleInGroupCount = groupItems.filter( listItemView => listItemView.isVisible ).length; | ||
|
||
totalItemsCount += group.items.length; | ||
resultsCount += isGroupLabelMatching ? group.items.length : visibleInGroupCount; | ||
group.isVisible = isGroupLabelMatching || !!visibleInGroupCount; | ||
} | ||
|
||
return { | ||
resultsCount, | ||
totalItemsCount | ||
}; | ||
} |
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
94 changes: 94 additions & 0 deletions
94
packages/ckeditor5-ui/tests/highlightedtext/buttonlabelwithhighlightview.js
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,94 @@ | ||
/** | ||
* @license Copyright (c) 2003-2024, CKSource Holding sp. z o.o. All rights reserved. | ||
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license | ||
*/ | ||
|
||
import { global } from '@ckeditor/ckeditor5-utils'; | ||
import HighlightedTextView from '../../src/highlightedtext/highlightedtextview.js'; | ||
import ButtonLabelWithHighlightView from '../../src/highlightedtext/buttonlabelwithhighlightview.js'; | ||
|
||
describe( 'ButtonLabelWithHighlightView', () => { | ||
let view; | ||
|
||
beforeEach( () => { | ||
view = new ButtonLabelWithHighlightView( ); | ||
view.render(); | ||
|
||
global.document.body.appendChild( view.element ); | ||
} ); | ||
|
||
afterEach( () => { | ||
view.element.remove(); | ||
view.destroy(); | ||
} ); | ||
|
||
describe( 'constructor()', () => { | ||
it( 'should be HighlightedTextView instance', () => { | ||
expect( view ).to.be.instanceof( HighlightedTextView ); | ||
} ); | ||
|
||
it( 'should set initial properties as undefined', () => { | ||
expect( view.style ).to.equal( undefined ); | ||
expect( view.text ).to.equal( undefined ); | ||
expect( view.id ).to.equal( undefined ); | ||
} ); | ||
} ); | ||
|
||
describe( 'default template', () => { | ||
it( 'should bind view#style to template style', () => { | ||
view.style = 'color: red'; | ||
|
||
expect( view.element.getAttribute( 'style' ) ).to.equal( 'color: red' ); | ||
|
||
view.style = 'color: blue'; | ||
|
||
expect( view.element.getAttribute( 'style' ) ).to.equal( 'color: blue' ); | ||
} ); | ||
|
||
it( 'should bind view#text to template text', () => { | ||
view.text = 'Test'; | ||
|
||
expect( view.element.textContent ).to.equal( 'Test' ); | ||
|
||
view.text = undefined; | ||
|
||
expect( view.element.textContent ).to.equal( '' ); | ||
} ); | ||
|
||
it( 'should bind view#id to template id', () => { | ||
view.id = 'test-id'; | ||
|
||
expect( view.element.getAttribute( 'id' ) ).to.equal( 'test-id' ); | ||
|
||
view.id = 'new-id'; | ||
|
||
expect( view.element.getAttribute( 'id' ) ).to.equal( 'new-id' ); | ||
} ); | ||
} ); | ||
|
||
describe( 'Highlighting template text', () => { | ||
beforeEach( () => { | ||
view.text = 'Example text'; | ||
} ); | ||
|
||
it( 'should not highlight anything when no query is specified', () => { | ||
view.highlightText( null ); | ||
|
||
expect( view.element.innerHTML ).to.equal( 'Example text' ); | ||
} ); | ||
|
||
it( 'should highlight the query', () => { | ||
view.highlightText( new RegExp( /text/, 'ig' ) ); | ||
|
||
expect( view.element.innerHTML ).to.equal( 'Example <mark>text</mark>' ); | ||
} ); | ||
|
||
it( 'should highlight multiple occurences of the query', () => { | ||
view.highlightText( new RegExp( /e/, 'ig' ) ); | ||
|
||
expect( view.element.innerHTML ).to.equal( | ||
'<mark>E</mark>xampl<mark>e</mark> t<mark>e</mark>xt' | ||
); | ||
} ); | ||
} ); | ||
} ); |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tip
Codebase Verification
Several files in the codebase still use the old function signature.
domconverter.ts
.inlineObjectElements
array does not seem to be implemented.Analysis chain
Addition of 'mergeTag' to
inlineObjectElements
approved.Scripts Executed
The following scripts were executed for the analysis:
Script:
Length of output: 66
Script:
Length of output: 511
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be injected from the feature code. It's public property. The property itself is read-only but the content is not.
See how we handle other similar props:
ckeditor5/packages/ckeditor5-html-support/src/integrations/customelement.ts
Line 50 in 2e9b16d
ckeditor5/packages/ckeditor5-html-support/src/integrations/customelement.ts
Lines 82 to 85 in 2e9b16d
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@niegowski, thank you for your input. The handling of 'mergeTag' as an inline object element in the
DomConverter
class is indeed crucial for ensuring it integrates smoothly with the rest of the system, especially given its role in the UI components.From the examples you provided, it seems like the approach used in other parts of CKEditor 5 involves defining properties in a way that they are publicly accessible but their modification is controlled. This is typically achieved using getter/setter methods or similar patterns to encapsulate the property's value, ensuring it remains read-only externally while allowing its content to be modified internally.
Currently, 'mergeTag' is added directly to the
inlineObjectElements
array in theDomConverter
class, which makes it part of the internal configuration for handling inline objects. This approach is straightforward but does not allow external manipulation or extension in the same way that a getter/setter pattern would.If aligning the handling of 'mergeTag' with the approach you highlighted is desired, we could consider introducing a method to get and potentially set the contents of the
inlineObjectElements
array in a controlled manner. This would provide flexibility and maintain consistency with other parts of the codebase.Would you like me to draft a potential implementation for this adjustment, or is there a specific aspect of the integration you would like to discuss further?