> For AI agents: the complete documentation index is available at /next/zh/llms.txt, the full documentation bundle is available at /next/zh/llms-full.txt.

# `<markdown>`

APISummary
`<markdown>` 在 Lynx 中渲染 Markdown 内容，支持标题、段落、引用、列表、代码、链接、图片和表格，并提供内嵌 View、打字机动画与文本选择能力。

宿主需要集成并注册该原生元件。使用支持 `<markdown>` 的 Lynx Explorer 运行示例；各属性和方法的平台支持情况见[兼容性](#兼容性)。

## 使用指南

### 基础用法

**下面是一个示例: markdown**

**Bundle:** `dist/basic.lynx.bundle` | Web: `dist/basic.web.bundle`

```tsx
// Copyright 2026 The Lynx Authors. All rights reserved.
// Licensed under the Apache License Version 2.0 that can be found in the
// LICENSE file in the root directory of this source tree.

import { renderExample } from "../common.js";

function App() {
  const content = `
this is a **Markdown**!!
`;

  return (
    <view className="plain-surface">
      <markdown content={content} />
    </view>
  );
}

renderExample("Basic", <App />);

```

v0.2.2



上面的代码就是最简单的使用方式，将 Markdown 格式的文本传给 `<markdown>` 的 content 即可。它会使用默认的样式来渲染一个静态的 Markdown 页面。

### 修改样式

`<markdown>` 内部的元素并不是一个 Lynx 元素，因此无法通过 CSS 来赋予样式，但是我们可以通过 `markdown-style` 属性来修改内部元素的样式。

**下面是一个示例: markdown**

**Bundle:** `dist/style.lynx.bundle` | Web: `dist/style.web.bundle`

```tsx
// Copyright 2026 The Lynx Authors. All rights reserved.
// Licensed under the Apache License Version 2.0 that can be found in the
// LICENSE file in the root directory of this source tree.

import { renderExample } from "../common.js";
import type { MarkdownStyle } from "../intrinsic-element.js";

function App() {
  const content = `
this is a **Markdown**!!

this is a \`inline code\`.
`;
  const style: MarkdownStyle = {
    normalText: {
      fontSize: 25,
    },
    inlineCode: {
      fontSize: 20,
      color: "ff0000",
    },
  };

  return (
    <view className="plain-surface">
      <markdown content={content} markdown-style={style} />
    </view>
  );
}

renderExample("Style", <App />);

```

v0.2.2



在上面的代码中我们通过 `markdown-style` 传入了一个 object，它表示将所有的 `normalText` 即普通文本的字号设置为 25px 以及将 `inlineCode` 即行内代码的字号设置成了 20px、颜色设置成了红色。

`markdown-style` 就是这样的一系列 tag 到样式配置项的映射，通过它能修改某一个语法的样式。支持的 tag 及其配置项见[样式表](#样式表)。

#### `<span>` 标签

通过 tag 来修改样式会导致所有的同类文本样式变化：

**下面是一个示例: markdown**

**Bundle:** `dist/link_style.lynx.bundle` | Web: `dist/link_style.web.bundle`

```tsx
// Copyright 2026 The Lynx Authors. All rights reserved.
// Licensed under the Apache License Version 2.0 that can be found in the
// LICENSE file in the root directory of this source tree.

import { renderExample } from "../common.js";
import type { MarkdownStyle } from "../intrinsic-element.js";

function App() {
  const content = `
this is [link1](url1).

this is [link2](url1).
`;
  const style: MarkdownStyle = {
    link: {
      color: "ff0000",
    },
  };

  return (
    <view className="plain-surface">
      <markdown content={content} markdown-style={style} />
    </view>
  );
}

renderExample("Link Style", <App />);

```

v0.2.2



如上的代码中 link1 和 link2 都会被样式表中的 `link` 影响，从而被设置成红色。

但是如果我只想修改 link1 的颜色该怎么办呢？`markdown` 支持了简单的 `<span>` 标签，我们可以在 link1 外包裹一个带有 class 的 `<span>` 标签，然后在 `markdown-style` 中配置这个 class 对应的样式。

**下面是一个示例: markdown**

**Bundle:** `dist/span_style.lynx.bundle` | Web: `dist/span_style.web.bundle`

```tsx
// Copyright 2026 The Lynx Authors. All rights reserved.
// Licensed under the Apache License Version 2.0 that can be found in the
// LICENSE file in the root directory of this source tree.

import { renderExample } from "../common.js";
import type { MarkdownStyle } from "../intrinsic-element.js";

function App() {
  const content = `
this is [<span class="red">link1</span>](url1).

this is [link2](url1).
`;
  const style: MarkdownStyle = {
    ".red": {
      color: "ff0000",
    },
    link: {
      color: "0000ff",
    },
  };

  return (
    <view className="plain-surface">
      <markdown content={content} markdown-style={style} />
    </view>
  );
}

renderExample("Span Style", <App />);

```

v0.2.2



#### `<p>` 标签

类似的，我们可以用 `<p>` 标签来设置段落的样式，例如行高、对齐方式：

**下面是一个示例: markdown**

**Bundle:** `dist/paragraph_style.lynx.bundle` | Web: `dist/paragraph_style.web.bundle`

```tsx
// Copyright 2026 The Lynx Authors. All rights reserved.
// Licensed under the Apache License Version 2.0 that can be found in the
// LICENSE file in the root directory of this source tree.

import { renderExample } from "../common.js";
import type { MarkdownStyle } from "../intrinsic-element.js";

function App() {
  const content = `
<p class="center">paragraph alignment is center.</p>

<p class="right">paragraph alignment is right.</p>
`;
  const style: MarkdownStyle = {
    ".center": {
      textAlign: "center",
    },
    ".right": {
      textAlign: "right",
    },
  };

  return (
    <view className="plain-surface">
      <markdown content={content} markdown-style={style} />
    </view>
  );
}

renderExample("Paragraph Style", <App />);

```

v0.2.2



上面的写法与在 Markdown 中使用 HTML 类似，但是需要注意的是，`markdown` 只支持 `<span>` 标签用于设置文本的样式以及`<p>` 标签用于设置段落的样式，**不支持**其他标签，标签的样式也**不支持**内嵌，只能通过 class 在 `markdown-style` 中设置。

### 插入图片

在 `<markdown>` 中插入图片的语法与 Markdown 一致，例如：

**下面是一个示例: markdown**

**Bundle:** `dist/image.lynx.bundle` | Web: `dist/image.web.bundle`

```tsx
// Copyright 2026 The Lynx Authors. All rights reserved.
// Licensed under the Apache License Version 2.0 that can be found in the
// LICENSE file in the root directory of this source tree.

import { renderExample } from "../common.js";

const imageUrl = "https://upload.wikimedia.org/wikipedia/commons/b/be/Grapefruit_free.jpg";

function App() {
  const content = `
image:
![alt text](${imageUrl})
  `;

  return (
    <view className="plain-surface">
      <markdown content={content}></markdown>
    </view>
  );
}

renderExample("Image", <App />);

```

v0.2.2



#### 控制图片大小

Markdown 的语法中无法控制插入图片的大小，但是 `<markdown>` 支持在 URL 后添加 `width` 和 `height` 来控制图片的大小。

**下面是一个示例: markdown**

**Bundle:** `dist/image_size.lynx.bundle` | Web: `dist/image_size.web.bundle`

```tsx
// Copyright 2026 The Lynx Authors. All rights reserved.
// Licensed under the Apache License Version 2.0 that can be found in the
// LICENSE file in the root directory of this source tree.

import { renderExample } from "../common.js";

const imageUrl = "https://upload.wikimedia.org/wikipedia/commons/b/be/Grapefruit_free.jpg";

function App() {
  const content = `
image:

![alt text](${imageUrl} width=100 height=100)
  `;

  return (
    <view className="plain-surface">
      <markdown content={content}></markdown>
    </view>
  );
}

renderExample("Image Size", <App />);

```

v0.2.2



注意：`width` 和 `height` 的值只能是数字，单位为 px，并且等于号两边不允许有空格。

#### 图片标题

`<markdown>` 支持图片标题语法，添加标题的方式与 Markdown 中一致：`![alt text](url "caption")`。

**下面是一个示例: markdown**

**Bundle:** `dist/image_caption.lynx.bundle` | Web: `dist/image_caption.web.bundle`

```tsx
// Copyright 2026 The Lynx Authors. All rights reserved.
// Licensed under the Apache License Version 2.0 that can be found in the
// LICENSE file in the root directory of this source tree.

import { renderExample } from "../common.js";

const imageUrl = "https://upload.wikimedia.org/wikipedia/commons/b/be/Grapefruit_free.jpg";

function App() {
  const content = `
image:

![alt text](${imageUrl} width=100 height=100 "a grapefruit")
  `;

  return (
    <view className="plain-surface">
      <markdown content={content}></markdown>
    </view>
  );
}

renderExample("Image Caption", <App />);

```

v0.2.2



与其他文本类似，图片标题也可以通过 `markdown-style` 配置样式，`markdown-style` 中的 `imageCaption` 配置项就是用来配置图片标题的样式的，具体的配置项见[样式表](#样式表)。

**下面是一个示例: markdown**

**Bundle:** `dist/image_caption_style.lynx.bundle` | Web: `dist/image_caption_style.web.bundle`

```tsx
// Copyright 2026 The Lynx Authors. All rights reserved.
// Licensed under the Apache License Version 2.0 that can be found in the
// LICENSE file in the root directory of this source tree.

import { renderExample } from "../common.js";
import type { MarkdownStyle } from "../intrinsic-element.js";

const imageUrl = "https://upload.wikimedia.org/wikipedia/commons/b/be/Grapefruit_free.jpg";

function App() {
  const content = `
image:

![alt text](${imageUrl} width=100 height=100 "a grapefruit")
  `;
  const style: MarkdownStyle = {
    imageCaption: {
      color: "808080",
      fontSize: 13,
      textAlign: "left",
    },
  };

  return (
    <view className="plain-surface">
      <markdown content={content} markdown-style={style}>
        {" "}
      </markdown>
    </view>
  );
}

renderExample("Image Caption Style", <App />);

```

v0.2.2



#### GIF

Android 默认支持 GIF；在 iOS 上通过 `enable-gif={true}` 开启动画。

**下面是一个示例: markdown**

**Bundle:** `dist/gif.lynx.bundle` | Web: `dist/gif.web.bundle`

```tsx
// Copyright 2026 The Lynx Authors. All rights reserved.
// Licensed under the Apache License Version 2.0 that can be found in the
// LICENSE file in the root directory of this source tree.

import { renderExample } from "../common.js";

const gifUrl = "https://upload.wikimedia.org/wikipedia/commons/3/32/Earth_rotation.gif";

function App() {
  const content = `
gif:

![](${gifUrl})
  `;

  return (
    <view className="plain-surface">
      <markdown content={content} enable-gif={true}>
        {" "}
      </markdown>
    </view>
  );
}

renderExample("GIF", <App />);

```

v0.2.2



### 插入 Lynx View

Markdown 的语法相当有限，想要实现一些复杂的效果可以通过插入一些自定义的 Lynx View 来实现。比如说插入一段 gradient 颜色的文本：

**下面是一个示例: markdown**

**Bundle:** `dist/inline_view.lynx.bundle` | Web: `dist/inline_view.web.bundle`

```tsx
// Copyright 2026 The Lynx Authors. All rights reserved.
// Licensed under the Apache License Version 2.0 that can be found in the
// LICENSE file in the root directory of this source tree.

import { renderExample } from "../common.js";
import type { MarkdownStyle } from "../intrinsic-element.js";

function App() {
  const content = `
this is a ![](inlineview://mkd)!!
  `;
  const style: MarkdownStyle = {
    normalText: {
      fontSize: 20,
    },
  };

  return (
    <view className="plain-surface">
      <markdown content={content} markdown-style={style}>
        <view id="mkd" className="inline-mark" flatten={false}>
          <text className="inline-mark-text">
            Markdown
          </text>
        </view>
      </markdown>
    </view>
  );
}

renderExample("Inline View", <App />);

```

v0.2.2



示例会将 Markdown 中的 `![](inlineview://mkd)` 替换成 id 为 `mkd` 的子 view，而这个 view 中有一段我们需要的 gradient 颜色的文本。

inlineview 可以通过 `vertical-align` 来设置垂直对齐方式，默认是 `baseline`，在上面的代码中，为了使得文本能够对齐，将 `vertical-align` 设置为 `center`。

inlineview _**必须**_&#x662F;`markdown`的子 view，并且设置 `flatten` 为 `false`，否则会有渲染问题。

### 文本标记

#### 使用 span 设置高亮和下划线

为 `<span>` 指定 class，并在 `markdown-style` 中设置对应的 `backgroundImage` 或 `textDecorationLine` 等属性。

**下面是一个示例: markdown**

**Bundle:** `dist/span_mark.lynx.bundle` | Web: `dist/span_mark.web.bundle`

```tsx
// Copyright 2026 The Lynx Authors. All rights reserved.
// Licensed under the Apache License Version 2.0 that can be found in the
// LICENSE file in the root directory of this source tree.

import { renderExample } from "../common.js";
import type { MarkdownStyle } from "../intrinsic-element.js";

function App() {
  const content = `
<span class="hl">highlighted text</span>, <span class="uline">underlined text</span>.
`;
  const style: MarkdownStyle = {
    ".hl": {
      backgroundImage:
        "linear-gradient(180deg, rgba(255, 245, 157, 0) 0%, rgba(255, 245, 157, 0) 60%, rgba(255, 245, 157, 1) 60%, rgba(255, 245, 157, 1) 100%)",
      paddingLeft: 2,
      paddingRight: 2,
    },
    ".uline": {
      textDecorationLine: "underline",
      textDecorationColor: "ff9800",
      textDecorationStyle: "solid",
      textDecorationThickness: 2,
    },
  };

  return (
    <view className="plain-surface">
      <markdown content={content} markdown-style={style} />
    </view>
  );
}

renderExample("Span Mark", <App />);

```

v0.2.2



#### 按范围添加标记

通过 `text-mark-attachments` 为指定范围添加高亮、边框或渐变下划线。`indexType="source"` 使用 Markdown 源文本索引，`indexType="char"` 使用解析后的字符索引。

**下面是一个示例: markdown**

**Bundle:** `dist/text_mark_attachments.lynx.bundle` | Web: `dist/text_mark_attachments.web.bundle`

```tsx
// Copyright 2026 The Lynx Authors. All rights reserved.
// Licensed under the Apache License Version 2.0 that can be found in the
// LICENSE file in the root directory of this source tree.

import { renderExample } from "../common.js";
import type { MarkdownMarkAttachment } from "../intrinsic-element.js";

function App() {
  const content = `
highlighted text, overlapping text, underlined text.
`;
  const attachments: MarkdownMarkAttachment[] = [
    {
      startIndex: 0,
      endIndex: 35,
      indexType: "source",
      style: {
        color:
          "linear-gradient(180deg, rgba(255, 245, 157, 0) 0%, rgba(255, 245, 157, 0) 60%, rgba(255, 245, 157, 1) 60%, rgba(255, 245, 157, 1) 100%)",
      },
    },
    {
      startIndex: 18,
      endIndex: 53,
      indexType: "source",
      style: {
        borderBottom: {
          lineType: "dashed",
          width: "2px",
          color:
            "linear-gradient(90deg,rgba(42, 123, 155, 1) 0%, rgba(87, 199, 133, 1) 50%, rgba(237, 221, 83, 1) 100%)",
        },
      },
    },
  ];

  return (
    <view className="plain-surface">
      <markdown content={content} text-mark-attachments={attachments} />
    </view>
  );
}

renderExample("Text Mark Attachments", <App />);

```

v0.2.2



### 文本截断

`markdown` 自带超出截断功能，是否添加省略号可以通过 `overflow` 属性来设置，默认值为 `ellipsis` 代表会添加省略号，设置值为 `clip` 代表不会添加省略号，表格不支持添加省略号。

通过 `text-maxline` 属性可以控制文本的最大行数，通过 `height` 样式可以控制文本的最大高度，二者同时存在时会同时生效。

**下面是一个示例: markdown**

**Bundle:** `dist/truncation.lynx.bundle` | Web: `dist/truncation.web.bundle`

```tsx
// Copyright 2026 The Lynx Authors. All rights reserved.
// Licensed under the Apache License Version 2.0 that can be found in the
// LICENSE file in the root directory of this source tree.

import { renderExample } from "../common.js";

function App() {
  const content = `
this is a **Markdown**!!

this is a **Markdown**!!

this is a **Markdown**!!
  `;

  return (
    <view className="plain-surface">
      <markdown
        id="markdown"
        content={content}
        text-maxline={2}
        style={{ height: "100px" }}
      />
    </view>
  );
}

renderExample("Truncation", <App />);

```

v0.2.2



#### 自定义截断文本

默认截断文本是一个省略号，修改截断文本需要通过 `markdown-style` 来配置。 `markdown-style` 中有一个特殊的 tag `truncation` 用于设置截断文本。

**下面是一个示例: markdown**

**Bundle:** `dist/truncation_text.lynx.bundle` | Web: `dist/truncation_text.web.bundle`

```tsx
// Copyright 2026 The Lynx Authors. All rights reserved.
// Licensed under the Apache License Version 2.0 that can be found in the
// LICENSE file in the root directory of this source tree.

import { renderExample } from "../common.js";
import type { MarkdownStyle } from "../intrinsic-element.js";

function App() {
  const content = `
this is a **Markdown**!!

this is a **Markdown**!!

this is a **Markdown**!!
  `;
  const style: MarkdownStyle = {
    truncation: {
      content: "...more",
    },
  };

  return (
    <view className="plain-surface">
      <markdown
        id="markdown"
        content={content}
        markdown-style={style}
        text-maxline={2}
        style="height:100px;"
      />
    </view>
  );
}

renderExample("Truncation Text", <App />);

```

v0.2.2



上面的代码将截断文本设置为“...more”，在截断时会在文本末尾添加“...more”而不是省略号。

#### 自定义截断 View

截断文本也可以是一个 Lynx View，只需要将 `truncation` 中的 `truncationType` 设置为 `view` 同时将 `content` 设置为一个 view id 即可，与 inlineview 类似，`content` 对应的子 view 就会替换截断文本。

**下面是一个示例: markdown**

**Bundle:** `dist/truncation_view.lynx.bundle` | Web: `dist/truncation_view.web.bundle`

```tsx
// Copyright 2026 The Lynx Authors. All rights reserved.
// Licensed under the Apache License Version 2.0 that can be found in the
// LICENSE file in the root directory of this source tree.

import { renderExample } from "../common.js";
import type { MarkdownStyle } from "../intrinsic-element.js";

function App() {
  const content = `
this is a **Markdown**!!

this is a **Markdown**!!

this is a **Markdown**!!
  `;
  const style: MarkdownStyle = {
    truncation: {
      content: "truncation",
      truncationType: "view",
    },
  };

  return (
    <view className="plain-surface" style="height:100vh;position:relative;">
      <markdown
        id="markdown"
        content={content}
        markdown-style={style}
        text-maxline={2}
        style="height:100px;"
      >
        <view id="truncation" className="truncation-view">
          <text className="truncation-text">...expand</text>
        </view>
      </markdown>
    </view>
  );
}

renderExample("Truncation View", <App />);

```

v0.2.2



使用 Lynx View 作为截断文本可以实现更多的自定义效果，比如监听截断文本的点击事件，点击截断文本展开全部内容。

### 打字机

打字机动画在 AI 输出中非常常见，`markdown` 内置支持了打字机动画，只需要将 `animation-type` 设置为 `typewriter` 即可开启打字机动画，同时可以通过 `animation-velocity` 来设置打字机动画的速度，单位是字符数每秒。

**下面是一个示例: markdown**

**Bundle:** `dist/typewriter.lynx.bundle` | Web: `dist/typewriter.web.bundle`

```tsx
// Copyright 2026 The Lynx Authors. All rights reserved.
// Licensed under the Apache License Version 2.0 that can be found in the
// LICENSE file in the root directory of this source tree.

import { renderExample } from "../common.js";

function App() {
  const content = `
this is a **Markdown**!!
`;

  return (
    <view className="plain-surface">
      <markdown
        content={content}
        animation-type="typewriter"
        animation-velocity={20}
      />
    </view>
  );
}

renderExample("Typewriter", <App />);

```

v0.2.2



#### 自定义光标

默认的打字机光标是一个省略号，如果想要改变光标可以通过 `markdown-style` 来设置。`markdown-style` 中有一个特殊的 tag 用于设置打字机光标，即 `typewriterCursor`。

**下面是一个示例: markdown**

**Bundle:** `dist/typewriter_cursor.lynx.bundle` | Web: `dist/typewriter_cursor.web.bundle`

```tsx
// Copyright 2026 The Lynx Authors. All rights reserved.
// Licensed under the Apache License Version 2.0 that can be found in the
// LICENSE file in the root directory of this source tree.

import { renderExample } from "../common.js";
import type { MarkdownStyle } from "../intrinsic-element.js";

function App() {
  const content = `
this is a **Markdown**!!
`;
  const style: MarkdownStyle = {
    typewriterCursor: {
      customCursor: "cursor",
    },
  };

  return (
    <view className="plain-surface">
      <markdown
        content={content}
        markdown-style={style}
        animation-type="typewriter"
        animation-velocity={20}
      >
        <view id="cursor" className="cursor" flatten={false}></view>
      </markdown>
    </view>
  );
}

renderExample("Typewriter Cursor", <App />);

```

v0.2.2



在 `typewriterCursor` 中可以通过 `customCursor` 来指定光标，与 inlineview 类似，`customCursor` 的值需要是一个 id， 而这个 id 对应的子 view 就会替换打字时的光标。

#### 不隐藏光标

默认情况下在当前内容输出完成后，打字机光标会被隐藏。但是通常 AI 的输出是分段的，如果不希望在内容未完整时就隐藏光标，可以将 `content-complete` 属性设置为 `false` 来使得打字机光标一直显示。

**下面是一个示例: markdown**

**Bundle:** `dist/typewriter_keep_cursor.lynx.bundle` | Web: `dist/typewriter_keep_cursor.web.bundle`

```tsx
// Copyright 2026 The Lynx Authors. All rights reserved.
// Licensed under the Apache License Version 2.0 that can be found in the
// LICENSE file in the root directory of this source tree.

import { renderExample } from "../common.js";
import type { MarkdownStyle } from "../intrinsic-element.js";

function App() {
  const content = `
this is a **Markdown**!!
`;
  const style: MarkdownStyle = {
    typewriterCursor: {
      customCursor: "cursor",
    },
  };

  return (
    <view className="plain-surface">
      <markdown
        content={content}
        markdown-style={style}
        animation-type="typewriter"
        animation-velocity={20}
        content-complete={false}
      >
        <view id="cursor" className="cursor" flatten={false}></view>
      </markdown>
    </view>
  );
}

renderExample("Typewriter Keep Cursor", <App />);

```

v0.2.2



#### 文本渐隐效果

如果想要在打字过程中末尾的文本渐隐而不是在末尾使用光标，可以将 `typewriterCursor` 中的 `customCursor` 设置为"none"来禁用光标，然后通过 `markdown-effect` 来设置文本的渐隐效果。

**下面是一个示例: markdown**

**Bundle:** `dist/typewriter_mask.lynx.bundle` | Web: `dist/typewriter_mask.web.bundle`

```tsx
// Copyright 2026 The Lynx Authors. All rights reserved.
// Licensed under the Apache License Version 2.0 that can be found in the
// LICENSE file in the root directory of this source tree.

import { useState } from "@lynx-js/react";

import { renderExample } from "../common.js";
import type { MarkdownEffect, MarkdownStyle } from "../intrinsic-element.js";

function App() {
  const content = `
this is a **Markdown**!!
`;
  const style: MarkdownStyle = {
    typewriterCursor: {
      customCursor: "none",
    },
  };
  const [effect, setEff] = useState<MarkdownEffect>({
    type: "text-mask",
    color: "linear-gradient(90deg, #ffffff00 0%, rgb(255, 255, 255) 100%)",
    rangeStart: -4,
    rangeEnd: -1,
  });

  return (
    <view className="plain-surface">
      <markdown
        content={content}
        markdown-style={style}
        animation-type="typewriter"
        animation-velocity={20}
        markdown-effect={effect}
        binddrawEnd={() => {
          setEff({});
        }}
      >
      </markdown>
    </view>
  );
}

renderExample("Typewriter Mask", <App />);

```

v0.2.2



在上面的代码中我们通过 `markdown-effect` 添加了一个文本的渐变蒙层效果，它会在末尾的 4 个字符上加上一层半透明蒙层。

这里我们还监听了 `drawEnd` 事件，这是因为 `markdown-effect` 不会在打字完成后自动消失，但是打字完成后，会触发 `drawEnd` 事件，在这个事件的回调里我们可以将 `markdown-effect` 清空，从而移除文本的渐隐效果。

与光标类似，在 `content-complete` 设置为 `false` 时，当前内容打字完成后也不会触发 `drawEnd` 事件，因此上面的代码会在内容完整并且打字完成后移除文本的渐隐效果。

### 文本选择与读取

#### 开启文本选择

设置 `text-selection={true}` 开启文本选择。

**下面是一个示例: markdown**

**Bundle:** `dist/text_selection.lynx.bundle` | Web: `dist/text_selection.web.bundle`

```tsx
// Copyright 2026 The Lynx Authors. All rights reserved.
// Licensed under the Apache License Version 2.0 that can be found in the
// LICENSE file in the root directory of this source tree.

import { renderExample } from "../common.js";

function App() {
  const content = `
this is a **Markdown**!!
`;

  return (
    <view className="plain-surface">
      <markdown
        content={content}
        text-selection={true}
        style="overflow:visible;"
      />
    </view>
  );
}

renderExample("Text Selection", <App />);

```

v0.2.2



长按文字区域可以开始选择。菜单和按钮行为由前端实现，开启选择不会自动提供剪贴板菜单。

#### 实现菜单

`getTextBoundingRect` 返回页面坐标。将它用于容器内绝对定位的菜单时，需要减去容器的 `boundingClientRect` 坐标。该示例只展示菜单；后续示例再添加按钮行为。

在选中区域有变化时，会触发 `selectionchange` 事件，事件的参数中会包含选中的起始位置和结束位置，如果当前选中区域为空，则起始位置和结束位置都为-1，我们可以通过判断起始位置和结束位置是否为-1来实现菜单的显示和隐藏。

在显示了菜单后，需要根据选中的区域来调整菜单的位置，这里我们可以通过 `getTextBoundingRect` 方法来获取选中区域的位置。这个方法需要传入选中区域的起始位置和结束位置，返回值是一个 `TextBoundingRect` 对象，对象中包含了选中区域的总的 boundingRect 以及每行单独的 boundingRect。

```ts
interface Rect {
  left: number;
  right: number;
  top: number;
  bottom: number;
  width: number;
  height: number;
}

interface TextBoundingRect {
  boundingRect: Rect;
  boxes: Rect[];
}
```

这里使用总 boundingRect 将菜单水平居中定位在选中区域上方。示例代码如下：

**下面是一个示例: markdown**

**Bundle:** `dist/selection_menu.lynx.bundle` | Web: `dist/selection_menu.web.bundle`

```tsx
// Copyright 2026 The Lynx Authors. All rights reserved.
// Licensed under the Apache License Version 2.0 that can be found in the
// LICENSE file in the root directory of this source tree.

import { useState } from "@lynx-js/react";

import type * as Lynx from "@lynx-js/types";
import { renderExample } from "../common.js";
import type { MarkdownTextBoundingRect } from "../intrinsic-element.js";
import { positionSelectionMenu } from "../selection.js";

function App() {
  const content = `
this is a **Markdown**!!

this is a **Markdown**!!

this is a **Markdown**!!
  `;
  const [menuVisible, setMenuVisible] = useState<"hidden" | "visible">(
    "hidden",
  );
  const [topOffset, setTopOffset] = useState(0);
  const [leftOffset, setLeftOffset] = useState(0);

  const onSelectionChange = (
    params: Lynx.BaseEvent<
      "bindselectionchange",
      { start: number; end: number }
    >,
  ) => {
    const start = params.detail.start;
    const end = params.detail.end;
    console.log("selection change: " + start + "," + end);
    if (start === -1) {
      setMenuVisible("hidden");
    } else {
      setMenuVisible("visible");
      lynx
        .createSelectorQuery()
        .select("#markdown")
        .invoke({
          method: "getTextBoundingRect",
          params: {
            start,
            end,
          },
          success(res: MarkdownTextBoundingRect) {
            console.log(res.boundingRect);
            positionSelectionMenu(res.boundingRect, setLeftOffset, setTopOffset);
          },
          fail(res) {
            console.log(res.code, res.data);
          },
        })
        .exec();
    }
  };

  return (
    <view id="selection-area" className="plain-surface selection-area">
      <markdown
        id="markdown"
        content={content}
        text-selection={true}
        bindselectionchange={onSelectionChange}
        style="overflow:visible;"
      />
      <view
        id="menu"
        className="selection-menu"
        style={{
          visibility: menuVisible,
          left: leftOffset + "px",
          top: topOffset + "px",
        }}
      >
        <view className="menu-inner">
          <text className="menu-button">Select</text>
          <view className="menu-divider" />
          <text className="menu-button">Copy</text>
        </view>
      </view>
    </view>
  );
}

renderExample("Selection Menu", <App />);

```

v0.2.2



#### 扩展选区

`markdown` 提供了一个 `setTextSelection` 方法来由前端设置选中区域，方法的参数为选中区域的起始触摸位置和结束触摸位置。

我们监听 全选 文本的点击事件，在点击事件的回调里把起始触摸位置设置为（0，0），结束触摸位置设置为（MAX_VALUE，MAX_VALUE），即可实现全选功能。

**下面是一个示例: markdown**

**Bundle:** `dist/selection_select_all.lynx.bundle` | Web: `dist/selection_select_all.web.bundle`

```tsx
// Copyright 2026 The Lynx Authors. All rights reserved.
// Licensed under the Apache License Version 2.0 that can be found in the
// LICENSE file in the root directory of this source tree.

import { useState } from "@lynx-js/react";

import type * as Lynx from "@lynx-js/types";
import { renderExample } from "../common.js";
import type { MarkdownTextBoundingRect } from "../intrinsic-element.js";
import { positionSelectionMenu } from "../selection.js";

function App() {
  const content = `
this is a **Markdown**!!

this is a **Markdown**!!

this is a **Markdown**!!
  `;
  const [menuVisible, setMenuVisible] = useState<"hidden" | "visible">(
    "hidden",
  );
  const [topOffset, setTopOffset] = useState(0);
  const [leftOffset, setLeftOffset] = useState(0);

  const onSelectionChange = (
    params: Lynx.BaseEvent<
      "bindselectionchange",
      { start: number; end: number }
    >,
  ) => {
    const start = params.detail.start;
    const end = params.detail.end;
    if (start === -1) {
      setMenuVisible("hidden");
      return;
    }

    setMenuVisible("visible");
    lynx
      .createSelectorQuery()
      .select("#markdown")
      .invoke({
        method: "getTextBoundingRect",
        params: {
          start,
          end,
        },
        success(res: MarkdownTextBoundingRect) {
          positionSelectionMenu(res.boundingRect, setLeftOffset, setTopOffset);
        },
      })
      .exec();
  };

  const onSelectAll = () => {
    lynx
      .createSelectorQuery()
      .select("#markdown")
      .invoke({
        method: "setTextSelection",
        params: {
          startX: 0,
          startY: 0,
          endX: Number.MAX_VALUE,
          endY: Number.MAX_VALUE,
        },
      })
      .exec();
  };

  return (
    <view id="selection-area" className="plain-surface selection-area">
      <markdown
        id="markdown"
        content={content}
        text-selection={true}
        bindselectionchange={onSelectionChange}
        style="overflow:visible;"
      />
      <view
        id="menu"
        className="selection-menu"
        style={{
          visibility: menuVisible,
          left: leftOffset + "px",
          top: topOffset + "px",
        }}
      >
        <view className="menu-inner">
          <text className="menu-button" bindtap={onSelectAll}>Select all</text>
          <view className="menu-divider" />
          <text className="menu-button">Copy</text>
        </view>
      </view>
    </view>
  );
}

renderExample("Selection Select All", <App />);

```

v0.2.2



#### 读取所选文本

通过 `getSelectedText` 读取选区内的纯文本。示例的 `Get text` 按钮显示返回内容，然后清除选区并隐藏菜单。该方法不会写入系统剪贴板；复制到剪贴板需要调用宿主提供的 Native Module。

**下面是一个示例: markdown**

**Bundle:** `dist/selection_copy.lynx.bundle` | Web: `dist/selection_copy.web.bundle`

```tsx
// Copyright 2026 The Lynx Authors. All rights reserved.
// Licensed under the Apache License Version 2.0 that can be found in the
// LICENSE file in the root directory of this source tree.

import { useState } from "@lynx-js/react";

import type * as Lynx from "@lynx-js/types";
import { renderExample } from "../common.js";
import type { MarkdownTextBoundingRect } from "../intrinsic-element.js";
import { positionSelectionMenu } from "../selection.js";

function App() {
  const content = `
this is a **Markdown**!!

this is a **Markdown**!!

this is a **Markdown**!!
  `;
  const [menuVisible, setMenuVisible] = useState<"hidden" | "visible">(
    "hidden",
  );
  const [topOffset, setTopOffset] = useState(0);
  const [leftOffset, setLeftOffset] = useState(0);
  const [selectedText, setSelectedText] = useState("");

  const clearSelection = () => {
    lynx
      .createSelectorQuery()
      .select("#markdown")
      .invoke({
        method: "setTextSelection",
        params: {
          startX: -1,
          startY: -1,
          endX: -1,
          endY: -1,
        },
      })
      .exec();
  };

  const onSelectionChange = (
    params: Lynx.BaseEvent<
      "bindselectionchange",
      { start: number; end: number }
    >,
  ) => {
    const start = params.detail.start;
    const end = params.detail.end;
    if (start === -1) {
      setMenuVisible("hidden");
      return;
    }

    setMenuVisible("visible");
    lynx
      .createSelectorQuery()
      .select("#markdown")
      .invoke({
        method: "getTextBoundingRect",
        params: {
          start,
          end,
        },
        success(res: MarkdownTextBoundingRect) {
          positionSelectionMenu(res.boundingRect, setLeftOffset, setTopOffset);
        },
      })
      .exec();
  };

  const onSelectAll = () => {
    lynx.createSelectorQuery().select("#markdown").invoke({
      method: "setTextSelection",
      params: {
        startX: 0,
        startY: 0,
        endX: Number.MAX_VALUE,
        endY: Number.MAX_VALUE,
      },
    }).exec();
  };

  const onGetSelectedText = () => {
    lynx
      .createSelectorQuery()
      .select("#markdown")
      .invoke({
        method: "getSelectedText",
        success(res: { selectedText: string }) {
          console.log("selected text: " + res.selectedText);
          setSelectedText(res.selectedText);
          clearSelection();
          setMenuVisible("hidden");
        },
      })
      .exec();
  };

  return (
    <view id="selection-area" className="plain-surface selection-area">
      <markdown
        id="markdown"
        content={content}
        text-selection={true}
        bindselectionchange={onSelectionChange}
        style="overflow:visible;"
      />
      <view
        id="menu"
        className="selection-menu"
        style={{
          visibility: menuVisible,
          left: leftOffset + "px",
          top: topOffset + "px",
        }}
      >
        <view className="menu-inner">
          <text className="menu-button" bindtap={onSelectAll}>Select all</text>
          <view className="menu-divider" />
          <text className="menu-button" bindtap={onGetSelectedText}>Get text</text>
        </view>
      </view>
      {selectedText ? <text className="copied-text">Selected text: {selectedText}</text> : null}
    </view>
  );
}

renderExample("Selection Copy", <App />);

```

v0.2.2



#### 选择段落或句子

`setTextSelection` 接收相对于 `<markdown>` 的坐标。用文本边界框的中心定位段落时，先减去 `<markdown>` 自身的页面坐标，再传入相同的起点和终点。

默认情况下 `markdown` 在长按之后只会选中当前触摸位置的字符，如果想要在长按之后选中一个段落，需要在 `selectionchange` 事件中调整选中区域。

`setTextSelection` 方法还可以传入一个 `selectionTextType` 参数，当 start 和 end 位置相同时，这个参数才会生效，它用来指定选中的文本类型，值可以是 `char`，`word`，`sentence` 以及 `paragraph`。

将这个参数设置为 `paragraph` 即可选中一个段落，同理，将这个参数设置为 `sentence` 即可选中一个句子。

**下面是一个示例: markdown**

**Bundle:** `dist/selection_paragraph.lynx.bundle` | Web: `dist/selection_paragraph.web.bundle`

```tsx
// Copyright 2026 The Lynx Authors. All rights reserved.
// Licensed under the Apache License Version 2.0 that can be found in the
// LICENSE file in the root directory of this source tree.

import { useRef, useState } from "@lynx-js/react";

import type * as Lynx from "@lynx-js/types";
import { renderExample } from "../common.js";
import type { MarkdownTextBoundingRect } from "../intrinsic-element.js";
import { positionSelectionMenu } from "../selection.js";

function App() {
  const content = `
this is a **Markdown**!!

this is a **Markdown**!!

this is a **Markdown**!!
  `;
  const inSelection = useRef(false);
  const [menuVisible, setMenuVisible] = useState<"hidden" | "visible">(
    "hidden",
  );
  const [topOffset, setTopOffset] = useState(0);
  const [leftOffset, setLeftOffset] = useState(0);

  const onSelectionChange = (
    params: Lynx.BaseEvent<
      "bindselectionchange",
      { start: number; end: number }
    >,
  ) => {
    const start = params.detail.start;
    const end = params.detail.end;
    console.log("selection change: " + start + "," + end);
    if (start === -1) {
      setMenuVisible("hidden");
      inSelection.current = false;
      return;
    }

    const modifySelection = !inSelection.current;
    setMenuVisible("visible");
    lynx
      .createSelectorQuery()
      .select("#markdown")
      .invoke({
        method: "getTextBoundingRect",
        params: {
          start,
          end,
        },
        success(res: MarkdownTextBoundingRect) {
          console.log(res.boundingRect);
          if (modifySelection) {
            lynx.createSelectorQuery().select("#markdown").invoke({
              method: "boundingClientRect",
              success(markdownRect: MarkdownTextBoundingRect["boundingRect"]) {
                const x = res.boundingRect.left - markdownRect.left + res.boundingRect.width / 2;
                const y = res.boundingRect.top - markdownRect.top + res.boundingRect.height / 2;
                lynx.createSelectorQuery().select("#markdown").invoke({
                  method: "setTextSelection",
                  params: {
                    startX: x,
                    startY: y,
                    endX: x,
                    endY: y,
                    selectionTextType: "paragraph",
                  },
                }).exec();
              },
            }).exec();
          } else {
            positionSelectionMenu(res.boundingRect, setLeftOffset, setTopOffset);
          }
        },
        fail(res) {
          console.log(res.code, res.data);
        },
      })
      .exec();
    inSelection.current = true;
  };

  return (
    <view id="selection-area" className="plain-surface selection-area">
      <markdown
        id="markdown"
        content={content}
        text-selection={true}
        bindselectionchange={onSelectionChange}
        style="overflow:visible;"
      />
      <view
        id="menu"
        className="selection-menu"
        style={{
          visibility: menuVisible,
          left: leftOffset + "px",
          top: topOffset + "px",
        }}
      >
        <view className="menu-inner">
          <text className="menu-button">Select</text>
          <view className="menu-divider" />
          <text className="menu-button">Copy</text>
        </view>
      </view>
    </view>
  );
}

renderExample("Selection Paragraph", <App />);

```

v0.2.2



## 属性

前端可以在元件上设置相应属性来定义组件的运行时行为，使用方法如下。

```tsx
<markdown content={content} />
```

### `content`

```ts
/**
 * markdown source content.
 */
content: string;
```

markdown 内容

### `content-id`

```ts
/**
 * mark the content when the event or UI method is triggered.
 */
'content-id'?: string;
```

作为`content`的唯一标识符，用于在事件中消费。

### `markdown-style`

```ts
/**
 * set the style of markdown.
 * @defaultValue {}
 */
'markdown-style'?: object
```

markdown 的样式，具体格式请参考[样式表](#样式表)

### `animation-type`

```ts
/**
 * which animation to use.
 * none: no animation
 * typewriter: typewriter animation
 * @defaultValue 'none'
 */
'animation-type'?: 'none' | 'typewriter'
```

markdown 的动画样式，可以选择指定开启打字机效果

### `animation-velocity`

```ts
/**
 * velocity of animation.
 * when animation-type is typewriter, it's the number of characters typed per second.
 * @defaultValue 1
 */
'animation-velocity'?:number;
```

markdown 打字机效果的速度

### `text-maxline`

```ts
/**
 * maximum number of text lines.
 * a table row is counted as a line
 */
'text-maxline'?: number;
```

markdown 文本最大行数

### `overflow`

```ts
overflow?: 'ellipsis' | 'clip';
```

控制文本溢出时显示省略号还是直接裁剪，默认为 `ellipsis`。

### `initial-animation-step`

```ts
/**
 * animation will start at the given step.
 * @defaultValue 0
 */
'initial-animation-step'?: number
```

指定 markdown 动画开始的位置

### `content-complete`

```ts
/**
 * whether to hide the typewriter cursor.
 * true: typewriter cursor will be hidden and drawEnd event will be triggered after the animation is complete.
 * false: typewriter cursor will be shown and drawEnd event will not be triggered.
 * @defaultValue true
 */
'content-complete'?: boolean;
```

标明当前`content`是否完整，如果为`true`，则会在动画结束后隐藏光标，否则会一直显示光标

### `typewriter-dynamic-height`

```ts
/**
 * whether markdown height is equal to the content height typed by typewriter
 * @defaultValue false
 */
'typewriter-dynamic-height'?: boolean
```

配置打字机效果是否动态改变元素高度

### `text-selection`

```ts
/**
 * whether markdown content is selectable.
 * @defaultValue false
 */
'text-selection'?: boolean
```

配置 markdown 内容是否可选择

### `text-mark-attachments`

用于复杂高亮：多段重叠、跨行、与下划线/描边混合的场景。

```ts
/**
 * 定义文本高亮附件，用于在指定字符范围内添加高亮或下划线。
 * 附件按行绘制，并在跨行时保持渐变连续。
 * @defaultValue []
 */
'text-mark-attachments'?: MarkAttachment[];

interface LineStyle {
  lineType: 'none' | 'solid' | 'dashed';
  color: string; // 16进制颜色或者gradient
  width: number; // 单位为px
  elementSize?: number; // 虚线元素长度
  emptySize?: number; // 虚线间隔长度
}

interface MarkStyle {
  radius?: number; // 圆角半径，单位为px
  left?: number; // 单位为px
  right?: number; // 单位为px
  top?: number; // 单位为px
  bottom?: number; // 单位为px
  color?: string; // 矩形填充颜色或者gradient
  borderLeft?: LineStyle;
  borderTop?: LineStyle;
  borderRight?: LineStyle;
  borderBottom?: LineStyle;
}

interface MarkAttachment {
  startIndex: number;
  endIndex: number; // 不包含该位置（exclusive）
  indexType: 'char' | 'source';
  clickable?: boolean;
  id?: string;
  layer?: 'background' | 'foreground';
  style: MarkStyle;
}
```

### `content-range`

```ts
/**
 * the range of content to be parsed.
 * @defaultValue [0, int32_max]
 */
'content-range'?: number[];
```

配置 Markdown 源文本的解析范围。

### `markdown-effect`

```ts
/**
 * additional effects
 * @defaultValue {}
 */
'markdown-effect'?: object
```

配置额外渲染效果。渐隐遮罩使用 `{ type: 'text-mask', color, rangeStart, rangeEnd }`，见[文本渐隐效果](#文本渐隐效果)。

### `typewriter-height-transition-duration`

```ts
/**
 * transition duration when height extended by typewriter animation.
 * @defaultValue 0
 */
'typewriter-height-transition-duration'?: number
```

配置打字机高度变化时的过渡时长，单位为秒，默认值为 `0`。配合 `typewriter-dynamic-height` 使用。

### `enable-gif`

```ts
/**
 * whether to enable gif animation.
 * @defaultValue false
 */
'enable-gif'?: boolean
```

配置iOS是否开启gif动画，安卓默认支持gif动画。

## 事件

前端可以在元件上绑定相应事件回调来监听组件的运行时行为，使用方法如下。

```tsx
<markdown content={content} binddrawEnd={onDrawEnd} />
```

### `binddrawStart`

```ts
/**
 * draw start
 */
binddrawStart?: (e: BaseEvent) => void;
```

markdown 开始绘制的事件

### `binddrawEnd`

```ts
/**
 * draw end
 */
binddrawEnd?: (e: BaseEvent) => void;
```

markdown 结束绘制事件

### `bindanimationStep`

```ts
export interface MarkdownAnimationStepEvent {
    /**
     * current step of animation.
     */
    animationStep: number;

    /**
     * maximum step of animation.
     */
    maxAnimationStep: number;
}

/**
 * callback after each animation frame, some animation steps may be skipped if animation velocity is too fast.
 */
bindanimationStep?: (e: BaseEvent<'bindanimationStep', MarkdownAnimationStepEvent>) => void;
```

markdown 每次动画帧的回调事件

### `bindoverflow`

```ts

export interface MarkdownOverflowEvent {
    /**
     * type of overflow.
     * ellipsis: overflow text will be replaced by ... or truncation view.
     * clip: overflow text will be clipped
     */
    type: 'ellipsis' | 'clip';
}

/**
 * callback when text overflow.
 */
bindoverflow?: (e: BaseEvent<'bindoverflow', MarkdownOverflowEvent>) => void;
```

markdown 文本溢出事件

### `bindlink`

```ts
export interface MarkdownLinkEvent {
    /**
     * link url
     */
    url: string;

    /**
     * link text
     */
    content: string;
}

/**
 * callback when link is clicked.
 */
bindlink?: (e: BaseEvent<'bindlink', MarkdownLinkEvent>) => void;
```

markdown 链接点击事件

### `bindselectionchange`

```ts
export interface MarkdownSelectionChangeEvent {
    /**
     * start char pos of selection range.
     */
    start: number;
    /**
     * end char pos of selection range.
     */
    end: number;
    /**
     * direction of selection.
     */
    direction: 'forward' | 'backward';
}

/**
 * callback when selection change.
 */
bindselectionchange?: (e: BaseEvent<'bindselectionchange', MarkdownSelectionChangeEvent>) => void;
```

markdown 光标变化事件

### `bindimageTap`

```ts
export interface MarkdownImageTapEvent {
    /**
     * image url
     */
    url: string;
}

/**
 * callback when image is clicked.
 */
bindimageTap?: (e: BaseEvent<'bindimageTap', MarkdownImageTapEvent>) => void;
```

markdown 图片点击事件

### `bindparseEnd`

```ts
export interface MarkdownParseEndEvent {
    /**
     * the id of content that parsed.
     */
    id: string;
}

/**
 * callback when parse end.
 */
bindparseEnd?: (e: BaseEvent<'bindparseEnd', MarkdownParseEndEvent>) => void;
```

markdown 解析结束事件

### `bindtextClick`

当 `text-mark-attachments` 中设置了 `clickable` 的附件被点击时触发，事件返回该附件的 `id`。

```ts
export interface MarkdownTextClickEvent {
  /** id of the clicked attachment */
  id: string;
}

/**
 * callback when a clickable attachment defined in `text-mark-attachments` is clicked.
 */
bindtextClick?: (e: BaseEvent<'bindtextClick', MarkdownTextClickEvent>) => void;
```

## 方法

前端可以通过 [SelectorQuery](/next/zh/api/lynx-api/nodes-ref/nodes-ref-invoke.md) API 执行元件的方法，使用方法如下：

```ts title=index.js
lynx
  .createSelectorQuery() // 创建 SelectorQuery
  .select('#markdown') // 指定目标节点的选择器
  .invoke({
    // 指定对目标节点的操作
    method: 'pauseAnimation',
    success: function (res) {
      console.log(res);
    },
    fail: function (res) {
      console.log(res.code, res.data);
    },
  })
  .exec(); // 执行查询
```

### `pauseAnimation`

```ts
/**
 */
export interface MarkdownPauseAnimationMethod extends BaseMethod {
  method: 'pauseAnimation';
  success?: Callback<{
    /**
     * current step of animation.
     */
    animationStep: number;
  }>;
}
```

暂停动画

### `resumeAnimation`

```ts
/**
 */
export interface MarkdownResumeAnimationMethod extends BaseMethod {
  method: 'resumeAnimation';
  params?: {
    /**
     * animation will start at the given step.
     */
    animationStep?: number;
  };
}
```

恢复动画

### `getContent`

```ts
/**
 * get parsed content
 */
export interface MarkdownGetContentMethod extends BaseMethod {
  method: 'getContent';
  params: {
    /**
     * start index of parsed content.
     * @defaultValue 0
     */
    start?: number;
    /**
     * end index of parsed content.
     * @defaultValue int32_max
     */
    end?: number;
  };
  success?: Callback<{
    /**
     * parsed content of the given range.
     */
    content: string;
  }>;
}
```

获取解析后的内容

### `getSelectedText`

```ts
/**
 */
export interface MarkdownGetSelectedTextMethod extends BaseMethod {
  method: 'getSelectedText';
  success?: Callback<{
    /**
     * selected text.
     */
    selectedText: string;
  }>;
}
```

获取选中的文本

### `setTextSelection`

```ts
/**
 * Control text selection highlighting.
 */
export interface MarkdownSetTextSelectionMethod extends BaseMethod {
  method: 'setTextSelection';
  params: {
    /**
     * The x-coordinate of the start of the selected text relative to the text component
     */
    startX: number;
    /**
     * The y-coordinate of the start of the selected text relative to the text component
     */
    startY: number;
    /**
     * The x-coordinate of the end of the selected text relative to the text component
     */
    endX: number;
    /**
     * The y-coordinate of the end of the selected text relative to the text component
     */
    endY: number;
    selectionTextType?: 'char' | 'word' | 'sentence' | 'paragraph';
  };
  success?: Callback<{
    /**
     * The bounding box of the selected text
     */
    boundingRect: {
      left: number;
      top: number;
      right: number;
      bottom: number;
      width: number;
      height: number;
    };
    /**
     * The bounding boxes of each line
     */
    boxes: {
      left: number;
      top: number;
      right: number;
      bottom: number;
      width: number;
      height: number;
    }[];
    /**
     * The cursor positions and the default radius
     */
    handles?: {
      x: number;
      y: number;
      radius: number;
    }[];
  }>;
}
```

设置文本选择框

### `getTextBoundingRect`

```ts
/**
 */
export interface MarkdownGetTextBoundingRectMethod extends BaseMethod {
  method: 'getTextBoundingRect';
  params: {
    /**
     * start index of parsed content.
     * @defaultValue 0
     */
    start?: number;
    /**
     * end index of parsed content.
     * @defaultValue int32_max
     */
    end?: number;
    /**
     * index type of the start and end.
     * @defaultValue 'char'
     */
    indexType?: 'source' | 'char';
  };
  success?: Callback<{
    /**
     * bounding rect of the given range.
     */
    boundingRect: {
      left: number;
      top: number;
      right: number;
      bottom: number;
      width: number;
      height: number;
    };
    /**
     * bounding boxes of each line.
     */
    boxes: {
      left: number;
      top: number;
      right: number;
      bottom: number;
      width: number;
      height: number;
    }[];
  }>;
}
```

获取指定范围的文本边界框

### `getImages`

```ts
/**
 * get all images in the markdown.
 */
export interface MarkdownGetImagesMethod extends BaseMethod {
  method: 'getImages';
  success?: Callback<{
    /**
     * all images in the markdown.
     */
    images: string[];
  }>;
}
```

获取 markdown 中的所有图片

### `getParseResult`

```ts
/**
 * get source ranges of the given tags.
 */
export interface MarkdownGetParseResultMethod extends BaseMethod {
  method: 'getParseResult';
  params: {
    /**
     * tags that you want to get its source range.
     */
    tags: string[];
  };
  success?: Callback<{
    /**
     * source ranges of the given tags.
     * key: tag
     * value: ranges
     */
    result: Record<
      string,
      {
        start: number;
        end: number;
      }[]
    >;
  }>;
}
```

获取指定标签的解析结果

## 样式表

### normalText - 普通文本样式

支持的属性：

- backgroundColor (color) - 背景颜色
- color (color) - 文字颜色
- direction (enum: normal, ltr, rtl) - 文本方向
- font (font) - 字体设置
- fontSize (float) - 字体大小
- fontWeight (enum: normal, bold, 100-900) - 字体粗细
- lastLineAlignment (enum: left, center, right, justify) - 最后一行对齐
- lineHeight (float) - 行高
- lineSpace (float) - 行间距
- marginBottom (float) - 下外边距
- marginLeft (float) - 左外边距
- marginRight (float) - 右外边距
- marginTop (float) - 上外边距
- paddingBottom (float) - 下内边距
- paddingLeft (float) - 左内边距
- paddingRight (float) - 右内边距
- paddingTop (float) - 上内边距
- paragraphSpace (float) - 段落间距
- textAlign (enum: left, center, right, justify) - 文本对齐
- textIndent (float) - 文本缩进
- textMaxline (int) - 最大行数
- textOverflow (enum: clip, ellipsis) - 文本溢出处理
- wordBreak (enum: normal, break-all) - 单词换行

### h1 - 一级标题样式

支持的属性：

- backgroundColor (color) - 背景颜色
- color (color) - 文字颜色
- direction (enum: normal, ltr, rtl) - 文本方向
- font (font) - 字体设置
- fontSize (float) - 字体大小
- fontWeight (enum: normal, bold, 100-900) - 字体粗细
- lastLineAlignment (enum: left, center, right, justify) - 最后一行对齐
- lineHeight (float) - 行高
- lineSpace (float) - 行间距
- marginBottom (float) - 下外边距
- marginLeft (float) - 左外边距
- marginRight (float) - 右外边距
- marginTop (float) - 上外边距
- paddingBottom (float) - 下内边距
- paddingLeft (float) - 左内边距
- paddingRight (float) - 右内边距
- paddingTop (float) - 上内边距
- paragraphSpace (float) - 段落间距
- textAlign (enum: left, center, right, justify) - 文本对齐
- textIndent (float) - 文本缩进
- textMaxline (int) - 最大行数
- textOverflow (enum: clip, ellipsis) - 文本溢出处理
- wordBreak (enum: normal, break-all) - 单词换行

### h2 - 二级标题样式

支持的属性：

- backgroundColor (color) - 背景颜色
- color (color) - 文字颜色
- direction (enum: normal, ltr, rtl) - 文本方向
- font (font) - 字体设置
- fontSize (float) - 字体大小
- fontWeight (enum: normal, bold, 100-900) - 字体粗细
- lastLineAlignment (enum: left, center, right, justify) - 最后一行对齐
- lineHeight (float) - 行高
- lineSpace (float) - 行间距
- marginBottom (float) - 下外边距
- marginLeft (float) - 左外边距
- marginRight (float) - 右外边距
- marginTop (float) - 上外边距
- paddingBottom (float) - 下内边距
- paddingLeft (float) - 左内边距
- paddingRight (float) - 右内边距
- paddingTop (float) - 上内边距
- paragraphSpace (float) - 段落间距
- textAlign (enum: left, center, right, justify) - 文本对齐
- textIndent (float) - 文本缩进
- textMaxline (int) - 最大行数
- textOverflow (enum: clip, ellipsis) - 文本溢出处理
- wordBreak (enum: normal, break-all) - 单词换行

### h3 - 三级标题样式

支持的属性：

- backgroundColor (color) - 背景颜色
- color (color) - 文字颜色
- direction (enum: normal, ltr, rtl) - 文本方向
- font (font) - 字体设置
- fontSize (float) - 字体大小
- fontWeight (enum: normal, bold, 100-900) - 字体粗细
- lastLineAlignment (enum: left, center, right, justify) - 最后一行对齐
- lineHeight (float) - 行高
- lineSpace (float) - 行间距
- marginBottom (float) - 下外边距
- marginLeft (float) - 左外边距
- marginRight (float) - 右外边距
- marginTop (float) - 上外边距
- paddingBottom (float) - 下内边距
- paddingLeft (float) - 左内边距
- paddingRight (float) - 右内边距
- paddingTop (float) - 上内边距
- paragraphSpace (float) - 段落间距
- textAlign (enum: left, center, right, justify) - 文本对齐
- textIndent (float) - 文本缩进
- textMaxline (int) - 最大行数
- textOverflow (enum: clip, ellipsis) - 文本溢出处理
- wordBreak (enum: normal, break-all) - 单词换行

### h4 - 四级标题样式

支持的属性：

- backgroundColor (color) - 背景颜色
- color (color) - 文字颜色
- direction (enum: normal, ltr, rtl) - 文本方向
- font (font) - 字体设置
- fontSize (float) - 字体大小
- fontWeight (enum: normal, bold, 100-900) - 字体粗细
- lastLineAlignment (enum: left, center, right, justify) - 最后一行对齐
- lineHeight (float) - 行高
- lineSpace (float) - 行间距
- marginBottom (float) - 下外边距
- marginLeft (float) - 左外边距
- marginRight (float) - 右外边距
- marginTop (float) - 上外边距
- paddingBottom (float) - 下内边距
- paddingLeft (float) - 左内边距
- paddingRight (float) - 右内边距
- paddingTop (float) - 上内边距
- paragraphSpace (float) - 段落间距
- textAlign (enum: left, center, right, justify) - 文本对齐
- textIndent (float) - 文本缩进
- textMaxline (int) - 最大行数
- textOverflow (enum: clip, ellipsis) - 文本溢出处理
- wordBreak (enum: normal, break-all) - 单词换行

### h5 - 五级标题样式

支持的属性：

- backgroundColor (color) - 背景颜色
- color (color) - 文字颜色
- direction (enum: normal, ltr, rtl) - 文本方向
- font (font) - 字体设置
- fontSize (float) - 字体大小
- fontWeight (enum: normal, bold, 100-900) - 字体粗细
- lastLineAlignment (enum: left, center, right, justify) - 最后一行对齐
- lineHeight (float) - 行高
- lineSpace (float) - 行间距
- marginBottom (float) - 下外边距
- marginLeft (float) - 左外边距
- marginRight (float) - 右外边距
- marginTop (float) - 上外边距
- paddingBottom (float) - 下内边距
- paddingLeft (float) - 左内边距
- paddingRight (float) - 右内边距
- paddingTop (float) - 上内边距
- paragraphSpace (float) - 段落间距
- textAlign (enum: left, center, right, justify) - 文本对齐
- textIndent (float) - 文本缩进
- textMaxline (int) - 最大行数
- textOverflow (enum: clip, ellipsis) - 文本溢出处理
- wordBreak (enum: normal, break-all) - 单词换行

### h6 - 六级标题样式

支持的属性：

- backgroundColor (color) - 背景颜色
- color (color) - 文字颜色
- direction (enum: normal, ltr, rtl) - 文本方向
- font (font) - 字体设置
- fontSize (float) - 字体大小
- fontWeight (enum: normal, bold, 100-900) - 字体粗细
- lastLineAlignment (enum: left, center, right, justify) - 最后一行对齐
- lineHeight (float) - 行高
- lineSpace (float) - 行间距
- marginBottom (float) - 下外边距
- marginLeft (float) - 左外边距
- marginRight (float) - 右外边距
- marginTop (float) - 上外边距
- paddingBottom (float) - 下内边距
- paddingLeft (float) - 左内边距
- paddingRight (float) - 右内边距
- paddingTop (float) - 上内边距
- paragraphSpace (float) - 段落间距
- textAlign (enum: left, center, right, justify) - 文本对齐
- textIndent (float) - 文本缩进
- textMaxline (int) - 最大行数
- textOverflow (enum: clip, ellipsis) - 文本溢出处理
- wordBreak (enum: normal, break-all) - 单词换行

### link - 链接样式

支持的属性：

- backgroundColor (color) - 背景颜色
- color (color) - 文字颜色
- font (font) - 字体设置
- fontSize (float) - 字体大小
- fontWeight (enum: normal, bold, 100-900) - 字体粗细
- textDecorationColor (color) - 文本装饰颜色
- textDecorationLine (enum: none, underline, overline, line-through) - 文本装饰线
- textDecorationStyle (enum: none, solid, double, dotted, dashed, wavy) - 文本装饰样式
- textDecorationThickness (float) - 文本装饰厚度

### inlineCode - 行内代码样式

支持的属性：

- backgroundColor (color) - 背景颜色
- borderColor (color) - 边框颜色
- borderRadius (float) - 边框圆角
- borderWidth (float) - 边框宽度
- color (color) - 文字颜色
- font (font) - 字体设置
- fontSize (float) - 字体大小
- fontWeight (enum: normal, bold, 100-900) - 字体粗细
- marginLeft (float) - 左外边距
- marginRight (float) - 右外边距
- paddingLeft (float) - 左内边距
- paddingRight (float) - 右内边距

### codeBlock - 代码块样式

支持的属性：

- backgroundColor (color) - 背景颜色
- borderColor (color) - 边框颜色
- borderRadius (float) - 边框圆角
- borderType (enum: none, solid) - 边框类型
- borderWidth (float) - 边框宽度
- color (color) - 文字颜色
- direction (enum: normal, ltr, rtl) - 文本方向
- font (font) - 字体设置
- fontSize (float) - 字体大小
- fontWeight (enum: normal, bold, 100-900) - 字体粗细
- lastLineAlignment (enum: left, center, right, justify) - 最后一行对齐
- lineHeight (float) - 行高
- lineSpace (float) - 行间距
- marginBottom (float) - 下外边距
- marginLeft (float) - 左外边距
- marginRight (float) - 右外边距
- marginTop (float) - 上外边距
- maxWidth (float) - 最大宽度
- paddingBottom (float) - 下内边距
- paddingLeft (float) - 左内边距
- paddingRight (float) - 右内边距
- paddingTop (float) - 上内边距
- paragraphSpace (float) - 段落间距
- scrollX (bool) - 水平滚动
- textAlign (enum: left, center, right, justify) - 文本对齐
- textIndent (float) - 文本缩进
- textMaxline (int) - 最大行数
- textOverflow (enum: clip, ellipsis) - 文本溢出处理
- wordBreak (enum: normal, break-all) - 单词换行

### quote - 引用样式

支持的属性：

- backgroundColor (color) - 背景颜色
- borderColor (color) - 边框颜色
- borderRadius (float) - 边框圆角
- borderType (enum: none, solid) - 边框类型
- borderWidth (float) - 边框宽度
- color (color) - 文字颜色
- direction (enum: normal, ltr, rtl) - 文本方向
- font (font) - 字体设置
- fontSize (float) - 字体大小
- fontWeight (enum: normal, bold, 100-900) - 字体粗细
- indent (float) - 缩进
- lastLineAlignment (enum: left, center, right, justify) - 最后一行对齐
- lineHeight (float) - 行高
- lineSpace (float) - 行间距
- marginBottom (float) - 下外边距
- marginLeft (float) - 左外边距
- marginRight (float) - 右外边距
- marginTop (float) - 上外边距
- paddingBottom (float) - 下内边距
- paddingLeft (float) - 左内边距
- paddingRight (float) - 右内边距
- paddingTop (float) - 上内边距
- paragraphSpace (float) - 段落间距
- textAlign (enum: left, center, right, justify) - 文本对齐
- textIndent (float) - 文本缩进
- textMaxline (int) - 最大行数
- textOverflow (enum: clip, ellipsis) - 文本溢出处理
- wordBreak (enum: normal, break-all) - 单词换行

### orderedList - 有序列表样式

支持的属性：

- backgroundColor (color) - 背景颜色
- color (color) - 文字颜色
- direction (enum: normal, ltr, rtl) - 文本方向
- font (font) - 字体设置
- fontSize (float) - 字体大小
- fontWeight (enum: normal, bold, 100-900) - 字体粗细
- indent (float) - 缩进
- lastLineAlignment (enum: left, center, right, justify) - 最后一行对齐
- lineHeight (float) - 行高
- lineSpace (float) - 行间距
- marginBottom (float) - 下外边距
- marginLeft (float) - 左外边距
- marginRight (float) - 右外边距
- marginTop (float) - 上外边距
- numberColor (color) - 数字颜色
- numberFont (font) - 数字字体
- numberFontSize (float) - 数字字体大小
- numberMarginRight (float) - 数字右边距
- numberType (enum: number, alphabet, roman-numerals, mixed) - 数字类型
- paddingBottom (float) - 下内边距
- paddingLeft (float) - 左内边距
- paddingRight (float) - 右内边距
- paddingTop (float) - 上内边距
- paragraphSpace (float) - 段落间距
- textAlign (enum: left, center, right, justify) - 文本对齐
- textIndent (float) - 文本缩进
- textMaxline (int) - 最大行数
- textOverflow (enum: clip, ellipsis) - 文本溢出处理
- wordBreak (enum: normal, break-all) - 单词换行

### unorderedList - 无序列表样式

支持的属性：

- backgroundColor (color) - 背景颜色
- color (color) - 文字颜色
- direction (enum: normal, ltr, rtl) - 文本方向
- font (font) - 字体设置
- fontSize (float) - 字体大小
- fontWeight (enum: normal, bold, 100-900) - 字体粗细
- indent (float) - 缩进
- lastLineAlignment (enum: left, center, right, justify) - 最后一行对齐
- lineHeight (float) - 行高
- lineSpace (float) - 行间距
- marginBottom (float) - 下外边距
- marginLeft (float) - 左外边距
- marginRight (float) - 右外边距
- marginTop (float) - 上外边距
- markColor (color) - 标记颜色
- markMarginRight (float) - 标记右边距
- markSize (float) - 标记大小
- markType (enum: ring, circle, square, mixed) - 标记类型
- paddingBottom (float) - 下内边距
- paddingLeft (float) - 左内边距
- paddingRight (float) - 右内边距
- paddingTop (float) - 上内边距
- paragraphSpace (float) - 段落间距
- textAlign (enum: left, center, right, justify) - 文本对齐
- textMaxline (int) - 最大行数
- textOverflow (enum: clip, ellipsis) - 文本溢出处理
- wordBreak (enum: normal, break-all) - 单词换行

### table - 表格样式

支持的属性：

- altColor (color) - 替代颜色
- backgroundColor (color) - 背景颜色
- borderColor (color) - 边框颜色
- borderRadius (float) - 边框圆角
- borderWidth (float) - 边框宽度
- marginBottom (float) - 下外边距
- marginLeft (float) - 左外边距
- marginRight (float) - 右外边距
- marginTop (float) - 上外边距
- maxWidth (float) - 最大宽度
- minWidth (float) - 最小宽度
- paddingBottom (float) - 下内边距
- paddingLeft (float) - 左内边距
- paddingRight (float) - 右内边距
- paddingTop (float) - 上内边距
- scrollX (bool) - 水平滚动
- tableBackground (enum: none, solid, chess-board) - 表格背景
- tableBorder (enum: none, full-rect, underline) - 表格边框

### tableCell - 表格单元格样式

支持的属性：

- backgroundColor (color) - 背景颜色
- color (color) - 文字颜色
- direction (enum: normal, ltr, rtl) - 文本方向
- font (font) - 字体设置
- fontSize (float) - 字体大小
- fontWeight (enum: normal, bold, 100-900) - 字体粗细
- lastLineAlignment (enum: left, center, right, justify) - 最后一行对齐
- lineHeight (float) - 行高
- lineSpace (float) - 行间距
- marginBottom (float) - 下外边距
- marginLeft (float) - 左外边距
- marginRight (float) - 右外边距
- marginTop (float) - 上外边距
- maxWidth (float) - 最大宽度
- paddingBottom (float) - 下内边距
- paddingLeft (float) - 左内边距
- paddingRight (float) - 右内边距
- paddingTop (float) - 上内边距
- textAlign (enum: left, center, right, justify) - 文本对齐
- textIndent (float) - 文本缩进
- wordBreak (enum: normal, break-all) - 单词换行

### split - 分割线样式

支持的属性：

- borderColor (color) - 颜色
- borderWidth (float) - 宽度
- marginBottom (float) - 下外边距
- marginTop (float) - 上外边距

### typewriterCursor - 打字机光标样式

支持的属性：

- customCursor (string) - 自定义光标
- verticalAlign (enum: baseline, top, center, bottom) - 光标垂直对齐

### truncation - 截断样式

支持的属性：

- content (string) - 截断内容
- truncationType (enum: text, view) - 截断类型

### listItem - 列表项样式

支持的属性：

- marginBottom (float) - 下外边距
- marginTop (float) - 上外边距
- paddingBottom (float) - 下内边距
- paddingTop (float) - 上内边距

### tableHeader - 表格头样式

支持的属性：

- backgroundColor (color) - 背景颜色
- color (color) - 文字颜色
- direction (enum: normal, ltr, rtl) - 文本方向
- font (font) - 字体设置
- fontSize (float) - 字体大小
- fontWeight (enum: normal, bold, 100-900) - 字体粗细
- lastLineAlignment (enum: left, center, right, justify) - 最后一行对齐
- lineHeight (float) - 行高
- lineSpace (float) - 行间距
- paddingBottom (float) - 下内边距
- paddingLeft (float) - 左内边距
- paddingRight (float) - 右内边距
- paddingTop (float) - 上内边距
- paragraphSpace (float) - 段落间距
- textAlign (enum: left, center, right, justify) - 文本对齐
- textIndent (float) - 文本缩进
- textMaxline (int) - 最大行数
- textOverflow (enum: clip, ellipsis) - 文本溢出处理
- verticalAlign (enum: baseline, top, center, bottom) - 垂直对齐
- wordBreak (enum: normal, break-all) - 单词换行

### image - 图片样式

支持的属性：

- altImage (string) - 替代图片
- enableAltText (bool) - 启用替代文本
- height (float) - 高度
- width (float) - 宽度

### quoteBorderLine - 引用边框线样式

支持的属性：

- color (color) - 文字颜色
- lineType (enum: none, solid, dashed) - 线条类型
- radius (float) - 半径
- shrink (float) - 收缩
- width (float) - 宽度

### unorderedListMarker - 无序列表标记样式

支持的属性：

- color (color) - 文字颜色
- height (float) - 高度
- marginBottom (float) - 下外边距
- marginLeft (float) - 左外边距
- marginRight (float) - 右外边距
- marginTop (float) - 上外边距
- markType (enum: ring, circle, square, mixed) - 标记类型
- width (float) - 宽度

### \<span> - span样式

支持的属性：

- backgroundColor (color) - 背景颜色
- backgroundImage (string) - 背景图片
- borderColor (color) - 边框颜色
- borderRadius (float) - 边框圆角
- borderWidth (float) - 边框宽度
- color (color) - 文字颜色
- direction (enum: normal, ltr, rtl) - 文本方向
- font (font) - 字体设置
- fontSize (float) - 字体大小
- fontWeight (enum: normal, bold, 100-900) - 字体粗细
- marginLeft (float) - 左外边距
- marginRight (float) - 右外边距
- paddingLeft (float) - 左内边距
- paddingRight (float) - 右内边距
- textDecorationColor (color) - 文本装饰线颜色
- textDecorationLine (enum: none, underline, overline, line-through) - 文本装饰线类型
- textDecorationStyle (enum: none, solid, double, dotted, dashed, wavy) - 文本装饰线样式
- textDecorationThickness (float) - 文本装饰线宽度

### \<p> - 段落样式

支持的属性：

- direction (enum: normal, ltr, rtl) - 文本方向
- lastLineAlignment (enum: left, center, right, justify) - 最后一行对齐
- lineHeight (float) - 行高
- lineSpace (float) - 行间距
- marginBottom (float) - 下外边距
- marginTop (float) - 上外边距
- paddingBottom (float) - 下内边距
- paddingTop (float) - 上内边距
- paragraphSpace (float) - 段落间距
- textAlign (enum: left, center, right, justify) - 文本对齐
- textIndent (float) - 文本缩进
- textMaxline (int) - 最大行数
- textOverflow (enum: clip, ellipsis) - 文本溢出处理
- wordBreak (enum: normal, break-all) - 单词换行

### orderedListNumber - 有序列表数字样式

支持的属性：

- backgroundColor (color) - 背景颜色
- color (color) - 文字颜色
- font (font) - 字体设置
- fontSize (float) - 字体大小
- fontWeight (enum: normal, bold, 100-900) - 字体粗细
- lineHeight (float) - 行高
- marginBottom (float) - 下外边距
- marginLeft (float) - 左外边距
- marginRight (float) - 右外边距
- marginTop (float) - 上外边距

### imageCaption - 图片标题样式

支持的属性：

- captionPosition (enum: top, bottom) - 标题位置
- color (color) - 文字颜色
- direction (enum: normal, ltr, rtl) - 文本方向
- font (font) - 字体设置
- fontSize (float) - 字体大小
- fontWeight (enum: normal, bold, 100-900) - 字体粗细
- lineHeight (float) - 行高
- textAlign (enum: left, center, right, justify) - 文本对齐

## 兼容性

**Compatibility Table**

**Query:** `elements.markdown`

[Source](https://github.com/lynx-family/lynx-website/tree/main/packages/lynx-compat-data/elements/markdown.json)

| Feature | Android | HarmonyOS | iOS | macOS | Windows | Web |
| --- | --- | --- | --- | --- | --- | --- |
| markdown | Yes (2.15) | Yes (3.1) | Yes (2.16) | Yes (2.18) | Yes (2.18) | Partial |
| allow-break-around-punctuation | Yes (3.2) | Yes (4.0) | Yes (3.2) | Yes (4.0) | Yes (4.0) | No |
| animation-frame-rate | Yes (3.2) | No | Yes (3.2) | Yes (4.0) | Yes (4.0) | No |
| animation-type | Yes (2.15) | Yes (3.1) | Yes (2.16) | Yes (2.18) | Yes (2.18) | Yes |
| animation-velocity | Yes (2.15) | Yes (3.1) | Yes (2.16) | Yes (2.18) | Yes (2.18) | Yes |
| content | Yes (2.15) | Yes (3.1) | Yes (2.16) | Yes (2.18) | Yes (2.18) | Yes |
| content-complete | Yes (2.17) | No | Yes (3.1) | Yes (4.0) | Yes (4.0) | Yes |
| content-id | Yes (3.1) | No | Yes (3.2) | Yes (4.0) | Yes (4.0) | Yes |
| content-range | Yes (2.18) | Yes (3.1) | Yes (3.1) | Yes (4.0) | Yes (4.0) | Yes |
| enable-break-around-punctuation | No | Yes (4.0) | No | No | No | No |
| enable-selection | No | Yes (4.0) | No | No | No | No |
| initial-animation-step | Yes (2.17) | Yes (3.1) | Yes (2.18) | Yes (4.0) | Yes (4.0) | Yes |
| markdown-effect | Yes (3.1) | No | Yes (3.2) | Yes (4.0) | Yes (4.0) | Yes |
| markdown-style | Yes (2.15) | Yes (3.1) | Yes (2.16) | Yes (2.18) | Yes (2.18) | Yes |
| text-maxline | Yes (2.15) | Yes (3.1) | Yes (2.16) | Yes (2.18) | Yes (2.18) | Yes |
| text-selection | Yes (2.17) | Yes (3.1) | Yes (2.18) | Yes (4.0) | Yes (4.0) | Yes |
| typewriter-dynamic-height | Yes (2.17) | No | Yes (2.18) | Yes (4.0) | Yes (4.0) | Yes |
| typewriter-height-transition-duration | Yes (3.2) | No | Yes (3.2) | Yes (4.0) | Yes (4.0) | Yes |
| bindanimationStep | Yes (2.17) | No | Yes (2.18) | Yes (4.0) | Yes (4.0) | No |
| binddrawEnd | Yes (2.15) | No | Yes (2.16) | Yes (2.18) | Yes (2.18) | No |
| binddrawStart | Yes (2.15) | No | Yes (2.16) | Yes (2.18) | Yes (2.18) | No |
| bindimageTap | Yes (3.1) | No | Yes (3.2) | Yes (4.0) | Yes (4.0) | No |
| bindlink | Yes (2.15) | No | Yes (2.16) | Yes (2.18) | Yes (2.18) | No |
| bindoverflow | Yes (2.16) | No | Yes (4.0) | Yes (2.18) | Yes (2.18) | No |
| bindparseEnd | Yes (3.1) | No | Yes (3.2) | Yes (4.0) | Yes (4.0) | No |
| bindselectionchange | Yes (2.17) | No | Yes (3.1) | Yes (4.0) | Yes (4.0) | No |
| getCharIndexByPoint | Yes (4.0) | No | Yes (4.0) | No | No | No |
| getContent | Yes (2.17) | Yes (3.1) | Yes (2.18) | Yes (4.0) | Yes (4.0) | Yes |
| getImages | Yes (3.1) | No | Yes (3.2) | Yes (4.0) | Yes (4.0) | Yes |
| getParseResult | Yes (3.1) | Yes (4.0) | Yes (3.2) | Yes (4.0) | Yes (4.0) | Yes |
| getSelectedText | Yes (2.17) | Yes (3.1) | Yes (2.18) | Yes (4.0) | Yes (4.0) | Yes |
| pauseAnimation | Yes (2.17) | No | Yes (3.1) | Yes (4.0) | Yes (4.0) | Yes |
| resumeAnimation | Yes (2.17) | No | Yes (3.1) | Yes (4.0) | Yes (4.0) | Yes |
| setTextSelection | Yes (2.17) | Yes (3.1) | Yes (2.18) | Yes (4.0) | Yes (4.0) | Yes |
| boundingClientRect | Yes (2.15) | Yes (2.16) | Yes (1.0) | Yes (4.0) | Yes (4.0) | Yes |
| requestAccessibilityFocus | Yes (2.15) | No | Yes (2.18) | No | No | No |
| scrollIntoView | Yes (2.15) | Yes (2.17) | Yes (2.18) | Yes (4.0) | Yes (4.0) | Yes |

**`markdown`**

markdown

- **Web — Supported (version unknown):** Partial support; Alternate name: `x-markdown`; Requires the opt-in <code>@lynx-js/web-elements/XMarkdown</code> import and the <code>x-markdown</code> tag. Native Markdown attributes and events are only partially implemented.

**`allow-break-around-punctuation`**

<code>allow-break-around-punctuation</code>

**`animation-frame-rate`**

<code>animation-frame-rate</code>

**`animation-type`**

<code>animation-type</code>

**`animation-velocity`**

<code>animation-velocity</code>

**`content`**

<code>content</code>

**`content-complete`**

<code>content-complete</code>

**`content-id`**

<code>content-id</code>

**`content-range`**

<code>content-range</code>

**`enable-break-around-punctuation`**

<code>enable-break-around-punctuation</code>

**`enable-selection`**

<code>enable-selection</code>

**`initial-animation-step`**

<code>initial-animation-step</code>

**`markdown-effect`**

<code>markdown-effect</code>

**`markdown-style`**

<code>markdown-style</code>

**`text-maxline`**

<code>text-maxline</code>

**`text-selection`**

<code>text-selection</code>

**`typewriter-dynamic-height`**

<code>typewriter-dynamic-height</code>

**`typewriter-height-transition-duration`**

<code>typewriter-height-transition-duration</code>

**`bindanimationStep`**

<code>bindanimationStep</code>

- **Web — Not supported:** The Web component emits DOM events with a bind prefix; native Lynx event bindings are not implemented for these events.

**`binddrawEnd`**

<code>binddrawEnd</code>

- **Web — Not supported:** The Web component emits DOM events with a bind prefix; native Lynx event bindings are not implemented for these events.

**`binddrawStart`**

<code>binddrawStart</code>

- **Web — Not supported:** The Web component emits DOM events with a bind prefix; native Lynx event bindings are not implemented for these events.

**`bindimageTap`**

<code>bindimageTap</code>

- **Web — Not supported:** The Web component emits DOM events with a bind prefix; native Lynx event bindings are not implemented for these events.

**`bindlink`**

<code>bindlink</code>

- **Web — Not supported:** The Web component emits DOM events with a bind prefix; native Lynx event bindings are not implemented for these events.

**`bindoverflow`**

<code>bindoverflow</code>

- **Web — Not supported:** The Web component emits DOM events with a bind prefix; native Lynx event bindings are not implemented for these events.

**`bindparseEnd`**

<code>bindparseEnd</code>

- **Web — Not supported:** The Web component emits DOM events with a bind prefix; native Lynx event bindings are not implemented for these events.

**`bindselectionchange`**

<code>bindselectionchange</code>

- **Web — Not supported:** The Web component emits DOM events with a bind prefix; native Lynx event bindings are not implemented for these events.

**`getCharIndexByPoint`**

<code>getCharIndexByPoint</code>

**`getContent`**

<code>getContent</code>

**`getImages`**

<code>getImages</code>

**`getParseResult`**

<code>getParseResult</code>

**`getSelectedText`**

<code>getSelectedText</code>

**`pauseAnimation`**

<code>pauseAnimation</code>

**`resumeAnimation`**

<code>resumeAnimation</code>

**`setTextSelection`**

<code>setTextSelection</code>

**`boundingClientRect`**

<code>boundingClientRect</code>

**`requestAccessibilityFocus`**

<code>requestAccessibilityFocus</code>

**`scrollIntoView`**

<code>scrollIntoView</code>

