Skip to content
This repository has been archived by the owner on Jun 15, 2021. It is now read-only.

Commit

Permalink
Merge remote-tracking branch 'upstream/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
danburzo committed Feb 11, 2017
2 parents 7af4b81 + a0a386c commit 91d011a
Show file tree
Hide file tree
Showing 5 changed files with 126 additions and 41 deletions.
20 changes: 0 additions & 20 deletions TODO

This file was deleted.

6 changes: 3 additions & 3 deletions src/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,9 @@ define(['immutable'], function (immutable) {


function defaults(options, defaultOptions) {
const optionsCopy = immutable.fromJS(options);
const defaultsCopy = immutable.fromJS(defaultOptions);
const mergedOptions = defaultsCopy.merge(optionsCopy);
var optionsCopy = immutable.fromJS(options);
var defaultsCopy = immutable.fromJS(defaultOptions);
var mergedOptions = defaultsCopy.merge(optionsCopy);
return mergedOptions.toJS();
}

Expand Down
96 changes: 96 additions & 0 deletions src/plugins/core/formatters/plain-text/escape-html-characters.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,99 @@
define('lodash-amd/modern/internal/baseToString',[], function() {

/**
* Converts `value` to a string if it is not one. An empty string is returned
* for `null` or `undefined` values.
*
* @private
* @param {*} value The value to process.
* @returns {string} Returns the string.
*/
function baseToString(value) {
if (typeof value == 'string') {
return value;
}
return value == null ? '' : (value + '');
}

return baseToString;
});

define('lodash-amd/modern/internal/escapeHtmlChar',[], function() {

/** Used to map characters to HTML entities. */
var htmlEscapes = {
'&': '&',
'<': '&lt;',
'>': '&gt;',
'"': '&quot;',
"'": '&#39;',
'`': '&#96;'
};

/**
* Used by `_.escape` to convert characters to HTML entities.
*
* @private
* @param {string} chr The matched character to escape.
* @returns {string} Returns the escaped character.
*/
function escapeHtmlChar(chr) {
return htmlEscapes[chr];
}

return escapeHtmlChar;
});

define('lodash-amd/modern/string/escape',['../internal/baseToString', '../internal/escapeHtmlChar'], function(baseToString, escapeHtmlChar) {

/** Used to match HTML entities and HTML characters. */
var reUnescapedHtml = /[&<>"'`]/g,
reHasUnescapedHtml = RegExp(reUnescapedHtml.source);

/**
* Converts the characters "&", "<", ">", '"', "'", and "\`", in `string` to
* their corresponding HTML entities.
*
* **Note:** No other characters are escaped. To escape additional characters
* use a third-party library like [_he_](https://mths.be/he).
*
* Though the ">" character is escaped for symmetry, characters like
* ">" and "/" don't require escaping in HTML and have no special meaning
* unless they're part of a tag or unquoted attribute value.
* See [Mathias Bynens's article](https://mathiasbynens.be/notes/ambiguous-ampersands)
* (under "semi-related fun fact") for more details.
*
* Backticks are escaped because in Internet Explorer < 9, they can break out
* of attribute values or HTML comments. See [#102](https://html5sec.org/#102),
* [#108](https://html5sec.org/#108), and [#133](https://html5sec.org/#133) of
* the [HTML5 Security Cheatsheet](https://html5sec.org/) for more details.
*
* When working with HTML you should always quote attribute values to reduce
* XSS vectors. See [Ryan Grove's article](http://wonko.com/post/html-escaping)
* for more details.
*
* @static
* @memberOf _
* @category String
* @param {string} [string=''] The string to escape.
* @returns {string} Returns the escaped string.
* @example
*
* _.escape('fred, barney, & pebbles');
* // => 'fred, barney, &amp; pebbles'
*/
function escape(string) {
// Reset `lastIndex` because in IE < 9 `String#replace` does not.
string = baseToString(string);
return (string && reHasUnescapedHtml.test(string))
? string.replace(reUnescapedHtml, escapeHtmlChar)
: string;
}

return escape;
});


define([
'lodash-amd/modern/string/escape'
], function (
Expand Down
8 changes: 8 additions & 0 deletions src/plugins/core/inline-elements-mode.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,14 @@ define(['../../node'], function (nodeHelpers) {
var brNode = document.createElement('br');

range.insertNode(brNode);

// Safari does not update the endoffset after inserting the BR element
// so we have to do it ourselves.
// References:
// https://bugs.webkit.org/show_bug.cgi?id=63538#c3
// https://dom.spec.whatwg.org/#dom-range-selectnode
range.setEndAfter(brNode);

// After inserting the BR into the range is no longer collapsed, so
// we have to collapse it again.
// TODO: Older versions of Firefox require this argument even though
Expand Down
37 changes: 19 additions & 18 deletions src/plugins/core/patches/commands/insert-list.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,24 +24,25 @@ define([], function () {
return node.nodeName === 'OL' || node.nodeName === 'UL';
});

/**
* Firefox: If we apply the insertOrderedList or the insertUnorderedList
* command on an empty block, a P will be inserted after the OL/UL.
* As per: http://jsbin.com/cubacoli/3/edit?html,js,output
*/

if (listElement.nextElementSibling &&
listElement.nextElementSibling.childNodes.length === 0) {
nodeHelpers.removeNode(listElement.nextElementSibling);
}
if (listElement) {

/**
* Chrome: If we apply the insertOrderedList or the insertUnorderedList
* command on an empty block, the OL/UL will be nested inside the block.
* As per: http://jsbin.com/eFiRedUc/1/edit?html,js,output
*/
/**
* Firefox: If we apply the insertOrderedList or the insertUnorderedList
* command on an empty block, a P will be inserted after the OL/UL.
* As per: http://jsbin.com/cubacoli/3/edit?html,js,output
*/

if (listElement.nextElementSibling &&
listElement.nextElementSibling.childNodes.length === 0) {
nodeHelpers.removeNode(listElement.nextElementSibling);
}

/**
* Chrome: If we apply the insertOrderedList or the insertUnorderedList
* command on an empty block, the OL/UL will be nested inside the block.
* As per: http://jsbin.com/eFiRedUc/1/edit?html,js,output
*/

if (listElement) {
var listParentNode = listElement.parentNode;
// If list is within a text block then split that block
if (listParentNode && /^(H[1-6]|P)$/.test(listParentNode.nodeName)) {
Expand All @@ -63,9 +64,9 @@ define([], function () {
nodeHelpers.removeNode(listParentNode);
}
}
}

nodeHelpers.removeChromeArtifacts(listElement);
nodeHelpers.removeChromeArtifacts(listElement);
}
}
}.bind(this));
};
Expand Down

0 comments on commit 91d011a

Please sign in to comment.