Skip to content

Commit

Permalink
Got Aloha editor working as a pattern.
Browse files Browse the repository at this point in the history
Next steps are to provide arguments with which it can be configured as well as
a extensive demo page.

refs: ploneintranet/ploneintranet.theme#93
  • Loading branch information
jcbrand committed Mar 3, 2015
1 parent 68dcc3b commit 7338704
Show file tree
Hide file tree
Showing 5 changed files with 63 additions and 19 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
node_modules
src/bower_components
stamp-bower
stamp-npm
5 changes: 5 additions & 0 deletions bower.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,11 @@
],
"dependencies": {
"aloha-editor": "~1.1.0",
"mockup-core": "~2.1.3",
"patternslib": "master"
},
"resolutions": {
"jquery": "1.11.1",
"patternslib": "master"
}
}
11 changes: 7 additions & 4 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,18 @@
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8">
<title>Aloha Editor Pattern demo</title>
<link rel="stylesheet" href="src/bower_components/aloha-editor/src/demo-app/app/css/bootstrap.css" />
<link rel="stylesheet" href="src/bower_components/aloha-editor/src/demo-app/app/css/aloha-editor-demo.css" />
<script data-main="../main" src="../src/bower_components/requirejs/require.js"></script>
<link rel="stylesheet" href="src/bower_components/aloha-editor/src/demo/demo-app/app/css/bootstrap.css" />
<link rel="stylesheet" href="src/bower_components/aloha-editor/src/demo/demo-app/app/css/aloha-editor-demo.css" />
<link rel="stylesheet" href="src/bower_components/aloha-editor/src/css/aloha.css" />
<script data-main="main" src="src/bower_components/requirejs/require.js"></script>
</head>
<body>
<div id="container">
<div>
<div class="item">
<h1>Masonry Pattern demo</h1>
<h1>Aloha Pattern demo</h1>

<textarea name="textarea" id="textarea" rows="10" class="xxlarge pat-editor"></textarea>
</div>
</div>
</div>
Expand Down
8 changes: 6 additions & 2 deletions main.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ require.config({
paths: {
"aloha-editor": "bower_components/aloha-editor/",
"jquery": "bower_components/jquery/dist/jquery",
"jquery.browser": "bower_components/jquery.browser/dist/jquery.browser",
"logging": "bower_components/logging/src/logging",
"mockup-parser": "bower_components/mockup-core/js/parser",
"mockup-patterns-base": "bower_components/mockup-core/js/pattern",
Expand Down Expand Up @@ -175,7 +176,7 @@ require.config({
"listenforcer/res": "bower_components/aloha-editor/src/plugins/extra/listenforcer/res",

// Aloha Plugins
"ui-plugin": "bower_components/aloha-editor/src/lib/aloha/ui/ui-plugin",
"ui/ui-plugin": "bower_components/aloha-editor/src/plugins/common/ui/lib/ui-plugin",
"link-plugin": "bower_components/aloha-editor/src/lib/aloha/link/link-plugin",
"table-plugin": "bower_components/aloha-editor/src/lib/aloha/table/table-plugin",
"format-plugin": "bower_components/aloha-editor/src/lib/aloha/format/format-plugin",
Expand All @@ -194,7 +195,10 @@ require.config({
"paste-plugin": "bower_components/aloha-editor/src/lib/aloha/paste/paste-plugin",
"autoparagraph-plugin": "bower_components/aloha-editor/src/lib/aloha/autoparagraph/autoparagraph-plugin",

"aloha": "bower_components/aloha-editor/src/lib/aloha/core"
"i18n": "bower_components/aloha-editor/src/lib/i18n",
"vendor": "bower_components/aloha-editor/src/lib/vendor",
"aloha": "bower_components/aloha-editor/src/lib/aloha",
"util": "bower_components/aloha-editor/src/lib/util"
},
"shim": {
"logging": { "exports": "logging" },
Expand Down
56 changes: 43 additions & 13 deletions src/pat-editor.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,26 +2,56 @@
if (typeof define === 'function' && define.amd) {
define([
"jquery",
"jquery.browser",
"mockup-patterns-base",
"pat-registry",
"pat-parser",
"aloha"
"pat-parser"
], function() {
return factory.apply(this, arguments);
});
} else {
factory($, Base, root.patterns, root.patterns.Parser, Aloha);
factory($, null, Base, root.patterns, root.patterns.Parser);
}
}(this, function($, Base, registry, Parser, Aloha) {
'use strict';
var parser = new Parser("editor");
}(this, function($, dummy, Base, registry, Parser) {
'use strict';
var parser = new Parser("editor");
parser.add_argument("aloha-settings", {}); // Allows the user to specify Aloha settings via JSON
parser.add_argument("toolbar-floating", false);

return Base.extend({
name: 'editor',
trigger: ".pat-editor",

init: function patEditor($el, opts) {
debugger;
}
});
return Base.extend({
name: 'editor',
trigger: ".pat-editor",

init: function patEditor() {
var options = parser.parse(this.$el);

if (typeof window.Aloha == "undefined") {
window.Aloha = { settings: {} };
}
// The "aloha-settings" parameter allows the user to override any
// Aloha setting by specifying a JSON object.
if (options.alohaSettings && options.alohaSettings.length) {
$.extend(true, Aloha.settings, options.alohaSettings);
}

Aloha.settings.toolbar = Aloha.settings.toolbar || {};
$.extend(true, Aloha.settings, { toolbar: { floating: options.toolBarFloating || false }});

Aloha.settings.logLevels = { 'error': true, 'warn': true, 'info': true, 'debug': false, 'deprecated': true };
Aloha.settings.errorhandling = false;
Aloha.settings.ribbon = {enable: true};
Aloha.settings.plugins = Aloha.settings.plugins || {};
Aloha.settings.plugins.load = "common/ui, common/format, common/link";

Aloha.settings.sidebar = Aloha.settings.sidebar || {};
Aloha.settings.sidebar.disabled = true;

require(['aloha'], function () {
Aloha.ready(function () {
Aloha.jQuery('#textarea').aloha();
}.bind(this));
});
}
});
}));

0 comments on commit 7338704

Please sign in to comment.