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

Find and Replace highlight words incorrectly after inline widget with text inside #11162

Closed
jswiderski opened this issue Jan 25, 2022 · 0 comments · Fixed by #17528
Closed

Find and Replace highlight words incorrectly after inline widget with text inside #11162

jswiderski opened this issue Jan 25, 2022 · 0 comments · Fixed by #17528
Assignees
Labels
package:find-and-replace squad:core Issue to be handled by the Core team. support:2 An issue reported by a commercially licensed client. type:bug This issue reports a buggy (incorrect) behavior.

Comments

@jswiderski
Copy link

📝 Provide detailed reproduction steps (if any)

  1. Reported based on ZD ticket 72478
  2. When there is an inline widget with text inside, Find and Replace feature highlights found text incorrectly after such a widget.

✔️ Expected result

What is the expected result of the above steps?

❌ Actual result

What is the actual result of the above steps?

❓ Possible solution

After some consulting with @niegowski, it has turned out that rangeToText method in ckeditor5-find-and-replace/src/utils.js had to be changed to:

 export function rangeToText( range ) {
    return Array.from( range.getItems( { shallow: true } ) ).reduce( ( rangeText, node ) => {
        // Trim text to a last occurrence of an inline element and update range start.
        if ( node.is( 'element' ) ) {
            // Editor has only one inline element defined in schema: `<softBreak>` which is treated as new line character in blocks.
            // Special handling might be needed for other inline elements (inline widgets).
            return rangeText + '\n';
        }
        return rangeText + node.data;
    }, '' );
} 

The key difference is a chnage to range.getItems( { shallow: true } ) from range.getItems()

📃 Other details

  • Browser: Any
  • OS: Any
  • First affected CKEditor version: 29.0.0
  • Installed CKEditor plugins: find-and-replace

If you'd like to see this fixed sooner, add a 👍 reaction to this post.

@jswiderski jswiderski added type:bug This issue reports a buggy (incorrect) behavior. package:find-and-replace labels Jan 25, 2022
@martynawierzbicka martynawierzbicka added the support:2 An issue reported by a commercially licensed client. label Jan 26, 2022
@Mati365 Mati365 self-assigned this Nov 25, 2024
@FilipTokarski FilipTokarski added the squad:core Issue to be handled by the Core team. label Nov 25, 2024
@CKEditorBot CKEditorBot added this to the iteration 81 milestone Nov 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
package:find-and-replace squad:core Issue to be handled by the Core team. support:2 An issue reported by a commercially licensed client. type:bug This issue reports a buggy (incorrect) behavior.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants