première tentative d'export du body en md, pas très concluant
This commit is contained in:
parent
8c8295b677
commit
c4892e919c
16 changed files with 477 additions and 0 deletions
63
site/plugins/epub-export/index.js
Normal file
63
site/plugins/epub-export/index.js
Normal file
|
|
@ -0,0 +1,63 @@
|
|||
(function() {
|
||||
"use strict";
|
||||
function normalizeComponent(scriptExports, render, staticRenderFns, functionalTemplate, injectStyles, scopeId, moduleIdentifier, shadowMode) {
|
||||
var options = typeof scriptExports === "function" ? scriptExports.options : scriptExports;
|
||||
if (render) {
|
||||
options.render = render;
|
||||
options.staticRenderFns = staticRenderFns;
|
||||
options._compiled = true;
|
||||
}
|
||||
return {
|
||||
exports: scriptExports,
|
||||
options
|
||||
};
|
||||
}
|
||||
const _sfc_main = {
|
||||
props: {
|
||||
pageId: String
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
loading: false,
|
||||
error: null
|
||||
};
|
||||
},
|
||||
methods: {
|
||||
async exportEpub() {
|
||||
this.loading = true;
|
||||
this.error = null;
|
||||
try {
|
||||
const response = await this.$api.post(`epub-export/${this.pageId}`);
|
||||
const blob = await response.blob();
|
||||
const url = window.URL.createObjectURL(blob);
|
||||
const a = document.createElement("a");
|
||||
a.href = url;
|
||||
a.download = this.pageId + ".epub";
|
||||
a.click();
|
||||
} catch (e) {
|
||||
this.error = "Erreur : " + e.message;
|
||||
} finally {
|
||||
this.loading = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
var _sfc_render = function render() {
|
||||
var _vm = this, _c = _vm._self._c;
|
||||
return _c("k-box", [_c("k-button", { attrs: { "theme": "positive", "icon": "download", "disabled": _vm.loading }, on: { "click": _vm.exportEpub } }, [_vm._v(" Exporter en EPUB ")]), _vm.loading ? _c("k-text", [_vm._v("Génération en cours…")]) : _vm._e(), _vm.error ? _c("k-text", { attrs: { "theme": "negative" } }, [_vm._v(_vm._s(_vm.error))]) : _vm._e()], 1);
|
||||
};
|
||||
var _sfc_staticRenderFns = [];
|
||||
_sfc_render._withStripped = true;
|
||||
var __component__ = /* @__PURE__ */ normalizeComponent(
|
||||
_sfc_main,
|
||||
_sfc_render,
|
||||
_sfc_staticRenderFns
|
||||
);
|
||||
__component__.options.__file = "C:/Users/anton/Desktop/studioVariable/actuelleInactuelle/actuel-inactuel/site/plugins/epub-export/src/components/ExportButton.vue";
|
||||
const ExportButton = __component__.exports;
|
||||
window.panel.plugin("getkirby/pluginkit", {
|
||||
sections: {
|
||||
epubexport: ExportButton
|
||||
}
|
||||
});
|
||||
})();
|
||||
Loading…
Add table
Add a link
Reference in a new issue