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 +4 -4
- data/app/assets/javascripts/dante/behaviors/paste.js.coffee +17 -5
- data/bower.json +1 -1
- data/dist/js/dante-editor.js +33 -22
- data/lib/dante-editor/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 42a79ee4be9f59793dce73ca060ce2cf8b8edc3e
|
4
|
+
data.tar.gz: caf812a9e82f5130b042ebd42b26bf739984fed2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
-
|
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
data/dist/js/dante-editor.js
CHANGED
@@ -8,7 +8,7 @@
|
|
8
8
|
defaults: {
|
9
9
|
image_placeholder: '../images/dante/media-loading-placeholder.png'
|
10
10
|
},
|
11
|
-
version: "0.1.
|
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)
|
1844
|
-
|
1845
|
-
|
1846
|
-
|
1847
|
-
|
1848
|
-
|
1849
|
-
|
1850
|
-
|
1851
|
-
|
1852
|
-
|
1853
|
-
|
1854
|
-
|
1855
|
-
|
1856
|
-
|
1857
|
-
|
1858
|
-
|
1859
|
-
|
1860
|
-
|
1861
|
-
|
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
|
}
|
data/lib/dante-editor/version.rb
CHANGED
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.
|
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-
|
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.
|
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.
|