From 8ad58fd6b87064aab6dc3d48f07e97e062938569 Mon Sep 17 00:00:00 2001 From: xdan Date: Sat, 4 Nov 2023 13:27:59 +0300 Subject: [PATCH] New version 4.0.0-beta.102 Read more https://github.com/xdan/jodit/blob/main/CHANGELOG.md --- package-lock.json | 4 ++-- package.json | 2 +- src/plugins/sticky/sticky.test.js | 3 +++ src/plugins/sticky/sticky.ts | 30 +++++++++++++++--------------- 4 files changed, 21 insertions(+), 18 deletions(-) diff --git a/package-lock.json b/package-lock.json index 310de6e3b..ced0410c0 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "jodit", - "version": "4.0.0-beta.101", + "version": "4.0.0-beta.102", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "jodit", - "version": "4.0.0-beta.101", + "version": "4.0.0-beta.102", "license": "MIT", "dependencies": { "autobind-decorator": "^2.4.0" diff --git a/package.json b/package.json index 6244d50b8..e23429221 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "jodit", - "version": "4.0.0-beta.101", + "version": "4.0.0-beta.102", "description": "Jodit is awesome and usefully wysiwyg editor with filebrowser", "main": "build/jodit.min.js", "types": "./types/index.d.ts", diff --git a/src/plugins/sticky/sticky.test.js b/src/plugins/sticky/sticky.test.js index ca7df3122..7d03e1bbc 100644 --- a/src/plugins/sticky/sticky.test.js +++ b/src/plugins/sticky/sticky.test.js @@ -89,9 +89,12 @@ describe('Sticky plugin', function () { await editor.async.requestIdlePromise(); + console.log(offset); window.scroll(0, offset.top + offset.height / 2); // scroll page to bottom simulateEvent('scroll', window); + console.log(window.scrollY); await editor.async.requestIdlePromise(); + await delay(100); expect(true).equals( editor.container.classList.contains('jodit_sticky') diff --git a/src/plugins/sticky/sticky.ts b/src/plugins/sticky/sticky.ts index b718e2561..c50fc7271 100644 --- a/src/plugins/sticky/sticky.ts +++ b/src/plugins/sticky/sticky.ts @@ -23,14 +23,14 @@ import { pluginSystem } from 'jodit/core/global'; import './config'; export class sticky extends Plugin { - private isToolbarSticked: boolean = false; - private dummyBox?: HTMLElement; + private __isToolbarStuck: boolean = false; + private __dummyBox?: HTMLElement; private createDummy = (toolbar: HTMLElement): void => { - if (!IS_ES_NEXT && IS_IE && !this.dummyBox) { - this.dummyBox = this.j.c.div(); - this.dummyBox.classList.add('jodit_sticky-dummy_toolbar'); - this.j.container.insertBefore(this.dummyBox, toolbar); + if (!IS_ES_NEXT && IS_IE && !this.__dummyBox) { + this.__dummyBox = this.j.c.div(); + this.__dummyBox.classList.add('jodit_sticky-dummy_toolbar'); + this.j.container.insertBefore(this.__dummyBox, toolbar); } }; @@ -38,11 +38,11 @@ export class sticky extends Plugin { * Add sticky */ addSticky = (toolbar: HTMLElement): void => { - if (!this.isToolbarSticked) { + if (!this.__isToolbarStuck) { this.createDummy(toolbar); this.j.container.classList.add('jodit_sticky'); - this.isToolbarSticked = true; + this.__isToolbarStuck = true; } // on resize it should work always @@ -51,8 +51,8 @@ export class sticky extends Plugin { width: this.j.container.offsetWidth - 2 }); - if (!IS_ES_NEXT && IS_IE && this.dummyBox) { - css(this.dummyBox, { + if (!IS_ES_NEXT && IS_IE && this.__dummyBox) { + css(this.__dummyBox, { height: toolbar.offsetHeight }); } @@ -62,14 +62,14 @@ export class sticky extends Plugin { * Remove sticky behaviour */ removeSticky = (toolbar: HTMLElement): void => { - if (this.isToolbarSticked) { + if (this.__isToolbarStuck) { css(toolbar, { width: '', top: '' }); this.j.container.classList.remove('jodit_sticky'); - this.isToolbarSticked = false; + this.__isToolbarStuck = false; } }; @@ -80,7 +80,7 @@ export class sticky extends Plugin { 'scroll.sticky wheel.sticky mousewheel.sticky resize.sticky', this.onScroll ) - .on('getStickyState.sticky', () => this.isToolbarSticked); + .on('getStickyState.sticky', () => this.__isToolbarStuck); } /** @@ -112,7 +112,7 @@ export class sticky extends Plugin { if ( jodit.o.toolbarSticky && jodit.o.toolbar === true && - this.isToolbarSticked !== doSticky + this.__isToolbarStuck !== doSticky ) { const container = jodit.toolbarContainer; @@ -140,7 +140,7 @@ export class sticky extends Plugin { /** @override */ beforeDestruct(jodit: IJodit): void { - this.dummyBox && Dom.safeRemove(this.dummyBox); + this.__dummyBox && Dom.safeRemove(this.__dummyBox); jodit.e .off( jodit.ow,