Skip to content

Commit

Permalink
All tests are green
Browse files Browse the repository at this point in the history
  • Loading branch information
xdan committed Feb 10, 2020
1 parent f535180 commit 45309a0
Show file tree
Hide file tree
Showing 18 changed files with 91 additions and 114 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.MD
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
### BugFix
* [#325](https://github.com/xdan/jodit/issues/325)
* [#327](https://github.com/xdan/jodit/issues/327)
* [#292](https://github.com/xdan/jodit/issues/292)

### Feature
* Added `Dom`.`isTag` method
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ An excellent WYSIWYG editor written in pure TypeScript without the use of additi
* [Playground - play with options](https://xdsoft.net/jodit/play.html)
* [Documentation](https://xdsoft.net/jodit/doc/)
* [Download&Changes](https://github.com/xdan/jodit/releases)
* [Changelog](https://github.com/xdan/jodit/blob/master/CHANGELOG.MD)

> For old version, please follow here [https://github.com/xdan/jodit2](https://github.com/xdan/jodit2)
Expand Down
4 changes: 2 additions & 2 deletions src/Jodit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -984,7 +984,7 @@ export class Jodit extends ViewWithToolbar implements IJodit {

this.setStatus(STATUSES.beforeInit);

if (this.options.events) {
if (this.options?.events) {
Object.keys(this.options.events).forEach((key: string) =>
this.events.on(key, this.options.events[key])
);
Expand Down Expand Up @@ -1029,7 +1029,7 @@ export class Jodit extends ViewWithToolbar implements IJodit {
}
}

currentPlace: IWorkPlace;
currentPlace: IWorkPlace
places: IWorkPlace[];

private elementToPlace: Map<HTMLElement, IWorkPlace> = new Map();
Expand Down
2 changes: 1 addition & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ Object.keys(Modules)
DefaultJodit.modules[key] = (Modules as any)[key];
});

['Confirm', 'Alert', 'Promt'].forEach((key: string) => {
['Confirm', 'Alert', 'Prompt'].forEach((key: string) => {
(DefaultJodit as any)[key] = (Modules as any)[key];
});

Expand Down
10 changes: 6 additions & 4 deletions src/modules/ImageEditor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import {
} from '../types';
import { IViewBased } from '../types/view';
import { Component } from './Component';
import { Alert, Dialog, Promt } from './dialog/';
import { Alert, Dialog, Prompt } from './dialog/';
import { $$, css, trim } from './helpers/';
import { ToolbarIcon } from './toolbar/icon';
import { Dom } from './Dom';
Expand Down Expand Up @@ -432,7 +432,9 @@ export class ImageEditor extends Component {
`.${jie}_slider,.${jie}_area`,
self.editor
).forEach(elm => elm.classList.remove('active'));

const slide = this.parentNode as HTMLElement;

slide.classList.add('active');
self.activeTab =
<ImageAction>slide.getAttribute('data-area') ||
Expand Down Expand Up @@ -502,7 +504,7 @@ export class ImageEditor extends Component {
);
if (rationResizeButton) {
rationResizeButton.addEventListener('change', () => {
self.resizeUseRatio = rationResizeButton.checked;
this.resizeUseRatio = rationResizeButton.checked;
});
}

Expand All @@ -513,7 +515,7 @@ export class ImageEditor extends Component {

if (rationCropButton) {
rationCropButton.addEventListener('change', () => {
self.cropUseRatio = rationCropButton.checked;
this.cropUseRatio = rationCropButton.checked;
});
}

Expand Down Expand Up @@ -595,7 +597,7 @@ export class ImageEditor extends Component {

switch (button.getAttribute('data-action')) {
case 'saveas':
Promt(
Prompt(
self.jodit.i18n('Enter new name'),
self.jodit.i18n('Save in new file'),
(name: string): false | void => {
Expand Down
7 changes: 3 additions & 4 deletions src/modules/dialog/alert.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,13 @@ export const Alert = (
}

const
dialog: Dialog = new Dialog(),
container: HTMLDivElement = dialog.create.div(className),
dialog = new Dialog(),
container = dialog.create.div(className),
okButton: HTMLAnchorElement = dialog.create.fromHTML(
'<a href="javascript:void(0)" style="float:right;" class="jodit_button">' +
ToolbarIcon.getIcon('cancel') +
'<span>' +
Jodit.prototype.i18n('Ok') +
dialog.i18n('Ok') +
'</span></a>'
) as HTMLAnchorElement;

Expand Down Expand Up @@ -74,6 +74,5 @@ export const Alert = (
return dialog;
};

import { Jodit } from '../../Jodit';
import { asArray } from '../helpers/array';
import { Dom } from '../Dom';
6 changes: 2 additions & 4 deletions src/modules/dialog/confirm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ export const Confirm = (
'<a href="javascript:void(0)" style="float:right;" class="jodit_button">' +
ToolbarIcon.getIcon('cancel') +
'<span>' +
Jodit.prototype.i18n('Cancel') +
dialog.i18n('Cancel') +
'</span>' +
'</a>'
) as HTMLAnchorElement;
Expand All @@ -69,7 +69,7 @@ export const Confirm = (
'<a href="javascript:void(0)" style="float:left;" class="jodit_button">' +
ToolbarIcon.getIcon('check') +
'<span>' +
Jodit.prototype.i18n('Yes') +
dialog.i18n('Yes') +
'</span>' +
'</a>'
) as HTMLAnchorElement;
Expand All @@ -88,5 +88,3 @@ export const Confirm = (

return dialog;
};

import { Jodit } from '../../Jodit';
2 changes: 1 addition & 1 deletion src/modules/dialog/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@

export { Dialog } from './dialog';
export { Alert } from './alert';
export { Promt } from './promt';
export { Prompt } from './prompt';
export { Confirm } from './confirm';
18 changes: 6 additions & 12 deletions src/modules/dialog/promt.ts → src/modules/dialog/prompt.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,16 @@ import { Dialog } from './dialog';
import { ToolbarIcon } from '../toolbar/icon';

/**
* Show `promt` dialog. Work without Jodit object
* Show `Prompt` dialog. Work without Jodit object
*
* @method Promt
* @method Prompt
* @param {string} msg Message
* @param {string|function} [title] Title or callback
* @param {function} [callback] callback. The first argument is the value entered
* @param {string} [placeholder] Placeholder for input
* @example
* ```javascript
* Jodit.Promt("Enter your name", "Promt Dialog", function (name) {
* Jodit.Prompt("Enter your name", "Prompt Dialog", function (name) {
* if (name.length < 3) {
* Jodit.Alert("The name must be at least 3 letters");
* return false;
Expand All @@ -25,7 +25,7 @@ import { ToolbarIcon } from '../toolbar/icon';
* });
* ```
*/
export const Promt = (
export const Prompt = (
msg: string,
title: string | (() => false | void) | undefined,
callback: (value: string) => false | void,
Expand All @@ -37,27 +37,23 @@ export const Promt = (
'<a href="javascript:void(0)" style="float:right;" class="jodit_button">' +
ToolbarIcon.getIcon('cancel') +
'<span>' +
Jodit.prototype.i18n('Cancel') +
dialog.i18n('Cancel') +
'</span></a>'
) as HTMLAnchorElement,

okButton: HTMLAnchorElement = dialog.create.fromHTML(
'<a href="javascript:void(0)" style="float:left;" class="jodit_button">' +
ToolbarIcon.getIcon('check') +
'<span>' +
Jodit.prototype.i18n('Ok') +
dialog.i18n('Ok') +
'</span></a>'
) as HTMLAnchorElement,

form: HTMLFormElement = dialog.create.element('form', {
class: 'jodit_prompt'
}),

inputElement: HTMLInputElement = dialog.create.element('input', {
autofocus: true,
class: 'jodit_input'
}),

labelElement: HTMLLabelElement = dialog.create.element(
'label'
) as HTMLLabelElement;
Expand Down Expand Up @@ -107,5 +103,3 @@ export const Promt = (

return dialog;
};

import { Jodit } from '../../Jodit';
8 changes: 4 additions & 4 deletions src/modules/filebrowser/fileBrowser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { Config, OptionsDefault } from '../../Config';
import * as consts from '../../constants';
import { Dialog } from '../dialog/dialog';
import { Confirm } from '../dialog/confirm';
import { Promt } from '../dialog/promt';
import { Prompt } from '../dialog/prompt';
import { ToolbarIcon } from '../toolbar/icon';

import {
Expand Down Expand Up @@ -763,7 +763,7 @@ export class FileBrowser extends ViewWithToolbar implements IFileBrowser {
'fileRename.filebrowser',
(name: string, path: string, source: string) => {
if (self.state.activeElements.length === 1) {
Promt(
Prompt(
self.i18n('Enter new name'),
self.i18n('Rename'),
(newName: string): false | void => {
Expand Down Expand Up @@ -883,7 +883,7 @@ export class FileBrowser extends ViewWithToolbar implements IFileBrowser {
name: string = a.getAttribute('data-name') || '',
path: string = a.getAttribute('data-source-path') || '';

Promt(
Prompt(
self.i18n('Enter new name'),
self.i18n('Rename'),
(newName: string): false | void => {
Expand Down Expand Up @@ -943,7 +943,7 @@ export class FileBrowser extends ViewWithToolbar implements IFileBrowser {
'click',
function(this: HTMLAnchorElement) {
if (this.classList.contains('addfolder')) {
Promt(
Prompt(
self.i18n('Enter Directory name'),
self.i18n('Create directory'),
(name: string) => {
Expand Down
2 changes: 1 addition & 1 deletion src/modules/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export { Ajax } from './Ajax';
export { EventsNative } from './events/eventsNative';
export { Component } from './Component';
export { ContextMenu } from './ContextMenu';
export { Alert, Confirm, Promt, Dialog } from './dialog/';
export { Alert, Confirm, Prompt, Dialog } from './dialog/';
export { Dom } from './Dom';
export { Plugin } from './Plugin';
export { Create } from './Create';
Expand Down
41 changes: 22 additions & 19 deletions src/plugins/resizer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,7 @@ export class resizer extends Plugin {
);

this.addEventListeners();
this.onChangeEditor();
}

private addEventListeners() {
Expand Down Expand Up @@ -388,28 +389,30 @@ export class resizer extends Plugin {
event.preventDefault();
}
})
.on(element, 'click', () => {
if (this.element !== element || !this.isShown) {
this.element = element;
.on(element, 'click', () => this.onClickElement(element));
}

this.show();
private onClickElement = (element: HTMLElement) => {
if (this.element !== element || !this.isShown) {
this.element = element;

if (
Dom.isTag(this.element, 'img') &&
!this.element.complete
) {
this.jodit.events.on(
this.element,
'load',
this.updateSize
);
}
}
});
}
this.show();

if (
Dom.isTag(this.element, 'img') &&
!this.element.complete
) {
this.jodit.events.on(
this.element,
'load',
this.updateSize
);
}
}
};

private updateSize() {
if (this.jodit.isInDestruct || !this.isShown) {
private updateSize = () => {
if (this.isInDestruct || !this.isShown) {
return;
}

Expand Down
3 changes: 0 additions & 3 deletions src/plugins/xpath.ts
Original file line number Diff line number Diff line change
Expand Up @@ -206,12 +206,9 @@ export class xpath extends Plugin {
.on(
'afterSetMode.xpath afterInit.xpath changePlace.xpath',
() => {
console.log(this.jodit.id, this.jodit.events.current);

if (!this.jodit.options.showXPathInStatusbar) {
return;
}
console.log(this.jodit.id, this.jodit.events.current);

this.jodit.statusbar.append(this.container);

Expand Down
2 changes: 1 addition & 1 deletion src/types/ajax.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ export type DataVariant = | IDictionary<string>
| null
| FormData
| string
| IDictionary<string | IDictionary<any>>;
| IDictionary<string | IDictionary>;

export interface IRequest {
url: string;
Expand Down
Loading

0 comments on commit 45309a0

Please sign in to comment.