Merge branch 'pad2' of github.com:xwiki-labs/cryptpad into pad2

pull/1/head
yflory 7 years ago
commit 33025a9df9

@ -27,7 +27,7 @@ CKEDITOR.editorConfig = function( config ) {
config.font_defaultLabel = 'Arial';
config.fontSize_defaultLabel = '16';
config.contentsCss = '/customize/ckeditor-contents.css';
config.contentsCss = '/customize/ckeditor-contents.css?' + CKEDITOR.CRYPTPAD_URLARGS;
config.keystrokes = [
[ CKEDITOR.ALT + 121 /*F10*/, 'toolbarFocus' ],
@ -55,3 +55,17 @@ CKEDITOR.editorConfig = function( config ) {
//skin: 'moono-dark,/pad/themes/moono-dark/'
//skin: 'office2013,/pad/themes/office2013/'
};
(function () {
// These are overrides inside of ckeditor which add ?ver= to the CSS files so that
// every part of ckeditor will get in the browser cache.
var fix = function (x) {
if (x.map) { return x.map(fix); }
console.log('> ' + x);
return (/\/bower_components\/.*\.css$/.test(x)) ? (x + '?ver=' + CKEDITOR.timestamp) : x;
};
CKEDITOR.tools._buildStyleHtml = CKEDITOR.tools.buildStyleHtml;
CKEDITOR.document._appendStyleSheet = CKEDITOR.document.appendStyleSheet;
CKEDITOR.tools.buildStyleHtml = function (x) { return CKEDITOR.tools._buildStyleHtml(fix(x)); };
CKEDITOR.document.appendStyleSheet = function (x) { return CKEDITOR.document._appendStyleSheet(fix(x)); };
}());

@ -2,7 +2,7 @@
define([
'/common/requireconfig.js'
], function (RequireConfig) {
require.config(RequireConfig);
require.config(RequireConfig());
// most of CryptPad breaks if you don't support isArray
if (!Array.isArray) {

@ -21,5 +21,7 @@ define([
}
};
Object.keys(ApiConfig.requireConf).forEach(function (k) { out[k] = ApiConfig.requireConf[k]; });
return out;
return function () {
return JSON.parse(JSON.stringify(out));
};
});

@ -2,20 +2,18 @@
// Note that this file is meant to be executed only inside of a sandbox iframe.
;(function () {
var req = JSON.parse(decodeURIComponent(window.location.hash.substring(1)));
if (req.cfg) { require.config(req.cfg); }
req.cfg = req.cfg || {};
if (req.pfx) {
require.config({
onNodeCreated: function (node, config, module, path) {
node.setAttribute('src', req.pfx + node.getAttribute('src'));
}
});
req.cfg.onNodeCreated = function (node, config, module, path) {
node.setAttribute('src', req.pfx + node.getAttribute('src'));
};
}
require.config(req.cfg);
if (req.req) { require(req.req, function () { }); }
window.addEventListener('message', function (msg) {
var data = JSON.parse(msg.data);
if (data.q !== 'INIT') { return; }
msg.source.postMessage(JSON.stringify({ txid: data.txid, content: 'OK' }), '*');
if (data.content && data.content.requireConf) { require.config(data.content.requireConf); }
require(['/common/sframe-boot2.js'], function () { });
});
}());

@ -1,7 +1,7 @@
// This is stage 1, it can be changed but you must bump the version of the project.
// Note: This must only be loaded from inside of a sandbox-iframe.
define(['/common/requireconfig.js'], function (RequireConfig) {
require.config(RequireConfig);
require.config(RequireConfig());
// most of CryptPad breaks if you don't support isArray
if (!Array.isArray) {

@ -145,7 +145,7 @@ define([
intr = setInterval(function () {
ow.postMessage(JSON.stringify({
txid: txid,
content: { requireConf: RequireConfig },
content: { requireConf: RequireConfig() },
q: 'INIT'
}), '*');
}, 1);

@ -606,7 +606,7 @@ define([
title: buttonTitle,
'class': "cryptpad-logo"
}).append($('<img>', {
src: '/customize/images/logo_white.png'
src: '/customize/images/logo_white.png?' + ApiConfig.requireConf.urlArgs
}));
var onClick = function (e) {
e.preventDefault();

@ -2,11 +2,7 @@
<html class="cp pad">
<head>
<meta content="text/html; charset=utf-8" http-equiv="content-type"/>
<link rel="stylesheet" href="/bower_components/components-font-awesome/css/font-awesome.min.css">
<script src="/bower_components/jquery/dist/jquery.min.js"></script>
<link rel="stylesheet" href="/bower_components/bootstrap/dist/css/bootstrap.min.css">
<script async data-bootload="/pad2/main.js" data-main="/common/sframe-boot.js?ver=1.0" src="/bower_components/requirejs/require.js?ver=2.3.5"></script>
<script src="/bower_components/ckeditor/ckeditor.js"></script>
<style>
html, body {
margin: 0px;

@ -1,4 +1,22 @@
console.log('one');
require(['/api/config'], function (ApiConfig) {
// see ckeditor_base.js getUrl()
window.CKEDITOR_GETURL = function (resource) {
if (resource.indexOf( '/' ) === 0) {
resource = window.CKEDITOR.basePath.replace(/\/bower_components\/.*/, '') + resource;
} else if (resource.indexOf(':/') === -1) {
resource = window.CKEDITOR.basePath + resource;
}
if (resource[resource.length - 1] !== '/' && resource.indexOf('ver=') === -1) {
var args = ApiConfig.requireConf.urlArgs;
if (resource.indexOf('/bower_components/') !== -1) {
args = 'ver=' + window.CKEDITOR.timestamp;
}
resource += (resource.indexOf('?') >= 0 ? '&' : '?') + args;
}
return resource;
};
require(['/bower_components/ckeditor/ckeditor.js']);
});
define([
'jquery',
'/bower_components/chainpad-crypto/crypto.js',
@ -14,15 +32,17 @@ define([
'/pad/links.js',
'/bower_components/nthen/index.js',
'/common/sframe-common.js',
'/api/config',
'/bower_components/file-saver/FileSaver.min.js',
'/bower_components/diff-dom/diffDOM.js',
'css!/bower_components/bootstrap/dist/css/bootstrap.min.css',
'css!/bower_components/components-font-awesome/css/font-awesome.min.css',
'less!/customize/src/less/cryptpad.less',
'less!/customize/src/less/toolbar.less'
], function ($, Crypto, Hyperjson,
Toolbar, Cursor, JsonOT, TypingTest, JSONSortify, TextPatcher, Cryptpad, Cryptget, Links, nThen, SFCommon) {
Toolbar, Cursor, JsonOT, TypingTest, JSONSortify, TextPatcher, Cryptpad, Cryptget, Links, nThen, SFCommon, ApiConfig) {
var saveAs = window.saveAs;
var Messages = Cryptpad.Messages;
var DiffDom = window.diffDOM;
@ -725,6 +745,8 @@ define([
} else {
$('meta[name=viewport]').attr('content', 'width=device-width, initial-scale=1.0, user-scalable=yes');
}
// Used in ckeditor-config.js
Ckeditor.CRYPTPAD_URLARGS = ApiConfig.requireConf.urlArgs;
editor = Ckeditor.replace('editor1', {
customConfig: '/customize/ckeditor-config.js',
});

@ -4,14 +4,17 @@ define([
'/common/requireconfig.js',
'/common/cryptget.js'
], function (ApiConfig, $, RequireConfig, Cryptget) {
var requireConfig = RequireConfig();
$(function () {
var req = {
cfg: RequireConfig,
cfg: requireConfig,
req: [ '/common/loading.js' ],
pfx: window.location.origin
};
window.rc = requireConfig;
window.apiconf = ApiConfig;
$('#sbox-iframe').attr('src',
ApiConfig.httpSafeOrigin + '/pad2/inner.html?' + ApiConfig.requireConf.urlArgs +
ApiConfig.httpSafeOrigin + '/pad2/inner.html?' + requireConfig.urlArgs +
'#' + encodeURIComponent(JSON.stringify(req)));
});
require([
@ -21,7 +24,6 @@ define([
'/common/cryptpad-common.js',
'/bower_components/chainpad-crypto/crypto.js'
], function (SFrameChannel, CpNfOuter, nThen, Cryptpad, Crypto) {
console.log('xxx');
var sframeChan;
var hashes;
var secret;

Loading…
Cancel
Save