Skip to content

Commit

Permalink
New version 4.0.0-beta.102 Read more https://github.com/xdan/jodit/bl…
Browse files Browse the repository at this point in the history
  • Loading branch information
xdan committed Nov 4, 2023
1 parent bd25e41 commit 8ad58fd
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 18 deletions.
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
3 changes: 3 additions & 0 deletions src/plugins/sticky/sticky.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down
30 changes: 15 additions & 15 deletions src/plugins/sticky/sticky.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,26 +23,26 @@ 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);
}
};

/**
* 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
Expand All @@ -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
});
}
Expand All @@ -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;
}
};

Expand All @@ -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);
}

/**
Expand Down Expand Up @@ -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;

Expand Down Expand Up @@ -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,
Expand Down

0 comments on commit 8ad58fd

Please sign in to comment.