Skip to content

Commit 5bb9f02

Browse files
committed
more consistent formatting and ID scheme that works in indexer
1 parent 124391a commit 5bb9f02

File tree

2 files changed

+12
-7
lines changed

2 files changed

+12
-7
lines changed

packages/host/app/components/ai-assistant/formatted-message.gts

+9-4
Original file line numberDiff line numberDiff line change
@@ -33,16 +33,21 @@ export default class FormattedMessage extends Component<FormattedMessageSignatur
3333
{{/if}}
3434

3535
<style scoped>
36-
.message {
37-
padding: var(--ai-assistant-message-padding, var(--boxel-sp));
38-
}
39-
4036
/* code blocks can be rendered inline and as blocks,
4137
this is the styling for when it is rendered as a block */
4238
.message > :deep(.preview-code.code-block) {
4339
width: calc(100% + 2 * var(--boxel-sp));
4440
}
4541
42+
.message > :deep(*) {
43+
margin-top: 0;
44+
margin-bottom: 0;
45+
}
46+
47+
.message > :deep(* + *) {
48+
margin-top: var(--boxel-sp);
49+
}
50+
4651
:deep(.preview-code) {
4752
--spacing: var(--boxel-sp-sm);
4853
--fill-container-spacing: calc(

packages/runtime-common/marked-sync.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { marked } from 'marked';
22
import { sanitizeHtml } from './dompurify-runtime';
3-
import { v4 as uuidv4 } from 'uuid';
3+
import { md5 } from 'super-fast-md5';
44

55
const CODEBLOCK_KEY_PREFIX = 'codeblock_';
66

@@ -11,8 +11,8 @@ export function markedSync(markdown: string) {
1111
// If you are relying on codeblocks in your
1212
// markdown, please use the `CodeBlock` modifier to render the
1313
// markdown.
14-
code(code, language) {
15-
let id = `${CODEBLOCK_KEY_PREFIX}${uuidv4()}`;
14+
code(code, language = '') {
15+
let id = `${CODEBLOCK_KEY_PREFIX}${md5(Date.now() + language + code)}`;
1616
// we pass the code thru using localstorage instead of in the DOM,
1717
// that way we don't have to worry about escaping code. note that the
1818
// DOM wants to render "<template>" strings when we put them in the

0 commit comments

Comments
 (0)