Skip to content
Snippets Groups Projects
Commit fc9082d6 authored by David Rouquet's avatar David Rouquet
Browse files

Merge branch 'main' into '15-choses-a-faire-css'

# Conflicts:
#   macao/layouts/partials/docs/inject/head.html
parents ef716964 1f912611
Branches
No related tags found
1 merge request!2Resolve "CSS Work"
Pipeline #2014 passed
...@@ -44,6 +44,22 @@ $(function () { ...@@ -44,6 +44,22 @@ $(function () {
// Load survey model from JSON // Load survey model from JSON
const survey = new Survey.Model(jsonStatic); const survey = new Survey.Model(jsonStatic);
// Instantiate `markdown-it`
const converter = markdownit({
html: true // Support HTML tags in the source (unsafe, see documentation)
});
survey.onTextMarkdown.add((_, options) => {
console.log("On text markdown")
// Convert Markdown to HTML
let str = converter.renderInline(options.text);
// ...
// Sanitize the HTML markup using a third-party library here
// ...
// Set HTML markup to render
options.html = str;
});
// Add "Check answers" button // Add "Check answers" button
survey.addNavigationItem({ survey.addNavigationItem({
id: "sv-nav-check", id: "sv-nav-check",
...@@ -65,12 +81,6 @@ $(function () { ...@@ -65,12 +81,6 @@ $(function () {
innerCss: "sd-btn nav-input" innerCss: "sd-btn nav-input"
}); });
survey.onTextMarkdown.add((survey, options) => {
// FIXME: this inserts raw HTML from the text, to remove as soon as Macao-Legacy converter
// can actually produce Markdown
options.html = options.text;
});
survey.onValueChanged.add((_, options) => { survey.onValueChanged.add((_, options) => {
console.log(options) console.log(options)
}); });
......
...@@ -9,6 +9,8 @@ ...@@ -9,6 +9,8 @@
<script defer type="text/javascript" <script defer type="text/javascript"
src="https://unpkg.com/survey-core/themes/default-light-panelless.min.js"></script> src="https://unpkg.com/survey-core/themes/default-light-panelless.min.js"></script>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.7.2/css/all.min.css" integrity="sha512-Evv84Mr4kqVGRNSgIGL/F/aIDqQb7xQ2vcrdIwxfjThSH8CSR7PBEakCr51Ck+w+/U6swU2Im1vVX0SVk9ABhg==" crossorigin="anonymous" referrerpolicy="no-referrer" /> <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.7.2/css/all.min.css" integrity="sha512-Evv84Mr4kqVGRNSgIGL/F/aIDqQb7xQ2vcrdIwxfjThSH8CSR7PBEakCr51Ck+w+/U6swU2Im1vVX0SVk9ABhg==" crossorigin="anonymous" referrerpolicy="no-referrer" />
<script src="https://cdn.jsdelivr.net/npm/markdown-it@14.1.0/dist/markdown-it.min.js"></script>
{{- $quizjs := slice -}} {{- $quizjs := slice -}}
{{- $quizjs = $quizjs | append (resources.Get "quiz.js") -}} {{- $quizjs = $quizjs | append (resources.Get "quiz.js") -}}
{{- $quizjs = $quizjs | append (resources.Get "custom.js") -}} {{- $quizjs = $quizjs | append (resources.Get "custom.js") -}}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment