mirror of
https://github.com/Fechin/reference.git
synced 2026-11-20 21:23:11 +03:00
feat: add support for running html canvas
This commit is contained in:
1 parent
4c68afe0f9
commit
d407354e16
2 files changed
+26
-7
No files matched your search
@@ -10,6 +10,7 @@ intro: |
|
||||
This HTML Canvas quick reference cheat sheet lists the common HTML5 Canvas design tags in readable layout.
|
||||
plugins:
|
||||
- copyCode
|
||||
- runCode
|
||||
---
|
||||
|
||||
## Getting Started
|
||||
@@ -23,12 +24,7 @@ plugins:
|
||||
<title>Canvas Example</title>
|
||||
</head>
|
||||
<body>
|
||||
<canvas
|
||||
id="myCanvas"
|
||||
width="500"
|
||||
height="400"
|
||||
style="border:1px solid #000000;"
|
||||
></canvas>
|
||||
<canvas id="myCanvas" width="500" height="400" style="border:1px solid #000000;"></canvas>
|
||||
<script src="script.js"></script>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
@@ -102,8 +102,11 @@
|
||||
if (language === 'ts') {
|
||||
language = 'typescript';
|
||||
}
|
||||
if (language === 'js') {
|
||||
language = 'javascript';
|
||||
}
|
||||
|
||||
const editorId = ['js', 'javascript', 'typescript', 'python', 'php', 'ruby', 'perl'].includes(language)
|
||||
const editorId = ['javascript', 'typescript', 'python', 'php', 'ruby', 'perl'].includes(language)
|
||||
? 'script'
|
||||
: ['css', 'scss'].includes(language)
|
||||
? 'style'
|
||||
@@ -208,6 +211,26 @@
|
||||
}
|
||||
}
|
||||
|
||||
if (language === 'javascript' && pageHeader.startsWith('HTML Canvas')) {
|
||||
if (!content.includes('const ctx =')) {
|
||||
content = `const canvas = document.getElementById("myCanvas");\nconst ctx = canvas.getContext("2d");\n\n${content}`;
|
||||
}
|
||||
config = {
|
||||
...baseConfig,
|
||||
markup: {
|
||||
language: 'html',
|
||||
content: "<canvas id=\"myCanvas\" width=\"500\" height=\"400\" style=\"border:1px solid #000000;\"></canvas>\n",
|
||||
},
|
||||
script: {
|
||||
language,
|
||||
content,
|
||||
},
|
||||
tools: {
|
||||
status: 'closed',
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
if (language === 'javascript' && pageHeader.startsWith('React')) {
|
||||
config = {
|
||||
...baseConfig,
|
||||
|
||||
Reference in new issue
Block a user