Skip to content

Commit 9f6552c

Browse files
authored
feat(editor): migrate code block to vue (#1806)
* feat(editor): migrate code block to vue * fix: test * chore: fix * chore: fix
1 parent f15ac5f commit 9f6552c

File tree

21 files changed

+550
-367
lines changed

21 files changed

+550
-367
lines changed

Diff for: e2e/shim.d.ts

-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
/// <reference types="cypress" />
21
/// <reference types="vite/client" />
32

43
import type { Editor } from '@milkdown/core'

Diff for: e2e/tests/crepe/latex.spec.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { expect, test } from '@playwright/test'
2-
import { focusEditor, getMarkdown } from 'tests/misc'
2+
import { focusEditor, getMarkdown } from '../misc'
33

44
test.beforeEach(async ({ page }) => {
55
await page.goto('/crepe/')
@@ -10,7 +10,7 @@ test('latex block preview toggle', async ({ page }) => {
1010
await page.keyboard.type('$$')
1111
await page.keyboard.press('Enter')
1212

13-
const codeBlock = page.locator('milkdown-code-block')
13+
const codeBlock = page.locator('.milkdown-code-block')
1414
const codemirror = codeBlock.locator('.codemirror-host')
1515
const preview = codeBlock.locator('.preview')
1616
const codeTools = codeBlock.locator('.tools')

Diff for: e2e/tests/crepe/listener.spec.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { expect, test } from '@playwright/test'
2-
import { focusEditor } from 'tests/misc'
2+
import { focusEditor } from '../misc'
33

44
test('listen change before editor is created', async ({ page }) => {
55
await page.addInitScript(() => {

Diff for: packages/components/src/__internal__/components/icon.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ export function Icon({ icon, class: className }: IconProps) {
1414
class={clsx('milkdown-icon', className)}
1515
ref={(el) => {
1616
if (el && icon) {
17-
;(el as HTMLElement).innerHTML = icon
17+
;(el as HTMLElement).innerHTML = icon.trim()
1818
}
1919
}}
2020
/>

Diff for: packages/components/src/code-block/config.ts

+7-11
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,23 @@
11
import { $ctx } from '@milkdown/utils'
22
import type { Extension } from '@codemirror/state'
33
import type { LanguageDescription } from '@codemirror/language'
4-
import { html } from 'atomico'
54
import { withMeta } from '../__internal__/meta'
65

76
export interface CodeBlockConfig {
87
extensions: Extension[]
98
languages: LanguageDescription[]
10-
expandIcon: () => ReturnType<typeof html> | string
11-
searchIcon: () => ReturnType<typeof html> | string
12-
clearSearchIcon: () => ReturnType<typeof html> | string
9+
expandIcon: () => string
10+
searchIcon: () => string
11+
clearSearchIcon: () => string
1312
searchPlaceholder: string
1413
noResultText: string
15-
renderLanguage: (
16-
language: string,
17-
selected: boolean
18-
) => ReturnType<typeof html>
14+
renderLanguage: (language: string, selected: boolean) => string
1915
renderPreview: (
2016
language: string,
2117
content: string
2218
) => null | string | HTMLElement
23-
previewToggleButton: (previewOnlyMode: boolean) => ReturnType<typeof html>
24-
previewLabel: () => ReturnType<typeof html>
19+
previewToggleButton: (previewOnlyMode: boolean) => string
20+
previewLabel: () => string
2521
}
2622

2723
export const defaultConfig: CodeBlockConfig = {
@@ -32,7 +28,7 @@ export const defaultConfig: CodeBlockConfig = {
3228
clearSearchIcon: () => '⌫',
3329
searchPlaceholder: 'Search language',
3430
noResultText: 'No result',
35-
renderLanguage: (language) => html`${language}`,
31+
renderLanguage: (language) => language,
3632
renderPreview: () => null,
3733
previewToggleButton: (previewOnlyMode) => (previewOnlyMode ? 'Edit' : 'Hide'),
3834
previewLabel: () => 'Preview',

Diff for: packages/components/src/code-block/view/component.ts

-282
This file was deleted.

0 commit comments

Comments
 (0)