Skip to content

Commit

Permalink
fix: prevent snippet height style
Browse files Browse the repository at this point in the history
  • Loading branch information
oeyoews committed Sep 25, 2024
1 parent 6b720c8 commit fc91aef
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 9 deletions.
1 change: 1 addition & 0 deletions .vscodeignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/archive/
Original file line number Diff line number Diff line change
Expand Up @@ -4,24 +4,24 @@ import {
snippetCompletion as snip
} from '@codemirror/autocomplete';
import conf from '@/cm6/config';
import { usersnippets } from '@/cm6/modules/completions/snippets';
import { usersnippets } from '@/cm6/modules/completions/builtin/snippets';

const section = 'snippet';
const type = 'cm-snippet';
const delimiter = '/';
const description = 'snippets';

const renderCodeBlock = (title: string, content: string) => {
const renderCodeBlock = (snippet: ISource) => {
console.log(snippet);
if (!conf.snippetPreview()) return '';
const domNode = document.createElement('div');
domNode.className = 'cm-snippet-preview';

const _text = $tw.wiki.getTiddlerText(title);
let renderText = () => {
// let html = `<pre><code>${_text}</code></pre>`;
const type = 'text/vnd.tiddlywiki';
let oldText = `<$codeblock code="""${_text || content}""" />`;
if (conf.footer() && _text) {
oldText += `\n<footer style="text-align: right;margin-right: 10px">${title}</footer>`;
let oldText = `<$codeblock code="""${snippet.text}""" />`;
if (conf.footer() && snippet.vanillaTitle) {
oldText += `\n<footer style="text-align: right;margin-right: 10px">${snippet.vanillaTitle}</footer>`;
}
let html = $tw.wiki.renderText('text/html', type, oldText);
return html;
Expand Down Expand Up @@ -84,7 +84,7 @@ function snippets() {
: 99,
// detail: info.vanillaTitle ? info.vanillaTitle : info.title,
// @ts-expect-error
info: () => renderCodeBlock(snippet.title, snippet.text)
info: () => renderCodeBlock(snippet)
});
});
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Completion } from '@codemirror/autocomplete';
import { words } from '../snippets';
import { words } from '../builtin/snippets';

const section = 'words';
const type = 'cm-word';
Expand Down
1 change: 1 addition & 0 deletions src/tiddlywiki-codemirror-6/tiddlers/styles/styles.tid
Original file line number Diff line number Diff line change
Expand Up @@ -429,6 +429,7 @@ color: #495057;
}

<!-- 有个max-width 400.xxxpx -->
.cm-snippet-preview,
.cm-image-preview {
overflow: auto;
width: 400px;
Expand Down

0 comments on commit fc91aef

Please sign in to comment.