Skip to content

Commit

Permalink
fix iframe div
Browse files Browse the repository at this point in the history
  • Loading branch information
wangyu committed Aug 17, 2016
1 parent 59e2aa6 commit ba4ea63
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 33 deletions.
4 changes: 2 additions & 2 deletions Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ module.exports = function (grunt) {
},
build: {
src: 'dist/js/medium-editor.js',
dest: 'dist/js/<%= pkg.name %>.min.js'
dest: 'dist/js/<%= pkg.name.replace("@terminus/","") %>.min.js'
}
};

Expand Down Expand Up @@ -274,7 +274,7 @@ module.exports = function (grunt) {
.concat(['src/wrappers/start.js'])
.concat(srcFiles)
.concat(['src/wrappers/end.js']),
dest: 'dist/js/<%= pkg.name %>.js',
dest: 'dist/js/<%= pkg.name.replace("@terminus/","") %>.js',
nonull: true
}
};
Expand Down
52 changes: 29 additions & 23 deletions dist/js/medium-editor.js
Original file line number Diff line number Diff line change
Expand Up @@ -2465,7 +2465,10 @@ MediumEditor.extensions = {};
// Helpers for event handling

attachDOMEvent: function (targets, event, listener, useCapture) {
targets = MediumEditor.util.isElement(targets) || [window, document].indexOf(targets) > -1 ? [targets] : targets;
var win = this.base.options.contentWindow,
doc = this.base.options.ownerDocument;

targets = MediumEditor.util.isElement(targets) || [win, doc].indexOf(targets) > -1 ? [targets] : targets;

Array.prototype.forEach.call(targets, function (target) {
target.addEventListener(event, listener, useCapture);
Expand All @@ -2474,8 +2477,11 @@ MediumEditor.extensions = {};
},

detachDOMEvent: function (targets, event, listener, useCapture) {
var index, e;
targets = MediumEditor.util.isElement(targets) || [window, document].indexOf(targets) > -1 ? [targets] : targets;
var index, e,
win = this.base.options.contentWindow,
doc = this.base.options.ownerDocument;

targets = MediumEditor.util.isElement(targets) || [win, doc].indexOf(targets) > -1 ? [targets] : targets;

Array.prototype.forEach.call(targets, function (target) {
index = this.indexOfListener(target, event, listener, useCapture);
Expand Down Expand Up @@ -2643,23 +2649,23 @@ MediumEditor.extensions = {};

// Helper method to call all listeners to execCommand
var callListeners = function (args, result) {
if (doc.execCommand.listeners) {
doc.execCommand.listeners.forEach(function (listener) {
listener({
command: args[0],
value: args[2],
args: args,
result: result
});
if (doc.execCommand.listeners) {
doc.execCommand.listeners.forEach(function (listener) {
listener({
command: args[0],
value: args[2],
args: args,
result: result
});
}
},
});
}
},

// Create a wrapper method for execCommand which will:
// 1) Call document.execCommand with the correct arguments
// 2) Loop through any listeners and notify them that execCommand was called
// passing extra info on the call
// 3) Return the result
// Create a wrapper method for execCommand which will:
// 1) Call document.execCommand with the correct arguments
// 2) Loop through any listeners and notify them that execCommand was called
// passing extra info on the call
// 3) Return the result
wrapper = function () {
var result = doc.execCommand.orig.apply(this, arguments);

Expand Down Expand Up @@ -2834,10 +2840,10 @@ MediumEditor.extensions = {};
// For clicks, we need to know if the mousedown that caused the click happened inside the existing focused element
// or one of the extension elements. If so, we don't want to focus another element
if (hadFocus &&
eventObj.type === 'click' &&
this.lastMousedownTarget &&
(MediumEditor.util.isDescendant(hadFocus, this.lastMousedownTarget, true) ||
isElementDescendantOfExtension(this.base.extensions, this.lastMousedownTarget))) {
eventObj.type === 'click' &&
this.lastMousedownTarget &&
(MediumEditor.util.isDescendant(hadFocus, this.lastMousedownTarget, true) ||
isElementDescendantOfExtension(this.base.extensions, this.lastMousedownTarget))) {
toFocus = hadFocus;
}

Expand All @@ -2855,7 +2861,7 @@ MediumEditor.extensions = {};

// Check if the target is external (not part of the editor, toolbar, or any other extension)
var externalEvent = !MediumEditor.util.isDescendant(hadFocus, target, true) &&
!isElementDescendantOfExtension(this.base.extensions, target);
!isElementDescendantOfExtension(this.base.extensions, target);

if (toFocus !== hadFocus) {
// If element has focus, and focus is going outside of editor
Expand Down
8 changes: 4 additions & 4 deletions dist/js/medium-editor.min.js

Large diffs are not rendered by default.

5 changes: 1 addition & 4 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "medium-editor",
"name": "@terminus/medium-editor",
"version": "5.21.1",
"author": "Davi Ferreira <hi@daviferreira.com>",
"contributors": [
Expand Down Expand Up @@ -34,9 +34,6 @@
"wysiwyg",
"rich-text"
],
"publishConfig": {
"registry": "http://registry.npmjs.org/"
},
"license": "MIT",
"devDependencies": {
"brfs": "1.4.2",
Expand Down

0 comments on commit ba4ea63

Please sign in to comment.