michmech / xonomy

A schema-driven XML editor for the web.
MIT License
91 stars 32 forks source link

¿Incompatibility between xonomy and ckeditor? #51

Closed estrellagrubio closed 2 years ago

estrellagrubio commented 2 years ago

We use two different editors on the same web page: Xonomy and CKEditor to do various tasks. Both work fine, but when I open Xonomy, after that, I can't type blanks, tabs in my CKEditor anymore. Has anyone encountered the same problem? Thanks in advance!

estrellagrubio commented 2 years ago

We use both editors in an application with angular 12. CKEditor version: https://ckeditor.com/docs/ckeditor5/latest/installation/getting-started/frameworks/angular.html Descriptive Summary: When I open a Xonomy editor on my page, after that, if I open ckeditor, the changeEvent doesn't work for spacebar or whitespace. Browser and OS names: Version 102.0.5005.63 (Official Build) (64-bit) Additional Plugins: CKeditor 5 Small Caps Feature

It seems that when I open the Xonomy editor, after that, the ckeditor's changeEditor event doesn't work when I press spacebar or whitespace. For the rest of the letters the event fires without problems. What is the reason that pressing spaces does not fire the changeEditor event after opening Xonomy on the webpage?

I have tried to use another editor (https://github.com/kolkov/angular-editor) and the same thing happens.

Thanks!

michmech commented 2 years ago

I don't know off the top of my head, but maybe Xonomy's keyboard navigation is interfering with that other editor? Are you using keyboard navigation in Xonomy by calling Xonomy.startKeyNav() from somewhere in your application, as described in section 15.2 of the Xonomy manual?

estrellagrubio commented 2 years ago

Indeed, you are right. In Xonomy.startKeyNav(), space is treated in the following line:

$(document).on("keydown", function (e) { if ([32, 37, 38, 39, 40].indexOf(e.keyCode) > -1 && $("input:focus, select:focus , textarea:focus").length == 0) e.preventDefault(); }); // prevent default browser from scrolling with arrow keys

I have removed the value 32 (Space) from the array and if I open Xonomy and then ckeditor, I can write blank spaces without problem in this other editor and the other characters (%, &, ', () do not give me any problem. Could another problem appear by not treating this character inside the function?

Thank you very, very much.

michmech commented 2 years ago

I think you've fixed the problem. I remember including the space character in that code because, in web browsers usually, pressing the space bar typically causes the page to scroll down (if it has a scroll bar). I admit that that wasn't very clever of me, to monopolize the space key like that.

estrellagrubio commented 2 years ago

Thanks a lot. You were very fast in giving a hint to solve the problem. Our team is very happy with your help. Thanks again. Best wishes, Estrella