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

Can't type after 'isObject' entity at the end of the paragraph or before <br> #1426

Closed
Oleg-Nagornov opened this issue Dec 21, 2018 · 5 comments
Assignees
Labels
type:bug This issue reports a buggy (incorrect) behavior.
Milestone

Comments

@Oleg-Nagornov
Copy link

Oleg-Nagornov commented Dec 21, 2018

🐞 Bug report

💻 Version of CKEditor

Used versions:
"@ckeditor/ckeditor5-core": "~11.1.0", "@ckeditor/ckeditor5-ui": "~11.2.0", "@ckeditor/ckeditor5-react": "~1.1.0", "@ckeditor/ckeditor5-dev-utils": "~11.0.1", "@ckeditor/ckeditor5-utils": "~11.1.0", "@ckeditor/ckeditor5-basic-styles": "~10.1.0", "@ckeditor/ckeditor5-theme-lark": "~12.0.0", "@ckeditor/ckeditor5-editor-classic": "~11.0.2", "@ckeditor/ckeditor5-alignment": "~10.0.4", "@ckeditor/ckeditor5-essentials": "~10.1.3", "@ckeditor/ckeditor5-heading": "~10.1.1", "@ckeditor/ckeditor5-link": "~10.1.0", "@ckeditor/ckeditor5-paragraph": "~10.0.4",

Editor initializations:

<CKEditor
                config={{
                    plugins: [Essentials, Heading, Paragraph, Bold, Italic, Strikethrough, Underline, Alignment, Link],
                    toolbar: ['Heading', '|', 'Bold', 'Italic', 'Strikethrough', 'Underline', 'Alignment', 'Link', 'Undo', 'Redo'],
                }}
                editor={ClassicEditor}
                data={''}
                onChange={(e, editor) => {}}
            />

📋 Steps to reproduce

  1. Register a new type of block, which is object and can be used into paragraph.
    editor.model.schema.register('myTag', {
    allowWhere: '$text',
    allowContentOf: '$block',
    allowIn: '$text',
    allowAttributes: ['tag', 'title', 'value'],
    isObject: true,
    });

  2. Pass sample text into editor:
    <p><myTag>xyz<myTag></p>
    <p>Test text <myTag>xyz<myTag></p>
    <p>Test text <myTag>xyz<myTag> test text test text</p>
    <p><myTag>xyz<myTag><br>xyz</p>

It means:

  1. Object is one entity into <p>
  2. Object is the last entity into <p>, prepended by text
  3. Object is the last entity into <p>, prepended and appended by text
  4. <br> tag is the next of Object.

✅ Expected result

I can type after objectTag and data:change will fired.

❎ Actual result

I can type only in cases 1 and 3, In cases 2 and 4 - i can't.

📃 Other details that might be useful

I suppose, it's closely connected with this issue: #407

@oleq
Copy link
Member

oleq commented Jan 4, 2019

What does your conversion to the view look like? What does myTag actually represent in your content?

@oleq oleq added type:bug This issue reports a buggy (incorrect) behavior. status:pending labels Jan 4, 2019
@Oleg-Nagornov
Copy link
Author

Oleg-Nagornov commented Jan 9, 2019

I apologize for delayed answer.

I suppose, that myTag will be in-text 'block', which should be non-editable.
These features have be already implemented, but there is an issue about typing after myTag element.

So, there are two cases:

  1. screenshot_20190109_120247
    If there is any text after myTag and before the end of the paragraph, all works fine.
  2. screenshot_20190109_120324
    If there isn't any text after myTag and before the end of the paragraph, i can't type after myTag.
    The html code in the editor field will be something like this:
    <p>Some text, some other text <myTag>myTag Content</myTag></p>

I use the next conversions:

editor.model.schema.register('myTag', {
allowWhere: '$text',
allowContentOf: '$block',
allowIn: '$text',
allowAttributes: ['myTag', 'title', 'value'],
isObject: true,
});

editor.conversion.elementToElement({
model: 'myTag',
view: {
name: 'myTag',
styles: {
'background-color': '#ececec',
},
},
});

editor.conversion.for('upcast').add(upcastElementToElement({
view: {
name: 'myTag',
},
model: 'myTag'
}));

editor.conversion.for('downcast').add(downcastAttributeToAttribute({
model: {
name: 'myTag',
key: 'myTag'
},
view: 'myTag'
}));

editor.conversion.for('upcast').add(upcastAttributeToAttribute({
model: {
name: 'myTag',
key: 'myTag'
},
view: 'myTag'
}));

@scofalik
Copy link
Contributor

scofalik commented Jan 9, 2019

Inline object elements are not much supported as of now -- we haven't took time yet to research this and fix all the things that are not clicking there as there were other priorities. We look forward to fix those issues but AFAIK this is not on our short term timeline ATM (I might be wrong, though).

@Reinmar
Copy link
Member

Reinmar commented Feb 6, 2019

@jodator isn't this fixed in one of your PRs?

@Reinmar Reinmar added this to the iteration 22 milestone Feb 6, 2019
@jodator
Copy link
Contributor

jodator commented Feb 6, 2019

Looks like the issue should be fixed after closing all PRs of: ckeditor/ckeditor5-widget#70. Basically it boils down to #1049.

The only change would be to mark myTag as an inline element:

editor.model.schema.register( 'myTag', {
    allowWhere: '$text',
    allowContentOf: '$block',
    allowIn: '$text',
    allowAttributes: [ 'myTag', 'title', 'value' ],
    isObject: true,
    isInline: true // <- this will mark it as a text-like element
} );

I didn't check how the inserting contents will work inside myTag but if this would be non-editable element then it should be OK.

Reinmar added a commit to ckeditor/ckeditor5-engine that referenced this issue Feb 18, 2019
Feature: Introduced support for inline objects (enables support for inline widgets). Introduced `Schema#isInline()`. Closes [ckeditor/ckeditor5#1049](ckeditor/ckeditor5#1049). Closes [ckeditor/ckeditor5#1426](ckeditor/ckeditor5#1426).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type:bug This issue reports a buggy (incorrect) behavior.
Projects
None yet
Development

No branches or pull requests

5 participants