docs(canvas): explain text tools and geometry gesture lifecycles

This commit is contained in:
2026-11-12 01:59:22 +08:00
parent 01c4a9d8c5
commit 838d3e5c46
8 changed files with 136 additions and 0 deletions
+10
View File
@@ -1,11 +1,21 @@
/**
* 图标目录数据与搜索入口。JSON保存名称、中文标签、关键词及分类等检索元数据;SVG路径另由图标加载器取得。
*/
import records from "./icon-catalog-data.json" with { type: "json" };
/** 分类展示顺序;common/all/other是搜索时有特殊含义的选项,其余按categories成员匹配。 */
export const iconCategories = [
["common", "常用"], ["all", "全部"], ["arrows", "箭头与导航"], ["people", "人物与表情"], ["office", "文件与办公"], ["media", "媒体与设计"], ["tech", "科技与设备"], ["business", "图表与商业"], ["nature", "自然与天气"], ["travel", "出行与地点"], ["shapes", "形状与符号"], ["other", "其他"],
] as const;
/** 导出静态记录数组供选择器统计与筛选,不在运行时下载整套图标路径。 */
export const iconCatalog = records;
/** 按图标name建Map供调用方直接定位记录;与目录共享记录对象,不复制或冻结内容。 */
export const iconsById = new Map(iconCatalog.map((icon) => [icon.name, icon]));
/** 来源过滤支持全部、Lucide和Tabler;分类与来源是独立条件。 */
export type IconSource = "all" | "lucide" | "tabler";
/** 去掉首尾空白、连字符、下划线及空白并转小写,再在名称+标签+关键词中做子串匹配。
* 筛选同时满足来源和分类;common看common标记,other指没有分类,all跳过对应限制。
* 保留目录原顺序,不计算相关性分数,也不限制结果数量;虚拟列表由调用方实现。 */
export function searchIcons(query: string, category = "all", source: IconSource = "all") {
const needle = query.trim().toLowerCase().replace(/[-_\s]/g, "");
return iconCatalog.filter((icon) => (source === "all" || icon.source === source)