Skip to content

Commit

Permalink
All added videos are deleted when you click Delete or Backspace #847
Browse files Browse the repository at this point in the history
Issue: #847
  • Loading branch information
xdan committed Jun 4, 2022
1 parent d5ae864 commit d3d0845
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 5 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.MD
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
#### :bug: Bug Fix

- [Multiple modals 'Paste as HTML' after longer pressing ctrl+v #849](https://github.com/xdan/jodit/issues/849)
- [All added videos are deleted when you click Delete or Backspace #847](https://github.com/xdan/jodit/issues/847)

## 3.18.6

Expand Down
5 changes: 3 additions & 2 deletions src/core/selection/select.ts
Original file line number Diff line number Diff line change
Expand Up @@ -623,7 +623,7 @@ export class Select implements ISelect {
}

if (fireChange && this.j.events) {
this.j.e.fire('synchro');
this.j.__imdSynchronizeValues();
}

if (this.j.events) {
Expand Down Expand Up @@ -692,7 +692,8 @@ export class Select implements ISelect {
}
}

this.j.synchronizeValues();
// There is no need to use synchronizeValues because you need to apply the changes immediately
this.j.__imdSynchronizeValues();
}

/**
Expand Down
12 changes: 10 additions & 2 deletions src/jodit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -440,6 +440,14 @@ export class Jodit extends ViewWithToolbar implements IJodit {

@throttle()
synchronizeValues(): void {
this.__imdSynchronizeValues();
}

/**
* This is an internal method, do not use it in your applications.
* @private
*/
__imdSynchronizeValues(): void {
this.setEditorValue();
}

Expand Down Expand Up @@ -549,7 +557,7 @@ export class Jodit extends ViewWithToolbar implements IJodit {
throw error('value must be string');
}

if (value !== undefined && this.getNativeEditorValue() !== value) {
if (!isVoid(value) && this.getNativeEditorValue() !== value) {
this.setNativeEditorValue(value);
}

Expand Down Expand Up @@ -604,7 +612,7 @@ export class Jodit extends ViewWithToolbar implements IJodit {
/**
* @deprecated Use `Jodit.value` instead
*/
setElementValue(value?: string): CanPromise<void> {
protected setElementValue(value?: string): CanPromise<void> {
const oldValue = this.getElementValue();

if (value === undefined || (isString(value) && value !== oldValue)) {
Expand Down
2 changes: 1 addition & 1 deletion src/plugins/keyboard/backspace/backspace.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ export class Backspace extends Plugin {

if (
!trim(jodit.editor.textContent || '') &&
!jodit.editor.querySelector('img') &&
!jodit.editor.querySelector('img,table,jodit,iframe,hr') &&
(!current || !Dom.closest(current, 'table', jodit.editor))
) {
jodit.editor.innerHTML = '';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
* Released under MIT see LICENSE.txt in the project root for license information.
* Copyright (c) 2013-2022 Valeriy Chupurnov. All rights reserved. https://xdsoft.net
*/

import type { IJodit } from 'jodit/types';

/**
Expand Down
6 changes: 6 additions & 0 deletions src/types/jodit.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,13 @@ interface IJodit extends IViewWithToolbar {
getNativeEditorValue(): string;
getEditorValue(removeSelectionMarkers?: boolean, consumer?: string): string;
setEditorValue(value?: string): void;

synchronizeValues(): void;
/**
* This is an internal method, do not use it in your applications.
* @private
*/
__imdSynchronizeValues(): void;

/**
* Only getter
Expand Down

0 comments on commit d3d0845

Please sign in to comment.