diff --git a/scripts/odf/templating/fillOdtElementTemplate.js b/scripts/odf/templating/fillOdtElementTemplate.js index 6e25366..728cb5f 100644 --- a/scripts/odf/templating/fillOdtElementTemplate.js +++ b/scripts/odf/templating/fillOdtElementTemplate.js @@ -1,5 +1,5 @@ import {traverse, Node, getAncestors, findCommonAncestor} from "../../DOMUtils.js"; -import {closingIfMarker, eachClosingMarker, eachStartMarkerRegex, elseMarker, ifStartMarkerRegex, variableRegex} from './markers.js' +import {closingIfMarker, eachClosingMarker, eachStartMarkerRegex, elseMarker, ifStartMarkerRegex, imageMarkerRegex, variableRegex} from './markers.js' /** * @typedef TextPlaceToFill @@ -554,6 +554,33 @@ function fillEachBlock(startNode, iterableExpression, itemExpression, endNode, c } +/** + * @param {string} str + * @param {Compartement} compartment + * @returns {} + */ +function findImageMarker(str, compartment) { + const imageRexExp = new RegExp(imageMarkerRegex.source, 'g'); + const match = imageRexExp.exec(str) + + if (match===null){ + return; + } + + const expression = match[1] + const value = compartment.evaluate(expression) + + if (value instanceof ArrayBuffer) { + // TODO : + // - Rajouter un fichier image dans le odt avec le ArrayBuffer comme contenu (ou autre type) + // - Rajouter un suffixe/titre (donc peut-être changer l'api pour que photo ça soit un objet qui contienne arraybuffer et d'autres choses) + // - puis remplacer le texte par peut-être