-
-
Notifications
You must be signed in to change notification settings - Fork 3.7k
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
Cannot type after inline widget #1049
Comments
I edited the issue to make it more clear. It looks like you are trying to implement Placeholder plugin, known from CKEditor 4. We haven't worked on inline widgets yet, although it is something that we want to work on in near future. The issue itself is weird -- whitespace is like any other character so it is very interesting that inserting it changes the editor behavior. Note that the whitespace might have been converted to My guess would be that there's something wrong with selection placement or view<->model mapping. |
I created a separate ticket to track inline widgets support: #1050. |
a new weird behavior (with the same code) : https://streamable.com/a780v |
while watching the dom, i have also found what might be a weird behavior related to my issue (it's not happening with images, by example) https://streamable.com/8sv43 |
more tests... https://streamable.com/lepds |
I removed my comment because it was completely incorrect. |
@scofalik, why did we need custom converters here?
|
I'm asking because it'd be good to have a minimal TC here that we could work on. |
We need custom converters to widgetize the inserted element. There's no |
Can't we provide a callback to |
Just like in one of the tests: conversion.for( 'editingDowncast' ).add( downcastElementToElement( {
model: 'fancywidget',
view: ( modelItem, viewWriter ) => {
const widgetElement = viewWriter.createContainerElement( 'figure', { class: 'fancy-widget' } );
viewWriter.insert( ViewPosition.createAt( widgetElement ), viewWriter.createText( 'widget' ) );
return toWidget( widgetElement, viewWriter );
}
} ) ); |
Oh, yeah, we could. |
I've been able to find a workaround which makes my code work but involves more bugs. It is working if I force a
unfortunately, when I click on my variable element, and press enter, it breaks my element in two. before : after : also, if I press backspace while on my element, it breaks in two but differently:
And in that case, if I try to fix it, this error is thrown:
The wanted behavior is close, actually. If only I could stop CKEditor from handling key presses such as |
OK, to start from the beginning... I created a small demo of an inline widget: https://github.com/ckeditor/ckeditor5-core/compare/t/ckeditor5/1049 According to my tests it works fine. To my surprise, I haven't found yet any issue :). EDIT: I have now – a placeholder doesn't work well inside another widget's nested editable. All the behaviours which you can see on the screencast (I tested clicking to focus, copy paste, typing after it, backspace and arrow keys behaviour) are as expected. Am I missing something? Could you test it yourself? |
I found one more issue – attributes get applied inside this element: And this is tricky... We need to think how to resolve this because so far we didn't have attribute elements used next to container elements. What's more, in the model it's the text inside the |
OK, two ideas:
The latter seems more correct to me. |
Buuut... if we want to allow generating data like this: <p><strong>xx <placehoder>yy</placeholder> yy</strong></p> we have a problem now because AFAIR a I'm afraid that we'll need some time to figure out things like this, @lucasriondel. As you can see, the feature seems to be working (and I guess it could be used in production), but this is a kinda "beginner's luck" :D Since we haven't focused on inline widgets yet there are certain architectural aspects we need to understand first. |
|
Okay, I see that your placeholder definition does not inherit attributes allowance from So, I think that the best final output would be something like: |
I don't think that we should use AttrElement here. AttrElements can get merged. You don't want widgets to be merged. Widgets are like containers. Self-contained, non-mergable, untouchable. I recall that @pjasiun was also for using ContainerElements here.
It does not matter. There's nothing wrong with using custom elements.
It may inherit attrs of
Yup. If the placeholder's text was supposed to be editable "inline", it would need to also be defined as a nested editable in the view. That's overcomplicated for this case, so we could assume that this text is editable via some balloon. |
If you don't like |
OK, let's wait for @pjasiun with this. This is an important decision. |
Well I still have this issue.. |
Would it be possible that you created a repo with all the code needed for us to reproduce it. Plus, please include the exact steps to reproduce this issue. The devil may be in the details. |
Sure, i'll try. |
I'll get back to this ticket once we'll release v10.1.0. It's a busy week, sorry. |
I understand, don't worry. Thanks again for your time. |
BTW, do you test this in Firefox maybe? I'm asking because this issue may be related to #1083. |
No, I am using chrome. |
@Reinmar I replicated the case by having the inline widget at the end of the paragraph. If the widget has a space( ) right before it, no text can be added after it. |
Thanks for the details. That may help us debugging it. I hoped that we'll be able to look into this right after the previous release but I wasn't able to keep this ticket above the 'fold'. I'll add it to the next iteration and hopefully that'll help. |
Should be related to the mutation observer in the typing package. Spaces cause a lot of problems. I guess we get a big children mutation of the paragraph and we end up in this lovely method: https://github.com/ckeditor/ckeditor5-typing/blob/e553afb1592c66a45f0964ccb41d6f1672ad3702/src/utils/injecttypingmutationshandling.js#L92 |
@Reinmar yep it might be also related to how spaces are handled - it looks like they are not normalized and there's change detected in the |
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).
I've read above. It seems I need to create element using Here's my
}` |
Is there any new Element to overcome this? |
The cursor doesn't work in chrome in the end of placeholder - for span, in Firefox - it works |
I tried to create a plugin that uses an inline widget. The plugin should insert an inline, non-editable HTML element with some text into the editor content. I used
toWidget
to widgetize the element. However I have a weird issue:blablabla<variable>myVar</variable>
) without any whitespace between text and widget, I am able to type text after the widget,blablabla <variable>myVar</variable>
), I cannot type anything after the widget, I only can put a caret there and press Enter.Here's a video of what's happening : https://streamable.com/2l4hz
And here's the code:
My plugin:
And here's my editor initialization (with a bit of React code, sorry about that) :
Any idea?
The text was updated successfully, but these errors were encountered: