Fix race condition in rich text and restrict pad settings

pull/1/head
yflory 4 years ago
parent 138b9398b4
commit 3fb8c52f0a

@ -1035,6 +1035,7 @@
&.fa-download { order: 30; } &.fa-download { order: 30; }
&.fa-print { order: 35; } &.fa-print { order: 35; }
&.fa-trash { order: 40; } &.fa-trash { order: 40; }
&.cp-toolbar-icon-pad-settings { order: 75; }
&.fa-info-circle { order: 100; } &.fa-info-circle { order: 100; }
&.cp-toolbar-icon-help { order: 150; } &.cp-toolbar-icon-help { order: 150; }

@ -1674,7 +1674,9 @@ define([
if (padData && padData.validateKey && store.messenger) { if (padData && padData.validateKey && store.messenger) {
store.messenger.storeValidateKey(data.channel, padData.validateKey); store.messenger.storeValidateKey(data.channel, padData.validateKey);
} }
onReadyEvt.reg(function () {
postMessage(clientId, "PAD_READY", pad.noCache); postMessage(clientId, "PAD_READY", pad.noCache);
});
}, },
onMessage: function (m, user, validateKey, isCp, hash) { onMessage: function (m, user, validateKey, isCp, hash) {
channel.lastHash = hash; channel.lastHash = hash;

@ -335,7 +335,7 @@ define([
var $settingsButton = framework._.sfCommon.createButton('', true, { var $settingsButton = framework._.sfCommon.createButton('', true, {
drawer: true, drawer: true,
text: Messages.pad_settings_title, text: Messages.pad_settings_title,
name: 'pad_settings', name: 'pad-settings',
icon: 'fa-cog', icon: 'fa-cog',
}, function () { }, function () {
UI.alert(getSettings()); UI.alert(getSettings());
@ -655,6 +655,7 @@ define([
var documentBody = ifrWindow.document.body; var documentBody = ifrWindow.document.body;
var inner = window.inner = documentBody; var inner = window.inner = documentBody;
var $inner = $(inner); var $inner = $(inner);
$inner.attr('contenteditable', 'false');
var observer = new MutationObserver(function(muts) { var observer = new MutationObserver(function(muts) {
muts.forEach(function(mut) { muts.forEach(function(mut) {
@ -712,7 +713,6 @@ define([
if (!privateData.isEmbed) { if (!privateData.isEmbed) {
mkHelpMenu(framework); mkHelpMenu(framework);
} }
mkSettingsMenu(framework);
framework._.sfCommon.getAttribute(['pad', 'width'], function(err, data) { framework._.sfCommon.getAttribute(['pad', 'width'], function(err, data) {
var active = data || typeof(data) === "undefined"; var active = data || typeof(data) === "undefined";
@ -1033,6 +1033,12 @@ define([
$inner.attr('contenteditable', 'false'); $inner.attr('contenteditable', 'false');
} }
common.getPadMetadata(null, function (md) {
if (md && md.error) { return; }
if (!common.isOwned(md.owners)) { return; }
mkSettingsMenu(framework);
});
var fmConfig = { var fmConfig = {
ckeditor: editor, ckeditor: editor,
dropArea: $inner, dropArea: $inner,

Loading…
Cancel
Save