aloha.js
1 |
define( |
---|---|
2 |
[ |
3 |
'Library/jquery-with-dependencies',
|
4 |
'Shared/Configuration',
|
5 |
'Content/Model/NodeSelection'
|
6 |
], |
7 |
function(
|
8 |
$,
|
9 |
Configuration, |
10 |
NodeSelection |
11 |
) { |
12 |
if (!window.T3.isContentModule) {
|
13 |
return;
|
14 |
} |
15 |
|
16 |
if (Configuration.get('Schema') === undefined) { |
17 |
// schema not yet loaded, we need to initialize aloha
|
18 |
Configuration.addObserver('Schema', function() { |
19 |
initAloha(); |
20 |
}); |
21 |
} else {
|
22 |
initAloha(); |
23 |
} |
24 |
|
25 |
function initAloha() { |
26 |
|
27 |
var nodeTypes = Configuration.get('Schema'); |
28 |
|
29 |
var nodeSettings = {};
|
30 |
$.each(nodeTypes, function(nodeTypeName, nodeType) { |
31 |
if (nodeType.properties && typeof nodeType.properties == 'object') { |
32 |
$.each(nodeType.properties, function(propertyName, property) { |
33 |
$.each(['table', 'link', 'list', 'alignment', 'format'], function(i, mode) { |
34 |
if (property.ui && property.ui.aloha && property.ui.aloha[mode]) {
|
35 |
var selector = '[typeof="typo3:' + nodeTypeName + '"]' + |
36 |
' [property="typo3:' + propertyName + '"]'; |
37 |
nodeSettings[mode] = nodeSettings[mode] ? nodeSettings[mode] : {}; |
38 |
nodeSettings[mode][selector] = property.ui.aloha[mode]; |
39 |
} |
40 |
}); |
41 |
}); |
42 |
} |
43 |
}); |
44 |
|
45 |
var Aloha = window.Aloha = window.Aloha || {__shouldInit: true}; |
46 |
|
47 |
Aloha.settings = { |
48 |
logLevels: {'error': true, 'warn': true, 'info': false, 'debug': false}, |
49 |
errorhandling : false, |
50 |
sidebar: {
|
51 |
disabled: true |
52 |
}, |
53 |
plugins: {
|
54 |
load: [
|
55 |
'common/ui',
|
56 |
'common/link',
|
57 |
'common/table',
|
58 |
'common/format',
|
59 |
'common/list',
|
60 |
//'image/image-plugin',
|
61 |
//'highlighteditables/highlighteditables-plugin',
|
62 |
'common/dom-to-xhtml',
|
63 |
'common/contenthandler',
|
64 |
//'common/characterpicker',
|
65 |
'common/commands',
|
66 |
'common/block',
|
67 |
'common/align',
|
68 |
//'common/abbr',
|
69 |
//'common/horizontalruler',
|
70 |
'common/paste',
|
71 |
// some extra plugins
|
72 |
//'toc/toc-plugin',
|
73 |
//'extra/cite',
|
74 |
//'flag-icons/flag-icons-plugin',
|
75 |
//'numerated-headers/numerated-headers-plugin',
|
76 |
'extra/formatlesspaste',
|
77 |
//'linkbrowser/linkbrowser-plugin',
|
78 |
//'imagebrowser/imagebrowser-plugin',
|
79 |
//'extra/ribbon',
|
80 |
//'extra/wai-lang',
|
81 |
//'extra/headerids',
|
82 |
//'metaview/metaview-plugin',
|
83 |
//'extra/listenforcer'
|
84 |
|
85 |
// 'neosAloha/neosintegration',
|
86 |
// 'neosAloha/neos-links'
|
87 |
'neosAloha/ajax-repository'
|
88 |
].join(','),
|
89 |
block: {
|
90 |
sidebarAttributeEditor: false |
91 |
}, |
92 |
/**
|
93 |
* FIXME:
|
94 |
* Currently the filtering of options for alignment and format don't work correctly,
|
95 |
* meaning that all options are still shown. This seems to be an Aloha bug and needs
|
96 |
* more research.
|
97 |
*/
|
98 |
table: { config: [], editables: nodeSettings['table'] }, |
99 |
link: { config: [], editables: nodeSettings['link'] }, |
100 |
list: { config: [], editables: nodeSettings['list'] }, |
101 |
alignment: { config: [], editables: nodeSettings['alignment'] }, |
102 |
format: { config: ['b', 'i', 'u', 'sub', 'sup', 'p', 'h1', 'h2', 'h3', 'pre', 'removeFormat'], editables: nodeSettings['format'] } |
103 |
}, |
104 |
toolbar: {
|
105 |
tabs: [
|
106 |
{ |
107 |
label: 'tab.format.label', |
108 |
// The "format" tab is shown in the top-menu, the remaining tabs are shown
|
109 |
// in the inspector.
|
110 |
components: [
|
111 |
[ 'formatBlock', 'bold', 'italic', 'underline', 'subscript', 'superscript', 'formatLink', 'editLink', 'createTable', 'formatAbbr', 'formatNumeratedHeaders', 'toggleDragDrop', 'toggleMetaView', 'wailang', 'toggleFormatlessPaste', 'alignLeft', 'alignCenter', 'alignRight', 'alignJustify', 'orderedList', 'unorderedList', 'indentList', 'outdentList', 'colorPicker'] |
112 |
] |
113 |
}, |
114 |
// we completely disable the "insert" tab, as the needed features should reside in the "format" tab.
|
115 |
{ |
116 |
label: "tab.insert.label", |
117 |
showOn: function() { |
118 |
return false; |
119 |
} |
120 |
}, |
121 |
// we completely disable the "link" tab, as this should all be in the "format" tab.
|
122 |
{ |
123 |
label: 'tab.link.label', |
124 |
showOn: function() { |
125 |
return false; |
126 |
} |
127 |
} |
128 |
|
129 |
] |
130 |
}, |
131 |
|
132 |
// Fine-tune some Aloha-SmartContentChange settings, making the whole system feel more responsive.
|
133 |
smartContentChange: {
|
134 |
idle: 500, |
135 |
delay: 150 |
136 |
}, |
137 |
bundles: {
|
138 |
// Path for custom bundle relative from require.js path
|
139 |
//neosAloha: '/_Resources/Static/Packages/TYPO3.Neos/JavaScript/alohaplugins/'
|
140 |
}, |
141 |
|
142 |
baseUrl: alohaBaseUrl,
|
143 |
|
144 |
// Pass on our jQuery instance to Aloha to prevent double loading of jQuery
|
145 |
jQuery: $, |
146 |
predefinedModules: {
|
147 |
'jqueryui': $.ui, |
148 |
NeosNodeSelection: NodeSelection
|
149 |
}, |
150 |
requireConfig: {
|
151 |
map: {
|
152 |
'../../JavaScript/LibraryExtensions/UiAlohaPlugin/button': {
|
153 |
'originalButton': 'ui/button' |
154 |
}, |
155 |
'*': {
|
156 |
'ui/ui-plugin': '../../JavaScript/LibraryExtensions/UiAlohaPlugin/ui-plugin', |
157 |
'ui/multiSplit': '../../JavaScript/LibraryExtensions/UiAlohaPlugin/multiSplit', |
158 |
'ui/button': '../../JavaScript/LibraryExtensions/UiAlohaPlugin/button' |
159 |
} |
160 |
}, |
161 |
paths: {
|
162 |
'ajax-repository': '../../JavaScript/Content/LibraryExtensions/AlohaLinkPlugin/lib' |
163 |
} |
164 |
}, |
165 |
// Basic sanitation of content
|
166 |
contentHandler: {
|
167 |
insertHtml: ['word', 'generic', 'oembed', 'sanitize'], |
168 |
initEditable: ['sanitize'], |
169 |
getContents: ['blockelement', 'sanitize', 'basic'], |
170 |
sanitize: 'relaxed', // relaxed, restricted, basic |
171 |
allows: {
|
172 |
elements: [
|
173 |
'a', 'abbr', 'b', 'blockquote', 'br', 'caption', 'cite', 'code', 'col', |
174 |
'colgroup', 'dd', 'del', 'dl', 'dt', 'em', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6', |
175 |
'i', 'img', 'li', 'ol', 'p', 'pre', 'q', 'small', 'strike', 'strong', |
176 |
'sub', 'sup', 'table', 'tbody', 'td', 'tfoot', 'th', 'thead', 'tr', 'u', |
177 |
'ul', 'span', 'hr', 'object', 'div' |
178 |
], |
179 |
attributes: {
|
180 |
'a': ['href', 'data-gentics-aloha-repository', 'data-gentics-aloha-object-id', 'data-ajax-repository-temporary-data'], |
181 |
'blockquote': ['cite'], |
182 |
'q': ['cite'], |
183 |
'div': ['id','class','style'], |
184 |
'p': ['class', 'style', 'id'], |
185 |
'td': ['abbr', 'axis', 'colSpan', 'rowSpan', 'colspan', 'rowspan', 'style'], |
186 |
'th': ['abbr', 'axis', 'colSpan', 'rowSpan', 'colspan', 'rowspan', 'scope'] |
187 |
}, |
188 |
|
189 |
protocols: {
|
190 |
'a': {'href': ['ftp', 'http', 'https', 'mailto', 'tel', '__relative__', 'node']}, |
191 |
'blockquote': {'cite': ['http', 'https', '__relative__']}, |
192 |
'q': {'cite': ['http', 'https', '__relative__']} |
193 |
} |
194 |
} |
195 |
} |
196 |
}; |
197 |
|
198 |
require( |
199 |
{ |
200 |
context: 'aloha', |
201 |
baseUrl: alohaBaseUrl
|
202 |
}, |
203 |
['aloha']
|
204 |
) |
205 |
} |
206 |
}); |