Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 2 additions & 14 deletions index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ function domPaste(e: Event, callback: (data: HTMLElement) => void) {
var backward: boolean = isBackward(selection);
var range: Range = currentRange(selection);
var activeElement = <HTMLElement>doc.activeElement;

// create temporary content editable contaner
var container: HTMLElement = doc.createElement('div');
container.contentEditable = 'true';
Expand All @@ -36,8 +36,7 @@ function domPaste(e: Event, callback: (data: HTMLElement) => void) {

doc.body.appendChild(container);

// observer for dom mutations in container
var observer = new MutationObserver(function() {
setTimeout(function() {
// remove br element, if it's still there (Firefox fix)
if (br.parentNode) {
br.parentNode.removeChild(br);
Expand All @@ -49,10 +48,6 @@ function domPaste(e: Event, callback: (data: HTMLElement) => void) {
setRange(selection, range, backward);
}

// avoid having handler fire again if changes
// are made within the callback
observer.disconnect();

try {
callback(container);
} finally {
Expand All @@ -61,13 +56,6 @@ function domPaste(e: Event, callback: (data: HTMLElement) => void) {
}
});

observer.observe(container, {
childList: true,
attributes: true,
characterData: true,
subtree: true
});

// move focus and selection to temporary container
container.focus();
var selector: Range = doc.createRange();
Expand Down