Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions e2e/src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ import { createApp, defineComponent, h } from 'vue'
import './style.css'
import { cases } from './data'

// oxlint-disable-next-line no-unused-expressions
h
function keepAlive(..._args: unknown[]) {}
keepAlive(h)

const App = defineComponent({
setup() {
Expand Down
3 changes: 3 additions & 0 deletions e2e/tests/data/ordered-list-custom-start.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
5. First
6. Second
7. Third
16 changes: 16 additions & 0 deletions e2e/tests/input/ordered-list.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,3 +50,19 @@ test('ordered list', async ({ page }) => {
'1. First item\n2. Second item\n\n 1. Sub list item 1\n 2. Sub list item 2\n3. Third item\n'
)
})

test('ordered list with custom start number', async ({ page }) => {
const editor = page.locator('.editor')
await focusEditor(page)
await page.keyboard.type('3. First item')
await expect(editor.locator('ol li')).toHaveText('First item')
await expect(editor.locator('ol')).toHaveAttribute('start', '3')
let markdown = await getMarkdown(page)
expect(markdown).toBe('3. First item\n')

await page.keyboard.press('Enter')
await page.keyboard.type('Second item')
await expect(editor.locator('ol li:last-child')).toHaveText('Second item')
markdown = await getMarkdown(page)
expect(markdown).toBe('3. First item\n4. Second item\n')
})
14 changes: 13 additions & 1 deletion e2e/tests/transform/list.spec.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { expect, test } from '@playwright/test'

import { focusEditor, loadFixture, setMarkdown } from '../misc'
import { focusEditor, getMarkdown, loadFixture, setMarkdown } from '../misc'

test.beforeEach(async ({ page }) => {
await page.goto('/preset-commonmark/')
Expand Down Expand Up @@ -31,3 +31,15 @@ test('list', async ({ page }) => {
expect(await page.locator('.editor>ul:last-child ul').count()).toBe(1)
expect(await page.locator('.editor>ul:last-child ol').count()).toBe(2)
})

test('ordered list with custom start number', async ({ page }) => {
await focusEditor(page)
const markdown = await loadFixture('ordered-list-custom-start.md')
await setMarkdown(page, markdown)

await expect(page.locator('.editor>ol')).toHaveAttribute('start', '5')
expect(await page.locator('.editor>ol>li').count()).toBe(3)

const output = await getMarkdown(page)
expect(output).toBe(markdown)
})
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
"jsdom": "^29.0.0",
"knip": "^6.0.0",
"lint-staged": "^16.0.0",
"oxfmt": "^0.41.0",
"oxfmt": "^0.42.0",
"oxlint": "^1.8.0",
"oxlint-tsgolint": "^0.17.1",
"pkg-pr-new": "^0.0.66",
Expand All @@ -72,7 +72,7 @@
"engines": {
"node": ">=22"
},
"packageManager": "pnpm@10.32.1",
"packageManager": "pnpm@10.33.0",
"pnpm": {
"peerDependencyRules": {
"ignoreMissing": [
Expand Down
5 changes: 3 additions & 2 deletions packages/components/src/__internal__/components/icon.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@ import clsx from 'clsx'
import DOMPurify from 'dompurify'
import { h } from 'vue'

// oxlint-disable-next-line no-unused-expressions
h
import { keepAlive } from '../keep-alive'

keepAlive(h)

type IconProps = {
icon?: string | null
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ import clsx from 'clsx'
import { customAlphabet } from 'nanoid'
import { defineComponent, ref, h, type Ref } from 'vue'

import { keepAlive } from '../keep-alive'
import { Icon } from './icon'

// oxlint-disable-next-line no-unused-expressions
h
keepAlive(h)

const nanoid = customAlphabet('abcdefg', 8)

Expand Down
3 changes: 3 additions & 0 deletions packages/components/src/__internal__/keep-alive.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
// Prevent tree-shaking from removing Vue's `h` and `Fragment`,
// which are required at runtime for TSX to work.
export function keepAlive(..._args: unknown[]) {}
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,12 @@ import type { CodeBlockConfig } from '../../config'
import type { LanguageInfo } from '../loader'

import { Icon } from '../../../__internal__/components/icon'
import { keepAlive } from '../../../__internal__/keep-alive'
import { CopyButton } from './copy-button'
import { LanguagePicker } from './language-picker'
import { PreviewPanel } from './preview-panel'

// oxlint-disable-next-line no-unused-expressions
h
// oxlint-disable-next-line no-unused-expressions
Fragment
keepAlive(h, Fragment)

export type CodeBlockProps = {
text: Ref<string>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
import { defineComponent, h, Fragment } from 'vue'

import { Icon } from '../../../__internal__/components/icon'
import { keepAlive } from '../../../__internal__/keep-alive'

// oxlint-disable-next-line no-unused-expressions
h
// oxlint-disable-next-line no-unused-expressions
Fragment
keepAlive(h, Fragment)

type CopyButtonProps = {
copyText: string
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,15 @@ import {
import type { CodeBlockProps } from './code-block'

import { Icon } from '../../../__internal__/components/icon'
import { keepAlive } from '../../../__internal__/keep-alive'

keepAlive(h, Fragment)

type LanguagePickerProps = Pick<
CodeBlockProps,
'language' | 'config' | 'setLanguage' | 'getAllLanguages' | 'getReadOnly'
>

// oxlint-disable-next-line no-unused-expressions
h
// oxlint-disable-next-line no-unused-expressions
Fragment

export const LanguagePicker = defineComponent<LanguagePickerProps>({
props: {
language: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,9 @@ import { defineComponent, ref, watchEffect, type Ref, h, Fragment } from 'vue'

import type { CodeBlockProps } from './code-block'

// oxlint-disable-next-line no-unused-expressions
h
// oxlint-disable-next-line no-unused-expressions
Fragment
import { keepAlive } from '../../../__internal__/keep-alive'

keepAlive(h, Fragment)

type PreviewPanelProps = Pick<
CodeBlockProps,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,10 @@ import { h, Fragment, type Ref, defineComponent } from 'vue'
import type { ImageBlockConfig } from '../../config'

import { ImageInput } from '../../../__internal__/components/image-input'
import { keepAlive } from '../../../__internal__/keep-alive'
import { ImageViewer } from './image-viewer'

// oxlint-disable-next-line no-unused-expressions
h
// oxlint-disable-next-line no-unused-expressions
Fragment
keepAlive(h, Fragment)

type Attrs = {
src: string
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,10 @@ import { defineComponent, ref, h, Fragment } from 'vue'
import type { MilkdownImageBlockProps } from './image-block'

import { Icon } from '../../../__internal__/components/icon'
import { keepAlive } from '../../../__internal__/keep-alive'
import { IMAGE_DATA_TYPE } from '../../schema'

// oxlint-disable-next-line no-unused-expressions
h
// oxlint-disable-next-line no-unused-expressions
Fragment
keepAlive(h, Fragment)

export const ImageViewer = defineComponent<MilkdownImageBlockProps>({
props: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,9 @@ import { h, Fragment, type Ref, defineComponent } from 'vue'
import type { InlineImageConfig } from '../config'

import { ImageInput } from '../../__internal__/components/image-input'
import { keepAlive } from '../../__internal__/keep-alive'

// oxlint-disable-next-line no-unused-expressions
h
// oxlint-disable-next-line no-unused-expressions
Fragment
keepAlive(h, Fragment)

type Attrs = {
src: string
Expand Down
4 changes: 2 additions & 2 deletions packages/components/src/link-tooltip/edit/component.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ import { defineComponent, ref, watch, type Ref, h } from 'vue'
import type { LinkTooltipConfig } from '../slices'

import { Icon } from '../../__internal__/components/icon'
import { keepAlive } from '../../__internal__/keep-alive'

// oxlint-disable-next-line no-unused-expressions
h
keepAlive(h)

type EditLinkProps = {
config: Ref<LinkTooltipConfig>
Expand Down
6 changes: 3 additions & 3 deletions packages/components/src/link-tooltip/preview/component.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ import { defineComponent, type Ref, h } from 'vue'
import type { LinkTooltipConfig } from '../slices'

import { Icon } from '../../__internal__/components/icon'
import { keepAlive } from '../../__internal__/keep-alive'

keepAlive(h)

type PreviewLinkProps = {
config: Ref<LinkTooltipConfig>
Expand All @@ -11,9 +14,6 @@ type PreviewLinkProps = {
onRemove: Ref<() => void>
}

// oxlint-disable-next-line no-unused-expressions
h

export const PreviewLink = defineComponent<PreviewLinkProps>({
props: {
config: {
Expand Down
4 changes: 2 additions & 2 deletions packages/components/src/list-item-block/component.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ import { computed, defineComponent, type Ref, h, type VNodeRef } from 'vue'
import type { ListItemBlockConfig } from './config'

import { Icon } from '../__internal__/components/icon'
import { keepAlive } from '../__internal__/keep-alive'

// oxlint-disable-next-line no-unused-expressions
h
keepAlive(h)

interface Attrs {
label: string
Expand Down
6 changes: 3 additions & 3 deletions packages/components/src/table-block/view/component.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,14 @@ import type { TableBlockConfig } from '../config'
import type { CellIndex, DragInfo, Refs } from './types'

import { Icon } from '../../__internal__/components/icon'
import { keepAlive } from '../../__internal__/keep-alive'
import { useDragHandlers } from './drag'
import { useOperation } from './operation'
import { usePointerHandlers } from './pointer'
import { recoveryStateBetweenUpdate } from './utils'

keepAlive(h)

type TableBlockProps = {
view: EditorView
ctx: Ctx
Expand All @@ -29,9 +32,6 @@ type TableBlockProps = {
node: Ref<Node>
}

// oxlint-disable-next-line no-unused-expressions
h

export const TableBlock = defineComponent<TableBlockProps>({
props: {
view: {
Expand Down
7 changes: 3 additions & 4 deletions packages/crepe/src/feature/block-edit/handle/component.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
import { Icon } from '@milkdown/kit/component'
import { defineComponent, ref, h, Fragment } from 'vue'

// oxlint-disable-next-line no-unused-expressions
h
// oxlint-disable-next-line no-unused-expressions
Fragment
import { keepAlive } from '../../../utils/keep-alive'

keepAlive(h, Fragment)

interface BlockHandleProps {
onAdd: () => void
Expand Down
4 changes: 2 additions & 2 deletions packages/crepe/src/feature/block-edit/menu/component.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@ import {

import type { BlockEditFeatureConfig } from '..'

import { keepAlive } from '../../../utils/keep-alive'
import { getGroups } from './config'

// oxlint-disable-next-line no-unused-expressions
h
keepAlive(h)

type MenuProps = {
ctx: Ctx
Expand Down
7 changes: 4 additions & 3 deletions packages/crepe/src/feature/latex/inline-tooltip/component.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,16 @@ import { defineComponent, type ShallowRef, type VNodeRef, h } from 'vue'

import type { LatexConfig } from '..'

import { keepAlive } from '../../../utils/keep-alive'

keepAlive(h)

type LatexTooltipProps = {
config: Partial<LatexConfig>
innerView: ShallowRef<EditorView | null>
updateValue: ShallowRef<() => void>
}

// oxlint-disable-next-line no-unused-expressions
h

export const LatexTooltip = defineComponent<LatexTooltipProps>({
props: {
config: {
Expand Down
9 changes: 3 additions & 6 deletions packages/crepe/src/feature/toolbar/component.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,10 @@ import {

import type { ToolbarFeatureConfig } from '.'

import { keepAlive } from '../../utils/keep-alive'
import { getGroups, type ToolbarItem } from './config'

// oxlint-disable-next-line no-unused-expressions
h
// oxlint-disable-next-line no-unused-expressions
Fragment
keepAlive(h, Fragment)

type ToolbarProps = {
ctx: Ctx
Expand Down Expand Up @@ -65,8 +63,7 @@ export const Toolbar = defineComponent<ToolbarProps>({

function checkActive(checker: ToolbarItem['active']) {
// make sure the function subscribed to vue reactive
// oxlint-disable-next-line no-unused-expressions
props.selection.value
keepAlive(props.selection.value)
// Check if the edtior is ready
const status = ctx.get(editorCtx).status
if (status !== EditorStatus.Created) return false
Expand Down
3 changes: 3 additions & 0 deletions packages/crepe/src/utils/keep-alive.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
// Prevent tree-shaking from removing Vue's `h` and `Fragment`,
// which are required at runtime for TSX to work.
export function keepAlive(..._args: unknown[]) {}
6 changes: 2 additions & 4 deletions packages/integrations/vue/src/editor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,8 @@ import type { GetEditor } from './types'
import { editorInfoCtxKey } from './consts'
import { useGetEditor } from './use-get-editor'

// oxlint-disable-next-line no-unused-expressions
h
// oxlint-disable-next-line no-unused-expressions
Fragment
function keepAlive(..._args: unknown[]) {}
keepAlive(h, Fragment)

export const Milkdown = defineComponent({
name: 'Milkdown',
Expand Down
Loading
Loading