Skip to content

Commit

Permalink
Fix a lot of bugs with backspace keypressing
Browse files Browse the repository at this point in the history
  • Loading branch information
xdan committed Feb 6, 2018
1 parent 3d76d42 commit 67ab7e1
Show file tree
Hide file tree
Showing 12 changed files with 703 additions and 206 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "jodit",
"version": "3.1.27",
"description": "Jodit is awesome and usefully wysiwyg editor with filebrowser",
"main": "index.js",
"main": "build/jodit.min.js",
"scripts": {
"newversion": "npm test && npm version patch --no-git-tag-version && npm run build && npm run newversiongit && npm publish ./",
"newversiongit": "git add --all && git commit -m \"New version %npm_package_version%. Read more https://github.com/xdan/jodit/releases/tag/%npm_package_version% \" && git tag %npm_package_version% && git push --tags origin HEAD:master",
Expand Down
23 changes: 21 additions & 2 deletions src/modules/Dom.ts
Original file line number Diff line number Diff line change
Expand Up @@ -429,8 +429,8 @@ export class Dom {
* @param elm
* @param newElement
*/
static after(elm: HTMLElement, newElement: HTMLElement|DocumentFragment) {
const parentNode: Node|null = elm.parentNode;
static after(elm: HTMLElement, newElement: HTMLElement | DocumentFragment) {
const parentNode: Node | null = elm.parentNode;

if (!parentNode) {
return;
Expand All @@ -443,6 +443,25 @@ export class Dom {
}
}

/**
* Move all content to another element
*
* @param {Node} from
* @param {Node} to
* @param {boolean} inStart
*/
static moveContent(from: Node, to: Node, inStart: boolean = false) {
const fragment: DocumentFragment = from.ownerDocument.createDocumentFragment();
[].slice.call(from.childNodes).forEach((node: Node) => {
fragment.appendChild(node);
});
if (!inStart || !to.firstChild) {
to.appendChild(fragment);
} else {
to.insertBefore(fragment, to.firstChild);
}
}

static all(node: Node, condition: (element: Node) => boolean|void, prev: boolean = false): Node|void {
let nodes: Node[] = node.childNodes ? Array.prototype.slice.call(node.childNodes) : [];

Expand Down
295 changes: 246 additions & 49 deletions src/plugins/backspace.ts

Large diffs are not rendered by default.

11 changes: 4 additions & 7 deletions test/tests/dialogTest.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
describe('Dialog system tests', function() {
appendTestArea('dialog_area', true);
describe('About dialog', function() {
it('Should be opened when use clicks on the About button', function () {
getBox().style.width = '100%';
var editor = new Jodit('#dialog_area', {
var editor = new Jodit(appendTestArea(), {
disablePlugins: 'mobile'
});

Expand Down Expand Up @@ -48,7 +47,7 @@ describe('Dialog system tests', function() {
describe('Dialog image', function () {
describe('Opened dialog image', function () {
it('Should disable margin inputs for left, bottom, right if element has equals margins(margin:10px;)', function () {
var editor = new Jodit('#dialog_area', {
var editor = new Jodit(appendTestArea(), {
observer: {
timeout: 0
},
Expand All @@ -65,7 +64,7 @@ describe('Dialog system tests', function() {
expect(dialog.querySelectorAll('input.margins[disabled]').length).to.equal(3);
});
it('Should enable margin inputs for left, bottom, right if element has not equals margins(margin:10px 5px;)', function () {
var editor = new Jodit('#dialog_area', {
var editor = new Jodit(appendTestArea(), {
observer: {
timeout: 0
},
Expand All @@ -83,13 +82,11 @@ describe('Dialog system tests', function() {
});
});
});
after(function() {
dialog_area.parentNode.removeChild(dialog_area);
});
afterEach(function () {
var i, keys = Object.keys(Jodit.instances);
for (i = 0; i < keys.length; i += 1) {
Jodit.instances[keys[i]].destruct();
}
removeStuff();
});
});
Loading

0 comments on commit 67ab7e1

Please sign in to comment.