forked from alohaeditor/Aloha-Editor
-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathaloha-config.coffee
More file actions
109 lines (96 loc) · 3.78 KB
/
aloha-config.coffee
File metadata and controls
109 lines (96 loc) · 3.78 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
# # Configure Aloha
# This module configures Aloha and runs before Aloha loads.
#
# Aloha is configured by a global `Aloha` object.
# This module creates it and when Aloha finishes loading its shim removes the global
@Aloha = @Aloha or {}
@Aloha.settings =
jQuery: @jQuery # Use the same version of jQuery
logLevels:
error: false
warn: true
info: false
debug: false
requireConfig:
paths:
# Override location of jquery-ui and use our own. Because
# jquery-ui and bootstrap conflict in a few cases (buttons,
# tooltip) our copy has those removed.
jqueryui: '../../oerpub/js/jquery-ui-1.9.0.custom-aloha'
errorhandling: true
plugins:
# All the plugins we use in Aloha
load: [
'common/ui'
'oer/toolbar'
'oer/popover'
'oer/format'
'common/contenthandler'
'common/paste'
'common/block'
'common/list'
'oer/table'
'oer/popover'
'oer/math'
'extra/draganddropfiles'
'common/image'
'oer/assorted'
'oer/title'
'common/undo'
'oer/undobutton'
'oer/genericbutton'
'oer/semanticblock'
'oer/exercise'
'oer/note'
]
note: [
{ label: 'Note', cls: 'note', hasTitle: true }
{ label: 'Aside', cls: 'note', hasTitle: true, type: 'aside' }
{ label: 'Warning', cls: 'note', hasTitle: true, type: 'warning' }
{ label: 'Tip', cls: 'note', hasTitle: true, type: 'tip' }
{ label: 'Important', cls: 'note', hasTitle: true, type: 'important' }
{ label: 'Noteish', cls: 'noteish', hasTitle: true }
{ label: 'Noteish (no Title)', cls: 'noteish-notitle', hasTitle: false }
]
# This whole thing is what's needed to:
#
# - set a custom URL to send files to
# - register a callback that updates the IMG with the new src
draganddropfiles:
upload:
config:
method: 'POST'
url: '/resource'
fieldName: 'upload'
send_multipart_form: true
callback: (resp) ->
# **TODO:** add xhr to Aloha.trigger('aloha-upload-*') in dropfilesrepository.js
# dropfilesrepository.js triggers 'aloha-upload-success'
# and 'aloha-upload-failure' but does not provide the
# response text (URL).
# We should probably change dropfilesrepository.js to be:
#
# Aloha.trigger('aloha-upload-success', that, xhr);
# Then, instead of configuring a callback we could just listen to that event.
# If the response is a URL then change the Image source to it
# The URL could be absolute (`/^http/`) or relative (`/\//` or `[a-z]`).
unless resp.match(/^http/) or resp.match(/^\//) or resp.match(/^[a-z]/)
alert 'You dropped a file and we sent a message to the server to do something with it.\nIt responded with some gibberish so we are showing you some other file to show it worked'
resp = 'src/test/AlohaEditorLogo.png'
# Drag and Drop creates an <img id='{this.id}'> element but the
#
# - 'New Image' plugin doesn't have access to the UploadFile object (this)
# so all it can do is add a class.
# - If I combine both then we can set the attribute consistently.
# - **FIXME:** Don't assume only 1 image can be uploaded at a time
$img = Aloha.jQuery('.aloha-image-uploading').add('#' + @id)
$img.attr 'src', resp
$img.removeClass 'aloha-image-uploading'
console.log 'Updated Image src as a result of upload'
block:
defaults:
'.default-block': {}
figure:
'aloha-block-type': 'EditableImageBlock'
# In case some module wants the config object return it.
return @Aloha