Skip to content
This repository was archived by the owner on Jun 7, 2023. It is now read-only.

Commit 5ad1757

Browse files
committed
⬆️ Use micro Parsons as a dependecy
1 parent a45f678 commit 5ad1757

File tree

3 files changed

+19
-23
lines changed

3 files changed

+19
-23
lines changed

package-lock.json

Lines changed: 6 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
"handsontable": "7.2.2",
3737
"jexcel": "^3.9.1",
3838
"jquery-ui": "1.10.4",
39-
"micro-parsons": "https://github.com/amy21206/micro-parsons-element/releases/download/v0.1.0/micro-parsons-0.1.0.tgz",
39+
"micro-parsons": "https://github.com/amy21206/micro-parsons-element/releases/download/v0.1.3/micro-parsons-0.1.3.tgz",
4040
"select2": "^4.1.0-rc.0",
4141
"sql.js": "1.5.0",
4242
"vega-embed": "3.14.0",

runestone/hparsons/js/hparsons-sql.js

Lines changed: 12 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import "../css/hljs-xcode.css";
55
import BlockFeedback from "./BlockFeedback.js";
66
import SQLFeedback from "./SQLFeedback.js";
77
// import "micro-parsons.j" from 'micro-parsons';
8-
import 'micro-parsons/micro-parsons/micro-parsons.js';
8+
import {InitMicroParsons} from 'micro-parsons/micro-parsons/micro-parsons.js';
99
import 'micro-parsons/micro-parsons/micro-parsons.css';
1010

1111
export var hpList;
@@ -79,19 +79,7 @@ export default class SQLHParsons extends RunestoneBase {
7979
createEditor() {
8080
this.outerDiv = document.createElement("div");
8181
$(this.origElem).replaceWith(this.outerDiv);
82-
let parsonsHTML = `<micro-parsons id='${this.divid}-hparsons'`;
83-
parsonsHTML += ` input-type='parsons' `;
84-
if (this.reuse) {
85-
parsonsHTML += ` reuse-blocks="true"`;
86-
}
87-
if (this.randomize) {
88-
parsonsHTML += ` randomize="true"`;
89-
}
90-
if (this.language) {
91-
parsonsHTML += ` language="` + this.language + `"`;
92-
}
93-
parsonsHTML += `>`;
94-
this.outerDiv.innerHTML = parsonsHTML;
82+
this.outerDiv.id = `${this.divid}-container`;
9583
this.outerDiv.addEventListener("micro-parsons", (ev) => {
9684
this.logHorizontalParsonsEvent(ev.detail);
9785
this.feedbackController.clearFeedback();
@@ -107,9 +95,17 @@ export default class SQLHParsons extends RunestoneBase {
10795
: blocksString;
10896
blocks = blocksString.split("\n");
10997
}
110-
this.hparsonsInput = $(this.outerDiv).find("micro-parsons")[0];
11198
this.originalBlocks = blocks.slice(1, -1);
112-
this.hparsonsInput.parsonsData = blocks.slice(1, -1);
99+
const props = {
100+
selector: `#${this.divid}-container`,
101+
id: `${this.divid}-hparsons`,
102+
reuse: this.reuse,
103+
randomize: this.randomize,
104+
parsonsBlocks: blocks.slice(1, -1),
105+
language: this.language
106+
}
107+
InitMicroParsons(props);
108+
this.hparsonsInput = $(this.outerDiv).find("micro-parsons")[0];
113109
}
114110

115111
createOutput() {

0 commit comments

Comments
 (0)