2022-07-03 20:47:08 -07:00
|
|
|
import { apiInitializer } from "discourse/lib/api";
|
2023-08-30 13:36:22 -07:00
|
|
|
import SpreadsheetEditor from "../components/spreadsheet-editor";
|
2022-07-04 14:58:50 -07:00
|
|
|
import { action } from "@ember/object";
|
2023-08-30 13:36:22 -07:00
|
|
|
import { inject as service } from "@ember/service";
|
2022-07-03 20:47:08 -07:00
|
|
|
|
2022-07-04 14:58:50 -07:00
|
|
|
export default apiInitializer("0.11.1", (api) => {
|
2022-07-19 16:33:10 -07:00
|
|
|
api.modifyClass("controller:composer", {
|
2022-07-04 14:58:50 -07:00
|
|
|
pluginId: "discourse-table-builder",
|
2023-08-30 13:36:22 -07:00
|
|
|
modal: service(),
|
2022-07-04 14:58:50 -07:00
|
|
|
|
|
|
|
|
@action
|
2022-07-19 16:33:10 -07:00
|
|
|
showTableBuilder() {
|
2023-08-30 13:36:22 -07:00
|
|
|
this.modal.show(SpreadsheetEditor, {
|
|
|
|
|
model: {
|
|
|
|
|
toolbarEvent: this.toolbarEvent,
|
|
|
|
|
tableTokens: null,
|
|
|
|
|
},
|
2022-07-19 16:33:10 -07:00
|
|
|
});
|
2022-07-04 14:58:50 -07:00
|
|
|
},
|
|
|
|
|
});
|
|
|
|
|
|
2022-07-19 16:33:10 -07:00
|
|
|
api.addToolbarPopupMenuOptionsCallback(() => {
|
|
|
|
|
return {
|
2022-07-04 14:58:50 -07:00
|
|
|
id: "table-builder",
|
2022-07-19 16:33:10 -07:00
|
|
|
action: "showTableBuilder",
|
2022-07-04 14:58:50 -07:00
|
|
|
icon: "table",
|
2022-07-19 16:33:10 -07:00
|
|
|
label: themePrefix("discourse_table_builder.composer.button"),
|
|
|
|
|
};
|
2022-07-04 14:58:50 -07:00
|
|
|
});
|
|
|
|
|
});
|