Use the bounce app to open links from inner

pull/1/head
yflory 7 years ago
parent 812df7de6f
commit 644f6e9985

@ -125,7 +125,7 @@ define([
e.preventDefault(); e.preventDefault();
var $a = $t.is('a') ? $t : $t.parents('a').first(); var $a = $t.is('a') ? $t : $t.parents('a').first();
var href = $a.attr('href'); var href = $a.attr('href');
window.open(href); framework._.sfCommon.openUnsafeURL(href);
} }
}); });

@ -261,7 +261,7 @@ define([
return button; return button;
}; };
var createMdToolbar = function (editor) { var createMdToolbar = function (common, editor) {
var $toolbar = $('<div>', { var $toolbar = $('<div>', {
'class': 'cp-markdown-toolbar' 'class': 'cp-markdown-toolbar'
}); });
@ -359,13 +359,12 @@ define([
title: Messages.mdToolbar_help title: Messages.mdToolbar_help
}).click(function () { }).click(function () {
var href = Messages.mdToolbar_tutorial; var href = Messages.mdToolbar_tutorial;
var bounceHref = window.location.origin + '/bounce/#' + encodeURIComponent(href); common.openUnsafeURL(href);
window.open(bounceHref);
}).appendTo($toolbar); }).appendTo($toolbar);
return $toolbar; return $toolbar;
}; };
UIElements.createMarkdownToolbar = function (common, editor) { UIElements.createMarkdownToolbar = function (common, editor) {
var $toolbar = createMdToolbar(editor); var $toolbar = createMdToolbar(common, editor);
var cfg = { var cfg = {
title: Messages.mdToolbar_button, title: Messages.mdToolbar_button,
element: $toolbar element: $toolbar

@ -299,6 +299,10 @@ define([
funcs.gotoURL = function (url) { ctx.sframeChan.event('EV_GOTO_URL', url); }; funcs.gotoURL = function (url) { ctx.sframeChan.event('EV_GOTO_URL', url); };
funcs.openURL = function (url) { ctx.sframeChan.event('EV_OPEN_URL', url); }; funcs.openURL = function (url) { ctx.sframeChan.event('EV_OPEN_URL', url); };
funcs.openUnsafeURL = function (url) {
var bounceHref = window.location.origin + '/bounce/#' + encodeURIComponent(url);
window.open(bounceHref);
};
funcs.whenRealtimeSyncs = evRealtimeSynced.reg; funcs.whenRealtimeSyncs = evRealtimeSynced.reg;

@ -1,6 +1,5 @@
define([ define([
'jquery', 'jquery',
'/common/cryptpad-common.js',
'/customize/messages.js', '/customize/messages.js',
'/common/common-util.js', '/common/common-util.js',
'/common/common-interface.js', '/common/common-interface.js',
@ -8,36 +7,11 @@ define([
'/common/hyperscript.js', '/common/hyperscript.js',
'/bower_components/marked/marked.min.js', '/bower_components/marked/marked.min.js',
'/common/media-tag.js', '/common/media-tag.js',
], function ($, Cryptpad, Messages, Util, UI, Notifier, h, Marked, MediaTag) { ], function ($, Messages, Util, UI, Notifier, h, Marked, MediaTag) {
'use strict'; 'use strict';
var MessengerUI = {}; var MessengerUI = {};
var m = function (md) {
var d = h('div.cp-app-contacts-content');
try {
d.innerHTML = Marked(md || '');
var $d = $(d);
// remove potentially malicious elements
$d.find('script, iframe, object, applet, video, audio').remove();
// override link clicking, because we're in an iframe
$d.find('a').each(function () {
var href = $(this).click(function (e) {
e.preventDefault();
window.open(href);
}).attr('href');
});
// activate media-tags
$d.find('media-tag').each(function (i, e) { MediaTag(e); });
} catch (e) {
console.error(md);
console.error(e);
}
return d;
};
var dataQuery = function (curvePublic) { var dataQuery = function (curvePublic) {
return '[data-key="' + curvePublic + '"]'; return '[data-key="' + curvePublic + '"]';
}; };
@ -81,6 +55,31 @@ define([
find.inList(curvePublic).removeClass('cp-app-contacts-notify'); find.inList(curvePublic).removeClass('cp-app-contacts-notify');
}; };
var m = function (md) {
var d = h('div.cp-app-contacts-content');
try {
d.innerHTML = Marked(md || '');
var $d = $(d);
// remove potentially malicious elements
$d.find('script, iframe, object, applet, video, audio').remove();
// override link clicking, because we're in an iframe
$d.find('a').each(function () {
var href = $(this).click(function (e) {
e.preventDefault();
common.openUnsafeURL(href);
}).attr('href');
});
// activate media-tags
$d.find('media-tag').each(function (i, e) { MediaTag(e); });
} catch (e) {
console.error(md);
console.error(e);
}
return d;
};
var markup = {}; var markup = {};
markup.message = function (msg) { markup.message = function (msg) {
var curvePublic = msg.author; var curvePublic = msg.author;
@ -510,7 +509,7 @@ define([
console.error('TODO show something if that chatbox was active'); console.error('TODO show something if that chatbox was active');
}); });
Cryptpad.onDisplayNameChanged(function () { common.getMetadataMgr().onChange(function () {
//messenger.checkNewFriends(); //messenger.checkNewFriends();
messenger.updateMyData(); messenger.updateMyData();
}); });

@ -345,8 +345,9 @@ define([
var el = e.currentTarget; var el = e.currentTarget;
if (!el || el.nodeName !== 'A') { return; } if (!el || el.nodeName !== 'A') { return; }
var href = el.getAttribute('href'); var href = el.getAttribute('href');
var bounceHref = window.location.origin + '/bounce/#' + encodeURIComponent(href); if (href) {
if (href) { ifrWindow.open(bounceHref, '_blank'); } framework._.sfCommon.openUnsafeURL(href);
}
}; };
framework.onEditableChange(function (unlocked) { framework.onEditableChange(function (unlocked) {

@ -1206,7 +1206,7 @@ define([
var $a = $t.is('a') ? $t : $t.parents('a').first(); var $a = $t.is('a') ? $t : $t.parents('a').first();
var href = $a.attr('href'); var href = $a.attr('href');
if (!href) { return; } if (!href) { return; }
window.open(href); common.openUnsafeURL(href);
} }
}); });

@ -358,7 +358,7 @@ define([
}); });
}; };
var activateLinks = function ($content) { var activateLinks = function ($content, framework) {
$content.click(function (e) { $content.click(function (e) {
if (!e.target) { return; } if (!e.target) { return; }
var $t = $(e.target); var $t = $(e.target);
@ -366,7 +366,7 @@ define([
e.preventDefault(); e.preventDefault();
var $a = $t.is('a') ? $t : $t.parents('a').first(); var $a = $t.is('a') ? $t : $t.parents('a').first();
var href = $a.attr('href'); var href = $a.attr('href');
window.open(href); framework._.sfCommon.openUnsafeURL(href);
} }
}); });
}; };
@ -389,7 +389,7 @@ define([
var $toolbarDrawer = framework._.toolbar.$drawer; var $toolbarDrawer = framework._.toolbar.$drawer;
activateLinks($content); activateLinks($content, framework);
Slide.setModal(framework._.sfCommon, $modal, $content, slideOptions, Messages.slideInitialState); Slide.setModal(framework._.sfCommon, $modal, $content, slideOptions, Messages.slideInitialState);
mkPrintButton(framework, editor, $content, $print, $toolbarDrawer); mkPrintButton(framework, editor, $content, $print, $toolbarDrawer);
mkSlideOptionsButton(framework, slideOptions, $toolbarDrawer); mkSlideOptionsButton(framework, slideOptions, $toolbarDrawer);

Loading…
Cancel
Save