From b3d77cfdb9c8d0ff3acefec493c0c4454bb6404c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9mence=20Fernandez?= Date: Tue, 29 Jul 2025 19:05:17 +0200 Subject: [PATCH] =?UTF-8?q?WORK=20IN=20PROGRESS=20-=20trouver=20et=20?= =?UTF-8?q?=C3=A9valuer=20la=20balise=20image?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../odf/templating/fillOdtElementTemplate.js | 37 ++++++++++++++++++- 1 file changed, 36 insertions(+), 1 deletion(-) 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