From 928903b497be174a5af46b851e81a7d2d30e1028 Mon Sep 17 00:00:00 2001
From: unanmed <1319491857@qq.com>
Date: Thu, 26 Nov 2026 17:04:54 +0800
Subject: [PATCH] =?UTF-8?q?docs:=20=E8=A1=A5=E5=85=85=E6=96=87=E5=AD=97=20?=
=?UTF-8?q?typer=20=E6=BC=94=E7=A4=BA?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../builtin-textcontenttyper-config-demo.tsx | 72 +++++++++++++++++
.../builtin-textcontenttyper-typing-demo.tsx | 80 +++++++++++++++++++
...builtin-textcontenttyper-wrapping-demo.tsx | 73 +++++++++++++++++
3 files changed, 225 insertions(+)
create mode 100644 docs/.vitepress/components/demos/ui/builtin-textcontenttyper-config-demo.tsx
create mode 100644 docs/.vitepress/components/demos/ui/builtin-textcontenttyper-typing-demo.tsx
create mode 100644 docs/.vitepress/components/demos/ui/builtin-textcontenttyper-wrapping-demo.tsx
diff --git a/docs/.vitepress/components/demos/ui/builtin-textcontenttyper-config-demo.tsx b/docs/.vitepress/components/demos/ui/builtin-textcontenttyper-config-demo.tsx
new file mode 100644
index 0000000..b71be79
--- /dev/null
+++ b/docs/.vitepress/components/demos/ui/builtin-textcontenttyper-config-demo.tsx
@@ -0,0 +1,72 @@
+import { Font } from '@motajs/render';
+import { defineComponent, markRaw } from 'vue';
+import { TextContent } from '../../../../../packages-user/client-base/src/components/textbox';
+import {
+ TextAlign,
+ TextContentTyper
+} from '../../../../../packages-user/client-base/src/components/textboxTyper';
+
+const TEXT = '字体与字号\n行高与对齐\n颜色来自 typer';
+
+const LEFT = markRaw(
+ new TextContentTyper({
+ font: new Font('Verdana', 18),
+ lineHeight: 8,
+ textAlign: TextAlign.Left,
+ fillStyle: '#e8f0ff'
+ })
+);
+
+const CENTER = markRaw(
+ new TextContentTyper({
+ font: new Font('Georgia', 18),
+ lineHeight: 12,
+ textAlign: TextAlign.Center,
+ fillStyle: '#7ee787'
+ })
+);
+
+const RIGHT = markRaw(
+ new TextContentTyper({
+ font: new Font('Courier New', 16),
+ lineHeight: 6,
+ textAlign: TextAlign.Right,
+ fillStyle: '#f2b84b'
+ })
+);
+
+// typer 配置:字体、字号、行高、对齐与填充色分别写在三个 typer 上
+export default defineComponent(() => {
+ return () => (
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ );
+});
diff --git a/docs/.vitepress/components/demos/ui/builtin-textcontenttyper-typing-demo.tsx b/docs/.vitepress/components/demos/ui/builtin-textcontenttyper-typing-demo.tsx
new file mode 100644
index 0000000..47dd102
--- /dev/null
+++ b/docs/.vitepress/components/demos/ui/builtin-textcontenttyper-typing-demo.tsx
@@ -0,0 +1,80 @@
+import { defineComponent, markRaw, nextTick, ref } from 'vue';
+import {
+ TextContent,
+ TextContentExpose
+} from '../../../../../packages-user/client-base/src/components/textbox';
+import { TextContentTyper } from '../../../../../packages-user/client-base/src/components/textboxTyper';
+
+const TYPER = markRaw(
+ new TextContentTyper({
+ interval: 80,
+ lineHeight: 6,
+ fillStyle: '#e8f0ff'
+ })
+);
+
+const TEXT =
+ '第一行:点击开始后逐字出现。\n' +
+ '[c=#f2b84b]第二行:interval 控制每个字的间隔。[/c]\n' +
+ '[w=8]等待八个字的打字时间后继续。\n' +
+ '[c=#7ee787]最后一行:可以随时立即显示全文。[/c]';
+
+// 打字演示:初始不开始,按按钮后才逐字显示;重播与立即显示都是真实方法
+export default defineComponent(() => {
+ const content = ref();
+ const started = ref(false);
+ const status = ref('等待开始');
+
+ const start = async () => {
+ if (!started.value) {
+ started.value = true;
+ await nextTick();
+ }
+ content.value?.retype();
+ };
+
+ const reveal = () => {
+ content.value?.showAll();
+ };
+
+ return () => (
+
+
+
+
+
+
+
+ {
+ if (started.value) status.value = '正在打字';
+ }}
+ onTypeEnd={() => {
+ if (started.value) status.value = '打字结束';
+ }}
+ />
+
+
+
+
+
+
+
+
+
+
+ );
+});
diff --git a/docs/.vitepress/components/demos/ui/builtin-textcontenttyper-wrapping-demo.tsx b/docs/.vitepress/components/demos/ui/builtin-textcontenttyper-wrapping-demo.tsx
new file mode 100644
index 0000000..b27b9c9
--- /dev/null
+++ b/docs/.vitepress/components/demos/ui/builtin-textcontenttyper-wrapping-demo.tsx
@@ -0,0 +1,73 @@
+import { Font } from '@motajs/render';
+import { defineComponent, markRaw } from 'vue';
+import { TextContent } from '../../../../../packages-user/client-base/src/components/textbox';
+import {
+ TextContentTyper,
+ WordBreak
+} from '../../../../../packages-user/client-base/src/components/textboxTyper';
+
+const TEXT =
+ 'alpha beta gamma Supercalifragilisticexpialidocious delta epsilon';
+
+const NONE = markRaw(
+ new TextContentTyper({
+ font: new Font('Verdana', 14),
+ lineHeight: 4,
+ wordBreak: WordBreak.None,
+ fillStyle: '#f2b84b'
+ })
+);
+
+const SPACE = markRaw(
+ new TextContentTyper({
+ font: new Font('Verdana', 14),
+ lineHeight: 4,
+ wordBreak: WordBreak.Space,
+ fillStyle: '#7ee787'
+ })
+);
+
+const ALL = markRaw(
+ new TextContentTyper({
+ font: new Font('Verdana', 14),
+ lineHeight: 4,
+ wordBreak: WordBreak.All,
+ fillStyle: '#58c4dd'
+ })
+);
+
+// 折行规则:None 一行到底,Space 在空格与 CJK 处折行,All 任意字符可折行
+export default defineComponent(() => {
+ return () => (
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ );
+});