From 604fc960d53d7cb0e5b46ad6ebb7a049fdb7fe37 Mon Sep 17 00:00:00 2001 From: Simon Rozman Date: Fri, 14 Jun 2024 12:30:07 +0200 Subject: [PATCH] =?UTF-8?q?service2.js=20=E2=86=92=20service.js?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- samples/ckeditor.html | 25 +- samples/ckeditor2.html | 28 - .../div-contenteditable-plaintext-only.html | 2 +- samples/div-contenteditable.html | 2 +- samples/index.html | 760 ----- samples/mock-page.html | 2 +- samples/static-content.html | 2 +- samples/textarea.html | 2 +- service.js | 2627 +++++++++++------ service2.js | 2090 ------------- 10 files changed, 1688 insertions(+), 3852 deletions(-) delete mode 100644 samples/ckeditor2.html delete mode 100644 samples/index.html delete mode 100644 service2.js diff --git a/samples/ckeditor.html b/samples/ckeditor.html index 026d43f..493b5f5 100644 --- a/samples/ckeditor.html +++ b/samples/ckeditor.html @@ -1,27 +1,28 @@ - + - - CKEditor 5 Example + + + BesService CKEditor Example + +

This is an example of a CKEditor edit control. Edit the text, resize the control or browser window, scroll around, click...

- -

Na mizo nisem položil knjigo.

+

Tukaj vpišite besedilo ki ga želite popraviti.

+

Prišla je njena lepa hčera. Smatram da tega nebi bilo potrebno storiti. Predavanje je trajalo dve ure. S njim grem v Kamnik. Janez jutri nebo prišel. Prišel je z 100 idejami.

+

To velja tudi v Bledu. To se je zgodilo na velikemu vrtu. Prišel je na Kamnik. On je včeraj prišel z svojo torbo. Dve žemlje prosim. Pogosto brskam po temu forumu. Prišel je včeraj in sicer s otroci. To ne vem. Pogleda vse kar daš v odložišče. Nisem jo videl. Ona izgleda dobro. Pri zanikanju ne smete uporabljati tožilnik. Vlak gre v Ljubljano čez Zidani Most. Skočil je čez okno. Slovenija meji na avstrijo. Jaz pišem v Slovenščini vsak Torek. Novica, da je skupina 25 planincev hodila pod vodstvom gorskega vodnika je napačna in zavajujoča. Želim da poješ kosmizailo. Jaz pogosto brskam po temu forumu. Med tem ko je iskal ključe, so se odprla vrata. V takoimenovanem skladišču je bilo veliko ljudi. V sobi sta dve mize. Stekel je h mami. Videl sem Jurčič Micko. To je bil njegov življenski cilj. Po vrsti popravite vse kar želite. Preden zaspiva mi prebere pravljico. Prišel je s stricom. Oni zadanejo tarčo. Mi gremo teči po polju. Mi gremo peči kruh. Usedel se je k miza. Postreži kosilo! Skul je veslanje z dvemi vesli.

+

Na mizo nisem položil knjigo.

- + diff --git a/samples/ckeditor2.html b/samples/ckeditor2.html deleted file mode 100644 index 698fa7d..0000000 --- a/samples/ckeditor2.html +++ /dev/null @@ -1,28 +0,0 @@ - - - - - - BesService CKEditor Example - - - - - - - -

This is an example of a CKEditor edit control. Edit the text, resize the control or browser window, scroll around, click...

-
-

Tukaj vpišite besedilo ki ga želite popraviti.

-

Prišla je njena lepa hčera. Smatram da tega nebi bilo potrebno storiti. Predavanje je trajalo dve ure. S njim grem v Kamnik. Janez jutri nebo prišel. Prišel je z 100 idejami.

-

To velja tudi v Bledu. To se je zgodilo na velikemu vrtu. Prišel je na Kamnik. On je včeraj prišel z svojo torbo. Dve žemlje prosim. Pogosto brskam po temu forumu. Prišel je včeraj in sicer s otroci. To ne vem. Pogleda vse kar daš v odložišče. Nisem jo videl. Ona izgleda dobro. Pri zanikanju ne smete uporabljati tožilnik. Vlak gre v Ljubljano čez Zidani Most. Skočil je čez okno. Slovenija meji na avstrijo. Jaz pišem v Slovenščini vsak Torek. Novica, da je skupina 25 planincev hodila pod vodstvom gorskega vodnika je napačna in zavajujoča. Želim da poješ kosmizailo. Jaz pogosto brskam po temu forumu. Med tem ko je iskal ključe, so se odprla vrata. V takoimenovanem skladišču je bilo veliko ljudi. V sobi sta dve mize. Stekel je h mami. Videl sem Jurčič Micko. To je bil njegov življenski cilj. Po vrsti popravite vse kar želite. Preden zaspiva mi prebere pravljico. Prišel je s stricom. Oni zadanejo tarčo. Mi gremo teči po polju. Mi gremo peči kruh. Usedel se je k miza. Postreži kosilo! Skul je veslanje z dvemi vesli.

-

Na mizo nisem položil knjigo.

-
- - - - diff --git a/samples/div-contenteditable-plaintext-only.html b/samples/div-contenteditable-plaintext-only.html index 38b1292..6c6ee72 100644 --- a/samples/div-contenteditable-plaintext-only.html +++ b/samples/div-contenteditable-plaintext-only.html @@ -7,7 +7,7 @@ - +

This is an example of a simple <div contenteditable="plaintext-only"> edit control. Edit the text, resize the control or browser window, scroll around, click...

diff --git a/samples/div-contenteditable.html b/samples/div-contenteditable.html index 46cb539..15f1c50 100644 --- a/samples/div-contenteditable.html +++ b/samples/div-contenteditable.html @@ -7,7 +7,7 @@ - +

This is an example of a simple <div contenteditable="true"> edit control. Edit the text, resize the control or browser window, scroll around, click...

diff --git a/samples/index.html b/samples/index.html deleted file mode 100644 index 8be7700..0000000 --- a/samples/index.html +++ /dev/null @@ -1,760 +0,0 @@ - - - - - - BesService Example - - - - - -
Tukaj vpišite besedilo ki ga želite popraviti.
-
- - - - - - - - - - - - - - diff --git a/samples/mock-page.html b/samples/mock-page.html index b932010..c9f57d3 100644 --- a/samples/mock-page.html +++ b/samples/mock-page.html @@ -7,7 +7,7 @@ - +
diff --git a/samples/static-content.html b/samples/static-content.html index 77e2c07..560d221 100644 --- a/samples/static-content.html +++ b/samples/static-content.html @@ -7,7 +7,7 @@ - +

This is an example of grammar-checking static HTML content. The below text contains proofing markup.

diff --git a/samples/textarea.html b/samples/textarea.html index b96f7f5..aef765e 100644 --- a/samples/textarea.html +++ b/samples/textarea.html @@ -7,7 +7,7 @@ - +

This is an example of a <textarea> edit control. Edit the text, resize the control or browser window, scroll around, click...

diff --git a/service.js b/service.js index 05ea845..b150703 100644 --- a/service.js +++ b/service.js @@ -1,66 +1,274 @@ -let besServices = [] // Collection of all grammar checking services in the document +// TODO: Research if there is a way to disable languageTool & Grammarly extensions in CKEditor +// TODO: Revise absolute/relative placement of auxiliary
we inject into DOM. Absolute is more +// controllable, but lacks PlacementObserver; relative is tricky to prevent document flow +// issues, but moves with the DOM element. -/// -/// Grammar checking service base class -/// +/** + * Collection of all grammar checking services in the document + * + * We dispatch relevant window messages to all services registered here. + */ +let besServices = [] + +// TODO: Window resize may cause host element(s) to move. That needs correction panel and status +// icon repositioning. Also, should any parent element of our service host element move, we +// should reposition correction panel and status icon. How to do this? Alas there is no +// PlacementObserver to monitor host element movements. Switch to relative placement for our +// auxiliary
s? +window.addEventListener('resize', () => + besServices.forEach(service => service.onReposition()) +) + +/************************************************************************************************** + * + * Base class for all grammar-checking services + * + * This class provides properties and implementations of methods common to all types of HTML + * controls. + * + * This is an intermediate class and may not be used directly in client code. + * + *************************************************************************************************/ class BesService { - constructor(hostElement) { + /** + * Constructs class. + * + * @param {Element} hostElement The element in DOM tree we are providing grammar-checking service + * for + * @param {Element} textElement The element in DOM tree that hosts coordinate-measurable clone of + * the text to proof. Same as hostElement for
, separate for + *