mirror of
https://github.com/discourse/discourse.git
synced 2024-11-22 14:38:17 +08:00
DEV: Remove decorateCookedElement id parameters (#23544)
These are no longer required per https://github.com/discourse/discourse/pull/23543
This commit is contained in:
parent
e0d8dae0b3
commit
c3061d580c
|
@ -100,7 +100,6 @@ export default {
|
|||
|
||||
api.decorateCookedElement(_attachCommands, {
|
||||
onlyStream: true,
|
||||
id: "animated-images-pause-on-click",
|
||||
});
|
||||
|
||||
api.cleanupStream(_cleanUp);
|
||||
|
|
|
@ -43,7 +43,6 @@ export default {
|
|||
},
|
||||
{
|
||||
onlyStream: true,
|
||||
id: "codeblock-buttons",
|
||||
}
|
||||
);
|
||||
|
||||
|
|
|
@ -10,7 +10,6 @@ export default {
|
|||
withPluginApi("0.8.7", (api) => {
|
||||
api.decorateCookedElement((post) => decorateHashtags(post, site), {
|
||||
onlyStream: true,
|
||||
id: "hashtag-icons",
|
||||
});
|
||||
});
|
||||
},
|
||||
|
|
|
@ -14,8 +14,7 @@ export default {
|
|||
initWithApi(api) {
|
||||
const supportsAspectRatio = CSS.supports("aspect-ratio: 1");
|
||||
|
||||
api.decorateCookedElement(
|
||||
(element) => {
|
||||
api.decorateCookedElement((element) => {
|
||||
element.querySelectorAll("img").forEach((img) => {
|
||||
const declaredHeight = parseFloat(img.getAttribute("height"));
|
||||
const declaredWidth = parseFloat(img.getAttribute("width"));
|
||||
|
@ -38,18 +37,12 @@ export default {
|
|||
// It's not perfect, because it won't recompute on browser resize.
|
||||
// This property is consumed in `topic-post.scss` for responsive images only.
|
||||
// It's a no-op for non-responsive images.
|
||||
const calculatedHeight =
|
||||
img.width / (declaredWidth / declaredHeight);
|
||||
const calculatedHeight = img.width / (declaredWidth / declaredHeight);
|
||||
|
||||
img.style.setProperty(
|
||||
"--calculated-height",
|
||||
`${calculatedHeight}px`
|
||||
);
|
||||
img.style.setProperty("--calculated-height", `${calculatedHeight}px`);
|
||||
}
|
||||
});
|
||||
},
|
||||
{ id: "image-aspect-ratio" }
|
||||
);
|
||||
});
|
||||
},
|
||||
|
||||
initialize() {
|
||||
|
|
|
@ -40,14 +40,9 @@ function _cleanUp() {
|
|||
export default {
|
||||
initialize() {
|
||||
withPluginApi("0.8.42", (api) => {
|
||||
api.decorateCookedElement(
|
||||
(element) => {
|
||||
api.decorateCookedElement((element) => {
|
||||
decorateGithubOneboxBody(element);
|
||||
},
|
||||
{
|
||||
id: "onebox-github-body",
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
api.cleanupStream(_cleanUp);
|
||||
});
|
||||
|
|
|
@ -21,14 +21,9 @@ export default {
|
|||
const modal = owner.lookup("service:modal");
|
||||
// will eventually just be called lightbox
|
||||
const lightboxService = owner.lookup("service:lightbox");
|
||||
api.decorateCookedElement(
|
||||
(elem) => {
|
||||
api.decorateCookedElement((elem) => {
|
||||
return highlightSyntax(elem, siteSettings, session);
|
||||
},
|
||||
{
|
||||
id: "discourse-syntax-highlighting",
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
if (siteSettings.enable_experimental_lightbox) {
|
||||
api.decorateCookedElement(
|
||||
|
@ -42,23 +37,18 @@ export default {
|
|||
: null;
|
||||
},
|
||||
{
|
||||
id: "experimental-discourse-lightbox",
|
||||
onlyStream: true,
|
||||
}
|
||||
);
|
||||
|
||||
api.cleanupStream(lightboxService.cleanupLightboxes);
|
||||
} else {
|
||||
api.decorateCookedElement(
|
||||
(elem) => {
|
||||
api.decorateCookedElement((elem) => {
|
||||
return lightbox(elem, siteSettings);
|
||||
},
|
||||
{ id: "discourse-lightbox" }
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
api.decorateCookedElement(
|
||||
(elem) => {
|
||||
api.decorateCookedElement((elem) => {
|
||||
const grids = elem.querySelectorAll(".d-image-grid");
|
||||
|
||||
if (!grids.length) {
|
||||
|
@ -70,20 +60,15 @@ export default {
|
|||
columns: site.mobileView ? 2 : 3,
|
||||
});
|
||||
});
|
||||
},
|
||||
{ id: "discourse-image-grid" }
|
||||
);
|
||||
});
|
||||
|
||||
if (siteSettings.support_mixed_text_direction) {
|
||||
api.decorateCookedElement(setTextDirections, {
|
||||
id: "discourse-text-direction",
|
||||
});
|
||||
api.decorateCookedElement(setTextDirections, {});
|
||||
}
|
||||
|
||||
nativeLazyLoading(api);
|
||||
|
||||
api.decorateCookedElement(
|
||||
(elem) => {
|
||||
api.decorateCookedElement((elem) => {
|
||||
elem.querySelectorAll("audio").forEach((player) => {
|
||||
player.addEventListener("play", () => {
|
||||
const postId = parseInt(
|
||||
|
@ -95,9 +80,7 @@ export default {
|
|||
}
|
||||
});
|
||||
});
|
||||
},
|
||||
{ id: "discourse-audio" }
|
||||
);
|
||||
});
|
||||
|
||||
const caps = owner.lookup("service:capabilities");
|
||||
if (caps.isSafari || caps.isIOS) {
|
||||
|
@ -119,7 +102,7 @@ export default {
|
|||
}
|
||||
});
|
||||
},
|
||||
{ id: "safari-video-poster", afterAdopt: true, onlyStream: true }
|
||||
{ afterAdopt: true, onlyStream: true }
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -136,8 +119,7 @@ export default {
|
|||
wikipedia: "fab-wikipedia-w",
|
||||
};
|
||||
|
||||
api.decorateCookedElement(
|
||||
(elem) => {
|
||||
api.decorateCookedElement((elem) => {
|
||||
elem.querySelectorAll(".onebox").forEach((onebox) => {
|
||||
Object.entries(oneboxTypes).forEach(([key, value]) => {
|
||||
if (onebox.classList.contains(key)) {
|
||||
|
@ -147,12 +129,9 @@ export default {
|
|||
}
|
||||
});
|
||||
});
|
||||
},
|
||||
{ id: "onebox-source-icons" }
|
||||
);
|
||||
});
|
||||
|
||||
api.decorateCookedElement(
|
||||
(element) => {
|
||||
api.decorateCookedElement((element) => {
|
||||
element
|
||||
.querySelectorAll(".video-container")
|
||||
.forEach((videoContainer) => {
|
||||
|
@ -172,9 +151,7 @@ export default {
|
|||
}, 500);
|
||||
});
|
||||
});
|
||||
},
|
||||
{ id: "discourse-video-codecs" }
|
||||
);
|
||||
});
|
||||
|
||||
function _createButton() {
|
||||
const openPopupBtn = document.createElement("button");
|
||||
|
@ -234,7 +211,6 @@ export default {
|
|||
},
|
||||
{
|
||||
onlyStream: true,
|
||||
id: "fullscreen-table",
|
||||
}
|
||||
);
|
||||
});
|
||||
|
|
|
@ -5,12 +5,8 @@ function isLoaded(img) {
|
|||
}
|
||||
|
||||
export function nativeLazyLoading(api) {
|
||||
api.decorateCookedElement(
|
||||
(post) =>
|
||||
post.querySelectorAll("img").forEach((img) => (img.loading = "lazy")),
|
||||
{
|
||||
id: "discourse-lazy-load",
|
||||
}
|
||||
api.decorateCookedElement((post) =>
|
||||
post.querySelectorAll("img").forEach((img) => (img.loading = "lazy"))
|
||||
);
|
||||
|
||||
api.decorateCookedElement(
|
||||
|
@ -47,7 +43,6 @@ export function nativeLazyLoading(api) {
|
|||
});
|
||||
},
|
||||
{
|
||||
id: "discourse-lazy-load-after-adopt",
|
||||
afterAdopt: true,
|
||||
}
|
||||
);
|
||||
|
|
|
@ -131,7 +131,7 @@ class DecoratorHelper {
|
|||
* cooked.querySelector(".some-container"),
|
||||
* hbs`I will be appended to some-container`
|
||||
* );
|
||||
* }, { onlyStream: true, id: "my-id" });
|
||||
* }, { onlyStream: true });
|
||||
* ```
|
||||
*
|
||||
*/
|
||||
|
|
|
@ -47,7 +47,7 @@ acceptance("Acceptance | decorateCookedElement", function () {
|
|||
hbs` with more content from glimmer`
|
||||
);
|
||||
},
|
||||
{ id: "render-glimmer-test", onlyStream: true }
|
||||
{ onlyStream: true }
|
||||
);
|
||||
});
|
||||
|
||||
|
|
|
@ -120,8 +120,7 @@ export default {
|
|||
|
||||
// we want to decorate the chat quote dates regardless
|
||||
// of whether the current user has chat enabled
|
||||
api.decorateCookedElement(
|
||||
(elem) => {
|
||||
api.decorateCookedElement((elem) => {
|
||||
const currentUser = getOwner(this).lookup("service:current-user");
|
||||
const currentUserTimezone = currentUser?.user_option?.timezone;
|
||||
const chatTranscriptElements =
|
||||
|
@ -145,9 +144,7 @@ export default {
|
|||
|
||||
dateTimeEl.dataset.dateFormatted = true;
|
||||
});
|
||||
},
|
||||
{ id: "chat-transcript-datetime" }
|
||||
);
|
||||
});
|
||||
|
||||
if (!this.chatService.userCanChat) {
|
||||
return;
|
||||
|
|
|
@ -7,7 +7,7 @@ function initializePlugin(api) {
|
|||
const siteSettings = api.container.lookup("site-settings:main");
|
||||
|
||||
if (siteSettings.checklist_enabled) {
|
||||
api.decorateCookedElement(checklistSyntax, { id: "checklist" });
|
||||
api.decorateCookedElement(checklistSyntax);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -33,7 +33,7 @@ function initLazyEmbed(api) {
|
|||
}
|
||||
});
|
||||
},
|
||||
{ onlyStream: true, id: "discourse-lazy-videos" }
|
||||
{ onlyStream: true }
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
@ -149,8 +149,7 @@ function initializeDiscourseLocalDates(api) {
|
|||
site_name: siteSettings.title,
|
||||
});
|
||||
|
||||
api.decorateCookedElement(
|
||||
(elem, helper) => {
|
||||
api.decorateCookedElement((elem, helper) => {
|
||||
const dates = elem.querySelectorAll(".discourse-local-date");
|
||||
|
||||
applyLocalDates(dates, siteSettings);
|
||||
|
@ -159,9 +158,7 @@ function initializeDiscourseLocalDates(api) {
|
|||
dates.forEach((date) => {
|
||||
date.dataset.title = date.dataset.title || topicTitle || defaultTitle;
|
||||
});
|
||||
},
|
||||
{ id: "discourse-local-date" }
|
||||
);
|
||||
});
|
||||
|
||||
api.onToolbarCreate((toolbar) => {
|
||||
toolbar.addButton({
|
||||
|
|
|
@ -131,7 +131,6 @@ function initializePolls(api) {
|
|||
api.includePostAttributes("polls", "polls_votes");
|
||||
api.decorateCookedElement(attachPolls, {
|
||||
onlyStream: true,
|
||||
id: "discourse-poll",
|
||||
});
|
||||
api.cleanupStream(cleanUpPolls);
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user