|
14 | 14 | * limitations under the License. |
15 | 15 | */ |
16 | 16 |
|
17 | | -import { createMemo } from 'solid-js' |
| 17 | +import { Show, createMemo } from 'solid-js' |
18 | 18 | import { useNodeViewContext } from '@prosemirror-adapter/solid' |
19 | 19 | import { shikiBundledLanguagesInfo } from 'prosekit/extensions/code-block' |
20 | 20 |
|
@@ -44,20 +44,54 @@ export default function ShikiCodeBlockView(props: NodeViewContextProps) { |
44 | 44 |
|
45 | 45 | return ( |
46 | 46 | <NodeViewWrapper> |
47 | | - <div class={`highlight ${styles.CodeBlock}`}> |
48 | | - <div class={styles.codeBlockActions} contenteditable={false}> |
49 | | - <CodeBlockLanguageSelector |
50 | | - value={currentValue()} |
51 | | - setLanguage={setLanguage} |
52 | | - /> |
53 | | - <CodeBlockClipboard content={context().node.textContent} /> |
54 | | - </div> |
| 47 | + <Show |
| 48 | + fallback={ |
| 49 | + <> |
| 50 | + <div class={`highlight ${styles.CodeBlock}`}> |
| 51 | + <div class={styles.codeBlockActions} contenteditable={false}> |
| 52 | + <CodeBlockLanguageSelector |
| 53 | + value={currentValue()} |
| 54 | + setLanguage={setLanguage} |
| 55 | + /> |
| 56 | + <CodeBlockClipboard content={context().node.textContent} /> |
| 57 | + </div> |
| 58 | + |
| 59 | + <pre |
| 60 | + ref={props.contentRef} |
| 61 | + data-language={context().node.attrs.language} |
| 62 | + ></pre> |
| 63 | + </div> |
| 64 | + </> |
| 65 | + } |
| 66 | + when={context().node.attrs.isSuggestion} |
| 67 | + > |
| 68 | + <div class={styles.suggestChangeContainer}> |
| 69 | + <div class={styles.suggestChangeTitle}>Suggest changes</div> |
55 | 70 |
|
56 | | - <pre |
57 | | - ref={props.contentRef} |
58 | | - data-language={context().node.attrs.language} |
59 | | - ></pre> |
60 | | - </div> |
| 71 | + <div class={styles.codeBlockActions} contenteditable={false}> |
| 72 | + <CodeBlockLanguageSelector |
| 73 | + value={currentValue()} |
| 74 | + setLanguage={setLanguage} |
| 75 | + /> |
| 76 | + <CodeBlockClipboard content={context().node.textContent} /> |
| 77 | + </div> |
| 78 | + |
| 79 | + <div class={`highlight ${styles.CodeBlock} ${styles.diffOriginal}`}> |
| 80 | + <pre data-language={context().node.attrs.language}> |
| 81 | + { |
| 82 | + context().node.attrs.suggestChangeConfig |
| 83 | + ?.sourceContentFromDiffLines |
| 84 | + } |
| 85 | + </pre> |
| 86 | + </div> |
| 87 | + <div class={`highlight ${styles.CodeBlock} ${styles.diffAdd}`}> |
| 88 | + <pre |
| 89 | + ref={props.contentRef} |
| 90 | + data-language={context().node.attrs.language} |
| 91 | + ></pre> |
| 92 | + </div> |
| 93 | + </div> |
| 94 | + </Show> |
61 | 95 | </NodeViewWrapper> |
62 | 96 | ) |
63 | 97 | } |
0 commit comments