Skip to content

Commit 6751ab8

Browse files
committed
fixed bug where saving elements wouldn't work if slides were part of a quarto project
1 parent 7a0c0ad commit 6751ab8

File tree

2 files changed

+9
-15
lines changed

2 files changed

+9
-15
lines changed

_extensions/editable/editable.js

Lines changed: 4 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -401,8 +401,8 @@ function setupDraggableElt(elt) {
401401
}
402402
}
403403

404-
async function saveMovedElts() {
405-
index = await readIndexQmd();
404+
function saveMovedElts() {
405+
index = readIndexQmd();
406406
Elt_dim = extracteditableEltDimensions();
407407

408408
index = udpdateTextDivs(index);
@@ -412,19 +412,8 @@ async function saveMovedElts() {
412412
downloadString(index);
413413
}
414414
// Function to read index.qmd file
415-
async function readIndexQmd() {
416-
try {
417-
const filename = geteditableFilename();
418-
const response = await fetch(filename);
419-
if (!response.ok) {
420-
throw new Error(`HTTP error! status: ${response.status}`);
421-
}
422-
const content = await response.text();
423-
return content;
424-
} catch (error) {
425-
console.error("Error reading index.qmd:", error);
426-
return null;
427-
}
415+
function readIndexQmd() {
416+
return window._input_file;
428417
}
429418

430419
// Function to get data-filename attribute from editable div

_extensions/editable/editable.lua

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,9 @@
11
function Pandoc(doc)
2+
local text = assert(io.open(quarto.doc.input_file, "r")):read("a")
3+
text = string.gsub(text, "\"", "\\\"")
4+
text = string.gsub(text, "\n", "\\n\" + \"")
5+
text = "\"" .. text .. "\""
6+
doc.blocks:insert(pandoc.RawBlock("html", "<script> window._input_file = " .. text .. "</script>"))
27
doc.blocks:insert(pandoc.RawBlock("html", "<script> window._input_filename = '" .. quarto.doc.input_file .. "'</script>"))
38
return doc
49
end

0 commit comments

Comments
 (0)