-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
01436a7
commit 3aeecd3
Showing
32 changed files
with
2,229 additions
and
283 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,127 @@ | ||
:root { | ||
--background: #f3f3f3; | ||
--text: #444; | ||
--comment: #697070; | ||
--punctuation-tag: #444a; | ||
--tag-attr-name: #444; | ||
--attribute: #800; | ||
--deletion-number-quote-selector-class-id-string-template-tag-type: #800; | ||
--section-title: #800; | ||
--link-operator-regexp-selector-attr-pseudo-symbol-template-variable-variable: #ab5656; | ||
--literal: #695; | ||
--addition-built-in-bullet-code: #397300; | ||
--meta: #1f7199; | ||
--meta-string: #38a; | ||
} | ||
|
||
[data-theme="dark"] { | ||
--background: #2e2e2e; | ||
--text: #ccc; | ||
--comment: #8c8c8c; | ||
--punctuation-tag: #aaa; | ||
--tag-attr-name: #ccc; | ||
--attribute: #ff6347; | ||
--deletion-number-quote-selector-class-id-string-template-tag-type: #ff6347; | ||
--section-title: #ff6347; | ||
--link-operator-regexp-selector-attr-pseudo-symbol-template-variable-variable: #ff8c00; | ||
--literal: #bada55; | ||
--addition-built-in-bullet-code: #90ee90; | ||
--meta: #00bfff; | ||
--meta-string: #1e90ff; | ||
} | ||
|
||
pre code.hljs { | ||
display: block; | ||
overflow-x: auto; | ||
padding: 1em; | ||
background: var(--background); | ||
color: var(--text); | ||
} | ||
|
||
code.hljs { | ||
padding: 3px 5px; | ||
} | ||
|
||
.hljs { | ||
background: var(--background); | ||
color: var(--text); | ||
} | ||
|
||
.hljs-comment { | ||
color: var(--comment); | ||
} | ||
|
||
.hljs-punctuation, | ||
.hljs-tag { | ||
color: var(--punctuation-tag); | ||
} | ||
|
||
.hljs-tag .hljs-attr, | ||
.hljs-tag .hljs-name { | ||
color: var(--tag-attr-name); | ||
} | ||
|
||
.hljs-attribute, | ||
.hljs-doctag, | ||
.hljs-keyword, | ||
.hljs-meta .hljs-keyword, | ||
.hljs-name, | ||
.hljs-selector-tag { | ||
font-weight: 700; | ||
color: var(--attribute); | ||
} | ||
|
||
.hljs-deletion, | ||
.hljs-number, | ||
.hljs-quote, | ||
.hljs-selector-class, | ||
.hljs-selector-id, | ||
.hljs-string, | ||
.hljs-template-tag, | ||
.hljs-type { | ||
color: var(--deletion-number-quote-selector-class-id-string-template-tag-type); | ||
} | ||
|
||
.hljs-section, | ||
.hljs-title { | ||
color: var(--section-title); | ||
font-weight: 700; | ||
} | ||
|
||
.hljs-link, | ||
.hljs-operator, | ||
.hljs-regexp, | ||
.hljs-selector-attr, | ||
.hljs-selector-pseudo, | ||
.hljs-symbol, | ||
.hljs-template-variable, | ||
.hljs-variable { | ||
color: var(--link-operator-regexp-selector-attr-pseudo-symbol-template-variable-variable); | ||
} | ||
|
||
.hljs-literal { | ||
color: var(--literal); | ||
} | ||
|
||
.hljs-addition, | ||
.hljs-built_in, | ||
.hljs-bullet, | ||
.hljs-code { | ||
color: var(--addition-built-in-bullet-code); | ||
} | ||
|
||
.hljs-meta { | ||
color: var(--meta); | ||
} | ||
|
||
.hljs-meta .hljs-string { | ||
color: var(--meta-string); | ||
} | ||
|
||
.hljs-emphasis { | ||
font-style: italic; | ||
} | ||
|
||
.hljs-strong { | ||
font-weight: 700; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
import {CodeJar} from './codejar.js' | ||
// import * as hljs from '/js/highlight.js' | ||
hljs.configure({ | ||
ignoreUnescapedHTML: true | ||
}) | ||
|
||
export function CodeEditor(el) { | ||
const value = (el.getAttribute('value') ?? '').replace(/\\n/g, '\n') | ||
const readonly = el.hasAttribute('readonly') | ||
const disabled = el.hasAttribute('disabled') | ||
el.classList.add('language-' + el.getAttribute('lang')) | ||
|
||
|
||
function highlight(el) { | ||
return hljs.highlightElement(el) | ||
} | ||
|
||
console.log(hljs.highlightElement) | ||
const instance = CodeJar(el, highlight, { | ||
tab: ' ', | ||
|
||
// catchTab: false | ||
}) | ||
|
||
instance.onUpdate(val => delete el.dataset.highlighted) | ||
|
||
|
||
if(value) { | ||
instance.updateCode(value) | ||
} | ||
|
||
if(readonly) { | ||
el.setAttribute('contenteditable','false'); | ||
el.setAttribute('tabindex','0'); | ||
} | ||
|
||
if(disabled) { | ||
el.setAttribute('contenteditable','false'); | ||
} | ||
|
||
el.setValue = (val) => { | ||
instance.updateCode(val) | ||
} | ||
el.getValue = () => { | ||
return instance.toString() | ||
} | ||
} | ||
|
||
|
||
// let thisValue = instance.toString(); | ||
// instance.onUpdate(code => { | ||
// thisValue = code | ||
// this.$data.value = code | ||
// }) | ||
|
||
// Alpine.bind(el, { | ||
// 'u-modelable': 'value', | ||
// 'u-data'() { | ||
// return { | ||
// value: el.getAttribute('value') | ||
// } | ||
// }, | ||
|
||
// cleanup(() => { | ||
// instance.destroy() | ||
// }) | ||
|
||
// this.$watch('value', (value) => { | ||
|
||
// if(thisValue === value) return; | ||
|
||
// console.log('calling updateCode', value) | ||
// instance.updateCode(value) | ||
|
||
|
||
// }) | ||
// } | ||
// }) | ||
// }) |
Oops, something went wrong.