Compare commits

...

10 Commits

6 changed files with 80 additions and 86 deletions

View File

@ -187,8 +187,6 @@ const getAceFile = async () => {
filenames.push(matches[2]);
}
}
// Always include the require kernel.
filenames.push('../static/js/require-kernel.js');
data += ';\n';
data += 'Ace2Editor.EMBEDED = Ace2Editor.EMBEDED || {};\n';

View File

@ -1,33 +1,60 @@
{
"pad.js": [
"pad.js"
, "pad_utils.js"
, "browser.js"
, "pad_cookie.js"
, "pad_editor.js"
, "pad_editbar.js"
, "vendors/nice-select.js"
, "pad_modals.js"
, "pad_automatic_reconnect.js"
, "ace.js"
, "collab_client.js"
, "pad_userlist.js"
, "pad_impexp.js"
, "pad_savedrevs.js"
, "pad_connectionstatus.js"
, "chat.js"
, "gritter.js"
, "$js-cookie/src/js.cookie.js"
, "$tinycon/tinycon.js"
, "farbtastic.js"
, "skiplist.js"
, "contentcollector.js"
, "scroll.js"
, "caretPosition.js"
, "undomodule.js"
, "ace2_inner.js"
, "gritter.js"
, "rjquery.js"
, "jquery.js"
, "changesettracker.js"
, "pad_utils.js"
, "pluginfw/shared.js"
, "pluginfw/client_plugins.js"
, "pluginfw/hooks.js"
, "pluginfw/plugin_defs.js"
, "chat.js"
, "$security.js"
, "security.js"
, "$unorm/lib/unorm.js"
, "ace2_common.js"
, "$tinycon/tinycon.js"
, "$js-cookie/src/js.cookie.js"
, "collab_client.js"
, "pad_cookie.js"
, "pad_connectionstatus.js"
, "pad_userlist.js"
, "skin_variants.js"
, "pad_editor.js"
, "pad_modals.js"
, "pad_editbar.js"
, "ace.js"
, "pad_savedrevs.js"
, "underscore.js"
, "$underscore/underscore.js"
, "vendors/nice-select.js"
, "pad_automatic_reconnect.js"
, "pad_impexp.js"
, "colorutils.js"
, "socketio.js"
, "AttributePool.js"
, "Changeset.js"
, "cssmanager.js"
, "domline.js"
, "linestylefilter.js"
, "AttributeManager.js"
, "ChangesetUtils.js"
]
, "timeslider.js": [
"timeslider.js"
, "colorutils.js"
, "draggable.js"
, "pad_utils.js"
, "$js-cookie/src/js.cookie.js"
, "browser.js"
, "pad_cookie.js"
, "pad_editor.js"
@ -38,48 +65,26 @@
, "pad_savedrevs.js"
, "pad_impexp.js"
, "AttributePool.js"
, "ChangesetUtils.js"
, "Changeset.js"
, "domline.js"
, "linestylefilter.js"
, "AttributeManager.js"
, "cssmanager.js"
, "broadcast.js"
, "broadcast_slider.js"
, "broadcast_revisions.js"
, "socketio.js"
]
, "ace2_inner.js": [
"ace2_inner.js"
, "browser.js"
, "AttributePool.js"
, "Changeset.js"
, "ChangesetUtils.js"
, "skiplist.js"
, "cssmanager.js"
, "colorutils.js"
, "undomodule.js"
, "$unorm/lib/unorm.js"
, "contentcollector.js"
, "changesettracker.js"
, "linestylefilter.js"
, "domline.js"
, "AttributeManager.js"
, "scroll.js"
, "caretPosition.js"
]
, "ace2_common.js": [
"ace2_common.js"
, "browser.js"
, "jquery.js"
, "rjquery.js"
, "$async.js"
, "underscore.js"
, "$underscore.js"
, "$underscore/underscore.js"
, "security.js"
, "$security.js"
, "jquery.js"
, "pluginfw/client_plugins.js"
, "pluginfw/plugin_defs.js"
, "pluginfw/shared.js"
, "pluginfw/plugin_defs.js"
, "pluginfw/hooks.js"
, "$security.js"
, "security.js"
, "ace2_common.js"
, "underscore.js"
, "$underscore/underscore.js"
]
}

View File

@ -24,8 +24,6 @@
// requires: top
// requires: undefined
const KERNEL_SOURCE = '../static/js/require-kernel.js';
const hooks = require('./pluginfw/hooks');
const pluginUtils = require('./pluginfw/shared');
@ -196,18 +194,19 @@ const Ace2Editor = function () {
`../static/skins/${clientVars.skinName}/pad.css?v=${clientVars.randomVersionString}`);
pushStyleTagsFor(iframeHTML, includedCSS);
if (!Ace2Editor.EMBEDED || !Ace2Editor.EMBEDED[KERNEL_SOURCE]) {
// Remotely src'd script tag will not work in IE; it must be embedded, so
// throw an error if it is not.
throw new Error('Require kernel could not be found.');
}
iframeHTML.push(`<script type="text/javascript" src="../static/js/require-kernel.js?v=${clientVars.randomVersionString}"></script>`);
iframeHTML.push(scriptTag(
`${Ace2Editor.EMBEDED[KERNEL_SOURCE]}\n\
`
require.setRootURI("../javascripts/src");\n\
require.setLibraryURI("../javascripts/lib");\n\
require.setGlobalKeyPath("require");\n\
// we can't reuse require-kernel from main window (the one that embeds sidediv+ace_outer)
// as it would be scoped to the main window, but we need it scoped to ace_inner
window.__pad = require('ep_etherpad-lite/static/js/pad');\n\
delete window.__pad;\n\
\n\
var plugins = require("ep_etherpad-lite/static/js/pluginfw/client_plugins");\n\
plugins.adoptPluginsFromAncestorsOf(window);\n\

View File

@ -24,9 +24,8 @@
let socket;
// These jQuery things should create local references, but for now `require()`
// assigns to the global `$` and augments it with plugins.
require('./jquery');
// TODO: these globals should be removed when possible
window.$ = window.jQuery = require('./rjquery').$;
require('./farbtastic');
require('./gritter');

View File

@ -441,20 +441,19 @@
<script type="text/javascript" src="../static/js/require-kernel.js?v=<%=settings.randomVersionString%>"></script>
<!-- Include pad_utils manually -->
<script type="text/javascript" src="../javascripts/lib/ep_etherpad-lite/static/js/pad_utils.js?callback=require.define&v=<%=settings.randomVersionString%>"></script>
<script type="text/javascript">
// @license magnet:?xt=urn:btih:8e4f440f4c65981c5bf93c76d35135ba5064d8b7&dn=apache-2.0.txt
(function() {
// Display errors on page load to the user
// (Gets overridden by padutils.setupGlobalExceptionHandler)
var originalHandler = window.onerror;
const originalHandler = window.onerror;
window.onerror = function(msg, url, line) {
var box = document.getElementById('editorloadingbox');
box.innerHTML = '<p><b>An error occurred while loading the pad</b></p>'
+ '<p><b>'+msg+'</b> '
+ '<small>in '+ padutils.escapeHTML(url) +' (line '+ line +')</small></p>';
const box = document.getElementById('editorloadingbox');
const cleanMessage = msg.replace(/[^0-9a-zA-Z=\.?&:\/]+/,'');
const cleanSource = url.replace(/[^0-9a-zA-Z=\.?&:\/]+/,'');
const cleanLine = parseInt(line);
box.innerText = `An error occurred while loading the pad\n${cleanMessage} in
${cleanSource} at line ${cleanLine}`
// call original error handler
if(typeof(originalHandler) == 'function') originalHandler.call(null, arguments);
};
@ -464,10 +463,6 @@
<script type="text/javascript" src="../socket.io/socket.io.js?v=<%=settings.randomVersionString%>"></script>
<!-- Include base packages manually (this help with debugging) -->
<script type="text/javascript" src="../javascripts/lib/ep_etherpad-lite/static/js/pad.js?callback=require.define&v=<%=settings.randomVersionString%>"></script>
<script type="text/javascript" src="../javascripts/lib/ep_etherpad-lite/static/js/ace2_common.js?callback=require.define&v=<%=settings.randomVersionString%>"></script>
<% e.begin_block("customScripts"); %>
<script type="text/javascript" src="../static/skins/<%=encodeURI(settings.skinName)%>/pad.js?v=<%=settings.randomVersionString%>"></script>
<% e.end_block(); %>
@ -486,7 +481,8 @@
require.setLibraryURI(baseURL + "javascripts/lib");
require.setGlobalKeyPath("require");
$ = jQuery = require('ep_etherpad-lite/static/js/rjquery').jQuery; // Expose jQuery #HACK
// intentionally moved here before first using $/jQuery
pad = require('ep_etherpad-lite/static/js/pad').pad;
browser = require('ep_etherpad-lite/static/js/browser');
var plugins = require('ep_etherpad-lite/static/js/pluginfw/client_plugins');
@ -499,13 +495,12 @@
hooks.aCallAll('documentReady');
});
var pad = require('ep_etherpad-lite/static/js/pad');
pad.baseURL = baseURL;
pad.init();
const _pad = require('ep_etherpad-lite/static/js/pad');
_pad.baseURL = baseURL;
_pad.init();
});
/* TODO: These globals shouldn't exist. */
pad = require('ep_etherpad-lite/static/js/pad').pad;
chat = require('ep_etherpad-lite/static/js/chat').chat;
padeditbar = require('ep_etherpad-lite/static/js/pad_editbar').padeditbar;
padimpexp = require('ep_etherpad-lite/static/js/pad_impexp').padimpexp;

View File

@ -251,10 +251,6 @@
<script type="text/javascript" src="../../static/js/require-kernel.js?v=<%=settings.randomVersionString%>"></script>
<script type="text/javascript" src="../../socket.io/socket.io.js?v=<%=settings.randomVersionString%>"></script>
<!-- Include base packages manually (this help with debugging) -->
<script type="text/javascript" src="../../javascripts/lib/ep_etherpad-lite/static/js/timeslider.js?callback=require.define&v=<%=settings.randomVersionString%>"></script>
<script type="text/javascript" src="../../javascripts/lib/ep_etherpad-lite/static/js/ace2_common.js?callback=require.define&v=<%=settings.randomVersionString%>"></script>
<script type="text/javascript" src="../../static/skins/<%=encodeURI(settings.skinName)%>/timeslider.js?v=<%=settings.randomVersionString%>"></script>
<!-- Bootstrap -->
@ -268,16 +264,18 @@
// Strip 'p', the padname and 'timeslider' from the pathname and set as baseURL
var baseURL = pathComponents.slice(0,pathComponents.length-3).join('/') + '/';
require.setRootURI(baseURL + "javascripts/src");
require.setLibraryURI(baseURL + "javascripts/lib");
require.setGlobalKeyPath("require");
// this is intentionally moved here so that timeslider, which is a package that contains
// most of the code needed for timeslider functionality, is loaded first.
var socket = require('ep_etherpad-lite/static/js/timeslider').socket;
$ = jQuery = require('ep_etherpad-lite/static/js/rjquery').jQuery; // Expose jQuery #HACK
browser = require('ep_etherpad-lite/static/js/browser');
var plugins = require('ep_etherpad-lite/static/js/pluginfw/client_plugins');
var socket = require('ep_etherpad-lite/static/js/timeslider').socket;
BroadcastSlider = require('ep_etherpad-lite/static/js/timeslider').BroadcastSlider;
plugins.baseURL = baseURL;