Skip to content

Commit 95d8f97

Browse files
committed
impl for DeepThought themes
1 parent a8aa445 commit 95d8f97

File tree

6 files changed

+206
-0
lines changed

6 files changed

+206
-0
lines changed

src/DeepThought/chart.js

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
CMS.registerEditorComponent({
2+
id: "chart",
3+
label: "Chart",
4+
fields: [
5+
{
6+
name: "body",
7+
label: "the body text",
8+
widget: "text"
9+
},
10+
],
11+
pattern: /^{% chart\(\) %}\n(.*?)\n^{% end %}$/ms,
12+
fromBlock: function(match) {
13+
return {
14+
body: match[1],
15+
};
16+
},
17+
toBlock: function(obj) {
18+
const body = obj.body || '';
19+
return `
20+
{% chart() %}
21+
${body}
22+
{% end %}
23+
`;
24+
},
25+
toPreview: function(obj) {
26+
const body = obj.body || '';
27+
return `
28+
{% chart() %}
29+
${body}
30+
{% end %}
31+
`;
32+
},
33+
});

src/DeepThought/galleria.js

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
CMS.registerEditorComponent({
2+
id: "galleria",
3+
label: "Galleria",
4+
fields: [
5+
{
6+
name: "body",
7+
label: "the body text",
8+
widget: "text"
9+
},
10+
],
11+
pattern: /^{% galleria\(\) %}\n(.*?)\n^{% end %}$/ms,
12+
fromBlock: function(match) {
13+
return {
14+
body: match[1],
15+
};
16+
},
17+
toBlock: function(obj) {
18+
const body = obj.body || '';
19+
return `
20+
{% galleria() %}
21+
${body}
22+
{% end %}
23+
`;
24+
},
25+
toPreview: function(obj) {
26+
const body = obj.body || '';
27+
return `
28+
{% galleria() %}
29+
${body}
30+
{% end %}
31+
`;
32+
},
33+
});

src/DeepThought/katex.js

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
CMS.registerEditorComponent({
2+
id: "katex",
3+
label: "Katex",
4+
fields: [
5+
{
6+
name: "body",
7+
label: "the body text",
8+
widget: "text"
9+
},
10+
{
11+
name: "block",
12+
label: "if true, add `mode=display` into type of the script tag.",
13+
widget: "boolean"
14+
},
15+
],
16+
pattern: /^{% katex\(block=(true|false)\) %}\n(.*?)\n^{% end %}$/ms,
17+
fromBlock: function(match) {
18+
return {
19+
block: match[1],
20+
body: match[2],
21+
};
22+
},
23+
toBlock: function(obj) {
24+
const block = !!obj.block;
25+
const body = obj.body || '';
26+
return `
27+
{% katex(block=${block}) %}
28+
${body}
29+
{% end %}
30+
`;
31+
},
32+
toPreview: function(obj) {
33+
const block = !!obj.block;
34+
const body = obj.body || '';
35+
return `
36+
{% katex(block=${block}) %}
37+
${body}
38+
{% end %}
39+
`;
40+
},
41+
});

src/DeepThought/mapbox.js

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
CMS.registerEditorComponent({
2+
id: "mapbox",
3+
label: "Mapbox",
4+
fields: [
5+
{
6+
name: "body",
7+
label: "the body text",
8+
widget: "text"
9+
},
10+
{
11+
name: "zoom",
12+
label: "zoom level. see https://docs.mapbox.com/help/glossary/zoom-level/",
13+
widget: "number"
14+
},
15+
],
16+
pattern: /^{% mapbox\(zoom=([0-9]+)\) %}\n(.*?)\n^{% end %}$/ms,
17+
fromBlock: function(match) {
18+
return {
19+
zoom: match[1],
20+
body: match[2],
21+
};
22+
},
23+
toBlock: function(obj) {
24+
const zoom = obj.zoom ?? 10;
25+
const body = obj.body || '';
26+
return `
27+
{% mapbox(zoom=${zoom}) %}
28+
${body}
29+
{% end %}
30+
`;
31+
},
32+
toPreview: function(obj) {
33+
const zoom = obj.zoom ?? 10;
34+
const body = obj.body || '';
35+
return `
36+
{% mapbox(zoom=${zoom}) %}
37+
${body}
38+
{% end %}
39+
`;
40+
},
41+
});

src/DeepThought/mermaid.js

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
CMS.registerEditorComponent({
2+
id: "mermaid",
3+
label: "Mermaid",
4+
fields: [
5+
{
6+
name: "body",
7+
label: "the body text",
8+
widget: "text"
9+
},
10+
],
11+
pattern: /^{% mermaid\(\) %}\n(.*?)\n^{% end %}$/ms,
12+
fromBlock: function(match) {
13+
return {
14+
body: match[1],
15+
};
16+
},
17+
toBlock: function(obj) {
18+
const body = obj.body || '';
19+
return `
20+
{% mermaid() %}
21+
${body}
22+
{% end %}
23+
`;
24+
},
25+
toPreview: function(obj) {
26+
const body = obj.body || '';
27+
return `
28+
{% mermaid() %}
29+
${body}
30+
{% end %}
31+
`;
32+
},
33+
});

src/DeepThought/vimeo.js

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
CMS.registerEditorComponent({
2+
id: "vimeo",
3+
label: "Vimeo",
4+
fields: [
5+
{
6+
name: "id",
7+
label: "the video id (mandatory)",
8+
widget: "string"
9+
},
10+
],
11+
pattern: /{{ vimeo\(id="([0-9]+)"\) }}/,
12+
fromBlock: function(match) {
13+
return {
14+
id: match[1],
15+
};
16+
},
17+
toBlock: function(obj) {
18+
const id = obj.id || '';
19+
return `{{ vimeo(id="${obj.id || ''}") }}`;
20+
},
21+
toPreview: function(obj) {
22+
const id = obj.id || '';
23+
return `{{ vimeo(id="${obj.id || ''}") }}`;
24+
},
25+
});

0 commit comments

Comments
 (0)