Skip to content

Commit

Permalink
New version 3.0.13. Read more https://github.com/xdan/jodit/releases/…
Browse files Browse the repository at this point in the history
  • Loading branch information
xdan committed Aug 18, 2017
1 parent bba3e82 commit ba94ab7
Show file tree
Hide file tree
Showing 12 changed files with 140 additions and 108 deletions.
4 changes: 2 additions & 2 deletions build/jodit.min.css

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions build/jodit.min.js

Large diffs are not rendered by default.

16 changes: 8 additions & 8 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -84,14 +84,14 @@
observer: {
timeout: 0
},
// uploader: {
// url: 'http://localhost:8181/index-test.php?action=upload'
// },
// filebrowser: {
// ajax: {
// url: 'http://localhost:8181/index-test.php'
// }
// },
uploader: {
url: 'https://xdsoft.net/jodit/connector/index.php?action=upload'
},
filebrowser: {
ajax: {
url: 'https://xdsoft.net/jodit/connector/index.php'
}
},
//debugLanguage: true,
buttons: Jodit.defaultOptions.buttons.concat([
{
Expand Down
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": "3.0.12",
"version": "3.0.13",
"description": "Jodit is awesome and usefully wysiwyg editor with filebrowser",
"main": "index.js",
"scripts": {
Expand Down
4 changes: 3 additions & 1 deletion src/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,4 +64,6 @@ export const MODE_SPLIT = 3;
export const TEXT_PLAIN = isIE() ? 'text' : 'text/plain';


export const MARKER_CLASS = 'jodit_selection_marker';
export const MARKER_CLASS = 'jodit_selection_marker';

export const EMULATE_DBLCLICK_TIMEOUT = 300;
52 changes: 33 additions & 19 deletions src/modules/FileBrowser.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import Jodit from '../Jodit';
import Component from './Component';
import Dialog, {Confirm, Promt} from '../modules/Dialog';
import Dialog, {Alert, Confirm, Promt} from '../modules/Dialog';
import {Config} from '../Config';
import {
$$, css, ctrlKey, debounce, dom, each, extend, humanSizeToBytes, isPlainObject, offset,
Expand All @@ -10,7 +10,7 @@ import Toolbar from "./Toolbar";
import ContextMenu from "./ContextMenu";
import Uploader from "./Uploader";
import Ajax from "./Ajax";
import {TEXT_PLAIN} from "../constants";
import * as consts from "../constants";
import ImageEditor from "./ImageEditor";
import Cookie from "./Cookie";

Expand Down Expand Up @@ -235,9 +235,12 @@ type FileBrowserAnswer = {
success: boolean,
time: string,
data: {
messages?: string[],
sources: ISourcesFiles,
code: number
messages?: string[];
sources: ISourcesFiles;
code: number;
path: string;
name: string;
source: string;
}
};

Expand Down Expand Up @@ -690,7 +693,7 @@ export default class FileBrowser extends Component {
})
.__on(self.files, 'dragstart', 'a', function (this: HTMLElement, e: DragEvent) {
self.dragger = this;
e.dataTransfer.setData(TEXT_PLAIN, this.getAttribute('href'));
e.dataTransfer.setData(consts.TEXT_PLAIN, this.getAttribute('href'));
e.stopPropagation();
})
.__on(self.files, 'contextmenu', 'a', function (this: HTMLElement, e: DragEvent) {
Expand Down Expand Up @@ -990,8 +993,10 @@ export default class FileBrowser extends Component {

private __ajax2: Ajax;

private send(name, success, error) {
let xhr, opts = extend(true, {}, this.options.ajax, this.options[name] !== undefined ? this.options[name] : this.options.ajax);
private send(name: string, success: (resp: FileBrowserAnswer) => void, error: (error: string) => void) {
let xhr: Ajax,
opts: FileBrowserAjaxOptions = extend(true, {}, this.options.ajax, this.options[name] !== undefined ? this.options[name] : this.options.ajax);

opts.data = opts.prepareData.call(this, opts.data);
xhr = new Ajax(this.jodit, opts);

Expand All @@ -1017,14 +1022,14 @@ export default class FileBrowser extends Component {
getPathByUrl = (url: string, success: (path: string, name: string, source: string) => void, failed) => {
let action = 'getlocalfilebyurl', self = this;
this.options[action].data.url = url;
this.send(action, (resp) => {
this.send(action, (resp: FileBrowserAnswer) => {
if (self.options.isSuccess(resp)) {
success(resp.data.path, resp.data.name, resp.data.source);
} else {
failed(self.options.getMessage(resp));
failed(resp);
}
}, (resp) => {
failed(self.options.getMessage(resp));
failed(resp);
});
};

Expand All @@ -1044,8 +1049,9 @@ export default class FileBrowser extends Component {
let respData = <FileBrowserAnswer>self.options.items.process.call(self, resp);
self.generateItemsBox(respData.data.sources);
self.someSelectedWasChanged();
}, () => {
self.status(self.jodit.i18n('Error on load list'));
}, (message: string) => {
Alert(message);
self.status(self.jodit.i18n(message));
});
}
};
Expand Down Expand Up @@ -1170,9 +1176,9 @@ export default class FileBrowser extends Component {

private onSelect(callback: (data: FileBrowserCallBcackData) => void) {
return () => {
let actives = this.__getActiveElements();
const actives = this.__getActiveElements();
if (actives.length) {
let urls = [];
const urls: string[] = [];
actives.forEach((elm) => {
urls.push(elm.getAttribute('data-url'));
});
Expand Down Expand Up @@ -1207,9 +1213,17 @@ export default class FileBrowser extends Component {
open = (callback: (data: FileBrowserCallBcackData) => void) => {
if (this.options.items.url) {

let localTimeot = 0;
this
.__off(this.files, 'dblclick')
.__on(this.files, 'dblclick', 'a', this.onSelect(callback));
.__on(this.files, 'dblclick', 'a', this.onSelect(callback))
.__on(this.files, 'touchstart', 'a', () => {
let now: number = (new Date()).getTime();
if (now - localTimeot < consts.EMULATE_DBLCLICK_TIMEOUT) {
this.onSelect(callback)();
}
localTimeot = now;
});

this
.__off(this.buttons.select, 'click')
Expand Down Expand Up @@ -1287,10 +1301,10 @@ export default class FileBrowser extends Component {
onFailed(this.options.getMessage(resp));
}
}
}, (resp) => {
failed(this.options.getMessage(resp));
}, (resp: string) => {
failed(resp);
if (onFailed) {
onFailed(this.options.getMessage(resp));
onFailed(resp);
}
});
});
Expand Down
119 changes: 59 additions & 60 deletions src/modules/Toolbar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ export default class Toolbar extends Component{
name: string = typeof item === 'string' ? item : (item.name || 'empty'),
a: HTMLAnchorElement = btn.querySelector('a');

let iconSVG = Toolbar.getIcon(name, false);
let iconSVG: string|false = Toolbar.getIcon(name, false);

if (iconSVG === false) {
iconSVG = Toolbar.getIcon(typeof control.name === 'string' ? control.name : 'empty');
Expand All @@ -242,7 +242,7 @@ export default class Toolbar extends Component{
Toolbar.__toggleButton(btn, enable);
});

let icon = dom(iconSVG);
let icon = dom(<string>iconSVG);
icon.classList.add('jodit_icon', 'jodit_icon_' + clearName);
a.appendChild(icon);

Expand All @@ -269,70 +269,69 @@ export default class Toolbar extends Component{
btn.removeChild(btn.querySelector('.jodit_tooltip'));
}

btn
.addEventListener('mousedown', (originalEvent) => {
originalEvent.stopImmediatePropagation();
originalEvent.preventDefault();
this.__on(btn, 'mousedown touchend', (originalEvent) => {
originalEvent.stopImmediatePropagation();
originalEvent.preventDefault();

if (btn.classList.contains('jodit_disabled')) {
return false;
}
if (btn.classList.contains('jodit_disabled')) {
return false;
}


if (control.list) {
this.openList(btn);
each(control.list, (key: string, value: string) => {
let elm;
if (this.jodit.options.controls[value] !== undefined) {
elm = this.addButton(value, this.jodit.options.controls[value], '', target); // list like array {"align": {list: ["left", "right"]}}
} else if (this.jodit.options.controls[key] !== undefined) {
elm = this.addButton(key, extend({}, this.jodit.options.controls[key], value),'', target); // list like object {"align": {list: {"left": {exec: alert}, "right": {}}}}
} else {
elm = this.addButton(key, {
exec: control.exec,
command: control.command,
args: [
(control.args && control.args[0]) || key,
(control.args && control.args[1]) || value
]
},
control.template && control.template(
this.jodit,
key,
value
),
target
);
}
if (control.list) {
this.openList(btn);
each(control.list, (key: string, value: string) => {
let elm;
if (this.jodit.options.controls[value] !== undefined) {
elm = this.addButton(value, this.jodit.options.controls[value], '', target); // list like array {"align": {list: ["left", "right"]}}
} else if (this.jodit.options.controls[key] !== undefined) {
elm = this.addButton(key, extend({}, this.jodit.options.controls[key], value),'', target); // list like object {"align": {list: {"left": {exec: alert}, "right": {}}}}
} else {
elm = this.addButton(key, {
exec: control.exec,
command: control.command,
args: [
(control.args && control.args[0]) || key,
(control.args && control.args[1]) || value
]
},
control.template && control.template(
this.jodit,
key,
value
),
target
);
}

this.list.appendChild(elm);
});
btn.appendChild(this.list);
} else if (control.exec !== undefined && typeof control.exec === 'function') {
control.exec(
this.jodit,
target || this.jodit.selection.current(),
control,
originalEvent,
btn
);
this.jodit.setEditorValue();
this.jodit.events.fire('hidePopup');
this.list.appendChild(elm);
});
btn.appendChild(this.list);
} else if (control.exec !== undefined && typeof control.exec === 'function') {
control.exec(
this.jodit,
target || this.jodit.selection.current(),
control,
originalEvent,
btn
);
this.jodit.setEditorValue();
this.jodit.events.fire('hidePopup');
this.closeAll();
} else if (control.popup !== undefined && typeof control.popup === 'function') {
this.openPopup(btn, control.popup(
this.jodit,
target || this.jodit.selection.current(),
control,
this.closeAll
));
} else {
if (control.command || name) {
this.jodit.execCommand(control.command || name, (control.args && control.args[0]) || false, (control.args && control.args[1]) || null);
this.closeAll();
} else if (control.popup !== undefined && typeof control.popup === 'function') {
this.openPopup(btn, control.popup(
this.jodit,
target || this.jodit.selection.current(),
control,
this.closeAll
));
} else {
if (control.command || name) {
this.jodit.execCommand(control.command || name, (control.args && control.args[0]) || false, (control.args && control.args[1]) || null);
this.closeAll();
}
}
});
}
})

this.buttonList.push({
control,
Expand Down
12 changes: 5 additions & 7 deletions src/modules/Widget.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,13 +50,9 @@ export namespace Widget {

form.appendChild(dom('<a data-color="" href="javascript:void(0)">' + Jodit.modules.Toolbar.getIcon('eraser') + '</a>'));

form
.addEventListener('mousedown', (e) => {
editor
.__on(form, 'mousedown touchstart', (e: MouseEvent) => {
e.stopPropagation();
});

form
.addEventListener('mousedown', (e: MouseEvent) => {
let target: HTMLElement = <HTMLElement>e.target;

if (target.tagName.toUpperCase() === 'SVG' || target.tagName.toUpperCase() === 'PATH') {
Expand Down Expand Up @@ -139,7 +135,8 @@ export namespace Widget {
}

tabBox.appendChild(tab);
button.addEventListener('mousedown', (e) => {

editor.__on(button, 'mousedown touchstart', (e) => {
$$('a', buttons).forEach((a) => {
a.classList.remove('active');
});
Expand All @@ -155,6 +152,7 @@ export namespace Widget {
e.stopPropagation();
return false;
});

tabcount += 1;
});
if (!tabcount) {
Expand Down
Loading

0 comments on commit ba94ab7

Please sign in to comment.