Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
vinhtranchau committed May 6, 2018
1 parent bcf6a91 commit 93806ba
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 18 deletions.
12 changes: 6 additions & 6 deletions app.css
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@ body {
margin: 0;
}
.jodit_wysiwyg{
color: #000;
padding: 10px;
overflow-x: auto;
color: #000;
padding: 10px;
min-height: 40px;
/*color: #000;*/
/*padding: 10px;*/
/*overflow-x: auto;*/
/*color: #000;*/
/*padding: 10px;*/
/*min-height: 40px;*/
}
* {
-webkit-box-sizing: border-box;
Expand Down
10 changes: 7 additions & 3 deletions src/Jodit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -323,10 +323,7 @@ export class Jodit extends Component {
private __createEditor() {
if (this.events.fire('createEditor') !== false) {
this.editor = <HTMLDivElement>dom(`<div class="jodit_wysiwyg" contenteditable aria-disabled="false" tabindex="${this.options.tabIndex}"></div>`, this.ownerDocument);
// fix fo ie
this.workplace.appendChild(this.ownerDocument.createTextNode("\n"));
this.workplace.appendChild(this.editor);
this.workplace.appendChild(this.ownerDocument.createTextNode("\n"));
}

if (this.options.editorCssClass) {
Expand Down Expand Up @@ -377,7 +374,13 @@ export class Jodit extends Component {
}
}

/**
* Editor was destructed
*
* @type {boolean}
*/
isDestructed: boolean = false;

/**
* Jodit's Destructor. Remove editor, and return source input
*/
Expand All @@ -387,6 +390,7 @@ export class Jodit extends Component {
}

this.isDestructed = true;

/**
* Triggered before {@link events:beforeDestruct|beforeDestruct} executed. If returned false method stopped
*
Expand Down
16 changes: 8 additions & 8 deletions src/modules/Selection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -269,14 +269,14 @@ export class Select extends Component{
range: Range = jodit.editorDocument.createRange();

if (!sel.rangeCount || !this.current()) {
let child: Node|null = jodit.editor.firstChild;

if (!child) {
child = jodit.editorDocument.createTextNode(consts.INVISIBLE_SPACE);
jodit.editor.appendChild(child);
}

range.selectNodeContents(child);
// let child: Node|null = jodit.editor.firstChild;
//
// if (!child) {
// child = jodit.editorDocument.createTextNode(consts.INVISIBLE_SPACE);
// jodit.editor.appendChild(child);
// }

range.setStart(jodit.editor, 0);
range.collapse(true);
sel.removeAllRanges();
sel.addRange(range);
Expand Down
6 changes: 5 additions & 1 deletion src/plugins/autofocus.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,11 @@ export function autofocus(editor: Jodit) {
})
.on('mousedown', (e: MouseEvent) => {
if (editor.isEditorMode() && e.target && Dom.isBlock(<Node>e.target) && !(<HTMLElement>e.target).childNodes.length) {
editor.selection.setCursorIn(<HTMLElement>e.target);
if (editor.editor === e.target) {
editor.selection.focus()
} else {
editor.selection.setCursorIn(<HTMLElement>e.target);
}
}
})
.on('beforeDestruct', () => {
Expand Down

0 comments on commit 93806ba

Please sign in to comment.