From 3fb8c52f0a082f766ade6c844d0711d1f7a52b1b Mon Sep 17 00:00:00 2001 From: yflory Date: Wed, 10 Feb 2021 12:28:02 +0100 Subject: [PATCH] Fix race condition in rich text and restrict pad settings --- customize.dist/src/less2/include/toolbar.less | 1 + www/common/outer/async-store.js | 4 +++- www/pad/inner.js | 10 ++++++++-- 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/customize.dist/src/less2/include/toolbar.less b/customize.dist/src/less2/include/toolbar.less index d54778efd..7b4e43d0d 100644 --- a/customize.dist/src/less2/include/toolbar.less +++ b/customize.dist/src/less2/include/toolbar.less @@ -1035,6 +1035,7 @@ &.fa-download { order: 30; } &.fa-print { order: 35; } &.fa-trash { order: 40; } + &.cp-toolbar-icon-pad-settings { order: 75; } &.fa-info-circle { order: 100; } &.cp-toolbar-icon-help { order: 150; } diff --git a/www/common/outer/async-store.js b/www/common/outer/async-store.js index 900172f16..32cf421d5 100644 --- a/www/common/outer/async-store.js +++ b/www/common/outer/async-store.js @@ -1674,7 +1674,9 @@ define([ if (padData && padData.validateKey && store.messenger) { store.messenger.storeValidateKey(data.channel, padData.validateKey); } - postMessage(clientId, "PAD_READY", pad.noCache); + onReadyEvt.reg(function () { + postMessage(clientId, "PAD_READY", pad.noCache); + }); }, onMessage: function (m, user, validateKey, isCp, hash) { channel.lastHash = hash; diff --git a/www/pad/inner.js b/www/pad/inner.js index 5e529d12d..3e171c479 100644 --- a/www/pad/inner.js +++ b/www/pad/inner.js @@ -335,7 +335,7 @@ define([ var $settingsButton = framework._.sfCommon.createButton('', true, { drawer: true, text: Messages.pad_settings_title, - name: 'pad_settings', + name: 'pad-settings', icon: 'fa-cog', }, function () { UI.alert(getSettings()); @@ -655,6 +655,7 @@ define([ var documentBody = ifrWindow.document.body; var inner = window.inner = documentBody; var $inner = $(inner); + $inner.attr('contenteditable', 'false'); var observer = new MutationObserver(function(muts) { muts.forEach(function(mut) { @@ -712,7 +713,6 @@ define([ if (!privateData.isEmbed) { mkHelpMenu(framework); } - mkSettingsMenu(framework); framework._.sfCommon.getAttribute(['pad', 'width'], function(err, data) { var active = data || typeof(data) === "undefined"; @@ -1033,6 +1033,12 @@ define([ $inner.attr('contenteditable', 'false'); } + common.getPadMetadata(null, function (md) { + if (md && md.error) { return; } + if (!common.isOwned(md.owners)) { return; } + mkSettingsMenu(framework); + }); + var fmConfig = { ckeditor: editor, dropArea: $inner,