fix(core): update

This commit is contained in:
Philipp Kunz 2023-04-06 17:29:07 +02:00
parent aec2cf18fd
commit beef47959b
2 changed files with 16 additions and 7 deletions

View File

@ -3,6 +3,6 @@
*/
export const commitinfo = {
name: '@designestate/dees-catalog',
version: '1.0.160',
version: '1.0.161',
description: 'website for lossless.com'
}

View File

@ -30,9 +30,10 @@ export class DeesDataviewCodebox extends DeesElement {
public progLang: string = 'typescript';
@property({
type: String
type: String,
reflect: true,
})
public codeToDisplay: string = '// no code set';
public codeToDisplay: string = '';
constructor() {
super();
@ -143,12 +144,15 @@ export class DeesDataviewCodebox extends DeesElement {
})
})()}
</div>
<pre><code class="${this.progLang}">${this.codeToDisplay}</code></pre>
<pre><code></code></pre>
</div>
</div>
`;
}
@state()
private codeToDisplayStore = '';
public async updated(_changedProperties) {
super.updated(_changedProperties);
console.log('highlighting now');
@ -159,11 +163,16 @@ export class DeesDataviewCodebox extends DeesElement {
slottedCodeNodes.push(childNode as Text);
}
});
if (slottedCodeNodes[0] && slottedCodeNodes[0].wholeText) {
this.codeToDisplay = smartstring.indent.normalize(slottedCodeNodes[0].wholeText);
if (this.codeToDisplay && this.codeToDisplay !== this.codeToDisplayStore) {
this.codeToDisplayStore = smartstring.indent.normalize(this.codeToDisplay);
}
if (slottedCodeNodes[0] && slottedCodeNodes[0].wholeText && !this.codeToDisplay) {
this.codeToDisplayStore = smartstring.indent.normalize(slottedCodeNodes[0].wholeText);
this.codeToDisplay = this.codeToDisplayStore;
}
await domtools.plugins.smartdelay.delayFor(0);
const localCodeNode = this.shadowRoot.querySelector('code');
hlight.highlightBlock(localCodeNode);
const html = hlight.highlight(this.codeToDisplayStore, {language: this.progLang, ignoreIllegals: true});
localCodeNode.innerHTML = html.value;
}
}