diff --git a/.vscodeignore b/.vscodeignore new file mode 100644 index 00000000..ca30e708 --- /dev/null +++ b/.vscodeignore @@ -0,0 +1 @@ +/archive/ \ No newline at end of file diff --git a/src/tiddlywiki-codemirror-6/modules/completions/snippets.ts b/src/tiddlywiki-codemirror-6/modules/completions/builtin/snippets.ts similarity index 100% rename from src/tiddlywiki-codemirror-6/modules/completions/snippets.ts rename to src/tiddlywiki-codemirror-6/modules/completions/builtin/snippets.ts diff --git a/src/tiddlywiki-codemirror-6/modules/completions/sources/snippets.ts b/src/tiddlywiki-codemirror-6/modules/completions/sources/snippets.ts index 8600ab51..e752d958 100644 --- a/src/tiddlywiki-codemirror-6/modules/completions/sources/snippets.ts +++ b/src/tiddlywiki-codemirror-6/modules/completions/sources/snippets.ts @@ -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 = `
${_text}
`;
const type = 'text/vnd.tiddlywiki';
- let oldText = `<$codeblock code="""${_text || content}""" />`;
- if (conf.footer() && _text) {
- oldText += `\n`;
+ let oldText = `<$codeblock code="""${snippet.text}""" />`;
+ if (conf.footer() && snippet.vanillaTitle) {
+ oldText += `\n`;
}
let html = $tw.wiki.renderText('text/html', type, oldText);
return html;
@@ -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)
});
});
}
diff --git a/src/tiddlywiki-codemirror-6/modules/completions/sources/words.ts b/src/tiddlywiki-codemirror-6/modules/completions/sources/words.ts
index 9da24865..12aab753 100644
--- a/src/tiddlywiki-codemirror-6/modules/completions/sources/words.ts
+++ b/src/tiddlywiki-codemirror-6/modules/completions/sources/words.ts
@@ -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';
diff --git a/src/tiddlywiki-codemirror-6/tiddlers/styles/styles.tid b/src/tiddlywiki-codemirror-6/tiddlers/styles/styles.tid
index 798357d8..18532313 100644
--- a/src/tiddlywiki-codemirror-6/tiddlers/styles/styles.tid
+++ b/src/tiddlywiki-codemirror-6/tiddlers/styles/styles.tid
@@ -429,6 +429,7 @@ color: #495057;
}
+.cm-snippet-preview,
.cm-image-preview {
overflow: auto;
width: 400px;