-
-
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
Balloon editor crashes on init when there is a comment in source html #5734
Comments
Interesting. It does not blow up |
By a coincident, there may be a PR which fixes this issue: ckeditor/ckeditor5-engine#1806. But it's unfinished and its author didn't explain what bug it fixes. |
If you integrate ckeditor into Blazor app successfully, can you open source? |
const BalloonEditor = require('@ckeditor/ckeditor5-build-balloon');
window["BlazorCKE"] = {
init: function (params) {
BalloonEditor
.create(document.querySelector('#' + params.selector))
.then(editor => {
editor.setData(params.content ? params.content : '');
editor.model.document.on('change:data', () => {
params.instance.invokeMethodAsync('updateText', editor.getData());
});
})
.catch(error => {
console.error(error);
});
}
};
public partial class CKEComponent
{
private string EditorId { get; } = $"cke_{Guid.NewGuid()}";
protected override bool TryParseValueFromString(string value, out string result,
out string validationErrorMessage)
{
result = value;
validationErrorMessage = "";
return true;
}
protected override async Task OnAfterRenderAsync(bool firstRender)
{
await base.OnAfterRenderAsync(firstRender);
if (firstRender)
{
await initialiseEditor();
}
}
public ValueTask<string> initialiseEditor()
{
var arg = new {selector = $"{EditorId}", instance = DotNetObjectReference.Create(this), content = Value};
return JsRuntime.InvokeAsync<string>(
"BlazorCKE.init",
arg);
}
[JSInvokable]
public async Task<bool> updateText(string editorText)
{
Value = editorText;
await ValueChanged.InvokeAsync(Value);
EditContext?.NotifyFieldChanged(FieldIdentifier);
return true;
}
}
@using Microsoft.JSInterop
@inject IJSRuntime JsRuntime
@inherits Microsoft.AspNetCore.Components.Forms.InputBase<string>
<div id="@EditorId"></div>
<CKEComponent @bind-Value="Value"/> |
For people who face this issue while it is not fixed yet, there is the workaround of just removing all Comment Nodes before the CKEditor is mounted (of course, this does not work if something relies on those comments in the future)
|
I just checked this issue, and I can no longer reproduce it so it looks like we fixed this somewhere down the line. |
@mlewand, unfortunately, I can still reproduce this issue. |
I checked it with frameworks integrations and I had the following results:
|
Issue:
Solution: As proposed in the PR, the |
new PR is available at #7403 |
Fix (engine): The editor should not crash when the initial data includes HTML comments. Closes #5734.
Hello!
📝 Provide detailed reproduction steps (if any)
✔️ Expected result
Editor works
❌ Actual result
Exception
📃 Other details
Here is repo with reproduction - https://github.com/pogromistik/CKEditor-comment-bug. And you can view result here - https://pogromistik.github.io/CKEditor-comment-bug/.
We are trying to integrate ckeditor into Blazor app and face this problem, cause Blazor inserts comments into html for elements tracking.
It can be related to this change - #3860
The text was updated successfully, but these errors were encountered: