dante2-editor 0.2.0 → 0.3.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (144) hide show
  1. checksums.yaml +4 -4
  2. data/.babelrc +20 -0
  3. data/.eslint +13 -0
  4. data/.gitignore +15 -0
  5. data/README.md +5 -1
  6. data/dante2.gemspec +2 -4
  7. data/{app → demo}/assets/index.html +2 -2
  8. data/{app → demo}/assets/license.html +1 -1
  9. data/{app → demo}/assets/options.html +1 -5
  10. data/{app → demo}/assets/store.json +0 -0
  11. data/demo/data/poc.js +9 -0
  12. data/demo/demo.js +9 -0
  13. data/demo/initialize.js +7 -0
  14. data/{app → demo}/styles/layout/layout.scss +0 -0
  15. data/{app → demo}/styles/layout/normalize.css +0 -0
  16. data/{app → demo}/styles/layout/scaffold.scss +0 -0
  17. data/{app → demo}/styles/layout/tooltips.scss +0 -0
  18. data/dist/Dante2.js +2995 -0
  19. data/dist/Dante2.min.js +3 -0
  20. data/dist/Dante2.min.js.map +1 -0
  21. data/dist/DanteStyles.css +2 -0
  22. data/dist/DanteStyles.css.map +1 -0
  23. data/dist/DanteStyles.js +102 -0
  24. data/dist/DanteStyles.min.js +2 -0
  25. data/dist/DanteStyles.min.js.map +1 -0
  26. data/dist/dante-vendors.js +48316 -0
  27. data/dist/dante-vendors.min.js +29 -0
  28. data/dist/dante-vendors.min.js.map +1 -0
  29. data/{app/styles/fonts/dante → dist/fonts}/dante.eot +0 -0
  30. data/{app/styles/fonts/dante → dist/fonts}/dante.svg +0 -0
  31. data/{app/styles/fonts/dante → dist/fonts}/dante.ttf +0 -0
  32. data/{app/styles/fonts/dante → dist/fonts}/dante.woff +0 -0
  33. data/{app/styles/fonts/dante → dist/fonts}/fontello.eot +0 -0
  34. data/{app/styles/fonts/dante → dist/fonts}/fontello.svg +0 -0
  35. data/{app/styles/fonts/dante → dist/fonts}/fontello.ttf +0 -0
  36. data/{app/styles/fonts/dante → dist/fonts}/fontello.woff +0 -0
  37. data/docs/app.css +430 -1
  38. data/docs/app.css.map +1 -1
  39. data/docs/app.js +62 -2
  40. data/docs/app.js.map +1 -1
  41. data/docs/dante-vendors.js +49513 -22
  42. data/docs/dante-vendors.js.map +1 -1
  43. data/docs/dante.css +1602 -1
  44. data/docs/dante.css.map +1 -1
  45. data/docs/dante.js +3310 -3
  46. data/docs/dante.js.map +1 -1
  47. data/docs/doc.html +3 -7
  48. data/docs/index.html +4 -4
  49. data/docs/license.html +3 -3
  50. data/docs/options.html +53 -0
  51. data/package.json +47 -17
  52. data/rb_lib/dante2-editor/rails.rb +15 -0
  53. data/{lib → rb_lib}/dante2-editor/version.rb +1 -1
  54. data/{lib → rb_lib}/dante2-editor.rb +0 -0
  55. data/src/components/blocks/embed.js +126 -0
  56. data/src/components/blocks/image.js +377 -0
  57. data/src/components/blocks/placeholder.js +68 -0
  58. data/src/components/blocks/video.js +80 -0
  59. data/src/components/dante.js +291 -0
  60. data/src/components/dante_editor.js +928 -0
  61. data/src/components/debug.js +104 -0
  62. data/src/components/decorators/link.js +64 -0
  63. data/src/components/popovers/addButton.js +318 -0
  64. data/src/components/popovers/image.js +188 -0
  65. data/src/components/popovers/link.js +107 -0
  66. data/src/components/popovers/toolTip.js +402 -0
  67. data/{app/utils/logger.coffee → src/components/wrapper.js} +0 -0
  68. data/{app → src}/images/dante/media-loading-placeholder.png +0 -0
  69. data/{app → src}/images/site/dante-demo.png +0 -0
  70. data/{app → src}/images/site/dante-editor-logo.png +0 -0
  71. data/{app → src}/images/site/github-logo.png +0 -0
  72. data/src/index.js +9 -0
  73. data/{app → src}/model/index.js +0 -0
  74. data/src/style.js +3 -0
  75. data/{app → src}/styles/dante/_animations.scss +0 -0
  76. data/{app → src}/styles/dante/_caption.scss +0 -0
  77. data/{app → src}/styles/dante/_debug.scss +0 -0
  78. data/{app → src}/styles/dante/_fonts.scss +0 -0
  79. data/{app → src}/styles/dante/_graf.scss +0 -0
  80. data/{app → src}/styles/dante/_icons.scss +0 -0
  81. data/{app → src}/styles/dante/_media.scss +0 -0
  82. data/{app → src}/styles/dante/_menu.scss +0 -0
  83. data/{app → src}/styles/dante/_needsorder.scss +0 -0
  84. data/{app → src}/styles/dante/_popover.scss +0 -0
  85. data/{app → src}/styles/dante/_post.scss +0 -0
  86. data/{app → src}/styles/dante/_scaffold.scss +0 -0
  87. data/{app → src}/styles/dante/_tooltip.scss +0 -0
  88. data/{app → src}/styles/dante/_utilities.scss +0 -0
  89. data/{app → src}/styles/dante/_variables.scss +0 -0
  90. data/{app → src}/styles/dante/blame.scss +0 -0
  91. data/{app → src}/styles/dante.scss +0 -0
  92. data/{app → src}/styles/draft.css +0 -0
  93. data/src/styles/fonts/dante/dante.eot +0 -0
  94. data/src/styles/fonts/dante/dante.svg +18 -0
  95. data/src/styles/fonts/dante/dante.ttf +0 -0
  96. data/src/styles/fonts/dante/dante.woff +0 -0
  97. data/src/styles/fonts/dante/fontello.eot +0 -0
  98. data/src/styles/fonts/dante/fontello.svg +36 -0
  99. data/src/styles/fonts/dante/fontello.ttf +0 -0
  100. data/src/styles/fonts/dante/fontello.woff +0 -0
  101. data/src/utils/find_entities.js +17 -0
  102. data/src/utils/html2content.js +127 -0
  103. data/src/utils/save_content.js +80 -0
  104. data/{app → src}/utils/selection.js +0 -0
  105. data/tools/.eslintrc +9 -0
  106. data/tools/amd/README.md +7 -0
  107. data/tools/amd/bower.json +19 -0
  108. data/tools/amd/build.js +36 -0
  109. data/tools/build-cli.js +46 -0
  110. data/tools/build.js +30 -0
  111. data/tools/buildBabel.js +32 -0
  112. data/tools/constants.js +10 -0
  113. data/tools/dist/build.js +13 -0
  114. data/tools/docs/build.js +12 -0
  115. data/tools/es/build.js +27 -0
  116. data/tools/exec.js +50 -0
  117. data/tools/fs-utils.js +35 -0
  118. data/tools/lib/build.js +14 -0
  119. data/tools/promisify.js +14 -0
  120. data/webpack/base.config.js +89 -0
  121. data/webpack/docs.config.js +147 -0
  122. data/webpack/webpack.config.js +78 -0
  123. data/webpack.config-doc.js +5 -0
  124. data/webpack.config.js +3 -147
  125. data/yarn.lock +973 -718
  126. metadata +108 -64
  127. data/app/components/App.cjsx +0 -1083
  128. data/app/components/blocks/embed.cjsx +0 -109
  129. data/app/components/blocks/image.cjsx +0 -316
  130. data/app/components/blocks/placeholder.cjsx +0 -60
  131. data/app/components/blocks/video.cjsx +0 -75
  132. data/app/components/debug.cjsx +0 -96
  133. data/app/components/decorators/link.cjsx +0 -61
  134. data/app/components/popovers/addButton.cjsx +0 -247
  135. data/app/components/popovers/image.cjsx +0 -160
  136. data/app/components/popovers/link.cjsx +0 -87
  137. data/app/components/popovers/toolTip.cjsx +0 -326
  138. data/app/data/poc.js +0 -15
  139. data/app/demo.js +0 -7
  140. data/app/initialize.js +0 -4
  141. data/app/utils/find_entities.coffee +0 -20
  142. data/app/utils/html2content.coffee +0 -120
  143. data/app/utils/save_content.coffee +0 -63
  144. data/lib/dante2-editor/rails.rb +0 -16
@@ -1,247 +0,0 @@
1
- React = require('react')
2
- ReactDOM = require('react-dom')
3
-
4
- {
5
- Entity
6
- RichUtils
7
- AtomicBlockUtils
8
- EditorState
9
- } = require('draft-js')
10
-
11
- {
12
- addNewBlock
13
- resetBlockWithType
14
- updateDataOfBlock
15
- getCurrentBlock
16
- getNode
17
- } = require('../../model/index.js')
18
-
19
- {
20
- getSelectionRect
21
- getSelection
22
- } = require("../../utils/selection.js")
23
-
24
- class DanteInlineTooltip extends React.Component
25
-
26
- constructor: (props) ->
27
- super props
28
-
29
- @state =
30
- position: {top: 0, left:0}
31
- show: false
32
- scaled: false
33
-
34
- display: (b)=>
35
- if b then @show() else @hide()
36
-
37
- show: =>
38
- @setState
39
- show: true
40
-
41
- hide: =>
42
- @setState
43
- show: false
44
-
45
- setPosition: (coords)->
46
- @setState
47
- position: coords
48
-
49
- _toggleScaled: (ev)=>
50
- if @state.scaled then @collapse() else @scale()
51
-
52
- scale: =>
53
- @setState
54
- scaled: true
55
-
56
- collapse: =>
57
- @setState
58
- scaled: false
59
-
60
- componentWillReceiveProps: (newProps)=>
61
- @collapse()
62
-
63
- activeClass: ->
64
- #if @props.show then "is-active" else ""
65
- if @isActive() then "is-active" else ""
66
-
67
- isActive: ->
68
- @state.show
69
-
70
- scaledClass: ->
71
- if @state.scaled then "is-scaled" else ""
72
-
73
- scaledWidth: ->
74
- if @state.scaled then "124" else "0"
75
-
76
- clickOnFileUpload: =>
77
- @.refs.fileInput.click()
78
- @collapse()
79
- @hide()
80
-
81
- handlePlaceholder: (input)=>
82
- opts =
83
- type: input.widget_options.insert_block
84
- placeholder: input.options.placeholder
85
- endpoint: input.options.endpoint
86
-
87
- @props.onChange(resetBlockWithType(@props.editorState, 'placeholder', opts));
88
-
89
- insertImage: (file) =>
90
- opts =
91
- url: URL.createObjectURL(file)
92
- file: file
93
-
94
- @props.onChange(addNewBlock(@props.editorState, 'image', opts));
95
-
96
- handleFileInput: (e)=>
97
- fileList = e.target.files
98
- # TODO: support multiple file uploads
99
- ###
100
- Object.keys(fileList).forEach (o)=>
101
- @.insertImage(fileList[0])
102
- ###
103
- @.insertImage(fileList[0])
104
-
105
- widgets: =>
106
- @.props.editor.widgets
107
-
108
- clickHandler: (e, type)=>
109
- request_block = @widgets().find (o)->
110
- o.icon is type
111
-
112
- switch request_block.widget_options.insertion
113
- when "upload"
114
- @clickOnFileUpload(e, request_block)
115
- when "placeholder"
116
- @handlePlaceholder(request_block)
117
- else
118
- console.log "WRONG TYPE FOR #{request_block.widget_options.insertion}"
119
-
120
- getItems: ->
121
- @widgets().filter (o)=>
122
- o.widget_options.displayOnInlineTooltip
123
-
124
- isDescendant: (parent, child)->
125
- node = child.parentNode
126
- while node != null
127
- if (node is parent)
128
- return true
129
- node = node.parentNode
130
- return false
131
-
132
- relocate: ()=>
133
- editorState = @props.editorState
134
-
135
- if editorState.getSelection().isCollapsed()
136
-
137
- currentBlock = getCurrentBlock(editorState)
138
- blockType = currentBlock.getType()
139
-
140
- contentState = editorState.getCurrentContent()
141
- selectionState = editorState.getSelection()
142
-
143
- block = contentState.getBlockForKey(selectionState.anchorKey);
144
-
145
- nativeSelection = getSelection(window);
146
- if !nativeSelection.rangeCount
147
- return;
148
-
149
- node = getNode()
150
-
151
- selectionBoundary = getSelectionRect(nativeSelection);
152
- coords = selectionBoundary #utils.getSelectionDimensions(node)
153
-
154
- parent = ReactDOM.findDOMNode(@props.editor);
155
- parentBoundary = parent.getBoundingClientRect();
156
-
157
- # hide if selected node is not in editor
158
- # debugger
159
- #console.log @isDescendant(parent, nativeSelection.anchorNode)
160
-
161
- if !@isDescendant(parent, nativeSelection.anchorNode)
162
- @hide()
163
- return
164
-
165
- # checkeamos si esta vacio
166
- @display block.getText().length is 0 and blockType is "unstyled"
167
- @setPosition
168
- top: coords.top + window.scrollY
169
- left: coords.left + window.scrollX - 60
170
-
171
- ###
172
- @refs.image_popover.display(blockType is "image")
173
-
174
- if blockType is "image"
175
- selectionBoundary = node.anchorNode.parentNode.parentNode.parentNode.getBoundingClientRect()
176
- #el = document.querySelector("#dante_image_popover")
177
- el = @refs.image_popover.refs.image_popover
178
- padd = el.offsetWidth / 2
179
- @refs.image_popover.setPosition
180
- top: selectionBoundary.top - parentBoundary.top + 60
181
- left: selectionBoundary.left + (selectionBoundary.width / 2) - padd
182
-
183
-
184
- #@setState
185
- # image_popover_position:
186
- # top: selectionBoundary.top - parentBoundary.top + 60
187
- # left: selectionBoundary.left + (selectionBoundary.width / 2) - padd
188
- #
189
- ###
190
-
191
- else
192
- @hide()
193
-
194
- render: ->
195
- return (
196
-
197
- <div className="inlineTooltip #{@activeClass()} #{@scaledClass()}"
198
- style={@state.position}>
199
-
200
- <button className="inlineTooltip-button control"
201
- title="Close Menu"
202
- data-action="inline-menu"
203
- onClick={@_toggleScaled}
204
- >
205
- <span className="tooltip-icon dante-icon-plus"></span>
206
- </button>
207
-
208
- <div className="inlineTooltip-menu" style={{width: "#{@scaledWidth()}px"}}>
209
-
210
- {
211
- @getItems().map (item, i)=>
212
- <InlineTooltipItem
213
- item={item}
214
- key={i}
215
- clickHandler={@clickHandler}
216
- />
217
- }
218
-
219
- <input type="file"
220
- style={{display: 'none'}}
221
- ref="fileInput"
222
- multiple="multiple"
223
- onChange={@.handleFileInput}
224
- />
225
-
226
- </div>
227
-
228
- </div>
229
-
230
- )
231
-
232
- class InlineTooltipItem extends React.Component
233
-
234
- clickHandler: (e)=>
235
- e.preventDefault()
236
- @props.clickHandler(e, @props.item.icon)
237
-
238
- render: ->
239
- return (
240
- <button className="inlineTooltip-button scale"
241
- title={@props.title} onMouseDown={@clickHandler}>
242
- <span className="tooltip-icon dante-icon-#{@props.item.icon}">
243
- </span>
244
- </button>
245
- )
246
-
247
- module.exports = DanteInlineTooltip
@@ -1,160 +0,0 @@
1
-
2
- React = require('react')
3
- ReactDOM = require('react-dom')
4
-
5
- {
6
- Entity
7
- RichUtils
8
- AtomicBlockUtils
9
- EditorState
10
- } = require('draft-js')
11
-
12
- {
13
- getSelectionRect
14
- getSelection
15
- } = require("../../utils/selection.js")
16
-
17
- {
18
- getCurrentBlock
19
- getNode
20
- } = require('../../model/index.js')
21
-
22
-
23
- class DanteImagePopover extends React.Component
24
-
25
- constructor: (props) ->
26
- super props
27
-
28
- @state =
29
- position:
30
- top: 0
31
- left:0
32
- show: false
33
- scaled: false
34
- buttons: [
35
- {type: "left" }
36
- {type: "center" }
37
- {type: "fill" }
38
- {type: "wide" }
39
- ]
40
-
41
- display: (b)=>
42
- if b then @show() else @hide()
43
-
44
- show: =>
45
- @setState
46
- show: true
47
-
48
- hide: =>
49
- @setState
50
- show: false
51
-
52
- setPosition: (coords)->
53
- @setState
54
- position: coords
55
-
56
- _toggleScaled: (ev)=>
57
- if @state.scaled then @collapse() else @scale()
58
-
59
- scale: =>
60
- @setState
61
- scaled: true
62
-
63
- collapse: =>
64
- @setState
65
- scaled: false
66
-
67
- relocate: ()=>
68
- editorState = @props.editorState
69
-
70
- if editorState.getSelection().isCollapsed()
71
-
72
- currentBlock = getCurrentBlock(editorState)
73
- blockType = currentBlock.getType()
74
-
75
- contentState = editorState.getCurrentContent()
76
- selectionState = editorState.getSelection()
77
-
78
- block = contentState.getBlockForKey(selectionState.anchorKey)
79
-
80
- nativeSelection = getSelection(window)
81
- if !nativeSelection.rangeCount
82
- return;
83
-
84
- node = getNode()
85
-
86
- selectionBoundary = getSelectionRect(nativeSelection)
87
- coords = selectionBoundary
88
-
89
- parent = ReactDOM.findDOMNode(@props.editor);
90
- parentBoundary = parent.getBoundingClientRect();
91
-
92
- @display(blockType is "image")
93
-
94
- if blockType is "image"
95
- selectionBoundary = node.anchorNode.parentNode.parentNode.parentNode.getBoundingClientRect()
96
- el = @refs.image_popover
97
- padd = el.offsetWidth / 2
98
- @setPosition
99
- top: selectionBoundary.top - parentBoundary.top + 60
100
- left: selectionBoundary.left + (selectionBoundary.width / 2) - padd
101
-
102
- else
103
- @hide()
104
-
105
- componentWillReceiveProps: (newProps)=>
106
- @collapse()
107
-
108
- getStyle: ->
109
- return {} if !@state.position
110
-
111
- handleClick: (item)=>
112
- @props.editor.setDirection(item.type)
113
-
114
- render: ->
115
- return (
116
-
117
- <div ref="image_popover"
118
- className="dante-popover popover--Aligntooltip popover--top popover--animated #{'is-active' if @state.show}"
119
- style={{top: @state.position.top, left: @state.position.left}}>
120
-
121
- <div className='popover-inner'>
122
-
123
- <ul className='dante-menu-buttons'>
124
-
125
- {
126
- @state.buttons.map (item, i)=>
127
- <DanteImagePopoverItem
128
- item={item}
129
- handleClick={@handleClick}
130
- key={i}
131
- />
132
- }
133
-
134
- </ul>
135
-
136
- </div>
137
-
138
- <div className='popover-arrow'>
139
- </div>
140
- </div>
141
-
142
- )
143
-
144
- class DanteImagePopoverItem extends React.Component
145
-
146
- handleClick: (e)=>
147
- e.preventDefault()
148
- @props.handleClick(@props.item)
149
-
150
- render: =>
151
- return (
152
- <li
153
- className="dante-menu-button align-#{@props.item.type}"
154
- onMouseDown={@handleClick}>
155
- <span className="tooltip-icon dante-icon-image-#{@props.item.type}"></span>
156
- </li>
157
- )
158
-
159
- module.exports = DanteImagePopover
160
-
@@ -1,87 +0,0 @@
1
-
2
- React = require('react')
3
- ReactDOM = require('react-dom')
4
-
5
- {
6
- getCurrentBlock
7
- } = require('../../model/index.js')
8
-
9
- class DanteAnchorPopover extends React.Component
10
-
11
- constructor: (props) ->
12
-
13
- super props
14
- @state =
15
- position:
16
- top: 0
17
- left:0
18
- show: false
19
- url: ""
20
-
21
-
22
- display: (b)=>
23
- if b then @show() else @hide()
24
-
25
- show: =>
26
- @setState
27
- show: true
28
-
29
- hide: =>
30
- @setState
31
- show: false
32
-
33
- setPosition: (coords)->
34
- @setState
35
- position: coords
36
-
37
- relocate: (node=null)=>
38
- return unless node
39
-
40
- editorState = @props.editorState
41
- currentBlock = getCurrentBlock(editorState)
42
- blockType = currentBlock.getType()
43
-
44
- contentState = editorState.getCurrentContent()
45
- selectionState = editorState.getSelection()
46
-
47
- selectionBoundary = node.getBoundingClientRect()
48
- coords = selectionBoundary
49
-
50
- el = @refs.dante_popover
51
- padd = el.offsetWidth / 2
52
-
53
- parent = ReactDOM.findDOMNode(@props.editor);
54
- parentBoundary = parent.getBoundingClientRect()
55
-
56
- {
57
- top: selectionBoundary.top - parentBoundary.top + 160
58
- left: selectionBoundary.left + (selectionBoundary.width/2) - (padd)
59
- }
60
-
61
-
62
- render: =>
63
- position = @state.position
64
- style = {
65
- left: position.left,
66
- top: position.top,
67
- visibility: "#{if @state.show then 'visible' else 'hidden'}"
68
- }
69
- return (
70
- <div
71
- ref="dante_popover"
72
- className='dante-popover popover--tooltip popover--Linktooltip popover--bottom is-active'
73
- style={style}
74
- onMouseOver={@props.handleOnMouseOver}
75
- onMouseOut={@props.handleOnMouseOut}
76
- >
77
- <div className='popover-inner'>
78
- <a href={@props.url} target='_blank'>
79
- {@state.url}
80
- </a>
81
- </div>
82
- <div className='popover-arrow'>
83
- </div>
84
- </div>
85
- )
86
-
87
- module.exports = DanteAnchorPopover