Problem with hyphen wrapped in bold

Created on 5 October 2023, about 1 year ago
Updated 15 December 2023, 11 months ago

When I try to add a soft hyphen to a text that is also bold, the output ends up like this:
<strong>Long</strong>&shy;<strong>text</strong>

Instead of:
<strong>Long&shy;text</strong>

This makes the hyphen none-bold when it's visible.

I get the same problem if the text is wrapped with other inline-elements like italic, underline or links.

πŸ› Bug report
Status

Needs review

Version

2.0

Component

Miscellaneous

Created by

πŸ‡ΈπŸ‡ͺSweden mrzoom

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

  • Issue created by @mrzoom
  • πŸ‡ΈπŸ‡ͺSweden mrzoom

    After some more digging, I think this is related to this issue:
    https://github.com/ckeditor/ckeditor5/issues/1068

    Where a "soft-break" (<br>) is handled the same way.

    I don't know how to create a path... But by adding:
    allowAttributesOf: '$text'

    To your schema like this:

    _defineSchema() {
        this.editor.model.schema.register("shy", {
            allowWhere: "$text",
            isInline: !0,
            allowAttributesOf: '$text'
        })
    }
    

    And change your execute() method to this:

    class t extends e.Command {
        execute() {
            this.editor.model.change((e => {
                const r = e.createElement('shy', this.editor.model.document.selection.getAttributes());
                this.editor.model.insertContent(r)
            }))
        }
    }
    

    Then the <shy> element is inserted inside for example <strong>, instead of breaking the text in to two separate <strong> element.

  • πŸ‡©πŸ‡ͺGermany stefan.korn Jossgrund

    confirm the issue and the fix

  • Status changed to Needs review 11 months ago
  • πŸ‡©πŸ‡ͺGermany stefan.korn Jossgrund

    Here is a patch based on #2.

    It would be better if the source that leads to shy.js would be provided, but until then one can just patch the shy.js directly I suppose.

Production build 0.71.5 2024