Revert "DEV: Switch theme to use new `addComposerToolbarPopupMenuOpti… (#62)

This reverts commit d59dc7caf4.

We have compatibility problems with themes and core right now: https://meta.discourse.org/t/-/282315/7
This commit is contained in:
Alan Guo Xiang Tan 2023-10-16 15:23:04 +08:00 committed by GitHub
parent d59dc7caf4
commit 04577e0b90
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 24 additions and 28 deletions

View File

@ -1,4 +1,3 @@
< 3.2.0.beta2-dev: 566d79fa39eacfa299a7e60afe5b8d75020f7f7c
3.1.999: 323bd485b08889360edcae826d6272fd8e77d180
2.7.13: 5b2f5a455e1adf8ce5e8c1cfb7fbc3c388d3d82a
2.6.0.beta3: 68d40fe9f5b625cf465adc31b502a54e16d02cc6

View File

@ -5,7 +5,7 @@ export default {
name: "disco-toc-composer",
initialize() {
withPluginApi("1.14.0", (api) => {
withPluginApi("1.0.0", (api) => {
const currentUser = api.getCurrentUser();
if (!currentUser) {
return;
@ -19,20 +19,28 @@ export default {
}
I18n.translations[I18n.currentLocale()].js.composer.contains_dtoc = " ";
api.addComposerToolbarPopupMenuOption({
action: (toolbarEvent) => {
toolbarEvent.applySurround(
`<div data-theme-toc="true">`,
`</div>`,
"contains_dtoc"
);
},
icon: "align-left",
label: themePrefix("insert_table_of_contents"),
condition: (composer) => {
return composer.model.topicFirstPost;
api.modifyClass("controller:composer", {
pluginId: "DiscoTOC",
actions: {
insertDtoc() {
this.get("toolbarEvent").applySurround(
`<div data-theme-toc="true">`,
`</div>`,
"contains_dtoc"
);
},
},
});
api.addToolbarPopupMenuOptionsCallback((controller) => {
return {
action: "insertDtoc",
icon: "align-left",
label: themePrefix("insert_table_of_contents"),
condition: controller.get("model.topicFirstPost"),
};
});
}
});
},

View File

@ -1,4 +1,3 @@
import I18n from "I18n";
import {
acceptance,
exists,
@ -20,10 +19,7 @@ acceptance("DiscoTOC - Composer", function (needs) {
await click("#create-topic");
const toolbarPopupMenu = selectKit(".toolbar-popup-menu-options");
await toolbarPopupMenu.expand();
await toolbarPopupMenu.selectRowByName(
I18n.t(themePrefix("insert_table_of_contents"))
);
await toolbarPopupMenu.selectRowByValue("insertDtoc");
assert.ok(query(".d-editor-input").value.includes('data-theme-toc="true"'));
});
@ -37,10 +33,7 @@ acceptance("DiscoTOC - Composer", function (needs) {
const toolbarPopupMenu = selectKit(".toolbar-popup-menu-options");
await toolbarPopupMenu.expand();
await toolbarPopupMenu.selectRowByName(
I18n.t(themePrefix("insert_table_of_contents"))
);
await toolbarPopupMenu.selectRowByValue("insertDtoc");
assert.ok(query(".d-editor-input").value.includes('data-theme-toc="true"'));
});
@ -51,10 +44,6 @@ acceptance("DiscoTOC - Composer", function (needs) {
const toolbarPopupMenu = selectKit(".toolbar-popup-menu-options");
await toolbarPopupMenu.expand();
assert.notOk(
toolbarPopupMenu
.rowByName(I18n.t(themePrefix("insert_table_of_contents")))
.exists()
);
assert.notOk(toolbarPopupMenu.rowByValue("insertDtoc").exists());
});
});