dante-editor 0.1.5 → 0.1.6

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 2cfab9a7cc9692beab99dac0d5a60bae095b0317
4
- data.tar.gz: 5665200f9948f8ef09ac040e941862240271ac95
3
+ metadata.gz: 42a79ee4be9f59793dce73ca060ce2cf8b8edc3e
4
+ data.tar.gz: caf812a9e82f5130b042ebd42b26bf739984fed2
5
5
  SHA512:
6
- metadata.gz: 32c100555c921c8f70f318e8f1f8b4fcf5af68c7192f595a04f9d4b7ca8c77d44c42eb76957b4e1d842776e1582e3c8e979392a1e59e8f21258a8694aaf7d267
7
- data.tar.gz: 17511f2883bb0b03a6614119ca4d1bd63f5e82f3f456cebe19f2d78d99c25af0da8f2d3218aecad31648f07672d86be14aa1ff5876743f492ba8706e2276bfc4
6
+ metadata.gz: 10ce2589c5954b40265a03f0b5563b87286ae926a196c2edb4e9cb38d642b205f4489d561efc631b77d542ef6d3eda83556e6abdc4473302b37209bea1977fc0
7
+ data.tar.gz: 7f7c6aa3f7c8870db6fd09dd67698db896b9d573acc2eed2a261323fb16bbc6a463f9c73a0ef6d88328377056c91802ca61393bb7e79b354fb3476a713cd2b87
@@ -22,20 +22,31 @@ class Dante.View.Behavior.Paste extends Dante.View.Behavior
22
22
  pastedText = if _.isEmpty(cbd.getData('text/html')) then cbd.getData('text/plain') else cbd.getData('text/html')
23
23
 
24
24
  utils.log("Process and handle text...")
25
+ utils.log(pastedText)
25
26
  #detect if is html
26
27
  if pastedText.match(/<\/*[a-z][^>]+?>/gi)
27
28
  utils.log("HTML DETECTED ON PASTE")
28
- pastedText = pastedText.replace(/&.*;/g, "")
29
+ #pastedText = pastedText.replace(/&.*;/g, "")
29
30
 
30
- #convert pasted divs in p before copy contents into div
31
+ # convert pasted divs in p before copy contents into div
31
32
  pastedText = pastedText.replace(/<div>([\w\W]*?)<\/div>/gi, '<p>$1</p>')
32
33
 
33
- #create the placeholder element and assign pasted content
34
+ # create the placeholder element and assign pasted content
34
35
  document.body.appendChild( $("<div id='#{@editor.paste_element_id.replace('#', '')}' class='dante-paste'></div>")[0] )
36
+
37
+ paste_el = $(@editor.paste_element_id)
38
+ paste_el.html("<span>#{pastedText}</span>")
39
+ nodes = $(paste_el.html()).insertBefore($(parent))
35
40
 
36
- $(@editor.paste_element_id).html("<span>#{pastedText}</span>")
41
+ # clean pasted content
42
+ # TODO: this will sanitize all editor
43
+ # content and the selection will be lost!
44
+ # but for now it works better
45
+
46
+ @editor.parseInitialMess()
37
47
 
38
- #clean pasted content
48
+ # clean pasted content
49
+ ###
39
50
  @editor.setupElementsClasses $(@editor.paste_element_id), (e)=>
40
51
  # e is the target object which is cleaned
41
52
  nodes = $(e.html()).insertAfter($(parent))
@@ -59,6 +70,7 @@ class Dante.View.Behavior.Paste extends Dante.View.Behavior
59
70
  $('html, body').animate
60
71
  scrollTop: top
61
72
  , 20
73
+ ###
62
74
 
63
75
  @editor.continue = false
64
76
  return false # Prevent the default handler from running.
data/bower.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name" : "dante",
3
3
  "description": "Just another Medium editor clone.",
4
4
  "homepage": "michelson.github.io/Dante/",
5
- "version" : "0.1.5",
5
+ "version" : "0.1.6",
6
6
  "keywords": [
7
7
  "css",
8
8
  "sass",
@@ -8,7 +8,7 @@
8
8
  defaults: {
9
9
  image_placeholder: '../images/dante/media-loading-placeholder.png'
10
10
  },
11
- version: "0.1.5"
11
+ version: "0.1.6"
12
12
  };
13
13
 
14
14
  }).call(this);
@@ -1825,7 +1825,7 @@
1825
1825
  };
1826
1826
 
1827
1827
  Paste.prototype.handlePaste = function(ev, parent) {
1828
- var cbd, pastedText;
1828
+ var cbd, nodes, paste_el, pastedText;
1829
1829
  utils.log("pasted!");
1830
1830
  pastedText = void 0;
1831
1831
  if (window.clipboardData && window.clipboardData.getData) {
@@ -1835,30 +1835,41 @@
1835
1835
  pastedText = _.isEmpty(cbd.getData('text/html')) ? cbd.getData('text/plain') : cbd.getData('text/html');
1836
1836
  }
1837
1837
  utils.log("Process and handle text...");
1838
+ utils.log(pastedText);
1838
1839
  if (pastedText.match(/<\/*[a-z][^>]+?>/gi)) {
1839
1840
  utils.log("HTML DETECTED ON PASTE");
1840
- pastedText = pastedText.replace(/&.*;/g, "");
1841
1841
  pastedText = pastedText.replace(/<div>([\w\W]*?)<\/div>/gi, '<p>$1</p>');
1842
1842
  document.body.appendChild($("<div id='" + (this.editor.paste_element_id.replace('#', '')) + "' class='dante-paste'></div>")[0]);
1843
- $(this.editor.paste_element_id).html("<span>" + pastedText + "</span>");
1844
- this.editor.setupElementsClasses($(this.editor.paste_element_id), (function(_this) {
1845
- return function(e) {
1846
- var last_node, new_node, nodes, num, top;
1847
- nodes = $(e.html()).insertAfter($(parent));
1848
- e.remove();
1849
- last_node = nodes.last()[0];
1850
- num = last_node.childNodes.length;
1851
- _this.editor.setRangeAt(last_node, num);
1852
- new_node = $(_this.editor.getNode());
1853
- _this.editor.markAsSelected(new_node);
1854
- _this.editor.displayTooltipAt($(_this.editor.el).find(".is-selected"));
1855
- _this.editor.handleUnwrappedImages(nodes);
1856
- top = new_node.offset().top;
1857
- return $('html, body').animate({
1858
- scrollTop: top
1859
- }, 20);
1860
- };
1861
- })(this));
1843
+ paste_el = $(this.editor.paste_element_id);
1844
+ paste_el.html("<span>" + pastedText + "</span>");
1845
+ nodes = $(paste_el.html()).insertBefore($(parent));
1846
+ this.editor.parseInitialMess();
1847
+
1848
+ /*
1849
+ @editor.setupElementsClasses $(@editor.paste_element_id), (e)=>
1850
+ * e is the target object which is cleaned
1851
+ nodes = $(e.html()).insertAfter($(parent))
1852
+ *remove paste div since we wont use it until the next paste
1853
+ e.remove()
1854
+ *set caret on newly created node
1855
+ last_node = nodes.last()[0]
1856
+ num = last_node.childNodes.length
1857
+ @editor.setRangeAt(last_node, num)
1858
+
1859
+ *select new node
1860
+ new_node = $(@editor.getNode())
1861
+ @editor.markAsSelected(new_node)
1862
+ @editor.displayTooltipAt($(@editor.el).find(".is-selected"))
1863
+
1864
+ * wrap new images
1865
+ @editor.handleUnwrappedImages(nodes)
1866
+
1867
+ *scroll to element top
1868
+ top = new_node.offset().top
1869
+ $('html, body').animate
1870
+ scrollTop: top
1871
+ , 20
1872
+ */
1862
1873
  this.editor["continue"] = false;
1863
1874
  return false;
1864
1875
  }
@@ -1,5 +1,5 @@
1
1
  require "dante-editor/version"
2
2
 
3
3
  module DanteEditor
4
- VERSION = "0.1.5"
4
+ VERSION = "0.1.6"
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dante-editor
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.5
4
+ version: 0.1.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Miguel Michelson
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2016-06-17 00:00:00.000000000 Z
12
+ date: 2016-06-18 00:00:00.000000000 Z
13
13
  dependencies: []
14
14
  description: dante-editor yet another Medium editor clone.
15
15
  email:
@@ -158,7 +158,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
158
158
  version: '0'
159
159
  requirements: []
160
160
  rubyforge_project:
161
- rubygems_version: 2.5.2
161
+ rubygems_version: 2.4.8
162
162
  signing_key:
163
163
  specification_version: 4
164
164
  summary: dante-editor yet another Medium editor clone.