mirror of
https://github.com/benngaihk/Tiptap-UI-Kit.git
synced 2026-12-05 08:00:42 +00:00
编辑器交互(丝滑) - 工具栏状态跟随光标:useReactiveEditor 组合式函数(shallowRef + triggerRef, 绕过 Vue computed 值相等截断),16 个工具栏组件接入 - 输入防抖:分页计算 rAF 合帧 + 200ms 防抖,@update 事件防抖派发, 卸载/重建前 flush 不丢最后输入;共享 debounce 工具(src/utils/debounce.ts) - v-model 支持(HTML/JSON 双模式):监听器检测(ref<string>() 初值安全)、 回环短路缓存、协作模式守卫 - 修复:标题下拉失焦、字数统计光标移动重算、LinkBubbleMenu 深度遍历、 事件监听器泄漏、页数按内容/字体/容器尺寸自动重算 暗色模式与样式 - 修复 9 个组件暗色选择器(.dark 类 → data-theme 属性,44 处); setTheme 同步挂 .dark 类兜底 - 补齐 ::selection/caret-color、:focus-visible、prefers-reduced-motion、 color-scheme、暗色滚动条、下拉/浮层过渡动画 - 落地页 blur 滤镜动画改为 transform-only(原会卡死合成器) 包体积(gzip 1.4MB → ~88KB,-94%) - 修复 Vite 6 lib+ES 跳过 terser(自定义 libTerser 插件) - KaTeX/mammoth/docx/file-saver 改为 external + 动态导入 - version 档位(minimal/basic/advanced/premium)真正裁剪扩展; 组件默认 premium 保持 0.1.x 行为兼容 - 依赖重分类:antd 系转 peer、协作库转可选 peer;删除死依赖与 278 个误提交的 .d.ts 构建产物;demo 构建目录分离 AI 文档助手(用文字描述编写和修改文档) - documentTools:7 个结构化编辑工具(块索引 + 文本查找寻址、 结构边界哨兵防跨单元格假匹配、多匹配消歧、replaceAll 单事务) - runDocumentAgent:OpenAI function-calling 循环,6 家 provider 通用, 超时兜底、abort、编辑器销毁保护、历史概要去重 - AiChatPanel:右下角聊天面板,步骤实时展示、IME 安全回车、 features.aiChat 可关;工具集与循环公开导出供自定义集成 - 修复 anthropic/ollama 默认端点(原 anthropic key 会被发往 openai.com) DX 与文档 - README 重写对齐真实 API;AGENTS.md 更新;locale 浏览器语言自动检测; 字体列表跨平台化;5 套主题 CSS 随包发布;demo 刷新保持状态; API key 安全警示;测试 2 → 57 个 BREAKING CHANGE: ant-design-vue/@ant-design/icons-vue 转为 peer 依赖; 协作功能需自装 yjs/y-websocket/@tiptap/extension-collaboration*; 数学公式需自行 import 'katex/dist/katex.min.css';@update 事件防抖 200ms; version="basic"/"minimal" 现在真正裁剪扩展(表格/公式/AI 不加载)。 迁移指南见 README「Migrating to 0.2」。 Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
115 lines
3.5 KiB
TypeScript
115 lines
3.5 KiB
TypeScript
import { defineConfig, type Plugin } from 'vite'
|
|
import vue from '@vitejs/plugin-vue'
|
|
import dts from 'vite-plugin-dts'
|
|
import { resolve } from 'path'
|
|
import { minify as terserMinify } from 'terser'
|
|
|
|
// Vite skips its built-in terser pass for lib builds with ES format
|
|
// (see vite:terser renderChunk), so we minify explicitly here.
|
|
// This plugin is the single source of truth for JS minification of the
|
|
// published bundle (including drop_console) — do not duplicate these
|
|
// options in build.minify/build.terserOptions.
|
|
function libTerser(): Plugin {
|
|
return {
|
|
name: 'lib-terser',
|
|
apply: 'build',
|
|
enforce: 'post',
|
|
async renderChunk(code, _chunk, outputOptions) {
|
|
if (outputOptions.format !== 'es') return null
|
|
const result = await terserMinify(code, {
|
|
module: true,
|
|
compress: {
|
|
drop_console: true,
|
|
drop_debugger: true,
|
|
},
|
|
})
|
|
return result.code ? { code: result.code, map: null } : null
|
|
},
|
|
}
|
|
}
|
|
|
|
export default defineConfig({
|
|
plugins: [
|
|
vue(),
|
|
libTerser(),
|
|
dts({
|
|
insertTypesEntry: true,
|
|
outDir: 'dist',
|
|
rollupTypes: true, // Bundle all .d.ts into one file
|
|
logLevel: 'error', // Only show errors
|
|
strictOutput: false, // Don't fail on declaration errors
|
|
skipDiagnostics: true, // Skip type diagnostics to avoid vue-types issue
|
|
// Exclude files that use ant-design-vue Popover (causes vue-types path issues)
|
|
exclude: ['src/ai/shared/CustomAiPopover.vue', 'src/ai/shared/AiSuggestionPopover.vue'],
|
|
beforeWriteFile: (filePath, content) => {
|
|
// Filter out problematic type references
|
|
return { filePath, content };
|
|
},
|
|
}),
|
|
],
|
|
resolve: {
|
|
alias: {
|
|
'@': resolve(__dirname, 'src'),
|
|
},
|
|
},
|
|
publicDir: false,
|
|
build: {
|
|
// Modern browsers that support CSS nesting
|
|
target: ['es2022', 'chrome105', 'safari16', 'firefox110', 'edge105'],
|
|
lib: {
|
|
entry: resolve(__dirname, 'src/index.ts'),
|
|
name: 'TiptapUIKit',
|
|
formats: ['es'],
|
|
fileName: () => 'index.esm.js',
|
|
cssFileName: 'style',
|
|
},
|
|
// Kept truthy so CSS gets minified (build.cssMinify defaults to it).
|
|
// JS minification of the ES lib output is handled solely by the
|
|
// libTerser plugin above — vite:terser skips lib+ES chunks.
|
|
minify: 'esbuild',
|
|
// Never inline assets (e.g. KaTeX fonts) as base64 into CSS/JS
|
|
assetsInlineLimit: 0,
|
|
rollupOptions: {
|
|
external: [
|
|
'vue',
|
|
'@tiptap/vue-3',
|
|
'@tiptap/core',
|
|
'@tiptap/pm',
|
|
'@tiptap/starter-kit',
|
|
/^@tiptap\/.*/,
|
|
'ant-design-vue',
|
|
'@ant-design/icons-vue',
|
|
/^#\/.*/, // Internal APIs (collaboration, etc.)
|
|
'yjs',
|
|
'y-prosemirror',
|
|
'y-websocket',
|
|
/^y-.*/,
|
|
'lowlight',
|
|
/^prosemirror-.*/,
|
|
// Heavy optional features — dynamically imported, resolved from the
|
|
// consumer's node_modules and code-split by their bundler
|
|
'katex',
|
|
/^katex\/.*/,
|
|
'mammoth',
|
|
'docx',
|
|
'file-saver',
|
|
],
|
|
output: {
|
|
globals: {
|
|
vue: 'Vue',
|
|
},
|
|
assetFileNames: (assetInfo) => {
|
|
if (assetInfo.name === 'style.css') return 'style.css'
|
|
return assetInfo.name || 'asset'
|
|
},
|
|
},
|
|
},
|
|
cssCodeSplit: false,
|
|
},
|
|
// Define for license validation
|
|
define: {
|
|
__BUILD_TIME__: JSON.stringify(new Date().toISOString()),
|
|
__VERSION__: JSON.stringify(process.env.npm_package_version || '0.1.1'),
|
|
},
|
|
})
|