quill-rails 0.1.3 → 0.1.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/README.md CHANGED
@@ -55,15 +55,27 @@ To have an id that's different from the name:
55
55
  <%= quill_editor nil, { name: 'my-name', id: 'my-id' } %>
56
56
  ```
57
57
 
58
+ To have an initial value in the editor:
59
+
60
+ ```
61
+ <%= quill_editor nil, { name: 'my-name', value: 'Awesome!' } %>
62
+ ```
63
+
58
64
  ## Custom Functionality
59
65
 
60
66
  Because this includes Quill assets, you can also refer to the [Quill Documentation](http://quilljs.com/docs/editor/) to use other, more custom, features.
61
67
 
68
+ # Changelog
69
+
70
+ ### 0.1.4
71
+ * Added 'value' option for the helper function (thanks nerdyglasses!)
72
+ * Updated from Quill 0.13 to 0.15
73
+
62
74
  # Roadmap
63
75
 
64
76
  The following features would be nice to have:
65
77
 
66
- - Configuring the default quill_editor e.g. pass in content, change wrapper, change theme, etc.
78
+ - Configuring the default quill_editor e.g. change wrapper, change theme, etc.
67
79
  - Have a form helper tag (f.quill_editor)
68
80
  - Parse any RTE input for malicious tags
69
81
 
@@ -1,4 +1,4 @@
1
- !function(e){if("object"==typeof exports)module.exports=e();else if("function"==typeof define&&define.amd)define(e);else{var f;"undefined"!=typeof window?f=window:"undefined"!=typeof global?f=global:"undefined"!=typeof self&&(f=self),f.Quill=e()}}(function(){var define,module,exports;return (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);throw new Error("Cannot find module '"+o+"'")}var f=n[o]={exports:{}};t[o][0].call(f.exports,function(e){var n=t[o][1][e];return s(n?n:e)},f,f.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(_dereq_,module,exports){
1
+ !function(e){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{var f;"undefined"!=typeof window?f=window:"undefined"!=typeof global?f=global:"undefined"!=typeof self&&(f=self),f.Quill=e()}}(function(){var define,module,exports;return (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);throw new Error("Cannot find module '"+o+"'")}var f=n[o]={exports:{}};t[o][0].call(f.exports,function(e){var n=t[o][1][e];return s(n?n:e)},f,f.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(_dereq_,module,exports){
2
2
  // shim for using process in browser
3
3
 
4
4
  var process = module.exports = {};
@@ -7935,8 +7935,7 @@ module.exports=_dereq_('4HJaAd');
7935
7935
  }
7936
7936
 
7937
7937
  Delta.prototype.apply = function(insertFn, deleteFn, applyAttrFn, context) {
7938
- var index, offset, retains,
7939
- _this = this;
7938
+ var index, offset, retains;
7940
7939
  if (insertFn == null) {
7941
7940
  insertFn = (function() {});
7942
7941
  }
@@ -7955,34 +7954,38 @@ module.exports=_dereq_('4HJaAd');
7955
7954
  index = 0;
7956
7955
  offset = 0;
7957
7956
  retains = [];
7958
- _.each(this.ops, function(op) {
7959
- if (Op.isInsert(op)) {
7960
- insertFn.call(context, index + offset, op.value, op.attributes);
7961
- return offset += op.getLength();
7962
- } else if (Op.isRetain(op)) {
7963
- if (op.start > index) {
7964
- deleteFn.call(context, index + offset, op.start - index);
7965
- offset -= op.start - index;
7957
+ _.each(this.ops, (function(_this) {
7958
+ return function(op) {
7959
+ if (Op.isInsert(op)) {
7960
+ insertFn.call(context, index + offset, op.value, op.attributes);
7961
+ return offset += op.getLength();
7962
+ } else if (Op.isRetain(op)) {
7963
+ if (op.start > index) {
7964
+ deleteFn.call(context, index + offset, op.start - index);
7965
+ offset -= op.start - index;
7966
+ }
7967
+ retains.push(new RetainOp(op.start + offset, op.end + offset, op.attributes));
7968
+ return index = op.end;
7966
7969
  }
7967
- retains.push(new RetainOp(op.start + offset, op.end + offset, op.attributes));
7968
- return index = op.end;
7969
- }
7970
- });
7970
+ };
7971
+ })(this));
7971
7972
  if (this.endLength < this.startLength + offset) {
7972
7973
  deleteFn.call(context, this.endLength, this.startLength + offset - this.endLength);
7973
7974
  }
7974
- return _.each(retains, function(op) {
7975
- _.each(op.attributes, function(value, format) {
7976
- if (value === null) {
7977
- return applyAttrFn.call(context, op.start, op.end - op.start, format, value);
7978
- }
7979
- });
7980
- return _.each(op.attributes, function(value, format) {
7981
- if (value != null) {
7982
- return applyAttrFn.call(context, op.start, op.end - op.start, format, value);
7983
- }
7984
- });
7985
- });
7975
+ return _.each(retains, (function(_this) {
7976
+ return function(op) {
7977
+ _.each(op.attributes, function(value, format) {
7978
+ if (value === null) {
7979
+ return applyAttrFn.call(context, op.start, op.end - op.start, format, value);
7980
+ }
7981
+ });
7982
+ return _.each(op.attributes, function(value, format) {
7983
+ if (value != null) {
7984
+ return applyAttrFn.call(context, op.start, op.end - op.start, format, value);
7985
+ }
7986
+ });
7987
+ };
7988
+ })(this));
7986
7989
  };
7987
7990
 
7988
7991
  Delta.prototype.applyToText = function(text) {
@@ -8430,15 +8433,16 @@ module.exports=_dereq_('4HJaAd');
8430
8433
  };
8431
8434
 
8432
8435
  Delta.prototype.merge = function(other) {
8433
- var ops,
8434
- _this = this;
8435
- ops = _.map(other.ops, function(op) {
8436
- if (Op.isRetain(op)) {
8437
- return new RetainOp(op.start + _this.startLength, op.end + _this.startLength, op.attributes);
8438
- } else {
8439
- return op;
8440
- }
8441
- });
8436
+ var ops;
8437
+ ops = _.map(other.ops, (function(_this) {
8438
+ return function(op) {
8439
+ if (Op.isRetain(op)) {
8440
+ return new RetainOp(op.start + _this.startLength, op.end + _this.startLength, op.attributes);
8441
+ } else {
8442
+ return op;
8443
+ }
8444
+ };
8445
+ })(this));
8442
8446
  ops = this.ops.concat(ops);
8443
8447
  return new Delta(this.startLength + other.startLength, ops);
8444
8448
  };
@@ -8627,8 +8631,7 @@ module.exports=_dereq_('4HJaAd');
8627
8631
  }, 0);
8628
8632
  },
8629
8633
  formatAt: function(delta, formatPoint, numToFormat, attrs, reference) {
8630
- var attr, charIndex, cur, curFormat, head, op, ops, reachedFormatPoint, tail, _formatBooleanAttribute, _formatNonBooleanAttribute, _i, _j, _len, _len1, _limitScope, _ref, _ref1, _splitOpInThree,
8631
- _this = this;
8634
+ var attr, charIndex, cur, curFormat, head, op, ops, reachedFormatPoint, tail, _formatBooleanAttribute, _formatNonBooleanAttribute, _i, _j, _len, _len1, _limitScope, _ref, _ref1, _splitOpInThree;
8632
8635
  _splitOpInThree = function(elem, splitAt, length, reference) {
8633
8636
  var cur, curStr, head, headStr, marker, newCur, op, origOps, tail, tailStr, _i, _len;
8634
8637
  if (InsertOp.isInsert(elem)) {
@@ -8727,37 +8730,39 @@ module.exports=_dereq_('4HJaAd');
8727
8730
  }
8728
8731
  }
8729
8732
  };
8730
- _formatNonBooleanAttribute = function(op, tail, attr, reference) {
8731
- var getNewAttrVal, referenceOps;
8732
- getNewAttrVal = function(prevVal) {
8733
- if (prevVal != null) {
8734
- return _.first(_.shuffle(_.without(domain.nonBooleanAttributes[attr], prevVal)));
8735
- } else {
8736
- return _.first(_.shuffle(_.without(domain.nonBooleanAttributes[attr], domain.defaultAttributeValue[attr])));
8737
- }
8738
- };
8739
- if (InsertOp.isInsert(op)) {
8740
- return op.attributes[attr] = getNewAttrVal(attr, op.attributes[attr]);
8741
- } else {
8742
- if (!RetainOp.isRetain(op)) {
8743
- throw new Error("Expected retain but got " + op);
8744
- }
8745
- referenceOps = reference.getOpsAt(op.start, op.getLength());
8746
- if (!_.every(referenceOps, function(op) {
8747
- return InsertOp.isInsert(op);
8748
- })) {
8749
- throw new Error("Formatting a retain that does not refer to an insert.");
8750
- }
8751
- if (referenceOps.length > 0) {
8752
- _limitScope(op, tail, attr, referenceOps);
8753
- if ((op.attributes[attr] != null) && Math.random() < 0.5) {
8754
- return delete op.attributes[attr];
8733
+ _formatNonBooleanAttribute = (function(_this) {
8734
+ return function(op, tail, attr, reference) {
8735
+ var getNewAttrVal, referenceOps;
8736
+ getNewAttrVal = function(prevVal) {
8737
+ if (prevVal != null) {
8738
+ return _.first(_.shuffle(_.without(domain.nonBooleanAttributes[attr], prevVal)));
8755
8739
  } else {
8756
- return op.attributes[attr] = getNewAttrVal(op.attributes[attr]);
8740
+ return _.first(_.shuffle(_.without(domain.nonBooleanAttributes[attr], domain.defaultAttributeValue[attr])));
8741
+ }
8742
+ };
8743
+ if (InsertOp.isInsert(op)) {
8744
+ return op.attributes[attr] = getNewAttrVal(attr, op.attributes[attr]);
8745
+ } else {
8746
+ if (!RetainOp.isRetain(op)) {
8747
+ throw new Error("Expected retain but got " + op);
8748
+ }
8749
+ referenceOps = reference.getOpsAt(op.start, op.getLength());
8750
+ if (!_.every(referenceOps, function(op) {
8751
+ return InsertOp.isInsert(op);
8752
+ })) {
8753
+ throw new Error("Formatting a retain that does not refer to an insert.");
8754
+ }
8755
+ if (referenceOps.length > 0) {
8756
+ _limitScope(op, tail, attr, referenceOps);
8757
+ if ((op.attributes[attr] != null) && Math.random() < 0.5) {
8758
+ return delete op.attributes[attr];
8759
+ } else {
8760
+ return op.attributes[attr] = getNewAttrVal(op.attributes[attr]);
8761
+ }
8757
8762
  }
8758
8763
  }
8759
- }
8760
- };
8764
+ };
8765
+ })(this);
8761
8766
  charIndex = 0;
8762
8767
  ops = [];
8763
8768
  _ref = delta.ops;
@@ -8955,30 +8960,31 @@ module.exports=_dereq_('4HJaAd');
8955
8960
  };
8956
8961
 
8957
8962
  Op.prototype.composeAttributes = function(attributes) {
8958
- var resolveAttributes,
8959
- _this = this;
8960
- resolveAttributes = function(oldAttrs, newAttrs) {
8961
- var key, resolvedAttrs, value;
8962
- if (!newAttrs) {
8963
- return oldAttrs;
8964
- }
8965
- resolvedAttrs = _.clone(oldAttrs);
8966
- for (key in newAttrs) {
8967
- value = newAttrs[key];
8968
- if (Op.isInsert(_this) && value === null) {
8969
- delete resolvedAttrs[key];
8970
- } else if (typeof value !== 'undefined') {
8971
- if (typeof resolvedAttrs[key] === 'object' && typeof value === 'object' && _.all([resolvedAttrs[key], newAttrs[key]], (function(val) {
8972
- return val !== null;
8973
- }))) {
8974
- resolvedAttrs[key] = resolveAttributes(resolvedAttrs[key], value);
8975
- } else {
8976
- resolvedAttrs[key] = value;
8963
+ var resolveAttributes;
8964
+ resolveAttributes = (function(_this) {
8965
+ return function(oldAttrs, newAttrs) {
8966
+ var key, resolvedAttrs, value;
8967
+ if (!newAttrs) {
8968
+ return oldAttrs;
8969
+ }
8970
+ resolvedAttrs = _.clone(oldAttrs);
8971
+ for (key in newAttrs) {
8972
+ value = newAttrs[key];
8973
+ if (Op.isInsert(_this) && value === null) {
8974
+ delete resolvedAttrs[key];
8975
+ } else if (typeof value !== 'undefined') {
8976
+ if (typeof resolvedAttrs[key] === 'object' && typeof value === 'object' && _.all([resolvedAttrs[key], newAttrs[key]], (function(val) {
8977
+ return val !== null;
8978
+ }))) {
8979
+ resolvedAttrs[key] = resolveAttributes(resolvedAttrs[key], value);
8980
+ } else {
8981
+ resolvedAttrs[key] = value;
8982
+ }
8977
8983
  }
8978
8984
  }
8979
- }
8980
- return resolvedAttrs;
8981
- };
8985
+ return resolvedAttrs;
8986
+ };
8987
+ })(this);
8982
8988
  return resolveAttributes(this.attributes, attributes);
8983
8989
  };
8984
8990
 
@@ -11943,7 +11949,7 @@ module.exports=_dereq_('Fq7WE+');
11943
11949
  },{}],18:[function(_dereq_,module,exports){
11944
11950
  module.exports={
11945
11951
  "name": "quilljs",
11946
- "version": "0.13.4",
11952
+ "version": "0.15.1",
11947
11953
  "description": "Cross browser rich text editor",
11948
11954
  "author": "Jason Chen <jhchen7@gmail.com>",
11949
11955
  "homepage": "http://quilljs.com",
@@ -11955,26 +11961,26 @@ module.exports={
11955
11961
  "dependencies": {
11956
11962
  "eventemitter2": "~0.4.13",
11957
11963
  "lodash": "~2.4.1",
11958
- "tandem-core": "~0.5.2",
11964
+ "tandem-core": "~0.6.1",
11959
11965
  "underscore.string": "~2.3.3"
11960
11966
  },
11961
11967
  "devDependencies": {
11962
- "async": "~0.6.2",
11968
+ "async": "~0.9.0",
11963
11969
  "coffeeify": "~0.6.0",
11964
11970
  "grunt": "~0.4.3",
11965
- "grunt-browserify": "~2.0.7",
11971
+ "grunt-browserify": "~2.1.0",
11966
11972
  "grunt-contrib-clean": "~0.5.0",
11967
11973
  "grunt-contrib-coffee": "~0.10.1",
11968
- "grunt-contrib-concat": "~0.3.0",
11974
+ "grunt-contrib-concat": "~0.4.0",
11969
11975
  "grunt-contrib-connect": "~0.7.1",
11970
11976
  "grunt-contrib-jade": "~0.11.0",
11971
- "grunt-contrib-stylus": "~0.13.2",
11977
+ "grunt-contrib-stylus": "~0.16.0",
11972
11978
  "grunt-contrib-uglify": "~0.4.0",
11973
11979
  "grunt-contrib-watch": "~0.6.1",
11974
11980
  "grunt-karma": "~0.8.0",
11975
11981
  "grunt-newer": "~0.7.0",
11976
11982
  "grunt-protractor-runner": "~0.2.4",
11977
- "grunt-shell": "~0.6.4",
11983
+ "grunt-shell": "~0.7.0",
11978
11984
  "istanbul": "~0.2.6",
11979
11985
  "jquery": "~1.11.0",
11980
11986
  "karma": "~0.12.0",
@@ -11988,7 +11994,7 @@ module.exports={
11988
11994
  "karma-safari-launcher": "~0.1.1",
11989
11995
  "karma-sauce-launcher": "~0.2.2",
11990
11996
  "load-grunt-tasks": "~0.4.0",
11991
- "protractor": "~0.21.0"
11997
+ "protractor": "~0.23.0"
11992
11998
  },
11993
11999
  "engines": {
11994
12000
  "node": ">=0.10"
@@ -12065,7 +12071,7 @@ Document = (function() {
12065
12071
 
12066
12072
  Document.prototype.findLine = function(node) {
12067
12073
  var line;
12068
- while ((node != null) && node.parentNode !== this.root) {
12074
+ while ((node != null) && (DOM.BLOCK_TAGS[node.tagName] == null)) {
12069
12075
  node = node.parentNode;
12070
12076
  }
12071
12077
  line = node != null ? this.lineMap[node.id] : null;
@@ -12143,14 +12149,17 @@ Document = (function() {
12143
12149
  var lineNode, lines, _results;
12144
12150
  lines = this.lines.toArray();
12145
12151
  lineNode = this.root.firstChild;
12152
+ if ((lineNode != null) && (DOM.LIST_TAGS[lineNode.tagName] != null)) {
12153
+ lineNode = lineNode.firstChild;
12154
+ }
12146
12155
  _.each(lines, (function(_this) {
12147
12156
  return function(line, index) {
12148
- var newLine;
12157
+ var newLine, _ref;
12149
12158
  while (line.node !== lineNode) {
12150
- if (line.node.parentNode === _this.root) {
12159
+ if (line.node.parentNode === _this.root || ((_ref = line.node.parentNode) != null ? _ref.parentNode : void 0) === _this.root) {
12151
12160
  lineNode = Normalizer.normalizeLine(lineNode);
12152
12161
  newLine = _this.insertLineBefore(lineNode, line);
12153
- lineNode = lineNode.nextSibling;
12162
+ lineNode = Utils.getNextLineNode(lineNode, _this.root);
12154
12163
  } else {
12155
12164
  return _this.removeLine(line);
12156
12165
  }
@@ -12159,21 +12168,25 @@ Document = (function() {
12159
12168
  line.node = Normalizer.normalizeLine(line.node);
12160
12169
  line.rebuild();
12161
12170
  }
12162
- return lineNode = line.node.nextSibling;
12171
+ return lineNode = Utils.getNextLineNode(lineNode, _this.root);
12163
12172
  };
12164
12173
  })(this));
12165
12174
  _results = [];
12166
12175
  while (lineNode != null) {
12167
12176
  lineNode = Normalizer.normalizeLine(lineNode);
12168
12177
  this.appendLine(lineNode);
12169
- _results.push(lineNode = lineNode.nextSibling);
12178
+ _results.push(lineNode = Utils.getNextLineNode(lineNode, this.root));
12170
12179
  }
12171
12180
  return _results;
12172
12181
  };
12173
12182
 
12174
12183
  Document.prototype.removeLine = function(line) {
12175
- if (line.node.parentNode === this.root) {
12176
- DOM.removeNode(line.node);
12184
+ if (line.node.parentNode != null) {
12185
+ if (DOM.LIST_TAGS[line.node.parentNode.tagName] && line.node.parentNode.childNodes.length === 1) {
12186
+ DOM.removeNode(line.node.parentNode);
12187
+ } else {
12188
+ DOM.removeNode(line.node);
12189
+ }
12177
12190
  }
12178
12191
  delete this.lineMap[line.id];
12179
12192
  return this.lines.remove(line);
@@ -12295,6 +12308,10 @@ DOM = {
12295
12308
  EMBED_TAGS: {
12296
12309
  'IMG': 'IMG'
12297
12310
  },
12311
+ LIST_TAGS: {
12312
+ 'OL': 'OL',
12313
+ 'UL': 'UL'
12314
+ },
12298
12315
  VOID_TAGS: {
12299
12316
  'AREA': 'AREA',
12300
12317
  'BASE': 'BASE',
@@ -12335,6 +12352,10 @@ DOM = {
12335
12352
  return propogate;
12336
12353
  });
12337
12354
  },
12355
+ addStyles: function(node, styles) {
12356
+ styles = _.defaults(styles, DOM.getStyles(node));
12357
+ return DOM.setStyles(node, styles);
12358
+ },
12338
12359
  clearAttributes: function(node, exception) {
12339
12360
  if (exception == null) {
12340
12361
  exception = [];
@@ -12411,9 +12432,6 @@ DOM = {
12411
12432
  if (node.textContent != null) {
12412
12433
  return node.textContent;
12413
12434
  }
12414
- if (node.innerText != null) {
12415
- return node.innerText.replace(/[\r\n]/g, '');
12416
- }
12417
12435
  return "";
12418
12436
  case DOM.TEXT_NODE:
12419
12437
  return node.data || "";
@@ -12531,6 +12549,11 @@ DOM = {
12531
12549
  return DOM.triggerEvent(select, 'change');
12532
12550
  }
12533
12551
  },
12552
+ setAttributes: function(node, attributes) {
12553
+ return _.each(attributes, function(value, name) {
12554
+ return node.setAttribute(name, value);
12555
+ });
12556
+ },
12534
12557
  setStyles: function(node, styles) {
12535
12558
  var styleString;
12536
12559
  styleString = _.map(styles, function(style, name) {
@@ -12541,12 +12564,7 @@ DOM = {
12541
12564
  setText: function(node, text) {
12542
12565
  switch (node.nodeType) {
12543
12566
  case DOM.ELEMENT_NODE:
12544
- if (node.textContent != null) {
12545
- return node.textContent = text;
12546
- } else {
12547
- return node.innerText = text;
12548
- }
12549
- break;
12567
+ return node.textContent = text;
12550
12568
  case DOM.TEXT_NODE:
12551
12569
  return node.data = text;
12552
12570
  }
@@ -12555,7 +12573,7 @@ DOM = {
12555
12573
  var attributes, newNode;
12556
12574
  newTag = newTag.toUpperCase();
12557
12575
  if (node.tagName === newTag) {
12558
- return;
12576
+ return node;
12559
12577
  }
12560
12578
  newNode = node.ownerDocument.createElement(newTag);
12561
12579
  attributes = DOM.getAttributes(node);
@@ -12630,11 +12648,16 @@ DOM = {
12630
12648
  return ret;
12631
12649
  },
12632
12650
  wrap: function(wrapper, node) {
12651
+ var parent;
12633
12652
  if (node.parentNode != null) {
12634
12653
  node.parentNode.insertBefore(wrapper, node);
12635
12654
  }
12636
- wrapper.appendChild(node);
12637
- return wrapper;
12655
+ parent = wrapper;
12656
+ while (parent.firstChild != null) {
12657
+ parent = wrapper.firstChild;
12658
+ }
12659
+ parent.appendChild(node);
12660
+ return parent;
12638
12661
  }
12639
12662
  };
12640
12663
 
@@ -12663,11 +12686,11 @@ Editor = (function() {
12663
12686
  this.iframeContainer = iframeContainer;
12664
12687
  this.quill = quill;
12665
12688
  this.options = options != null ? options : {};
12666
- this.renderer = new Renderer(this.iframeContainer, this.quill, this.options);
12689
+ this.renderer = new Renderer(this.iframeContainer, this.options);
12667
12690
  this.root = this.renderer.root;
12668
12691
  this.doc = new Document(this.root, this.options);
12669
12692
  this.delta = this.doc.toDelta();
12670
- this.selection = new Selection(this.doc, this.quill);
12693
+ this.selection = new Selection(this.doc, this.renderer.iframe, this.quill);
12671
12694
  this.timer = setInterval(_.bind(this.checkUpdate, this), this.options.pollInterval);
12672
12695
  this.quill.on(this.quill.constructor.events.SELECTION_CHANGE, (function(_this) {
12673
12696
  return function(range) {
@@ -12819,7 +12842,9 @@ Editor = (function() {
12819
12842
  line.insertText(offset, lineText, formatting);
12820
12843
  if (i < lineTexts.length - 1) {
12821
12844
  nextLine = _this.doc.splitLine(line, offset + lineText.length);
12822
- line.format(formatting);
12845
+ _.each(_.defaults({}, formatting, line.formats), function(value, format) {
12846
+ return line.format(format, formatting[format]);
12847
+ });
12823
12848
  offset = 0;
12824
12849
  }
12825
12850
  }
@@ -12953,24 +12978,19 @@ Format = (function() {
12953
12978
  align: {
12954
12979
  type: Format.types.LINE,
12955
12980
  style: 'textAlign',
12956
- "default": 'left',
12957
- prepare: function(doc, value) {
12958
- var command;
12959
- switch (value) {
12960
- case 'left':
12961
- command = 'justifyLeft';
12962
- break;
12963
- case 'center':
12964
- command = 'justifyCenter';
12965
- break;
12966
- case 'right':
12967
- command = 'justifyRight';
12968
- break;
12969
- case 'justify':
12970
- command = 'justifyFull';
12971
- }
12972
- return doc.execCommand(command, false);
12973
- }
12981
+ "default": 'left'
12982
+ },
12983
+ bullet: {
12984
+ type: Format.types.LINE,
12985
+ exclude: 'list',
12986
+ parentTag: 'UL',
12987
+ tag: 'LI'
12988
+ },
12989
+ list: {
12990
+ type: Format.types.LINE,
12991
+ exclude: 'bullet',
12992
+ parentTag: 'OL',
12993
+ tag: 'LI'
12974
12994
  }
12975
12995
  };
12976
12996
 
@@ -12980,13 +13000,23 @@ Format = (function() {
12980
13000
  }
12981
13001
 
12982
13002
  Format.prototype.add = function(node, value) {
12983
- var formatNode;
13003
+ var formatNode, parentNode, _ref, _ref1;
12984
13004
  if (!value) {
12985
13005
  return this.remove(node);
12986
13006
  }
12987
13007
  if (this.value(node) === value) {
12988
13008
  return node;
12989
13009
  }
13010
+ if (_.isString(this.config.parentTag)) {
13011
+ parentNode = this.document.createElement(this.config.parentTag);
13012
+ DOM.wrap(parentNode, node);
13013
+ if (node.parentNode.tagName === ((_ref = node.parentNode.previousSibling) != null ? _ref.tagName : void 0)) {
13014
+ Utils.mergeNodes(node.parentNode.previousSibling, node.parentNode);
13015
+ }
13016
+ if (node.parentNode.tagName === ((_ref1 = node.parentNode.nextSibling) != null ? _ref1.tagName : void 0)) {
13017
+ Utils.mergeNodes(node.parentNode, node.parentNode.nextSibling);
13018
+ }
13019
+ }
12990
13020
  if (_.isString(this.config.tag)) {
12991
13021
  formatNode = this.document.createElement(this.config.tag);
12992
13022
  if (DOM.VOID_TAGS[formatNode.tagName] != null) {
@@ -12995,6 +13025,8 @@ Format = (function() {
12995
13025
  }
12996
13026
  DOM.removeNode(node);
12997
13027
  node = formatNode;
13028
+ } else if (this.isType(Format.types.LINE)) {
13029
+ node = DOM.switchTag(node, this.config.tag);
12998
13030
  } else {
12999
13031
  node = DOM.wrap(formatNode, node);
13000
13032
  }
@@ -13026,10 +13058,13 @@ Format = (function() {
13026
13058
  };
13027
13059
 
13028
13060
  Format.prototype.match = function(node) {
13029
- var c, _i, _len, _ref;
13061
+ var c, _i, _len, _ref, _ref1;
13030
13062
  if (!DOM.isElement(node)) {
13031
13063
  return false;
13032
13064
  }
13065
+ if (_.isString(this.config.parentTag) && ((_ref = node.parentNode) != null ? _ref.tagName : void 0) !== this.config.parentTag) {
13066
+ return false;
13067
+ }
13033
13068
  if (_.isString(this.config.tag) && node.tagName !== this.config.tag) {
13034
13069
  return false;
13035
13070
  }
@@ -13040,9 +13075,9 @@ Format = (function() {
13040
13075
  return false;
13041
13076
  }
13042
13077
  if (_.isString(this.config["class"])) {
13043
- _ref = DOM.getClasses(node);
13044
- for (_i = 0, _len = _ref.length; _i < _len; _i++) {
13045
- c = _ref[_i];
13078
+ _ref1 = DOM.getClasses(node);
13079
+ for (_i = 0, _len = _ref1.length; _i < _len; _i++) {
13080
+ c = _ref1[_i];
13046
13081
  if (c.indexOf(this.config["class"]) === 0) {
13047
13082
  return true;
13048
13083
  }
@@ -13087,11 +13122,24 @@ Format = (function() {
13087
13122
  }
13088
13123
  }
13089
13124
  if (_.isString(this.config.tag)) {
13090
- node = DOM.switchTag(node, DOM.DEFAULT_INLINE_TAG);
13091
- if (DOM.EMBED_TAGS[this.config.tag] != null) {
13092
- DOM.setText(node, DOM.EMBED_TEXT);
13125
+ if (this.isType(Format.types.LINE)) {
13126
+ if (node.previousSibling != null) {
13127
+ Utils.splitAncestors(node, node.parentNode.parentNode);
13128
+ }
13129
+ if (node.nextSibling != null) {
13130
+ Utils.splitAncestors(node.nextSibling, node.parentNode.parentNode);
13131
+ }
13132
+ node = DOM.switchTag(node, DOM.DEFAULT_BLOCK_TAG);
13133
+ } else {
13134
+ node = DOM.switchTag(node, DOM.DEFAULT_INLINE_TAG);
13135
+ if (DOM.EMBED_TAGS[this.config.tag] != null) {
13136
+ DOM.setText(node, DOM.EMBED_TEXT);
13137
+ }
13093
13138
  }
13094
13139
  }
13140
+ if (_.isString(this.config.parentTag)) {
13141
+ DOM.unwrap(node.parentNode);
13142
+ }
13095
13143
  if (node.tagName === DOM.DEFAULT_INLINE_TAG && !node.hasAttributes()) {
13096
13144
  node = DOM.unwrap(node);
13097
13145
  }
@@ -13105,7 +13153,7 @@ Format = (function() {
13105
13153
  }
13106
13154
  if (_.isString(this.config.attribute)) {
13107
13155
  return node.getAttribute(this.config.attribute) || void 0;
13108
- } else if (_.isString(this.config.style) && node.style[this.config.style] !== this.config["default"]) {
13156
+ } else if (_.isString(this.config.style)) {
13109
13157
  return node.style[this.config.style] || void 0;
13110
13158
  } else if (_.isString(this.config["class"])) {
13111
13159
  _ref = DOM.getClasses(node);
@@ -13115,7 +13163,7 @@ Format = (function() {
13115
13163
  return c.slice(this.config["class"].length);
13116
13164
  }
13117
13165
  }
13118
- } else if (_.isString(this.config.tag) && node.tagName === this.config.tag) {
13166
+ } else if (_.isString(this.config.tag)) {
13119
13167
  return true;
13120
13168
  }
13121
13169
  return void 0;
@@ -13217,7 +13265,7 @@ ColorPicker = (function(_super) {
13217
13265
 
13218
13266
  function ColorPicker() {
13219
13267
  ColorPicker.__super__.constructor.apply(this, arguments);
13220
- DOM.addClass(this.container, 'sc-color-picker');
13268
+ DOM.addClass(this.container, 'ql-color-picker');
13221
13269
  }
13222
13270
 
13223
13271
  ColorPicker.prototype.buildItem = function(picker, option, index) {
@@ -13335,13 +13383,13 @@ DOM = _dereq_('../dom');
13335
13383
  Normalizer = _dereq_('../normalizer');
13336
13384
 
13337
13385
  Picker = (function() {
13338
- Picker.TEMPLATE = '<span class="sc-picker-label"></span><span class="sc-picker-options"></span>';
13386
+ Picker.TEMPLATE = '<span class="ql-picker-label"></span><span class="ql-picker-options"></span>';
13339
13387
 
13340
13388
  function Picker(select) {
13341
13389
  this.select = select;
13342
13390
  this.container = this.select.ownerDocument.createElement('span');
13343
13391
  this.buildPicker();
13344
- DOM.addClass(this.container, 'sc-picker');
13392
+ DOM.addClass(this.container, 'ql-picker');
13345
13393
  this.select.style.display = 'none';
13346
13394
  this.select.parentNode.insertBefore(this.container, this.select);
13347
13395
  DOM.addEventListener(this.select.ownerDocument, 'click', (function(_this) {
@@ -13353,7 +13401,7 @@ Picker = (function() {
13353
13401
  DOM.addEventListener(this.label, 'click', (function(_this) {
13354
13402
  return function() {
13355
13403
  return _.defer(function() {
13356
- return DOM.toggleClass(_this.container, 'sc-expanded');
13404
+ return DOM.toggleClass(_this.container, 'ql-expanded');
13357
13405
  });
13358
13406
  };
13359
13407
  })(this));
@@ -13361,11 +13409,11 @@ Picker = (function() {
13361
13409
  return function() {
13362
13410
  var item, option;
13363
13411
  if (_this.select.selectedIndex > -1) {
13364
- item = _this.container.querySelectorAll('.sc-picker-item')[_this.select.selectedIndex];
13412
+ item = _this.container.querySelectorAll('.ql-picker-item')[_this.select.selectedIndex];
13365
13413
  option = _this.select.options[_this.select.selectedIndex];
13366
13414
  }
13367
13415
  _this.selectItem(item, false);
13368
- return DOM.toggleClass(_this.label, 'sc-active', option !== DOM.getDefaultOption(_this.select));
13416
+ return DOM.toggleClass(_this.label, 'ql-active', option !== DOM.getDefaultOption(_this.select));
13369
13417
  };
13370
13418
  })(this));
13371
13419
  }
@@ -13374,7 +13422,7 @@ Picker = (function() {
13374
13422
  var item;
13375
13423
  item = this.select.ownerDocument.createElement('span');
13376
13424
  item.setAttribute('data-value', option.getAttribute('value'));
13377
- DOM.addClass(item, 'sc-picker-item');
13425
+ DOM.addClass(item, 'ql-picker-item');
13378
13426
  DOM.setText(item, DOM.getText(option));
13379
13427
  if (this.select.selectedIndex === index) {
13380
13428
  this.selectItem(item, false);
@@ -13396,8 +13444,8 @@ Picker = (function() {
13396
13444
  };
13397
13445
  })(this));
13398
13446
  this.container.innerHTML = Normalizer.stripWhitespace(Picker.TEMPLATE);
13399
- this.label = this.container.querySelector('.sc-picker-label');
13400
- picker = this.container.querySelector('.sc-picker-options');
13447
+ this.label = this.container.querySelector('.ql-picker-label');
13448
+ picker = this.container.querySelector('.ql-picker-options');
13401
13449
  return _.each(this.select.options, (function(_this) {
13402
13450
  return function(option, i) {
13403
13451
  var item;
@@ -13408,18 +13456,18 @@ Picker = (function() {
13408
13456
  };
13409
13457
 
13410
13458
  Picker.prototype.close = function() {
13411
- return DOM.removeClass(this.container, 'sc-expanded');
13459
+ return DOM.removeClass(this.container, 'ql-expanded');
13412
13460
  };
13413
13461
 
13414
13462
  Picker.prototype.selectItem = function(item, trigger) {
13415
13463
  var selected, value;
13416
- selected = this.container.querySelector('.sc-selected');
13464
+ selected = this.container.querySelector('.ql-selected');
13417
13465
  if (selected != null) {
13418
- DOM.removeClass(selected, 'sc-selected');
13466
+ DOM.removeClass(selected, 'ql-selected');
13419
13467
  }
13420
13468
  if (item != null) {
13421
13469
  value = item.getAttribute('data-value');
13422
- DOM.addClass(item, 'sc-selected');
13470
+ DOM.addClass(item, 'ql-selected');
13423
13471
  DOM.setText(this.label, DOM.getText(item));
13424
13472
  DOM.selectOption(this.select, value, trigger);
13425
13473
  return this.label.setAttribute('data-value', value);
@@ -13536,7 +13584,7 @@ Line = (function(_super) {
13536
13584
  node = Normalizer.normalizeNode(node);
13537
13585
  nodeFormats = _.clone(formats);
13538
13586
  _.each(_this.doc.formats, function(format, name) {
13539
- if (format.match(node)) {
13587
+ if (!format.isType(Format.types.LINE) && format.match(node)) {
13540
13588
  return nodeFormats[name] = format.value(node);
13541
13589
  }
13542
13590
  });
@@ -13606,9 +13654,16 @@ Line = (function(_super) {
13606
13654
  }
13607
13655
  _.each(formats, (function(_this) {
13608
13656
  return function(value, name) {
13609
- var format;
13657
+ var excludeFormat, format;
13610
13658
  format = _this.doc.formats[name];
13611
13659
  if (format.isType(Format.types.LINE)) {
13660
+ if (format.config.exclude && _this.formats[format.config.exclude]) {
13661
+ excludeFormat = _this.doc.formats[format.config.exclude];
13662
+ if (excludeFormat != null) {
13663
+ _this.node = excludeFormat.remove(_this.node);
13664
+ delete _this.formats[format.config.exclude];
13665
+ }
13666
+ }
13612
13667
  _this.node = format.add(_this.node, value);
13613
13668
  }
13614
13669
  if (value) {
@@ -13812,8 +13867,8 @@ Authorship = (function() {
13812
13867
  Authorship.prototype.attachButton = function(button) {
13813
13868
  return DOM.addEventListener(button, 'click', (function(_this) {
13814
13869
  return function() {
13815
- DOM.toggleClass(button, 'sc-on');
13816
- return _this.enable(DOM.hasClass(button, 'sc-on'));
13870
+ DOM.toggleClass(button, 'ql-on');
13871
+ return _this.enable(DOM.hasClass(button, 'ql-on'));
13817
13872
  };
13818
13873
  })(this));
13819
13874
  };
@@ -14227,10 +14282,17 @@ LinkTooltip = (function(_super) {
14227
14282
  };
14228
14283
 
14229
14284
  LinkTooltip.prototype.saveLink = function() {
14230
- var url;
14285
+ var anchor, url;
14231
14286
  url = this._normalizeURL(this.textbox.value);
14232
14287
  if (this.range != null) {
14233
- this.quill.formatText(this.range, 'link', url, 'user');
14288
+ if (this.range.isCollapsed()) {
14289
+ anchor = this._findAnchor(this.range);
14290
+ if (anchor != null) {
14291
+ anchor.href = url;
14292
+ }
14293
+ } else {
14294
+ this.quill.formatText(this.range, 'link', url, 'user');
14295
+ }
14234
14296
  }
14235
14297
  return this.setMode(url, false);
14236
14298
  };
@@ -14382,14 +14444,10 @@ MultiCursor = (function(_super) {
14382
14444
  return this.cursors = {};
14383
14445
  };
14384
14446
 
14385
- MultiCursor.prototype.moveCursor = function(userId, index, update) {
14447
+ MultiCursor.prototype.moveCursor = function(userId, index) {
14386
14448
  var cursor;
14387
- if (update == null) {
14388
- update = true;
14389
- }
14390
14449
  cursor = this.cursors[userId];
14391
14450
  cursor.index = index;
14392
- cursor.dirty = true;
14393
14451
  DOM.removeClass(cursor.elem, 'hidden');
14394
14452
  clearTimeout(cursor.timer);
14395
14453
  cursor.timer = setTimeout((function(_this) {
@@ -14398,9 +14456,7 @@ MultiCursor = (function(_super) {
14398
14456
  return cursor.timer = null;
14399
14457
  };
14400
14458
  })(this), this.options.timeout);
14401
- if (update) {
14402
- this._updateCursor(cursor);
14403
- }
14459
+ this._updateCursor(cursor);
14404
14460
  return cursor;
14405
14461
  };
14406
14462
 
@@ -14414,11 +14470,8 @@ MultiCursor = (function(_super) {
14414
14470
  return delete this.cursors[userId];
14415
14471
  };
14416
14472
 
14417
- MultiCursor.prototype.setCursor = function(userId, index, name, color, update) {
14473
+ MultiCursor.prototype.setCursor = function(userId, index, name, color) {
14418
14474
  var cursor;
14419
- if (update == null) {
14420
- update = true;
14421
- }
14422
14475
  if (this.cursors[userId] == null) {
14423
14476
  this.cursors[userId] = cursor = {
14424
14477
  userId: userId,
@@ -14430,45 +14483,34 @@ MultiCursor = (function(_super) {
14430
14483
  }
14431
14484
  _.defer((function(_this) {
14432
14485
  return function() {
14433
- return _this.moveCursor(userId, index, update);
14486
+ return _this.moveCursor(userId, index);
14434
14487
  };
14435
14488
  })(this));
14436
14489
  return this.cursors[userId];
14437
14490
  };
14438
14491
 
14439
- MultiCursor.prototype.shiftCursors = function(index, length, authorId, update) {
14492
+ MultiCursor.prototype.shiftCursors = function(index, length, authorId) {
14440
14493
  if (authorId == null) {
14441
14494
  authorId = null;
14442
14495
  }
14443
- if (update == null) {
14444
- update = true;
14445
- }
14446
- _.each(this.cursors, (function(_this) {
14496
+ return _.each(this.cursors, (function(_this) {
14447
14497
  return function(cursor, id) {
14448
14498
  if (!(cursor && (cursor.index > index || cursor.userId === authorId))) {
14449
14499
  return;
14450
14500
  }
14451
- cursor.index += Math.max(length, index - cursor.index);
14452
- return cursor.dirty = true;
14501
+ return cursor.index += Math.max(length, index - cursor.index);
14453
14502
  };
14454
14503
  })(this));
14455
- if (update) {
14456
- return this.update();
14457
- }
14458
14504
  };
14459
14505
 
14460
- MultiCursor.prototype.update = function(force) {
14461
- if (force == null) {
14462
- force = false;
14463
- }
14506
+ MultiCursor.prototype.update = function() {
14464
14507
  return _.each(this.cursors, (function(_this) {
14465
14508
  return function(cursor, id) {
14466
14509
  if (cursor == null) {
14467
14510
  return;
14468
14511
  }
14469
- if (cursor.dirty || force) {
14470
- return _this._updateCursor(cursor);
14471
- }
14512
+ _this._updateCursor(cursor);
14513
+ return true;
14472
14514
  };
14473
14515
  })(this));
14474
14516
  };
@@ -14476,15 +14518,15 @@ MultiCursor = (function(_super) {
14476
14518
  MultiCursor.prototype._applyDelta = function(delta) {
14477
14519
  delta.apply((function(_this) {
14478
14520
  return function(index, text, formatting) {
14479
- return _this.shiftCursors(index, text.length, formatting['author'], false);
14521
+ return _this.shiftCursors(index, text.length, formatting['author']);
14480
14522
  };
14481
14523
  })(this), (function(_this) {
14482
14524
  return function(index, length) {
14483
- return _this.shiftCursors(index, -1 * length, null, false);
14525
+ return _this.shiftCursors(index, -1 * length, null);
14484
14526
  };
14485
14527
  })(this), (function(_this) {
14486
14528
  return function(index, length, name, value) {
14487
- return _this.shiftCursors(index, 0, null, false);
14529
+ return _this.shiftCursors(index, 0, null);
14488
14530
  };
14489
14531
  })(this));
14490
14532
  return this.update();
@@ -14522,6 +14564,7 @@ MultiCursor = (function(_super) {
14522
14564
 
14523
14565
  MultiCursor.prototype._updateCursor = function(cursor) {
14524
14566
  var didSplit, guide, leaf, leftNode, offset, rightNode, _ref, _ref1;
14567
+ this.quill.editor.checkUpdate();
14525
14568
  _ref = this.quill.editor.doc.findLeafAt(cursor.index, true), leaf = _ref[0], offset = _ref[1];
14526
14569
  guide = this.container.ownerDocument.createElement('span');
14527
14570
  if (leaf != null) {
@@ -14537,7 +14580,7 @@ MultiCursor = (function(_super) {
14537
14580
  if (didSplit) {
14538
14581
  DOM.normalize(leaf.node.parentNode);
14539
14582
  }
14540
- return cursor.dirty = false;
14583
+ return this.quill.editor.selection.update('silent');
14541
14584
  };
14542
14585
 
14543
14586
  return MultiCursor;
@@ -14627,16 +14670,10 @@ Toolbar = (function() {
14627
14670
  };
14628
14671
 
14629
14672
  Toolbar.formats = {
14630
- BUTTON: {
14631
- 'bold': 'bold',
14632
- 'image': 'image',
14633
- 'italic': 'italic',
14634
- 'link': 'link',
14635
- 'strike': 'strike',
14636
- 'underline': 'underline'
14637
- },
14638
14673
  LINE: {
14639
- 'align': 'align'
14674
+ 'align': 'align',
14675
+ 'bullet': 'bullet',
14676
+ 'list': 'list'
14640
14677
  },
14641
14678
  SELECT: {
14642
14679
  'align': 'align',
@@ -14645,6 +14682,16 @@ Toolbar = (function() {
14645
14682
  'font': 'font',
14646
14683
  'size': 'size'
14647
14684
  },
14685
+ TOGGLE: {
14686
+ 'bold': 'bold',
14687
+ 'bullet': 'bullet',
14688
+ 'image': 'image',
14689
+ 'italic': 'italic',
14690
+ 'link': 'link',
14691
+ 'list': 'list',
14692
+ 'strike': 'strike',
14693
+ 'underline': 'underline'
14694
+ },
14648
14695
  TOOLTIP: {
14649
14696
  'image': 'image',
14650
14697
  'link': 'link'
@@ -14677,12 +14724,15 @@ Toolbar = (function() {
14677
14724
  } else {
14678
14725
  _this.quill.formatText(range, format, value, 'user');
14679
14726
  }
14680
- return _this.setActive(format, value);
14727
+ return _.defer(function() {
14728
+ _this.updateActive(range);
14729
+ return _this.setActive(format, value);
14730
+ });
14681
14731
  });
14682
14732
  };
14683
14733
  })(this));
14684
14734
  this.quill.on(this.quill.constructor.events.SELECTION_CHANGE, _.bind(this.updateActive, this));
14685
- DOM.addClass(this.container, 'sc-toolbar-container');
14735
+ DOM.addClass(this.container, 'ql-toolbar-container');
14686
14736
  if (DOM.isIOS()) {
14687
14737
  DOM.addClass(this.container, 'ios');
14688
14738
  }
@@ -14697,7 +14747,7 @@ Toolbar = (function() {
14697
14747
 
14698
14748
  Toolbar.prototype.initFormat = function(format, callback) {
14699
14749
  var eventName, input, selector;
14700
- selector = ".sc-" + format;
14750
+ selector = ".ql-" + format;
14701
14751
  if (Toolbar.formats.SELECT[format] != null) {
14702
14752
  selector = "select" + selector;
14703
14753
  eventName = 'change';
@@ -14712,7 +14762,7 @@ Toolbar = (function() {
14712
14762
  return DOM.addEventListener(input, eventName, (function(_this) {
14713
14763
  return function() {
14714
14764
  var range, value;
14715
- value = eventName === 'change' ? DOM.getSelectValue(input) : !DOM.hasClass(input, 'sc-active');
14765
+ value = eventName === 'change' ? DOM.getSelectValue(input) : !DOM.hasClass(input, 'ql-active');
14716
14766
  _this.preventUpdate = true;
14717
14767
  _this.quill.focus();
14718
14768
  range = _this.quill.getSelection();
@@ -14746,7 +14796,7 @@ Toolbar = (function() {
14746
14796
  }
14747
14797
  return this.triggering = false;
14748
14798
  } else {
14749
- return DOM.toggleClass(input, 'sc-active', value || false);
14799
+ return DOM.toggleClass(input, 'ql-active', value || false);
14750
14800
  }
14751
14801
  };
14752
14802
 
@@ -14768,14 +14818,18 @@ Toolbar = (function() {
14768
14818
  var leafFormats, lineFormats;
14769
14819
  leafFormats = this._getLeafActive(range);
14770
14820
  lineFormats = this._getLineActive(range);
14771
- return _.defaults(leafFormats, lineFormats);
14821
+ return _.defaults({}, leafFormats, lineFormats);
14772
14822
  };
14773
14823
 
14774
14824
  Toolbar.prototype._getLeafActive = function(range) {
14775
- var contents, formatsArr, start;
14825
+ var contents, formatsArr, line, offset, _ref;
14776
14826
  if (range.isCollapsed()) {
14777
- start = Math.max(0, range.start - 1);
14778
- contents = this.quill.getContents(start, range.end);
14827
+ _ref = this.quill.editor.doc.findLineAt(range.start), line = _ref[0], offset = _ref[1];
14828
+ if (offset === 0) {
14829
+ contents = this.quill.getContents(range.start, range.end + 1);
14830
+ } else {
14831
+ contents = this.quill.getContents(range.start - 1, range.end);
14832
+ }
14779
14833
  } else {
14780
14834
  contents = this.quill.getContents(range);
14781
14835
  }
@@ -14784,7 +14838,7 @@ Toolbar = (function() {
14784
14838
  };
14785
14839
 
14786
14840
  Toolbar.prototype._getLineActive = function(range) {
14787
- var firstLine, formats, formatsArr, lastLine, offset, _ref, _ref1;
14841
+ var firstLine, formatsArr, lastLine, offset, _ref, _ref1;
14788
14842
  formatsArr = [];
14789
14843
  _ref = this.quill.editor.doc.findLineAt(range.start), firstLine = _ref[0], offset = _ref[1];
14790
14844
  _ref1 = this.quill.editor.doc.findLineAt(range.end), lastLine = _ref1[0], offset = _ref1[1];
@@ -14792,10 +14846,7 @@ Toolbar = (function() {
14792
14846
  lastLine = lastLine.next;
14793
14847
  }
14794
14848
  while ((firstLine != null) && firstLine !== lastLine) {
14795
- formats = {
14796
- 'align': firstLine.formats['align']
14797
- };
14798
- formatsArr.push(firstLine.formats);
14849
+ formatsArr.push(_.clone(firstLine.formats));
14799
14850
  firstLine = firstLine.next;
14800
14851
  }
14801
14852
  return this._intersectFormats(formatsArr);
@@ -14821,7 +14872,7 @@ Toolbar = (function() {
14821
14872
  }
14822
14873
  });
14823
14874
  _.each(missing, function(name) {
14824
- if (Toolbar.formats.BUTTON[name] != null) {
14875
+ if (Toolbar.formats.TOGGLE[name] != null) {
14825
14876
  return delete activeFormats[name];
14826
14877
  } else if ((Toolbar.formats.SELECT[name] != null) && !_.isArray(activeFormats[name])) {
14827
14878
  return activeFormats[name] = [activeFormats[name]];
@@ -15159,7 +15210,9 @@ Normalizer = {
15159
15210
  'S': 'S',
15160
15211
  'U': 'U',
15161
15212
  'A': 'A',
15162
- 'IMG': 'IMG'
15213
+ 'IMG': 'IMG',
15214
+ 'UL': 'UL',
15215
+ 'LI': 'LI'
15163
15216
  },
15164
15217
  handleBreaks: function(lineNode) {
15165
15218
  var breaks;
@@ -15176,7 +15229,7 @@ Normalizer = {
15176
15229
  normalizeLine: function(lineNode) {
15177
15230
  lineNode = Normalizer.wrapInline(lineNode);
15178
15231
  lineNode = Normalizer.handleBreaks(lineNode);
15179
- Normalizer.pullBlocks(lineNode);
15232
+ lineNode = Normalizer.pullBlocks(lineNode);
15180
15233
  lineNode = Normalizer.normalizeNode(lineNode);
15181
15234
  Normalizer.unwrapText(lineNode);
15182
15235
  return lineNode;
@@ -15224,9 +15277,7 @@ Normalizer = {
15224
15277
  } else if ((node.previousSibling != null) && node.tagName === node.previousSibling.tagName) {
15225
15278
  if (_.isEqual(DOM.getAttributes(node), DOM.getAttributes(node.previousSibling))) {
15226
15279
  nodes.push(node.firstChild);
15227
- DOM.moveChildren(node.previousSibling, node);
15228
- DOM.normalize(node.previousSibling);
15229
- _results.push(DOM.removeNode(node));
15280
+ _results.push(Utils.mergeNodes(node.previousSibling, node));
15230
15281
  } else {
15231
15282
  _results.push(void 0);
15232
15283
  }
@@ -15237,31 +15288,33 @@ Normalizer = {
15237
15288
  return _results;
15238
15289
  },
15239
15290
  pullBlocks: function(lineNode) {
15240
- var curNode, _results;
15291
+ var curNode;
15241
15292
  curNode = lineNode.firstChild;
15242
- if (curNode == null) {
15243
- return;
15244
- }
15245
- if (DOM.BLOCK_TAGS[curNode.tagName] != null) {
15246
- if (curNode.nextSibling != null) {
15247
- Utils.splitAncestors(curNode.nextSibling, lineNode.parentNode);
15248
- }
15249
- DOM.unwrap(curNode);
15250
- Normalizer.pullBlocks(lineNode);
15251
- }
15252
- curNode = curNode.nextSibling;
15253
- _results = [];
15254
15293
  while (curNode != null) {
15255
- if (DOM.BLOCK_TAGS[curNode.tagName] != null) {
15256
- lineNode = Utils.splitAncestors(curNode, lineNode.parentNode);
15294
+ if ((DOM.BLOCK_TAGS[curNode.tagName] != null) && curNode.tagName !== 'LI') {
15295
+ if (curNode.previousSibling != null) {
15296
+ Utils.splitAncestors(curNode, lineNode.parentNode);
15297
+ }
15298
+ if (curNode.nextSibling != null) {
15299
+ Utils.splitAncestors(curNode.nextSibling, lineNode.parentNode);
15300
+ }
15301
+ if (DOM.LIST_TAGS[curNode.tagName] == null) {
15302
+ DOM.unwrap(curNode);
15303
+ Normalizer.pullBlocks(lineNode);
15304
+ } else {
15305
+ DOM.unwrap(curNode.parentNode);
15306
+ if (lineNode.parentNode == null) {
15307
+ lineNode = curNode;
15308
+ }
15309
+ }
15257
15310
  break;
15258
15311
  }
15259
- _results.push(curNode = curNode.nextSibling);
15312
+ curNode = curNode.nextSibling;
15260
15313
  }
15261
- return _results;
15314
+ return lineNode;
15262
15315
  },
15263
15316
  stripComments: function(html) {
15264
- return html = html.replace(/<!--[\s\S]*?-->/g, '');
15317
+ return html.replace(/<!--[\s\S]*?-->/g, '');
15265
15318
  },
15266
15319
  stripWhitespace: function(html) {
15267
15320
  html = html.replace(/^\s+/, '').replace(/\s+$/, '');
@@ -15382,7 +15435,7 @@ Quill = (function(_super) {
15382
15435
  Quill.Theme = Themes;
15383
15436
 
15384
15437
  Quill.DEFAULTS = {
15385
- formats: ['align', 'bold', 'italic', 'strike', 'underline', 'color', 'background', 'font', 'size', 'link', 'image'],
15438
+ formats: ['align', 'bold', 'italic', 'strike', 'underline', 'color', 'background', 'font', 'size', 'link', 'image', 'bullet', 'list'],
15386
15439
  modules: {
15387
15440
  'keyboard': true,
15388
15441
  'paste-manager': true,
@@ -15397,7 +15450,6 @@ Quill = (function(_super) {
15397
15450
  MODULE_INIT: 'module-init',
15398
15451
  POST_EVENT: 'post-event',
15399
15452
  PRE_EVENT: 'pre-event',
15400
- RENDER_UPDATE: 'renderer-update',
15401
15453
  SELECTION_CHANGE: 'selection-change',
15402
15454
  TEXT_CHANGE: 'text-change'
15403
15455
  };
@@ -15508,9 +15560,6 @@ Quill = (function(_super) {
15508
15560
  Quill.prototype.formatText = function(start, end, name, value, source) {
15509
15561
  var delta, formats, _ref;
15510
15562
  _ref = this._buildParams(start, end, name, value, source), start = _ref[0], end = _ref[1], formats = _ref[2], source = _ref[3];
15511
- if (!(end > start)) {
15512
- return;
15513
- }
15514
15563
  formats = _.reduce(formats, (function(_this) {
15515
15564
  return function(formats, value, name) {
15516
15565
  var format;
@@ -15607,7 +15656,11 @@ Quill = (function(_super) {
15607
15656
  if (!(range != null ? range.isCollapsed() : void 0)) {
15608
15657
  return;
15609
15658
  }
15610
- return format.prepare(value);
15659
+ if (format.isType(Format.types.LINE)) {
15660
+ return this.formatLine(range, name, value, Quill.sources.USER);
15661
+ } else {
15662
+ return format.prepare(value);
15663
+ }
15611
15664
  };
15612
15665
 
15613
15666
  Quill.prototype.setContents = function(delta, source) {
@@ -15615,15 +15668,14 @@ Quill = (function(_super) {
15615
15668
  source = Quill.sources.API;
15616
15669
  }
15617
15670
  if (_.isArray(delta)) {
15618
- delta = Tandem.Delta.makeDelta({
15671
+ delta = {
15619
15672
  startLength: this.getLength(),
15620
15673
  ops: delta
15621
- });
15674
+ };
15622
15675
  } else {
15623
- delta = Tandem.Delta.makeDelta(delta);
15624
15676
  delta.startLength = this.getLength();
15625
15677
  }
15626
- return this.editor.applyDelta(delta, source);
15678
+ return this.updateContents(delta, source);
15627
15679
  };
15628
15680
 
15629
15681
  Quill.prototype.setHTML = function(html, source) {
@@ -15655,6 +15707,7 @@ Quill = (function(_super) {
15655
15707
  if (source == null) {
15656
15708
  source = Quill.sources.API;
15657
15709
  }
15710
+ delta = Tandem.Delta.makeDelta(delta);
15658
15711
  return this.editor.applyDelta(delta, source);
15659
15712
  };
15660
15713
 
@@ -15787,11 +15840,13 @@ Renderer = (function() {
15787
15840
  Renderer.buildFrame = function(container) {
15788
15841
  var iframe, iframeDoc, root;
15789
15842
  iframe = container.ownerDocument.createElement('iframe');
15790
- iframe.setAttribute('frameBorder', '0');
15791
- iframe.setAttribute('height', '100%');
15792
- iframe.setAttribute('width', '100%');
15793
- iframe.setAttribute('title', 'Quill Rich Text Editor');
15794
- iframe.setAttribute('role', 'presentation');
15843
+ DOM.setAttributes(iframe, {
15844
+ frameBorder: '0',
15845
+ height: '100%',
15846
+ width: '100%',
15847
+ title: 'Quill Rich Text Editor',
15848
+ role: 'presentation'
15849
+ });
15795
15850
  container.appendChild(iframe);
15796
15851
  iframeDoc = iframe.contentWindow.document;
15797
15852
  iframeDoc.open();
@@ -15802,21 +15857,26 @@ Renderer = (function() {
15802
15857
  return [root, iframe];
15803
15858
  };
15804
15859
 
15805
- function Renderer(container, emitter, options) {
15860
+ function Renderer(container, options) {
15806
15861
  var _ref;
15807
15862
  this.container = container;
15808
- this.emitter = emitter;
15809
15863
  this.options = options != null ? options : {};
15810
15864
  this.container.innerHTML = '';
15811
15865
  _ref = Renderer.buildFrame(this.container), this.root = _ref[0], this.iframe = _ref[1];
15812
15866
  this.root.id = this.options.id;
15813
15867
  DOM.addClass(this.root, 'editor-container');
15814
- DOM.addClass(this.container, 'sc-container');
15868
+ DOM.addClass(this.container, 'ql-container');
15815
15869
  DOM.addEventListener(this.container, 'focus', (function(_this) {
15816
15870
  return function() {
15817
15871
  return _this.root.focus();
15818
15872
  };
15819
15873
  })(this));
15874
+ if (DOM.isIOS()) {
15875
+ DOM.addStyles(this.container, {
15876
+ 'overflow': 'auto',
15877
+ '-webkit-overflow-scrolling': 'touch'
15878
+ });
15879
+ }
15820
15880
  this.addStyles(DEFAULT_STYLES);
15821
15881
  if (this.options.styles != null) {
15822
15882
  _.defer(_.bind(this.addStyles, this, this.options.styles));
@@ -15836,25 +15896,22 @@ Renderer = (function() {
15836
15896
  };
15837
15897
 
15838
15898
  Renderer.prototype.addStyles = function(css) {
15839
- var style;
15840
- style = this.root.ownerDocument.createElement('style');
15841
- style.type = 'text/css';
15842
- if (!_.isString(css)) {
15899
+ var link, style;
15900
+ if (typeof css === 'object') {
15901
+ style = this.root.ownerDocument.createElement('style');
15902
+ style.type = 'text/css';
15843
15903
  css = Renderer.objToCss(css);
15844
- }
15845
- if (style.styleSheet != null) {
15846
- style.styleSheet.cssText = css;
15847
- } else {
15848
15904
  style.appendChild(this.root.ownerDocument.createTextNode(css));
15905
+ return this.root.ownerDocument.head.appendChild(style);
15906
+ } else if (typeof css === 'string') {
15907
+ link = this.root.ownerDocument.createElement('link');
15908
+ DOM.setAttributes(link, {
15909
+ type: 'text/css',
15910
+ rel: 'stylesheet',
15911
+ href: css
15912
+ });
15913
+ return this.root.ownerDocument.head.appendChild(link);
15849
15914
  }
15850
- return _.defer((function(_this) {
15851
- return function() {
15852
- _this.root.ownerDocument.querySelector('head').appendChild(style);
15853
- if (_this.emitter != null) {
15854
- return _this.emitter.emit(_this.emitter.constructor.events.RENDER_UPDATE, css);
15855
- }
15856
- };
15857
- })(this));
15858
15915
  };
15859
15916
 
15860
15917
  return Renderer;
@@ -15865,7 +15922,7 @@ module.exports = Renderer;
15865
15922
 
15866
15923
 
15867
15924
  },{"./dom":20,"./normalizer":38,"./utils":44,"lodash":"4HJaAd"}],41:[function(_dereq_,module,exports){
15868
- var DOM, Leaf, Range, Selection, _;
15925
+ var DOM, Leaf, Normalizer, Range, Selection, Utils, _;
15869
15926
 
15870
15927
  _ = _dereq_('lodash');
15871
15928
 
@@ -15873,11 +15930,16 @@ DOM = _dereq_('./dom');
15873
15930
 
15874
15931
  Leaf = _dereq_('./leaf');
15875
15932
 
15933
+ Normalizer = _dereq_('./normalizer');
15934
+
15876
15935
  Range = _dereq_('./lib/range');
15877
15936
 
15937
+ Utils = _dereq_('./utils');
15938
+
15878
15939
  Selection = (function() {
15879
- function Selection(doc, emitter) {
15940
+ function Selection(doc, iframe, emitter) {
15880
15941
  this.doc = doc;
15942
+ this.iframe = iframe;
15881
15943
  this.emitter = emitter;
15882
15944
  this.document = this.doc.root.ownerDocument;
15883
15945
  this.range = this.getRange();
@@ -15885,7 +15947,13 @@ Selection = (function() {
15885
15947
  }
15886
15948
 
15887
15949
  Selection.prototype.checkFocus = function() {
15888
- return this.document.activeElement === this.doc.root;
15950
+ if (this.document.activeElement !== this.doc.root) {
15951
+ return false;
15952
+ }
15953
+ if ((document.activeElement != null) && document.activeElement.tagName === 'IFRAME') {
15954
+ return document.activeElement === this.iframe;
15955
+ }
15956
+ return true;
15889
15957
  };
15890
15958
 
15891
15959
  Selection.prototype.getRange = function() {
@@ -15898,10 +15966,10 @@ Selection = (function() {
15898
15966
  return null;
15899
15967
  }
15900
15968
  start = this._positionToIndex(nativeRange.startContainer, nativeRange.startOffset);
15901
- if (nativeRange.endContainer !== nativeRange.startContainer) {
15902
- end = this._positionToIndex(nativeRange.endContainer, nativeRange.endOffset);
15969
+ if (nativeRange.startContainer === nativeRange.endContainer && nativeRange.startOffset === nativeRange.endOffset) {
15970
+ end = start;
15903
15971
  } else {
15904
- end = start - nativeRange.startOffset + nativeRange.endOffset;
15972
+ end = this._positionToIndex(nativeRange.endContainer, nativeRange.endOffset);
15905
15973
  }
15906
15974
  return new Range(Math.min(start, end), Math.max(start, end));
15907
15975
  };
@@ -15973,6 +16041,7 @@ Selection = (function() {
15973
16041
  };
15974
16042
 
15975
16043
  Selection.prototype._encodePosition = function(node, offset) {
16044
+ var text;
15976
16045
  while (true) {
15977
16046
  if (DOM.isTextNode(node) || node.tagName === DOM.DEFAULT_BREAK_TAG || (DOM.EMBED_TAGS[node.tagName] != null)) {
15978
16047
  return [node, offset];
@@ -15980,10 +16049,23 @@ Selection = (function() {
15980
16049
  node = node.childNodes[offset];
15981
16050
  offset = 0;
15982
16051
  } else if (node.childNodes.length === 0) {
16052
+ if (Normalizer.TAGS[node.tagName] == null) {
16053
+ text = node.ownerDocument.createTextNode('');
16054
+ node.appendChild(text);
16055
+ node = text;
16056
+ }
15983
16057
  return [node, 0];
15984
16058
  } else {
15985
16059
  node = node.lastChild;
15986
- offset = node.childNodes.length + 1;
16060
+ if (DOM.isElement(node)) {
16061
+ if (node.tagName === DOM.DEFAULT_BREAK_TAG || (DOM.EMBED_TAGS[node.tagName] != null)) {
16062
+ return [node, 1];
16063
+ } else {
16064
+ offset = node.childNodes.length;
16065
+ }
16066
+ } else {
16067
+ return [node, Utils.getNodeLength(node)];
16068
+ }
15987
16069
  }
15988
16070
  }
15989
16071
  };
@@ -16072,7 +16154,7 @@ Selection = (function() {
16072
16154
  module.exports = Selection;
16073
16155
 
16074
16156
 
16075
- },{"./dom":20,"./leaf":23,"./lib/range":27,"lodash":"4HJaAd"}],42:[function(_dereq_,module,exports){
16157
+ },{"./dom":20,"./leaf":23,"./lib/range":27,"./normalizer":38,"./utils":44,"lodash":"4HJaAd"}],42:[function(_dereq_,module,exports){
16076
16158
  var DefaultTheme;
16077
16159
 
16078
16160
  DefaultTheme = (function() {
@@ -16221,7 +16303,7 @@ SnowTheme = (function(_super) {
16221
16303
  _.each(['color', 'background', 'font', 'size', 'align'], (function(_this) {
16222
16304
  return function(format) {
16223
16305
  var picker, select;
16224
- select = module.container.querySelector(".sc-" + format);
16306
+ select = module.container.querySelector(".ql-" + format);
16225
16307
  if (select == null) {
16226
16308
  return;
16227
16309
  }
@@ -16234,9 +16316,9 @@ SnowTheme = (function(_super) {
16234
16316
  case 'color':
16235
16317
  case 'background':
16236
16318
  picker = new ColorPicker(select);
16237
- _.each(picker.container.querySelectorAll('.sc-picker-item'), function(item, i) {
16319
+ _.each(picker.container.querySelectorAll('.ql-picker-item'), function(item, i) {
16238
16320
  if (i < 7) {
16239
- return DOM.addClass(item, 'sc-primary-color');
16321
+ return DOM.addClass(item, 'ql-primary-color');
16240
16322
  }
16241
16323
  });
16242
16324
  }
@@ -16302,6 +16384,17 @@ Utils = {
16302
16384
  }
16303
16385
  return [child, offset];
16304
16386
  },
16387
+ getNextLineNode: function(curNode, root) {
16388
+ var nextNode;
16389
+ nextNode = curNode.nextSibling;
16390
+ if ((nextNode == null) && curNode.parentNode !== root) {
16391
+ nextNode = curNode.parentNode.nextSibling;
16392
+ }
16393
+ if ((nextNode != null) && (DOM.LIST_TAGS[nextNode.tagName] != null)) {
16394
+ nextNode = nextNode.firstChild;
16395
+ }
16396
+ return nextNode;
16397
+ },
16305
16398
  getNodeLength: function(node) {
16306
16399
  var length;
16307
16400
  if (node == null) {
@@ -16318,6 +16411,17 @@ Utils = {
16318
16411
  version = document.documentMode;
16319
16412
  return version && maxVersion >= version;
16320
16413
  },
16414
+ mergeNodes: function(newNode, oldNode) {
16415
+ var text;
16416
+ if (DOM.isElement(newNode)) {
16417
+ DOM.moveChildren(newNode, oldNode);
16418
+ DOM.normalize(newNode);
16419
+ } else {
16420
+ text = DOM.getText(newNode) + DOM.getText(oldNode);
16421
+ DOM.setText(newNode, text);
16422
+ }
16423
+ return DOM.removeNode(oldNode);
16424
+ },
16321
16425
  splitAncestors: function(refNode, root, force) {
16322
16426
  var nextNode, parentClone, parentNode;
16323
16427
  if (force == null) {
@@ -16378,4 +16482,4 @@ module.exports = Utils;
16378
16482
 
16379
16483
  },{"./dom":20,"lodash":"4HJaAd"}]},{},[39])
16380
16484
  (39)
16381
- });
16485
+ });