Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion Optimizely_release_change_log.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,5 @@ Date / Plugin Version / Changes made since last version
2023-03-09 / 4.2.1 / Add version number on admin page, update form action url to be more resilient
2025-09-03 / 4.3.1 / Update icons for Siteimprove rebranding
2026-02-09 / 4.3.2 / Removed toolbar button in favor of integrated button in side panel, fixed bug where publishing while logged out would always open the login popup, and fixed intermittent error when registering highlighting and prepublish callbacks
2026-02-24 / 4.3.3 / Small change on siteimprove.js file
2026-02-24 / 4.3.3 / Small change on siteimprove.js file
2026-07-14 / 4.3.4 / Resolve preview iframe document at check time, fixing intermittent missing "Run content check" button and content checks running against a blank/stale page
Binary file removed SiteImprove.Optimizely.Plugin.4.3.3.nupkg
Binary file not shown.
Binary file added SiteImprove.Optimizely.Plugin.4.3.4.nupkg
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
<PackageProjectUrl>https://github.com/Siteimprove/CMS-plugin-Optimizely</PackageProjectUrl>
<PackageIcon>icon.png</PackageIcon>
<Description>Optimizely plugin from SiteImprove</Description>
<Version>4.3.3</Version>
<Version>4.3.4</Version>
</PropertyGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,38 +38,29 @@
topic.subscribe('epi/shell/context/request', this.contextChange.bind(this));
topic.subscribe('/epi/cms/content/statuschange/', this.statusChange.bind(this));

this.waitForPreviewIFrame(function (iFrameContentWindow) {
const dom = iFrameContentWindow?.document;
if (!dom) return;
var si = window._si || [];

si.push([
'onHighlight',
function (highlightInfo) {
var si = window._si || [];
var getPreviewDom = this.getPreviewDom;

si.push([
'onHighlight',
function (highlightInfo) {
var dom = getPreviewDom();
if (dom) {
si.push(['applyDefaultHighlighting', highlightInfo, dom]);
},
]);
}
},
]);

si.push(['registerPrepublishCallback', () => dom]);
});
}.bind(this));
si.push(['registerPrepublishCallback', getPreviewDom]);
}.bind(this));
},
/**
* Waits for the preview iframe to be available, then executes the callback with the iframe's document as parameter.
* Will try for a certain amount of attempts before giving up.
* Resolves the preview iframe's document at call time. The iframe's document is
* replaced on every in-CMS navigation, so it must never be cached.
*/
waitForPreviewIFrame: async function (callback) {
const maxAttempts = 10;

for (let i = 0; i < maxAttempts; i++) {
const previewIFrame = document.querySelector('iframe[name="sitePreview"]');
if (previewIFrame && previewIFrame.contentWindow) {
callback(previewIFrame.contentWindow);
return;
} else if (i < maxAttempts - 1) {
await new Promise(resolve => setTimeout(resolve, 1000)); // wait 1 second before trying again
}
}
getPreviewDom: function () {
var previewIFrame = document.querySelector('iframe[name="sitePreview"]');
return previewIFrame && previewIFrame.contentWindow ? previewIFrame.contentWindow.document : null;
},
/**
* Event for shell updates. Gets current context. Should only be called one to initialize the _si plugin.
Expand Down