Skip to content

Commit e9857fb

Browse files
committed
keep layout fixes even when after saving the page. fix error when there's no favorites.
1 parent e18aa42 commit e9857fb

File tree

1 file changed

+13
-7
lines changed

1 file changed

+13
-7
lines changed

src/SitecoreLayoutImprovements.js

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -86,13 +86,18 @@
8686
const txts = document.querySelectorAll('.scEditorFieldMarkerInputCell textarea');
8787
if (txts.length === 0) return;
8888

89-
const style = document.createElement('style');
90-
style.innerHTML = `
89+
if (!document.getElementById('fixInputCellTextArea')) {
90+
const style = document.createElement('style');
91+
style.id = 'fixInputCellTextArea';
92+
style.innerHTML = `
9193
.monospace-font {font-family: Consolas, Monaco, "Andale Mono", "Ubuntu Mono", monospace;}
9294
`;
93-
document.querySelector('body').appendChild(style);
95+
document.querySelector('body').appendChild(style);
96+
}
9497

9598
txts.forEach((txt) => {
99+
if (txt.classList.contains('monospace-font')) return;
100+
96101
txt.classList.add('monospace-font');
97102
txt.setAttribute('spellcheck', false);
98103

@@ -204,13 +209,14 @@
204209
cursor: pointer;
205210
background: red;
206211
white-space: nowrap;
207-
}
208-
`;
212+
}`;
209213
}
210214

211215
chrome.storage.sync.get('favorites', ({ favorites }) => {
212216
favorites = favorites || [];
213-
favorites = favorites.sort((a, b) => (a.path > b.path ? 1 : -1));
217+
if (favorites.length > 1) {
218+
favorites = favorites.sort((a, b) => (a.path > b.path ? 1 : -1));
219+
}
214220

215221
const accInfo = document.querySelector('.sc-accountInformation');
216222
let fav = document.querySelector('#ChromeExtensionForSitecoreFavorites');
@@ -323,10 +329,10 @@
323329
if (location.pathname === '/sitecore/shell/Applications/Content%20Editor.aspx') {
324330
stretchColumn();
325331
scrollToItem();
326-
fixInputCellTextArea();
327332
addFocusHeightOnElements();
328333

329334
addBookmark();
335+
setInterval(fixInputCellTextArea, 500);
330336
setInterval(addBookmark, 500);
331337

332338
setInterval(enlargeTreelist, 500);

0 commit comments

Comments
 (0)