Repository: graphif/project-graph Branch: master Commit: 2359b62de4de Files: 664 Total size: 3.0 MB Directory structure: gitextract_v1_e28b6/ ├── .cursor/ │ └── skills/ │ ├── create-keybind/ │ │ └── SKILL.md │ └── create-setting-item/ │ └── SKILL.md ├── .github/ │ ├── FUNDING.yml │ ├── ISSUE_TEMPLATE/ │ │ ├── config.yml │ │ └── no-issues.yml │ ├── copilot-instructions.md │ ├── scripts/ │ │ ├── enable-sourcemap.mjs │ │ ├── generate-changelog.mjs │ │ ├── generate-pkgbuild.mjs │ │ ├── set-tauri-features.mjs │ │ └── set-version.mjs │ └── workflows/ │ ├── nightly.yml │ ├── publish.yml │ ├── release.yml │ └── render-docs-svg.yml ├── .gitignore ├── .husky/ │ └── pre-commit ├── .lintstagedrc ├── .prettierignore ├── .prettierrc ├── .trae/ │ ├── documents/ │ │ ├── plan_20251223_165257.md │ │ ├── plan_20260101_170503.md │ │ ├── 为LineEdge添加虚线形态属性.md │ │ ├── 为RecentFilesWindow添加独立的隐私模式功能.md │ │ ├── 优化Tab键和反斜杠键创建节点的字体大小.md │ │ ├── 优化嫁接操作与添加反向操作.md │ │ ├── 优化文本节点渲染判断逻辑.md │ │ ├── 修复Ctrl+T快捷键只能触发一个功能的问题.md │ │ ├── 修复引用块转换时连线悬空问题.md │ │ ├── 全局快捷键重构方案.md │ │ ├── 在快捷键设置页面添加重置所有快捷键按钮.md │ │ ├── 实现 Section 的 isHidden 属性功能.md │ │ ├── 实现Section框大标题相机缩放阈值控制.md │ │ ├── 实现关闭软件前的未保存文件警告.md │ │ ├── 实现图片节点拖拽缩放功能.md │ │ ├── 实现引用块节点的精准连线定位.md │ │ ├── 实现快捷键开关功能.md │ │ ├── 实现搜索范围选项.md │ │ ├── 实现背景图片功能和背景管理器.md │ │ ├── 引用块节点精准连线定位功能问题记录.md │ │ ├── 文本节点自定义文字大小功能设计方案.md │ │ ├── 添加大标题遮罩透明度设置.md │ │ ├── 添加快捷键冲突检测和提醒功能.md │ │ └── 粘贴bug崩溃报告.txt │ └── skills/ │ ├── create-keybind/ │ │ └── SKILL.md │ └── create-setting-item/ │ └── SKILL.md ├── .vscode/ │ ├── extensions.json │ ├── launch.json │ ├── settings.json │ └── tasks.json ├── .zed/ │ └── settings.json ├── CODE_OF_CONDUCT.md ├── CONTRIBUTING.md ├── TODO.md ├── app/ │ ├── .browserslistrc │ ├── LICENSE │ ├── README.md │ ├── components.json │ ├── index.html │ ├── package.json │ ├── scripts/ │ │ ├── sync-locales.ts │ │ └── tauri_build.js │ ├── splash.html │ ├── src/ │ │ ├── App.tsx │ │ ├── DropWindowCover.tsx │ │ ├── ProjectTabs.tsx │ │ ├── assets/ │ │ │ └── versions.json │ │ ├── cli.tsx │ │ ├── components/ │ │ │ ├── context-menu-content.tsx │ │ │ ├── editor/ │ │ │ │ ├── editor-base-kit.tsx │ │ │ │ ├── plugins/ │ │ │ │ │ ├── align-base-kit.tsx │ │ │ │ │ ├── basic-blocks-base-kit.tsx │ │ │ │ │ ├── basic-blocks-kit.tsx │ │ │ │ │ ├── basic-marks-base-kit.tsx │ │ │ │ │ ├── basic-marks-kit.tsx │ │ │ │ │ ├── callout-base-kit.tsx │ │ │ │ │ ├── code-block-base-kit.tsx │ │ │ │ │ ├── code-block-kit.tsx │ │ │ │ │ ├── column-base-kit.tsx │ │ │ │ │ ├── comment-base-kit.tsx │ │ │ │ │ ├── comment-kit.tsx │ │ │ │ │ ├── date-base-kit.tsx │ │ │ │ │ ├── discussion-kit.tsx │ │ │ │ │ ├── fixed-toolbar-kit.tsx │ │ │ │ │ ├── floating-toolbar-kit.tsx │ │ │ │ │ ├── font-base-kit.tsx │ │ │ │ │ ├── font-kit.tsx │ │ │ │ │ ├── indent-base-kit.tsx │ │ │ │ │ ├── indent-kit.tsx │ │ │ │ │ ├── line-height-base-kit.tsx │ │ │ │ │ ├── link-base-kit.tsx │ │ │ │ │ ├── link-kit.tsx │ │ │ │ │ ├── list-base-kit.tsx │ │ │ │ │ ├── list-kit.tsx │ │ │ │ │ ├── markdown-kit.tsx │ │ │ │ │ ├── math-base-kit.tsx │ │ │ │ │ ├── math-kit.tsx │ │ │ │ │ ├── media-base-kit.tsx │ │ │ │ │ ├── mention-base-kit.tsx │ │ │ │ │ ├── suggestion-base-kit.tsx │ │ │ │ │ ├── suggestion-kit.tsx │ │ │ │ │ ├── table-base-kit.tsx │ │ │ │ │ ├── table-kit.tsx │ │ │ │ │ ├── toc-base-kit.tsx │ │ │ │ │ └── toggle-base-kit.tsx │ │ │ │ └── transforms.ts │ │ │ ├── key-tooltip.tsx │ │ │ ├── render-sub-windows.tsx │ │ │ ├── right-toolbar.tsx │ │ │ ├── theme-mode-switch.tsx │ │ │ ├── toolbar-content.tsx │ │ │ ├── ui/ │ │ │ │ ├── ai-node.tsx │ │ │ │ ├── ai-toolbar-button.tsx │ │ │ │ ├── alert-dialog.tsx │ │ │ │ ├── alert.tsx │ │ │ │ ├── align-toolbar-button.tsx │ │ │ │ ├── avatar.tsx │ │ │ │ ├── block-discussion.tsx │ │ │ │ ├── block-list-static.tsx │ │ │ │ ├── block-list.tsx │ │ │ │ ├── block-selection.tsx │ │ │ │ ├── block-suggestion.tsx │ │ │ │ ├── blockquote-node-static.tsx │ │ │ │ ├── blockquote-node.tsx │ │ │ │ ├── button.tsx │ │ │ │ ├── calendar.tsx │ │ │ │ ├── callout-node-static.tsx │ │ │ │ ├── callout-node.tsx │ │ │ │ ├── caption.tsx │ │ │ │ ├── card.tsx │ │ │ │ ├── checkbox.tsx │ │ │ │ ├── code-block-node-static.tsx │ │ │ │ ├── code-block-node.tsx │ │ │ │ ├── code-node-static.tsx │ │ │ │ ├── code-node.tsx │ │ │ │ ├── collapsible.tsx │ │ │ │ ├── column-node-static.tsx │ │ │ │ ├── column-node.tsx │ │ │ │ ├── command.tsx │ │ │ │ ├── comment-node-static.tsx │ │ │ │ ├── comment-node.tsx │ │ │ │ ├── comment-toolbar-button.tsx │ │ │ │ ├── comment.tsx │ │ │ │ ├── context-menu.tsx │ │ │ │ ├── date-node-static.tsx │ │ │ │ ├── date-node.tsx │ │ │ │ ├── dialog.tsx │ │ │ │ ├── dropdown-menu.tsx │ │ │ │ ├── editor-static.tsx │ │ │ │ ├── editor.tsx │ │ │ │ ├── emoji-node.tsx │ │ │ │ ├── emoji-toolbar-button.tsx │ │ │ │ ├── equation-node-static.tsx │ │ │ │ ├── equation-node.tsx │ │ │ │ ├── equation-toolbar-button.tsx │ │ │ │ ├── export-toolbar-button.tsx │ │ │ │ ├── field.tsx │ │ │ │ ├── file-chooser.tsx │ │ │ │ ├── fixed-toolbar-buttons.tsx │ │ │ │ ├── fixed-toolbar.tsx │ │ │ │ ├── floating-toolbar-buttons.tsx │ │ │ │ ├── floating-toolbar.tsx │ │ │ │ ├── font-color-toolbar-button.tsx │ │ │ │ ├── font-size-toolbar-button.tsx │ │ │ │ ├── heading-node-static.tsx │ │ │ │ ├── heading-node.tsx │ │ │ │ ├── highlight-node-static.tsx │ │ │ │ ├── highlight-node.tsx │ │ │ │ ├── history-toolbar-button.tsx │ │ │ │ ├── hr-node-static.tsx │ │ │ │ ├── hr-node.tsx │ │ │ │ ├── import-toolbar-button.tsx │ │ │ │ ├── indent-toolbar-button.tsx │ │ │ │ ├── inline-combobox.tsx │ │ │ │ ├── input.tsx │ │ │ │ ├── insert-toolbar-button.tsx │ │ │ │ ├── kbd-node-static.tsx │ │ │ │ ├── kbd-node.tsx │ │ │ │ ├── key-bind.tsx │ │ │ │ ├── line-height-toolbar-button.tsx │ │ │ │ ├── link-node-static.tsx │ │ │ │ ├── link-node.tsx │ │ │ │ ├── link-toolbar-button.tsx │ │ │ │ ├── link-toolbar.tsx │ │ │ │ ├── list-toolbar-button.tsx │ │ │ │ ├── mark-toolbar-button.tsx │ │ │ │ ├── markdown.tsx │ │ │ │ ├── media-audio-node-static.tsx │ │ │ │ ├── media-audio-node.tsx │ │ │ │ ├── media-file-node-static.tsx │ │ │ │ ├── media-file-node.tsx │ │ │ │ ├── media-image-node-static.tsx │ │ │ │ ├── media-image-node.tsx │ │ │ │ ├── media-toolbar-button.tsx │ │ │ │ ├── media-toolbar.tsx │ │ │ │ ├── media-video-node-static.tsx │ │ │ │ ├── media-video-node.tsx │ │ │ │ ├── mention-node-static.tsx │ │ │ │ ├── mention-node.tsx │ │ │ │ ├── menubar.tsx │ │ │ │ ├── mode-toolbar-button.tsx │ │ │ │ ├── more-toolbar-button.tsx │ │ │ │ ├── paragraph-node-static.tsx │ │ │ │ ├── paragraph-node.tsx │ │ │ │ ├── popover.tsx │ │ │ │ ├── progress.tsx │ │ │ │ ├── resize-handle.tsx │ │ │ │ ├── select.tsx │ │ │ │ ├── separator.tsx │ │ │ │ ├── sheet.tsx │ │ │ │ ├── sidebar.tsx │ │ │ │ ├── skeleton.tsx │ │ │ │ ├── slider.tsx │ │ │ │ ├── sonner.tsx │ │ │ │ ├── suggestion-node-static.tsx │ │ │ │ ├── suggestion-node.tsx │ │ │ │ ├── suggestion-toolbar-button.tsx │ │ │ │ ├── switch.tsx │ │ │ │ ├── table-icons.tsx │ │ │ │ ├── table-node-static.tsx │ │ │ │ ├── table-node.tsx │ │ │ │ ├── table-toolbar-button.tsx │ │ │ │ ├── tabs.tsx │ │ │ │ ├── textarea.tsx │ │ │ │ ├── toc-node-static.tsx │ │ │ │ ├── toc-node.tsx │ │ │ │ ├── toggle-node-static.tsx │ │ │ │ ├── toggle-node.tsx │ │ │ │ ├── toggle-toolbar-button.tsx │ │ │ │ ├── toolbar.tsx │ │ │ │ ├── tooltip.tsx │ │ │ │ ├── tree.tsx │ │ │ │ └── turn-into-toolbar-button.tsx │ │ │ ├── vditor-panel.tsx │ │ │ └── welcome-page.tsx │ │ ├── core/ │ │ │ ├── Project.tsx │ │ │ ├── algorithm/ │ │ │ │ ├── arrayFunctions.tsx │ │ │ │ ├── geometry/ │ │ │ │ │ ├── README.md │ │ │ │ │ └── convexHull.tsx │ │ │ │ ├── numberFunctions.tsx │ │ │ │ ├── random.tsx │ │ │ │ └── setFunctions.tsx │ │ │ ├── fileSystemProvider/ │ │ │ │ ├── FileSystemProviderDraft.tsx │ │ │ │ └── FileSystemProviderFile.tsx │ │ │ ├── interfaces/ │ │ │ │ └── Service.tsx │ │ │ ├── loadAllServices.tsx │ │ │ ├── plugin/ │ │ │ │ ├── PluginCodeParseData.tsx │ │ │ │ ├── PluginWorker.tsx │ │ │ │ ├── README.md │ │ │ │ ├── UserScriptsManager.tsx │ │ │ │ ├── apis.tsx │ │ │ │ └── types.tsx │ │ │ ├── render/ │ │ │ │ ├── 3d/ │ │ │ │ │ └── README.md │ │ │ │ ├── canvas2d/ │ │ │ │ │ ├── README.md │ │ │ │ │ ├── basicRenderer/ │ │ │ │ │ │ ├── ImageRenderer.tsx │ │ │ │ │ │ ├── curveRenderer.tsx │ │ │ │ │ │ ├── shapeRenderer.tsx │ │ │ │ │ │ ├── svgRenderer.tsx │ │ │ │ │ │ └── textRenderer.tsx │ │ │ │ │ ├── controllerRenderer/ │ │ │ │ │ │ ├── README.md │ │ │ │ │ │ └── drawingRenderer.tsx │ │ │ │ │ ├── debugRender.tsx │ │ │ │ │ ├── entityRenderer/ │ │ │ │ │ │ ├── CollisionBoxRenderer.tsx │ │ │ │ │ │ ├── EntityDetailsButtonRenderer.tsx │ │ │ │ │ │ ├── EntityRenderer.tsx │ │ │ │ │ │ ├── ReferenceBlockRenderer.tsx │ │ │ │ │ │ ├── edge/ │ │ │ │ │ │ │ ├── EdgeRenderer.tsx │ │ │ │ │ │ │ ├── EdgeRendererClass.tsx │ │ │ │ │ │ │ └── concrete/ │ │ │ │ │ │ │ ├── StraightEdgeRenderer.tsx │ │ │ │ │ │ │ ├── SymmetryCurveEdgeRenderer.tsx │ │ │ │ │ │ │ └── VerticalPolyEdgeRenderer.tsx │ │ │ │ │ │ ├── multiTargetUndirectedEdge/ │ │ │ │ │ │ │ └── MultiTargetUndirectedEdgeRenderer.tsx │ │ │ │ │ │ ├── section/ │ │ │ │ │ │ │ └── SectionRenderer.tsx │ │ │ │ │ │ ├── svgNode/ │ │ │ │ │ │ │ └── SvgNodeRenderer.tsx │ │ │ │ │ │ ├── textNode/ │ │ │ │ │ │ │ └── TextNodeRenderer.tsx │ │ │ │ │ │ └── urlNode/ │ │ │ │ │ │ └── urlNodeRenderer.tsx │ │ │ │ │ ├── renderer.tsx │ │ │ │ │ └── utilsRenderer/ │ │ │ │ │ ├── RenderUtils.tsx │ │ │ │ │ ├── WorldRenderUtils.tsx │ │ │ │ │ ├── backgroundRenderer.tsx │ │ │ │ │ ├── globalMaskRenderer.tsx │ │ │ │ │ └── searchContentHighlightRenderer.tsx │ │ │ │ ├── domElement/ │ │ │ │ │ ├── RectangleElement.tsx │ │ │ │ │ └── inputElement.tsx │ │ │ │ └── svg/ │ │ │ │ ├── README.md │ │ │ │ └── SvgUtils.tsx │ │ │ ├── service/ │ │ │ │ ├── AssetsRepository.tsx │ │ │ │ ├── FeatureFlags.tsx │ │ │ │ ├── GlobalMenu.tsx │ │ │ │ ├── QuickSettingsManager.tsx │ │ │ │ ├── Settings.tsx │ │ │ │ ├── SettingsIcons.tsx │ │ │ │ ├── SubWindow.tsx │ │ │ │ ├── Telemetry.tsx │ │ │ │ ├── Themes.tsx │ │ │ │ ├── Tourials.tsx │ │ │ │ ├── UserState.tsx │ │ │ │ ├── controlService/ │ │ │ │ │ ├── DirectionKeyUtilsEngine/ │ │ │ │ │ │ └── directionKeyUtilsEngine.tsx │ │ │ │ │ ├── MouseLocation.tsx │ │ │ │ │ ├── autoLayoutEngine/ │ │ │ │ │ │ ├── autoLayoutFastTreeMode.tsx │ │ │ │ │ │ └── mainTick.tsx │ │ │ │ │ ├── controller/ │ │ │ │ │ │ ├── Controller.tsx │ │ │ │ │ │ ├── ControllerClass.tsx │ │ │ │ │ │ └── concrete/ │ │ │ │ │ │ ├── ControllerAssociationReshape.tsx │ │ │ │ │ │ ├── ControllerCamera/ │ │ │ │ │ │ │ └── mac.tsx │ │ │ │ │ │ ├── ControllerCamera.tsx │ │ │ │ │ │ ├── ControllerContextMenu.tsx │ │ │ │ │ │ ├── ControllerCutting.tsx │ │ │ │ │ │ ├── ControllerEdgeEdit.tsx │ │ │ │ │ │ ├── ControllerEntityClickSelectAndMove.tsx │ │ │ │ │ │ ├── ControllerEntityCreate.tsx │ │ │ │ │ │ ├── ControllerEntityLayerMoving.tsx │ │ │ │ │ │ ├── ControllerEntityResize.tsx │ │ │ │ │ │ ├── ControllerImageScale.tsx │ │ │ │ │ │ ├── ControllerNodeConnection.tsx │ │ │ │ │ │ ├── ControllerNodeEdit.tsx │ │ │ │ │ │ ├── ControllerPenStrokeControl.tsx │ │ │ │ │ │ ├── ControllerPenStrokeDrawing.tsx │ │ │ │ │ │ ├── ControllerRectangleSelect.tsx │ │ │ │ │ │ ├── ControllerSectionEdit.tsx │ │ │ │ │ │ ├── README.md │ │ │ │ │ │ └── utilsControl.tsx │ │ │ │ │ ├── keyboardOnlyEngine/ │ │ │ │ │ │ ├── README.md │ │ │ │ │ │ ├── keyboardOnlyDirectionController.tsx │ │ │ │ │ │ ├── keyboardOnlyEngine.tsx │ │ │ │ │ │ ├── keyboardOnlyGraphEngine.tsx │ │ │ │ │ │ ├── keyboardOnlyTreeEngine.tsx │ │ │ │ │ │ ├── newTargetLocationSelector.tsx │ │ │ │ │ │ └── selectChangeEngine.tsx │ │ │ │ │ ├── rectangleSelectEngine/ │ │ │ │ │ │ └── rectangleSelectEngine.tsx │ │ │ │ │ ├── shortcutKeysEngine/ │ │ │ │ │ │ ├── GlobalShortcutManager.tsx │ │ │ │ │ │ ├── KeyBinds.tsx │ │ │ │ │ │ ├── KeyBindsUI.tsx │ │ │ │ │ │ ├── ShortcutKeyFixer.tsx │ │ │ │ │ │ └── shortcutKeysRegister.tsx │ │ │ │ │ └── stageMouseInteractionCore/ │ │ │ │ │ └── stageMouseInteractionCore.tsx │ │ │ │ ├── dataFileService/ │ │ │ │ │ ├── AutoSaveBackupService.tsx │ │ │ │ │ ├── RecentFileManager.tsx │ │ │ │ │ └── StartFilesManager.tsx │ │ │ │ ├── dataGenerateService/ │ │ │ │ │ ├── autoComputeEngine/ │ │ │ │ │ │ ├── AutoComputeUtils.tsx │ │ │ │ │ │ ├── functions/ │ │ │ │ │ │ │ ├── compareLogic.tsx │ │ │ │ │ │ │ ├── mathLogic.tsx │ │ │ │ │ │ │ ├── nodeLogic.tsx │ │ │ │ │ │ │ ├── programLogic.tsx │ │ │ │ │ │ │ └── stringLogic.tsx │ │ │ │ │ │ ├── logicNodeNameEnum.tsx │ │ │ │ │ │ └── mainTick.tsx │ │ │ │ │ ├── crossFileContentQuery.tsx │ │ │ │ │ ├── dataTransferEngine/ │ │ │ │ │ │ └── dataTransferEngine.tsx │ │ │ │ │ ├── generateFromFolderEngine/ │ │ │ │ │ │ └── GenerateFromFolderEngine.tsx │ │ │ │ │ ├── generateScreenshot.tsx │ │ │ │ │ ├── stageExportEngine/ │ │ │ │ │ │ ├── BaseExporter.tsx │ │ │ │ │ │ ├── MarkdownExporter.tsx │ │ │ │ │ │ ├── MermaidExporter.tsx │ │ │ │ │ │ ├── PlainTextExporter.tsx │ │ │ │ │ │ ├── StageExportPng.tsx │ │ │ │ │ │ ├── StageExportSvg.tsx │ │ │ │ │ │ ├── TabExporter.tsx │ │ │ │ │ │ └── stageExportEngine.tsx │ │ │ │ │ └── stageImportEngine/ │ │ │ │ │ ├── BaseImporter.tsx │ │ │ │ │ ├── GraphImporter.tsx │ │ │ │ │ ├── MarkdownImporter.tsx │ │ │ │ │ ├── MermaidImporter.tsx │ │ │ │ │ ├── TreeImporter.tsx │ │ │ │ │ └── stageImportEngine.tsx │ │ │ │ ├── dataManageService/ │ │ │ │ │ ├── ComplexityDetector.tsx │ │ │ │ │ ├── aiEngine/ │ │ │ │ │ │ ├── AIEngine.tsx │ │ │ │ │ │ └── AITools.tsx │ │ │ │ │ ├── colorSmartTools.tsx │ │ │ │ │ ├── connectNodeSmartTools.tsx │ │ │ │ │ ├── contentSearchEngine/ │ │ │ │ │ │ └── contentSearchEngine.tsx │ │ │ │ │ ├── copyEngine/ │ │ │ │ │ │ ├── VirtualClipboard.tsx │ │ │ │ │ │ ├── copyEngine.tsx │ │ │ │ │ │ ├── copyEngineImage.tsx │ │ │ │ │ │ ├── copyEngineText.tsx │ │ │ │ │ │ ├── copyEngineUtils.tsx │ │ │ │ │ │ └── stringValidTools.tsx │ │ │ │ │ ├── dragFileIntoStageEngine/ │ │ │ │ │ │ └── dragFileIntoStageEngine.tsx │ │ │ │ │ └── textNodeSmartTools.tsx │ │ │ │ └── feedbackService/ │ │ │ │ ├── ColorManager.tsx │ │ │ │ ├── SoundService.tsx │ │ │ │ ├── effectEngine/ │ │ │ │ │ ├── README.md │ │ │ │ │ ├── concrete/ │ │ │ │ │ │ ├── CircleChangeRadiusEffect.tsx │ │ │ │ │ │ ├── CircleFlameEffect.tsx │ │ │ │ │ │ ├── EdgeCutEffect.tsx │ │ │ │ │ │ ├── EntityAlignEffect.tsx │ │ │ │ │ │ ├── EntityCreateFlashEffect.tsx │ │ │ │ │ │ ├── EntityDashTipEffect.tsx │ │ │ │ │ │ ├── EntityJumpMoveEffect.tsx │ │ │ │ │ │ ├── EntityShakeEffect.tsx │ │ │ │ │ │ ├── EntityShrinkEffect.tsx │ │ │ │ │ │ ├── ExplodeDashEffect.tsx │ │ │ │ │ │ ├── LineCuttingEffect.tsx │ │ │ │ │ │ ├── LineEffect.tsx │ │ │ │ │ │ ├── MouseTipFeedbackEffect.tsx │ │ │ │ │ │ ├── NodeMoveShadowEffect.tsx │ │ │ │ │ │ ├── PenStrokeDeletedEffect.tsx │ │ │ │ │ │ ├── README.md │ │ │ │ │ │ ├── RectangleLittleNoteEffect.tsx │ │ │ │ │ │ ├── RectangleNoteEffect.tsx │ │ │ │ │ │ ├── RectangleNoteReversedEffect.tsx │ │ │ │ │ │ ├── RectanglePushInEffect.tsx │ │ │ │ │ │ ├── RectangleRenderEffect.tsx │ │ │ │ │ │ ├── RectangleSlideEffect.tsx │ │ │ │ │ │ ├── RectangleSplitTwoPartEffect.tsx │ │ │ │ │ │ ├── TextRaiseEffectLocated.tsx │ │ │ │ │ │ ├── ViewFlashEffect.tsx │ │ │ │ │ │ └── ViewOutlineFlashEffect.tsx │ │ │ │ │ ├── effectElements/ │ │ │ │ │ │ └── effectParticle.tsx │ │ │ │ │ ├── effectMachine.tsx │ │ │ │ │ ├── effectObject.tsx │ │ │ │ │ └── mathTools/ │ │ │ │ │ ├── README.md │ │ │ │ │ ├── animateFunctions.tsx │ │ │ │ │ ├── easings.tsx │ │ │ │ │ └── rateFunctions.tsx │ │ │ │ └── stageStyle/ │ │ │ │ ├── README.md │ │ │ │ ├── StageStyleManager.tsx │ │ │ │ └── stageStyle.tsx │ │ │ └── stage/ │ │ │ ├── Camera.tsx │ │ │ ├── Canvas.tsx │ │ │ ├── ProjectUpgrader.tsx │ │ │ ├── stageManager/ │ │ │ │ ├── StageHistoryManager.tsx │ │ │ │ ├── StageManager.tsx │ │ │ │ ├── basicMethods/ │ │ │ │ │ ├── GraphMethods.tsx │ │ │ │ │ ├── PenStrokeMethods.tsx │ │ │ │ │ └── SectionMethods.tsx │ │ │ │ └── concreteMethods/ │ │ │ │ ├── LayoutManager.tsx │ │ │ │ ├── README.md │ │ │ │ ├── SectionCollisionSolver.tsx │ │ │ │ ├── StageAutoAlignManager.tsx │ │ │ │ ├── StageDeleteManager.tsx │ │ │ │ ├── StageEntityMoveManager.tsx │ │ │ │ ├── StageManagerUtils.tsx │ │ │ │ ├── StageMultiTargetEdgeMove.tsx │ │ │ │ ├── StageNodeAdder.tsx │ │ │ │ ├── StageNodeConnector.tsx │ │ │ │ ├── StageObjectColorManager.tsx │ │ │ │ ├── StageObjectSelectCounter.tsx │ │ │ │ ├── StageReferenceManager.tsx │ │ │ │ ├── StageSectionInOutManager.tsx │ │ │ │ ├── StageSectionPackManager.tsx │ │ │ │ ├── StageTagManager.tsx │ │ │ │ └── stageNodeRotate.tsx │ │ │ └── stageObject/ │ │ │ ├── README.md │ │ │ ├── abstract/ │ │ │ │ ├── Association.tsx │ │ │ │ ├── ConnectableEntity.tsx │ │ │ │ ├── StageEntity.tsx │ │ │ │ ├── StageObject.tsx │ │ │ │ └── StageObjectInterface.tsx │ │ │ ├── association/ │ │ │ │ ├── CubicCatmullRomSplineEdge.tsx │ │ │ │ ├── Edge.tsx │ │ │ │ ├── EdgeCollisionBoxGetter.tsx │ │ │ │ ├── LineEdge.tsx │ │ │ │ └── MutiTargetUndirectedEdge.tsx │ │ │ ├── collisionBox/ │ │ │ │ └── collisionBox.tsx │ │ │ ├── entity/ │ │ │ │ ├── ConnectPoint.tsx │ │ │ │ ├── ImageNode.tsx │ │ │ │ ├── PenStroke.tsx │ │ │ │ ├── ReferenceBlockNode.tsx │ │ │ │ ├── Section.tsx │ │ │ │ ├── SvgNode.tsx │ │ │ │ ├── TextNode.tsx │ │ │ │ └── UrlNode.tsx │ │ │ └── tools/ │ │ │ └── entityDetailsManager.tsx │ │ ├── css/ │ │ │ ├── index.css │ │ │ └── markdown.css │ │ ├── examples/ │ │ │ └── tauri-global-shortcut-guide.md │ │ ├── hooks/ │ │ │ ├── use-debounce.ts │ │ │ ├── use-mobile.ts │ │ │ └── use-mounted.ts │ │ ├── locales/ │ │ │ ├── README.md │ │ │ ├── en.yml │ │ │ ├── id.yml │ │ │ ├── zh_CN.yml │ │ │ ├── zh_TW.yml │ │ │ └── zh_TWC.yml │ │ ├── main.tsx │ │ ├── state.tsx │ │ ├── sub/ │ │ │ ├── AIToolsWindow.tsx │ │ │ ├── AIWindow.tsx │ │ │ ├── AttachmentsWindow.tsx │ │ │ ├── AutoCompleteWindow.tsx │ │ │ ├── AutoComputeWindow.tsx │ │ │ ├── BackgroundManagerWindow.tsx │ │ │ ├── ColorPaletteWindow.tsx │ │ │ ├── ColorWindow.tsx │ │ │ ├── ExportPngWindow.tsx │ │ │ ├── FindWindow.tsx │ │ │ ├── GenerateNodeWindow.tsx │ │ │ ├── KeyboardRecentFilesWindow.tsx │ │ │ ├── LoginWindow.tsx │ │ │ ├── NewExportPngWindow.tsx │ │ │ ├── NodeDetailsWindow.tsx │ │ │ ├── OnboardingWindow.tsx │ │ │ ├── RecentFilesWindow.tsx │ │ │ ├── ReferencesWindow.tsx │ │ │ ├── SettingsWindow/ │ │ │ │ ├── about.tsx │ │ │ │ ├── appearance/ │ │ │ │ │ ├── effects.tsx │ │ │ │ │ ├── index.tsx │ │ │ │ │ └── sounds.tsx │ │ │ │ ├── assets/ │ │ │ │ │ └── font.css │ │ │ │ ├── credits.tsx │ │ │ │ ├── index.tsx │ │ │ │ ├── keybinds.tsx │ │ │ │ ├── keybindsGlobal.tsx │ │ │ │ ├── quick-settings.tsx │ │ │ │ ├── settings.tsx │ │ │ │ └── themes/ │ │ │ │ ├── editor.tsx │ │ │ │ └── index.tsx │ │ │ ├── TagWindow.tsx │ │ │ ├── TestWindow.tsx │ │ │ └── UserWindow.tsx │ │ ├── themes/ │ │ │ ├── dark-blue.pg-theme │ │ │ ├── dark.pg-theme │ │ │ ├── light.pg-theme │ │ │ ├── macaron.pg-theme │ │ │ ├── morandi.pg-theme │ │ │ └── park.pg-theme │ │ ├── types/ │ │ │ ├── cursors.tsx │ │ │ ├── directions.tsx │ │ │ ├── metadata.tsx │ │ │ └── node.tsx │ │ ├── utils/ │ │ │ ├── base64.tsx │ │ │ ├── cn.tsx │ │ │ ├── dateChecker.tsx │ │ │ ├── emacs.tsx │ │ │ ├── externalOpen.tsx │ │ │ ├── font.tsx │ │ │ ├── imageExport.tsx │ │ │ ├── keyboardFunctions.tsx │ │ │ ├── markdownParse.tsx │ │ │ ├── otherApi.tsx │ │ │ ├── path.tsx │ │ │ ├── pathString.tsx │ │ │ ├── platform.tsx │ │ │ ├── sleep.tsx │ │ │ ├── store.tsx │ │ │ ├── updater.tsx │ │ │ ├── xml.tsx │ │ │ └── yaml.tsx │ │ └── vite-env.d.ts │ ├── src-tauri/ │ │ ├── .gitignore │ │ ├── Cargo.toml │ │ ├── build.rs │ │ ├── capabilities/ │ │ │ ├── default.json │ │ │ └── desktop.json │ │ ├── gen/ │ │ │ └── android/ │ │ │ ├── .editorconfig │ │ │ ├── .gitignore │ │ │ ├── app/ │ │ │ │ ├── .gitignore │ │ │ │ ├── build.gradle.kts │ │ │ │ ├── proguard-rules.pro │ │ │ │ └── src/ │ │ │ │ └── main/ │ │ │ │ ├── AndroidManifest.xml │ │ │ │ ├── java/ │ │ │ │ │ └── liren/ │ │ │ │ │ └── project_graph/ │ │ │ │ │ └── MainActivity.kt │ │ │ │ └── res/ │ │ │ │ ├── drawable/ │ │ │ │ │ └── ic_launcher_background.xml │ │ │ │ ├── drawable-v24/ │ │ │ │ │ └── ic_launcher_foreground.xml │ │ │ │ ├── layout/ │ │ │ │ │ └── activity_main.xml │ │ │ │ ├── value-night/ │ │ │ │ │ └── styles.xml │ │ │ │ ├── values/ │ │ │ │ │ ├── colors.xml │ │ │ │ │ ├── strings.xml │ │ │ │ │ └── styles.xml │ │ │ │ └── xml/ │ │ │ │ └── file_paths.xml │ │ │ ├── build.gradle.kts │ │ │ ├── buildSrc/ │ │ │ │ ├── build.gradle.kts │ │ │ │ └── src/ │ │ │ │ └── main/ │ │ │ │ └── java/ │ │ │ │ └── liren/ │ │ │ │ └── project_graph/ │ │ │ │ └── kotlin/ │ │ │ │ ├── BuildTask.kt │ │ │ │ └── RustPlugin.kt │ │ │ ├── gradle/ │ │ │ │ └── wrapper/ │ │ │ │ ├── gradle-wrapper.jar │ │ │ │ └── gradle-wrapper.properties │ │ │ ├── gradle.properties │ │ │ ├── gradlew │ │ │ ├── gradlew.bat │ │ │ ├── keystore.properties │ │ │ └── settings.gradle │ │ ├── icons/ │ │ │ └── icon.icns │ │ ├── nsis/ │ │ │ └── installer.nsh │ │ ├── src/ │ │ │ ├── cmd/ │ │ │ │ ├── device.rs │ │ │ │ ├── fs.rs │ │ │ │ └── mod.rs │ │ │ ├── lib.rs │ │ │ └── main.rs │ │ └── tauri.conf.json │ ├── tsconfig.json │ ├── tsconfig.node.json │ ├── vite-plugins/ │ │ └── i18n-auto-tw.ts │ └── vite.config.ts ├── config.xlings ├── docs-pg/ │ ├── Project Graph v2.json │ ├── ProjectGraph决策日志.json │ ├── ProjectGraph开发进程图.json │ ├── ProjectGraph开发进程图.prg │ ├── ProjectGraph继承体系.json │ ├── ProjectGraph项目架构.json │ ├── README_FOR_AI.md │ ├── issue分类.json │ └── 服务器.prg ├── eslint.config.js ├── nx.json ├── package.json ├── packages/ │ ├── api/ │ │ ├── .npmignore │ │ ├── LICENSE │ │ ├── package.json │ │ ├── src/ │ │ │ ├── apis/ │ │ │ │ ├── camera.ts │ │ │ │ ├── controller.ts │ │ │ │ └── dialog.ts │ │ │ ├── index.ts │ │ │ └── types.ts │ │ └── tsconfig.json │ ├── data-structures/ │ │ ├── .gitignore │ │ ├── .npmignore │ │ ├── LICENSE │ │ ├── package.json │ │ ├── src/ │ │ │ ├── Cache.ts │ │ │ ├── Color.ts │ │ │ ├── LimitLengthQueue.ts │ │ │ ├── MonoStack.ts │ │ │ ├── ProgressNumber.ts │ │ │ ├── Queue.ts │ │ │ ├── Stack.ts │ │ │ ├── Vector.ts │ │ │ └── index.ts │ │ ├── tests/ │ │ │ ├── Cache.test.ts │ │ │ ├── Color.test.ts │ │ │ ├── LimitLengthQueue.test.ts │ │ │ ├── MonoStack.test.ts │ │ │ ├── ProgressNumber.test.ts │ │ │ ├── Queue.test.ts │ │ │ ├── Stack.test.ts │ │ │ └── Vector.test.ts │ │ ├── tsconfig.json │ │ └── tsdown.config.ts │ ├── serializer/ │ │ ├── .gitignore │ │ ├── .npmignore │ │ ├── LICENSE │ │ ├── README.md │ │ ├── package.json │ │ ├── src/ │ │ │ └── index.ts │ │ ├── tests/ │ │ │ └── index.test.ts │ │ └── tsconfig.json │ └── shapes/ │ ├── .gitignore │ ├── .npmignore │ ├── LICENSE │ ├── package.json │ ├── src/ │ │ ├── Circle.ts │ │ ├── CubicCatmullRomSpline.ts │ │ ├── Curve.ts │ │ ├── Line.ts │ │ ├── Rectangle.ts │ │ ├── Shape.ts │ │ └── index.ts │ ├── tests/ │ │ ├── Circle.test.ts │ │ ├── CubicCatmullRomSpline.test.ts │ │ ├── Curve.test.ts │ │ ├── Line.test.ts │ │ └── Rectangle.test.ts │ ├── tsconfig.json │ └── tsdown.config.ts ├── patches/ │ └── typescript.patch ├── pnpm-workspace.yaml ├── utils/ │ ├── add-ts-nocheck.ts │ ├── class2namespace.ts │ ├── generate-service-docs.sh │ ├── lines.sh │ └── relative2alias.ts ├── vitest.config.ts └── 文本节点功能分析.md ================================================ FILE CONTENTS ================================================ ================================================ FILE: .cursor/skills/create-keybind/SKILL.md ================================================ --- name: create-keybind description: 指导如何在 Project Graph 项目中创建新的快捷键。当用户需要添加新的快捷键、修改快捷键绑定或需要了解快捷键系统的实现方式时使用此技能。 --- # 创建新的快捷键功能 本技能指导如何在 Project Graph 项目中创建新的快捷键。 ## 创建快捷键的步骤 创建新快捷键需要完成以下 4 个步骤: ### 1. 在 shortcutKeysRegister.tsx 中注册快捷键 在 `app/src/core/service/controlService/shortcutKeysEngine/shortcutKeysRegister.tsx` 文件的 `allKeyBinds` 数组中添加新的快捷键定义。 **快捷键定义结构:** ```typescript { id: "uniqueKeybindId", // 唯一标识符,使用驼峰命名 defaultKey: "A-S-m", // 默认快捷键组合 onPress: (project?: Project) => void, // 按下时的回调函数 onRelease?: (project?: Project) => void, // 松开时的回调函数(可选) isGlobal?: boolean, // 是否为全局快捷键(可选,默认 false) isUI?: boolean, // 是否为 UI 级别快捷键(可选,默认 false) defaultEnabled?: boolean, // 默认是否启用(可选,默认 true) } ``` **快捷键键位格式:** - `C-` = Ctrl (Windows/Linux) 或 Command (macOS) - `A-` = Alt (Windows/Linux) 或 Option (macOS) - `S-` = Shift - `M-` = Meta (macOS 上等同于 Command) - `F11`, `F12` 等 = 功能键 - `arrowup`, `arrowdown`, `arrowleft`, `arrowright` = 方向键 - `home`, `end`, `pageup`, `pagedown` = 导航键 - `space`, `enter`, `escape` = 特殊键 - 普通字母直接写,如 `m`, `t`, `k` 等 - 多个按键用空格分隔,如 `"t t t"` 表示连续按三次 t **注意:** Mac 系统会自动将 `C-` 和 `M-` 互换,所以不需要手动处理平台差异。 **示例:** ```typescript { id: "setWindowToMiniSize", defaultKey: "A-S-m", // Alt+Shift+M onPress: async () => { const window = getCurrentWindow(); // 执行操作 await window.setSize(new LogicalSize(width, height)); }, isUI: true, // UI 级别快捷键,不需要项目上下文 }, ``` **快捷键类型说明:** - **项目级快捷键(默认)**:需要项目上下文,`onPress` 会接收 `project` 参数 - **UI 级别快捷键(`isUI: true`)**:不需要项目上下文,可以在没有打开项目时使用 - **全局快捷键(`isGlobal: true`)**:使用 Tauri 全局快捷键系统,即使应用不在焦点也能触发 **使用 Tauri API 时的类型处理:** 如果快捷键需要使用 Tauri 窗口 API(如 `setSize`),需要导入正确的类型: ```typescript import { getCurrentWindow } from "@tauri-apps/api/window"; import { LogicalSize } from "@tauri-apps/api/dpi"; // 或 PhysicalSize // 使用 LogicalSize(推荐,会自动处理 DPI 缩放) await window.setSize(new LogicalSize(width, height)); // 或使用 PhysicalSize(物理像素) await window.setSize(new PhysicalSize(width, height)); ``` ### 2. 将快捷键添加到分组中 在 `app/src/sub/SettingsWindow/keybinds.tsx` 文件的 `shortcutKeysGroups` 数组中,将新快捷键的 `id` 添加到相应的分组数组中。 **分组结构:** ```typescript export const shortcutKeysGroups: ShortcutKeysGroup[] = [ { title: "basic", // 分组标识符(对应翻译文件中的 key) icon: , // 分组图标 keys: [ // 该分组包含的快捷键 ID 列表 "saveFile", "openFile", "undo", "redo", // ... ], }, { title: "ui", // UI 控制分组 icon: , keys: [ "closeAllSubWindows", "toggleFullscreen", "setWindowToMiniSize", // 添加新快捷键 // ... ], }, // ... 其他分组 ]; ``` **可用分组:** - `basic` - 基础快捷键(撤销、重做、保存、打开等) - `camera` - 摄像机控制(移动、缩放、重置视野等) - `app` - 应用控制(切换项目、切换模式等) - `ui` - UI 控制(关闭窗口、全屏、窗口大小等) - `draw` - 涂鸦相关 - `select` - 切换选择 - `moveEntity` - 移动实体 - `generateTextNodeInTree` - 生长节点 - `generateTextNodeRoundedSelectedNode` - 在选中节点周围生成节点 - `aboutTextNode` - 关于文本节点(分割、合并、创建等) - `section` - Section 框相关 - `edge` - 连线相关 - `color` - 颜色相关 - `node` - 节点相关 **分组选择指南:** - **UI 控制(`ui`)**:窗口管理、界面切换、全屏、窗口大小等 - **基础快捷键(`basic`)**:文件操作、编辑操作(撤销、重做、复制、粘贴等) - **摄像机控制(`camera`)**:视野移动、缩放、重置等 - **应用控制(`app`)**:项目切换、模式切换等 - **文本节点相关(`aboutTextNode`)**:节点创建、分割、合并、编辑等 - **其他**:根据功能特性选择最合适的分组 **注意:** 如果快捷键不属于任何现有分组,可以: 1. 添加到最接近的现有分组 2. 创建新的分组(需要同时更新翻译文件) ### 3. 添加翻译文本 在所有语言文件中添加翻译: - `app/src/locales/zh_CN.yml` - 简体中文 - `app/src/locales/zh_TW.yml` - 繁体中文 - `app/src/locales/en.yml` - 英文 - `app/src/locales/zh_TWC.yml` - 繁体中文(台湾) - `app/src/locales/id.yml` - 印度尼西亚语 **翻译结构:** 在 `keyBinds` 部分添加: ```yaml keyBinds: keybindId: title: "快捷键标题" description: | 快捷键的详细描述 可以多行 说明快捷键的功能和使用场景 ``` **示例:** ```yaml keyBinds: setWindowToMiniSize: title: 设置窗口为迷你大小 description: | 将窗口大小设置为设置中配置的迷你窗口宽度和高度。 ``` **翻译文件位置:** - 简体中文:`app/src/locales/zh_CN.yml` - 繁体中文:`app/src/locales/zh_TW.yml` - 繁体中文(台湾):`app/src/locales/zh_TWC.yml` - 英文:`app/src/locales/en.yml` - 印度尼西亚语:`app/src/locales/id.yml` **注意:** - 翻译键名(`keybindId`)必须与快捷键定义中的 `id` 完全一致 - 所有语言文件都需要添加翻译,否则会显示默认值或键名 ### 4. 更新分组翻译(如果需要创建新分组) 如果创建了新的快捷键分组,需要在所有语言文件的 `keyBindsGroup` 部分添加分组翻译: ```yaml keyBindsGroup: newGroupName: title: "新分组标题" description: | 分组的详细描述 说明该分组包含哪些类型的快捷键 ``` **示例:** ```yaml keyBindsGroup: ui: title: UI控制 description: | 用于控制UI的一些功能 ``` ## 快捷键类型详解 ### 项目级快捷键(默认) 项目级快捷键需要项目上下文,`onPress` 函数会接收 `project` 参数: ```typescript { id: "myKeybind", defaultKey: "C-k", onPress: (project) => { if (!project) { toast.warning("请先打开工程文件"); return; } // 使用 project 进行操作 project.stageManager.doSomething(); }, } ``` ### UI 级别快捷键 UI 级别快捷键不需要项目上下文,可以在没有打开项目时使用: ```typescript { id: "myUIKeybind", defaultKey: "A-S-m", onPress: async () => { // 不需要 project 参数 const window = getCurrentWindow(); await window.setSize(new LogicalSize(300, 300)); }, isUI: true, // 标记为 UI 级别 } ``` ### 全局快捷键 全局快捷键使用 Tauri 全局快捷键系统,即使应用不在焦点也能触发: ```typescript { id: "myGlobalKeybind", defaultKey: "CommandOrControl+Shift+G", onPress: () => { // 全局快捷键逻辑 }, isGlobal: true, // 标记为全局快捷键 } ``` **注意:** 全局快捷键的键位格式与普通快捷键不同,使用 `CommandOrControl+Shift+G` 格式。 ## 访问快捷键配置 在代码中访问快捷键配置: ```typescript import { KeyBindsUI } from "@/core/service/controlService/shortcutKeysEngine/KeyBindsUI"; // 获取快捷键配置 const config = await KeyBindsUI.get("keybindId"); // 修改快捷键 await KeyBindsUI.changeOneUIKeyBind("keybindId", "new-key-combination"); // 重置所有快捷键 await KeyBindsUI.resetAllKeyBinds(); ``` ## 注意事项 1. **快捷键 ID 命名规范:** 使用驼峰命名法(camelCase),如 `setWindowToMiniSize` 2. **唯一性:** 快捷键 ID 必须唯一,不能与现有快捷键重复 3. **默认键位:** 选择不冲突的默认键位组合 4. **类型安全:** TypeScript 会自动推断类型,确保类型一致性 5. **翻译键名:** 翻译文件中的键名必须与快捷键的 `id` 完全一致 6. **分组必须:** 所有快捷键都必须添加到 `shortcutKeysGroups` 中的相应分组,否则不会在设置页面中显示 7. **分组选择:** 根据快捷键的功能特性选择合适的分组,保持设置页面的逻辑清晰 8. **Tauri API 类型:** 使用窗口 API 时,需要使用 `LogicalSize` 或 `PhysicalSize` 类型,不能直接使用普通对象 9. **Mac 兼容性:** Mac 系统会自动将 `C-` 和 `M-` 互换,无需手动处理 10. **UI vs 项目级:** 根据快捷键是否需要项目上下文选择合适的类型 ## 完整示例 假设要添加一个"设置窗口为迷你大小"的快捷键: **1. shortcutKeysRegister.tsx - 注册快捷键:** ```typescript import { getCurrentWindow } from "@tauri-apps/api/window"; import { LogicalSize } from "@tauri-apps/api/dpi"; import { Settings } from "@/core/service/Settings"; export const allKeyBinds: KeyBindItem[] = [ // ... 其他快捷键 { id: "setWindowToMiniSize", defaultKey: "A-S-m", onPress: async () => { const window = getCurrentWindow(); // 如果当前是最大化状态,先取消最大化 if (await window.isMaximized()) { await window.unmaximize(); store.set(isWindowMaxsizedAtom, false); } // 如果当前是全屏状态,先退出全屏 if (await window.isFullscreen()) { await window.setFullscreen(false); } // 设置窗口大小为设置中的迷你窗口大小 const width = Settings.windowCollapsingWidth; const height = Settings.windowCollapsingHeight; await window.setSize(new LogicalSize(width, height)); }, isUI: true, }, // ... 其他快捷键 ]; ``` **2. keybinds.tsx - 添加到分组:** ```typescript export const shortcutKeysGroups: ShortcutKeysGroup[] = [ // ... 其他分组 { title: "ui", icon: , keys: [ "closeAllSubWindows", "toggleFullscreen", "setWindowToMiniSize", // 添加到 UI 控制分组 // ... ], }, // ... 其他分组 ]; ``` **3. zh_CN.yml - 添加翻译:** ```yaml keyBinds: setWindowToMiniSize: title: 设置窗口为迷你大小 description: | 将窗口大小设置为设置中配置的迷你窗口宽度和高度。 ``` **4. 其他语言文件也需要添加相应翻译** ## 快捷键键位格式参考 **修饰键:** - `C-` = Ctrl/Command - `A-` = Alt/Option - `S-` = Shift - `M-` = Meta (macOS) **特殊键:** - `F1` - `F12` = 功能键 - `arrowup`, `arrowdown`, `arrowleft`, `arrowright` = 方向键 - `home`, `end`, `pageup`, `pagedown` = 导航键 - `space`, `enter`, `escape`, `tab`, `backspace`, `delete` = 特殊键 **组合示例:** - `"C-s"` = Ctrl+S - `"A-S-m"` = Alt+Shift+M - `"C-A-S-t"` = Ctrl+Alt+Shift+T - `"F11"` = F11 - `"C-F11"` = Ctrl+F11 - `"t t t"` = 连续按三次 T - `"arrowup"` = 上方向键 - `"S-arrowup"` = Shift+上方向键 ## 快捷键设置页面 快捷键添加到分组后,会在设置页面的"快捷键绑定"标签页中自动显示: 1. 用户可以在设置页面查看所有快捷键 2. 用户可以自定义快捷键键位 3. 用户可以启用/禁用快捷键 4. 用户可以重置快捷键为默认值 快捷键会自动保存到 `keybinds2.json` 文件中,并在应用重启后恢复。 ================================================ FILE: .cursor/skills/create-setting-item/SKILL.md ================================================ --- name: create-setting-item description: 指导如何在 Project Graph 项目中创建新的设置项。当用户需要添加新的设置项、配置选项或需要了解设置系统的实现方式时使用此技能。 --- # 创建新的设置项功能 本技能指导如何在 Project Graph 项目中创建新的设置项。 ## 创建设置项的步骤 创建新设置项需要完成以下 5 个步骤: ### 1. 在 Settings.tsx 中添加 Schema 定义 在 `app/src/core/service/Settings.tsx` 文件的 `settingsSchema` 对象中添加新的设置项定义。 **支持的 Zod 类型:** - `z.boolean().default(false)` - 布尔值开关 - `z.number().min(x).max(y).default(z)` - 数字(可添加 `.int()` 限制为整数) - `z.string().default("")` - 字符串 - `z.union([z.literal("option1"), z.literal("option2")]).default("option1")` - 枚举选择 - `z.tuple([z.number(), z.number(), z.number(), z.number()]).default([0,0,0,0])` - 元组(如颜色 RGBA) **示例:** ```typescript // 布尔值设置 enableNewFeature: z.boolean().default(false), // 数字范围设置(带滑块) newSliderValue: z.number().min(0).max(100).int().default(50), // 枚举选择设置 newMode: z.union([z.literal("mode1"), z.literal("mode2")]).default("mode1"), ``` ### 2. 在 SettingsIcons.tsx 中添加图标 在 `app/src/core/service/SettingsIcons.tsx` 文件的 `settingsIcons` 对象中添加对应的图标。 **步骤:** 1. 从 `lucide-react` 导入合适的图标组件 2. 在 `settingsIcons` 对象中添加映射:`settingKey: IconComponent` **示例:** ```typescript import { NewIcon } from "lucide-react"; export const settingsIcons = { // ... 其他设置项 enableNewFeature: NewIcon, }; ``` ### 3. 添加翻译文本 在所有语言文件中添加翻译: - `app/src/locales/zh_CN.yml` - 简体中文 - `app/src/locales/zh_TW.yml` - 繁体中文 - `app/src/locales/en.yml` - 英文 - `app/src/locales/zh_TWC.yml` - 接地气繁体中文 - `app/src/locales/id.yml` - 印度尼西亚语 **翻译结构:** ```yaml settings: settingKey: title: "设置项标题" description: | 设置项的详细描述 可以多行 options: # 仅枚举类型需要 option1: "选项1显示文本" option2: "选项2显示文本" ``` **示例:** ```yaml settings: enableNewFeature: title: "启用新功能" description: | 开启后将启用新功能特性。 此功能可能会影响性能。 newMode: title: "新模式" description: "选择新的模式选项" options: mode1: "模式一" mode2: "模式二" ``` ### 4. 将设置项添加到分组中 在 `app/src/sub/SettingsWindow/settings.tsx` 文件的 `categories` 对象中,将新设置项的键名添加到相应的分组数组中。 **分组结构:** ```typescript const categories = { visual: { // 一级分类:视觉 basic: [...], // 二级分组:基础 background: [...], // 二级分组:背景 node: [...], // 二级分组:节点样式 // ... }, automation: { // 一级分类:自动化 autoNamer: [...], autoSave: [...], // ... }, control: { // 一级分类:控制 mouse: [...], cameraMove: [...], // ... }, performance: { // 一级分类:性能 memory: [...], cpu: [...], // ... }, ai: { // 一级分类:AI api: [...], }, }; ``` **添加设置项到分组:** ```typescript const categories = { visual: { basic: [ "language", "isClassroomMode", "enableNewFeature", // 添加新设置项 // ... ], }, // ... }; ``` **分组选择指南:** - **visual(视觉)**:界面显示、主题、背景、节点样式、连线样式等 - `basic`: 基础视觉设置 - `background`: 背景相关设置 - `node`: 节点样式设置 - `edge`: 连线样式设置 - `section`: Section 框的样式设置 - `entityDetails`: 实体详情面板设置 - `debug`: 调试相关设置 - `miniWindow`: 迷你窗口设置 - `experimental`: 实验性视觉功能 - **automation(自动化)**:自动保存、自动备份、自动命名等 - `autoNamer`: 自动命名相关 - `autoSave`: 自动保存相关 - `autoBackup`: 自动备份相关 - `autoImport`: 自动导入相关 - **control(控制)**:鼠标、键盘、触摸板、相机控制等 - `mouse`: 鼠标相关设置 - `touchpad`: 触摸板设置 - `cameraMove`: 相机移动设置 - `cameraZoom`: 相机缩放设置 - `objectSelect`: 对象选择设置 - `textNode`: 文本节点编辑设置 - `edge`: 连线操作设置 - `generateNode`: 节点生成设置 - `gamepad`: 游戏手柄设置 - **performance(性能)**:内存、CPU、渲染性能相关 - `memory`: 内存相关设置 - `cpu`: CPU 相关设置 - `render`: 渲染相关设置 - `experimental`: 实验性性能功能 - **ai(AI)**:AI 相关设置 - `api`: AI API 配置 **注意:** 如果设置项不属于任何现有分组,可以: 1. 添加到最接近的现有分组 2. 在相应分类下创建新的分组(需要同时更新翻译文件中的分类结构) ### 5. 在设置页面中使用 SettingField 组件 设置项添加到分组后,会在设置页面的相应分组中自动显示。如果需要手动渲染或添加额外内容,可以使用 `SettingField` 组件: **基本用法:** ```tsx import { SettingField } from "@/components/ui/field"; ; ``` **带额外内容的用法:** ```tsx 额外按钮} /> ``` **注意:** 大多数情况下,只需要将设置项添加到 `categories` 中即可,设置页面会自动渲染。只有在需要特殊布局或额外功能时才需要手动使用 `SettingField` 组件。 ## SettingField 组件的自动类型推断 `SettingField` 组件会根据 schema 定义自动渲染对应的 UI 控件: - **字符串类型** → `Input` 输入框 - **数字类型(有 min/max)** → `Slider` 滑块 + `Input` 数字输入框 - **数字类型(无范围)** → `Input` 数字输入框 - **布尔类型** → `Switch` 开关 - **枚举类型(Union)** → `Select` 下拉选择框 ## 访问设置值 在代码中访问设置值: ```typescript import { Settings } from "@/core/service/Settings"; // 读取设置值 const value = Settings.enableNewFeature; // 修改设置值 Settings.enableNewFeature = true; // 监听设置变化(返回取消监听的函数) const unsubscribe = Settings.watch("enableNewFeature", (newValue) => { console.log("设置已更改:", newValue); }); // React Hook 方式(在组件中使用) const [value, setValue] = Settings.use("enableNewFeature"); ``` ## 注意事项 1. **设置项键名命名规范:** 使用驼峰命名法(camelCase),如 `enableNewFeature` 2. **默认值:** 所有设置项都必须提供默认值(`.default()`) 3. **类型安全:** TypeScript 会自动推断类型,确保类型一致性 4. **持久化:** 设置值会自动保存到 `settings.json` 文件中 5. **翻译键名:** 翻译文件中的键名必须与设置项的键名完全一致 6. **图标可选:** 如果不需要图标,可以不在 `settingsIcons` 中添加,组件会使用 Fragment 7. **分组必须:** 所有设置项都必须添加到 `categories` 对象中的相应分组,否则不会在设置页面中显示 8. **分组选择:** 根据设置项的功能特性选择合适的分类和分组,保持设置页面的逻辑清晰 ## 完整示例 假设要添加一个"启用暗色模式"的设置项: **1. Settings.tsx:** ```typescript export const settingsSchema = z.object({ // ... 其他设置项 enableDarkMode: z.boolean().default(false), }); ``` **2. SettingsIcons.tsx:** ```typescript import { Moon } from "lucide-react"; export const settingsIcons = { // ... 其他设置项 enableDarkMode: Moon, }; ``` **3. zh_CN.yml:** ```yaml settings: enableDarkMode: title: "启用暗色模式" description: "开启后将使用暗色主题界面" ``` **4. settings.tsx - 添加到分组:** ```typescript const categories = { visual: { basic: [ "language", "isClassroomMode", "enableDarkMode", // 添加到基础视觉设置分组 // ... ], // ... }, // ... }; ``` **5. 设置项会自动显示:** 设置项添加到 `categories` 后,会在设置页面的"视觉 > 基础"分组中自动显示,无需手动使用 `SettingField` 组件。 ## 快捷设置栏支持 如果希望设置项出现在快捷设置栏(Quick Settings Toolbar)中,需要: 1. 确保设置项已正确创建(完成上述 4 步) 2. 快捷设置栏会自动显示所有布尔类型的设置项 3. 可以通过 `QuickSettingsManager.addQuickSetting()` 手动添加非布尔类型的设置项 ================================================ FILE: .github/FUNDING.yml ================================================ # These are supported funding model platforms github: # Replace with up to 4 GitHub Sponsors-enabled usernames e.g., [user1, user2] patreon: # Replace with a single Patreon username open_collective: # Replace with a single Open Collective username ko_fi: # Replace with a single Ko-fi username tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry liberapay: # Replace with a single Liberapay username issuehunt: # Replace with a single IssueHunt username lfx_crowdfunding: # Replace with a single LFX Crowdfunding project-name e.g., cloud-foundry polar: # Replace with a single Polar username buy_me_a_coffee: # Replace with a single Buy Me a Coffee username thanks_dev: # Replace with a single thanks.dev username custom: # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2'] - 2y.nz/pgdonate ================================================ FILE: .github/ISSUE_TEMPLATE/config.yml ================================================ #blank_issues_enabled: false ================================================ FILE: .github/ISSUE_TEMPLATE/no-issues.yml ================================================ name: 不要创建 Issue,请前往 Disscussions! description: 不要创建issue body: - type: checkboxes attributes: label: 不要创建 Issue,请前往 Disscussions description: 鉴于大量低质量和重复的issue,从2025年7月开始,用户不可以自行创建issue options: - label: 我希望这个issue被删除 required: true - label: "[点这里前往Disscussions](https://github.com/graphif/project-graph/discussions/new/choose)" required: true ================================================ FILE: .github/copilot-instructions.md ================================================ ## Project Background Github Repository: `graphif/project-graph` Project Graph is a desktop application designed to visualize and manage complex project structures. It allows users to create, edit, and visualize project graphs, making it easier to understand relationships and dependencies within projects. ## Coding guidelines - Prioritize code correctness and clarity. Speed and efficiency are secondary priorities unless otherwise specified. - Do not write organizational or comments that summarize the code. Comments should only be written in order to explain "why" the code is written in some way in the case there is a reason that is tricky / non-obvious. - Prefer implementing functionality in existing files unless it is a new logical component. Avoid creating many small files. - Never silently discard errors with `catch {}` or `catch (e) { console.error(e) }` on fallible operations. Always handle errors appropriately: - Don't catch errors, let the calling function to handle them - If the error should be ignored, show a dialog instead of logging to console. User cannot see logs in the console. - Ensure errors propagate to the top of DOM (eg. `window`), so `ErrorHandler` component can catch it and show an user-friendly dialog - Example: avoid `try { something() } catch (e) { console.error(e) }` - use `something()` instead - Always use `something.tsx` instead of a single `index.tsx` in a directory. ## Tech-stack - React (TypeScript) + Tauri (Rust) - Vite + pnpm (monorepo) + turborepo - Canvas 2D - shadcn/ui + Tailwind CSS + self-developed sub-window system - Jotai ## Structure ### Tauri Application, and Frontend - Frontend Vite project: `/app` - Rust Project: `/app/src-tauri` ### Fumadocs - Next.js Project: `/docs` - Content: `/docs/content/docs` ### Open-source Libraries They are all in `/packages` directory, and are used in the frontend. ## Trade time for space Trade time for space, meaning that you should use more **storage** (not memory!) to reduce computation time ## RFCs The `tasks` the user refers to are **RFCs**. These RFCs are usually tracked in the repository’s Issues and their titles begin with `RFC:`. A user **cannot** take on tasks that are irrelevant to their own system. For example, a Linux user **cannot** complete a task that exists only on macOS. When the user asks which tasks remain unfinished, you must - assign **a unique number** to every task - sort the list by a combined score of **importance × implementation difficulty**, so the user can easily tell you to tick the finished items in the corresponding RFCs. ## Commit Message Use conventional commits ================================================ FILE: .github/scripts/enable-sourcemap.mjs ================================================ import { readFileSync, writeFileSync } from "fs"; const VITE_CONFIG_PATH = "app/vite.config.ts"; const conf = readFileSync(VITE_CONFIG_PATH); const updated = conf.toString().replace("sourcemap: false", "sourcemap: true"); writeFileSync(VITE_CONFIG_PATH, updated); console.log(updated); ================================================ FILE: .github/scripts/generate-changelog.mjs ================================================ /* eslint-disable */ import { execSync } from "child_process"; // 获取最近一次发布的标签 const lastRelease = execSync( "git for-each-ref --sort=-creatordate --format='%(refname:short)' \"refs/tags/v*\" | head -n 1", ) .toString() .trim(); // 获取 Git 提交记录 const commits = execSync(`git log ${lastRelease}.. --pretty=format:"%s" --reverse`).toString().trim(); /** * 生成降级版本的changelog(直接使用commit标题) * @param {string} commits - commit标题列表,用换行分隔 * @returns {string} 格式化的changelog */ function generateFallbackChangelog(commits) { if (!commits || commits.trim() === "") { return "## 更新内容\n\n本次更新暂无变更记录。"; } const commitList = commits .split("\n") .filter((line) => line.trim() !== "") .map((commit) => `- ${commit}`) .join("\n"); return `## 更新内容 > ⚠️ 注意:由于AI总结更新的内容服务不可用,以下内容为直接提取的commit记录 ${commitList} `; } // 定义提示信息 const prompt = ` 你是一个专业的软件文档撰写助手,负责将开发团队提供的commit历史记录转换为用户友好的更新日志(Changelog)。用户会提供git历史记录信息。 你的任务是生成一篇清晰、简洁的Changelog,面向最终用户(非技术人员),避免使用技术术语,专注于用户能直接感知的变更。请遵循以下规则: 1. **理解commit类型**: - \`feat\` / \`feature\`:新功能,归类为“新功能”。 - \`fix\` / \`hotfix\`:问题修复,归类为“问题修复”。 - \`docs\`:文档或内容更新,归类为“文档和内容更新”。 - \`chore\`:界面优化、配置调整或内部改进,归类为“改进和优化”(重点描述用户可见的变化)。 - 其他类型根据描述推断,确保归类合理。 2. **组织Changelog结构**: - 按类别分组commit(如“问题修复”、“文档和内容更新”、“改进和优化”等),每个类别使用子标题。 - 每个类别下用项目符号列表描述变更,语言口语化、正面积极(例如:用“修复了...问题”而非“修复bug”)。 - 如果多个commit相似,可合并描述以提高可读性。 3. **输出格式**: - 使用中文。 - 保持段落清晰,无需编号,但使用标题和项目符号。 - 开头不要有 \`## 更新日志\`,直接开始更新内容。 - 从二级标题开始(例如:\`## 新功能\`)。 请直接输出Changelog内容,无需额外解释。 ## Example \`\`\` ## 新功能 增加穿透点击功能,全局快捷键Alt+2可以开关窗口穿透,穿透点击开启后,副作用是会自动将透明度设置为0.2且自动打开窗口置顶 标签面板可以正常打开了,且增加标签管理器UI分裂功能,每一个标签都能分裂成一个可拖拽与改变大小的独立子窗口,且点击能够对准对应的节点 rua时,可以输入自定义连接符,如果输入了换行符作为连接,则rua出来的节点的换行策略会自动变为手动调整宽度模式 增加手动保存时是否自动清理历史记录的设置项 完成自动保存功能 完成自动备份功能 ## 操作优化 修复最后一个实体跳出框时,框附带移动到实体附近的bug section中最后一个节点跳出框时,自动变为文本节点 ## 视觉/交互优化 alt跳入框时,显示框会变大多少的虚线边缘 右键菜单中增加文本节点妙操作 开启穿透点击时,自动半透明窗口 给子窗口增加shadow 按住ctrl或者shift框选加选或者叉选时,增加视觉提示 给特效界面增加提示 ## Bug修复 修复涂鸦后没有记录历史的问题 防止一开始启动软件视野缩放过大 暂时修复详细信息报错问题 \`\`\` `; // 发送请求到 API try { const response = await fetch( "https://generativelanguage.googleapis.com/v1beta/models/gemini-2.0-flash-lite:generateContent?key=" + process.env.GEMINI_API_KEY, { method: "POST", headers: { "Content-Type": "application/json", }, body: JSON.stringify({ system_instruction: { parts: [ { text: prompt, }, ], }, contents: [ { parts: [ { text: commits, }, ], }, ], }), }, ); if (!response.ok) { throw new Error(`API request failed with status ${response.status}`); } const data = await response.json(); const changelog = data.candidates[0].content.parts[0].text; const finalChangelog = `以下内容为AI根据git历史自动生成总结,不保证完全准确 ${changelog} `; console.log(finalChangelog); } catch (err) { console.error("AI生成changelog失败,使用降级方案:", err.message); // 降级方案:直接输出commit列表 const fallbackChangelog = generateFallbackChangelog(commits); console.log(fallbackChangelog); } ================================================ FILE: .github/scripts/generate-pkgbuild.mjs ================================================ /* eslint-disable */ import { writeFileSync } from "fs"; // 命令行参数: // node ./generate-pkgbuild.mjs const pkgname = process.argv[2]; const pkgver = process.argv[3]; const sha256sums = process.argv[4]; if (!pkgname || !pkgver || !sha256sums) { console.error("Usage: node generate-pkgbuild.mjs "); process.exit(1); } const conflicts = pkgname === "project-graph-nightly-bin" ? ["project-graph-bin", "project-graph-git"] : ["project-graph-nightly-bin", "project-graph-git"]; const source = pkgname === "project-graph-nightly-bin" ? `https://github.com/LiRenTech/project-graph/releases/download/nightly/Project.Graph_0.0.0-nightly.${pkgver.slice(1)}_amd64.deb` : `https://github.com/LiRenTech/project-graph/releases/download/v${pkgver}/Project.Graph_${pkgver}_amd64.deb`; const PKGBUILD = `# Maintainer: zty012 pkgname=${pkgname} pkgver=${pkgver.replaceAll("-", ".")} pkgrel=1 pkgdesc="A simple tool to create topology diagrams." arch=('x86_64') url="https://github.com/LiRenTech/project-graph" license=('mit') depends=('cairo' 'desktop-file-utils' 'gdk-pixbuf2' 'glib2' 'gtk3' 'hicolor-icon-theme' 'libsoup' 'pango' 'webkit2gtk') options=('!strip' '!emptydirs') provides=('project-graph') conflicts=(${conflicts.map((x) => `'${x}'`).join(" ")}) install=${pkgname}.install source_x86_64=('${source}') sha256sums_x86_64=('${sha256sums}') package() { # Extract package data tar -xz -f data.tar.gz -C "\${pkgdir}" } `; console.log("===== PKGBUILD ====="); console.log(PKGBUILD); writeFileSync("./PKGBUILD", PKGBUILD); const SRCINFO = `pkgbase = ${pkgname} \tpkgdesc = A simple tool to create topology diagrams. \tpkgver = ${pkgver.replaceAll("-", ".")} \tpkgrel = 1 \turl = https://github.com/LiRenTech/project-graph \tinstall = ${pkgname}.install \tarch = x86_64 \tlicense = mit \tdepends = cairo \tdepends = desktop-file-utils \tdepends = gdk-pixbuf2 \tdepends = glib2 \tdepends = gtk3 \tdepends = hicolor-icon-theme \tdepends = libsoup \tdepends = pango \tdepends = webkit2gtk \tprovides = project-graph ${conflicts.map((x) => `\tconflicts = ${x}`).join("\n")} \toptions = !strip \toptions = !emptydirs \tsource_x86_64 = ${source} \tsha256sums_x86_64 = ${sha256sums} pkgname = ${pkgname}`; console.log("===== .SRCINFO ====="); console.log(SRCINFO); writeFileSync("./.SRCINFO", SRCINFO); ================================================ FILE: .github/scripts/set-tauri-features.mjs ================================================ /* eslint-disable */ import { readFileSync, writeFileSync } from "fs"; const features = process.argv[2].split(","); const CARGO_TOML_PATH = "app/src-tauri/Cargo.toml"; const conf = readFileSync(CARGO_TOML_PATH); const updated = conf .toString() .replace( /tauri = { version = "(.*)", features = \["(.*)"\] }/, `tauri = { version = "$1", features = ["macos-private-api", "${features.join('", "')}"] }`, ); writeFileSync(CARGO_TOML_PATH, updated); console.log(updated); ================================================ FILE: .github/scripts/set-version.mjs ================================================ /* eslint-disable */ import { readFileSync, writeFileSync } from "fs"; const version = process.argv[2]; const TAURI_CONF_PATH = "app/src-tauri/tauri.conf.json"; const conf = JSON.parse(readFileSync(TAURI_CONF_PATH)); conf.version = version; writeFileSync(TAURI_CONF_PATH, JSON.stringify(conf, null, 2)); console.log(conf); ================================================ FILE: .github/workflows/nightly.yml ================================================ name: "Nightly" run-name: "Nightly ${{ github.run_number }}" on: schedule: - cron: "0 0 * * *" workflow_dispatch: jobs: build: permissions: contents: write uses: ./.github/workflows/publish.yml with: android_key_alias: "upload" android_key_path: "upload.jks" app_version: 0.0.0-nightly.${{ github.run_number }} app_version_android: 0.0.${{ github.run_number }} aur_version: r${{ github.run_number }} aur_key_algorithm: "ed25519" aur_package_name: "project-graph-nightly-bin" delete_release: true prerelease: true release_name: Nightly ${{ inputs.version }} release_tag: nightly task_build: build:ci # task_build_android: build include_devtools: true secrets: ANDROID_KEYSTORE: ${{ secrets.ANDROID_RELEASE_KEYSTORE }} ANDROID_KEYSTORE_PASSWORD: ${{ secrets.ANDROID_RELEASE_PASSWORD }} AUR_SSH_PRIVATE_KEY: ${{ secrets.AUR_SSH_PRIVATE_KEY }} TAURI_SIGNING_PRIVATE_KEY: ${{ secrets.TAURI_SIGNING_PRIVATE_KEY }} TAURI_SIGNING_PRIVATE_KEY_PASSWORD: ${{ secrets.TAURI_SIGNING_PRIVATE_KEY_PASSWORD }} GEMINI_API_KEY: ${{ secrets.GEMINI_API_KEY }} ================================================ FILE: .github/workflows/publish.yml ================================================ name: Publish on: workflow_call: inputs: app_version: type: string description: The version of the app. required: false default: "0.0.0" app_version_android: type: string description: The version of the app for Android, CANNOT be `0.0.0` required: true release_name: type: string description: The name of the release. required: false default: Release release_tag: type: string description: The tag to use for the release. required: true prerelease: type: boolean description: Whether to make the release a prerelease. required: false default: false delete_release: type: boolean description: Whether to delete the release. required: false default: true android_key_path: type: string description: The path to the Android key file, relative to app_root required: false default: "upload.jks" aur_package_name: type: string description: The name of the AUR package. required: false default: "" aur_key_algorithm: type: string description: The algorithm to use for the AUR key. required: false default: "ed25519" aur_version: type: string description: The version of the AUR package. required: true task_build: type: string description: The task to run for building the app. required: false default: "tauri:build" task_build_android: type: string description: The task to run for building the app for Android. required: false default: "tauri:build:android" android_key_alias: type: string description: The alias of the Android key. required: false default: "upload" include_devtools: type: boolean description: Whether to include devtools in the build. required: false default: false secrets: TAURI_SIGNING_PRIVATE_KEY: description: Sign app binaries for updater support. required: false TAURI_SIGNING_PRIVATE_KEY_PASSWORD: description: Password for the signing key. required: false ANDROID_KEYSTORE: description: Base64 of `jks` file for APK signing. required: false ANDROID_KEYSTORE_PASSWORD: description: Password for the keystore. required: false BUILD_ENV: description: "Environment variables to pass to `tauri build`. Format: `key1=value1\\nkey2=value2\\n...`." required: false AUR_SSH_PRIVATE_KEY: description: "SSH private key for AUR publishing." required: false GEMINI_API_KEY: description: Authenticate Google Gemini to generate changelog. required: false jobs: create-release: runs-on: ubuntu-latest permissions: contents: write env: GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} steps: - uses: actions/checkout@v4 with: fetch-depth: 0 - name: Setup Node uses: actions/setup-node@v4 with: node-version: 24 - name: Install dependencies run: npm i -g node-fetch - name: Delete release if: inputs.delete_release == true run: | gh release delete ${{ inputs.release_tag }} --yes --cleanup-tag || true sleep 1 - name: Create release env: tag: ${{ inputs.release_tag }} name: ${{ inputs.release_name }} branch: ${{ github.ref_name }} run: | notes=$(GEMINI_API_KEY="${{ secrets.GEMINI_API_KEY }}" node ./.github/scripts/generate-changelog.mjs) gh release create "$tag" --target "$branch" --title "$name" --notes "$notes" ${{ inputs.prerelease == true && '--prerelease' || '' }} publish-tauri: needs: [create-release] outputs: hash: ${{ steps.sha256sum.outputs.hash }} permissions: contents: write strategy: fail-fast: false matrix: include: - platform: "ubuntu-22.04" dist: "src-tauri/target/release/bundle/**/*.{deb,AppImage,rpm,sig}" - platform: "windows-latest" dist: "src-tauri/target/release/bundle/nsis" - platform: "macos-latest" args: "--target universal-apple-darwin" rust_targets: "aarch64-apple-darwin,x86_64-apple-darwin" dist: "src-tauri/target/universal-apple-darwin/release/bundle/**/*.{dmg,tar.gz,sig}" runs-on: ${{ matrix.platform }} steps: - uses: actions/checkout@v4 #region Prepare environment - name: Linux - Install dependencies if: matrix.platform == 'ubuntu-22.04' run: | sudo apt-get update sudo apt-get install -y libwebkit2gtk-4.1-dev libappindicator3-dev librsvg2-dev patchelf libudev-dev - uses: pnpm/action-setup@v4 id: pnpm name: Install pnpm with: run_install: false - name: Install Node.js uses: actions/setup-node@v4 with: node-version: 24 cache: "pnpm" - name: Install dependencies run: pnpm install --no-frozen-lockfile - name: Install Rust uses: dtolnay/rust-toolchain@stable with: targets: ${{ matrix.rust_targets }} - name: Rust cache uses: swatinem/rust-cache@v2 with: workspaces: "app/src-tauri -> target" #endregion #region Android - Prepare environment - name: Android - Setup Java if: matrix.android uses: actions/setup-java@v4 with: distribution: "zulu" java-version: "17" - name: Android - Setup Android SDK if: matrix.android uses: android-actions/setup-android@v3 - name: Android - Setup Android NDK if: matrix.android run: sdkmanager "ndk;27.0.11902837" - name: Android - Setup Android APK Signing if: matrix.android run: | cd app/src-tauri/gen/android cat > keystore.properties < app/${{ inputs.android_key_path }} #endregion #region Edit version - name: Set app version if: ${{ !matrix.android && !matrix.variant }} run: | node ./.github/scripts/set-version.mjs ${{ inputs.app_version }} - name: Set app version when variant exists if: ${{ !matrix.android && matrix.variant }} run: | node ./.github/scripts/set-version.mjs ${{ inputs.app_version }}-${{ matrix.variant }} - name: Enable DevTools if: ${{ inputs.include_devtools }} run: | node ./.github/scripts/set-tauri-features.mjs devtools node ./.github/scripts/enable-sourcemap.mjs - name: Android - Set app version if: matrix.android run: | node ./.github/scripts/set-version.mjs ${{ inputs.app_version_android }} - name: Variant - win7 if: matrix.variant == 'win7' run: | (Get-Content ./app/src-tauri/tauri.conf.json).Replace('downloadBootstrapper', 'embedBootstrapper') | Set-Content ./app/src-tauri/tauri.conf.json cat ./app/src-tauri/tauri.conf.json #endregion #region Build - name: Write BUILD_ENV to .env file if: matrix.variant != 'foss' run: | echo "${{ secrets.BUILD_ENV }}" > app/.env - name: Build run: | pnpm run ${{ matrix.android && inputs.task_build_android || inputs.task_build }} env: TAURI_BUILD_ARGS: ${{ matrix.args }} NDK_HOME: ${{ env.ANDROID_HOME }}/ndk/27.0.11902837 GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} TAURI_SIGNING_PRIVATE_KEY: ${{ secrets.TAURI_SIGNING_PRIVATE_KEY }} TAURI_SIGNING_PRIVATE_KEY_PASSWORD: ${{ secrets.TAURI_SIGNING_PRIVATE_KEY_PASSWORD }} - name: MacOS - Rename app.tar.gz if: matrix.platform == 'macos-latest' run: | cd app/src-tauri/target/*/release/bundle/macos mv *.app.tar.gz "Project Graph_${{ inputs.app_version }}_universal.app.tar.gz" mv *.app.tar.gz.sig "Project Graph_${{ inputs.app_version }}_universal.app.tar.gz.sig" - name: Linux - Rename rpm if: matrix.platform == 'ubuntu-22.04' run: | cd app/src-tauri/target/release/bundle/rpm mv *.rpm "Project Graph_${{ inputs.app_version }}_amd64.rpm" - name: Linux / MacOS - Upload if: matrix.platform != 'windows-latest' run: | gh release upload ${{ inputs.release_tag }} app/${{ matrix.dist }} --clobber env: GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} - name: Windows - Upload if: matrix.platform == 'windows-latest' run: | gh release upload ${{ inputs.release_tag }} (Get-Item .\app\${{ matrix.dist }}\*.exe).FullName --clobber gh release upload ${{ inputs.release_tag }} (Get-Item .\app\${{ matrix.dist }}\*.sig).FullName --clobber env: GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} - id: sha256sum name: Linux - Calculate SHA256 hash for AUR package if: matrix.platform == 'ubuntu-22.04' run: | cd app/src-tauri/target/release/bundle/deb sha256sum ./*.deb | awk '{print $1}' > sha256sum.txt echo "hash=$(cat sha256sum.txt)" >> "$GITHUB_OUTPUT" #endregion # publish-tauri-linux-arm: # runs-on: ubuntu-22.04 # needs: [create-release, build-frontend] # permissions: # contents: write # strategy: # matrix: # arch: [aarch64] # include: # - arch: aarch64 # cpu: cortex-a72 # base_image: https://dietpi.com/downloads/images/DietPi_RPi5-ARMv8-Bookworm.img.xz # deb: arm64 # rpm: aarch64 # appimage: aarch64 # # - arch: armv7l # # cpu: cortex-a53 # # deb: armhfp # # rpm: arm # # appimage: armhf # # base_image: https://dietpi.com/downloads/images/DietPi_RPi-ARMv7-Bookworm.img.xz # steps: # - uses: actions/checkout@v3 # - name: Cache rust build artifacts # uses: Swatinem/rust-cache@v2 # with: # workspaces: src-tauri # cache-on-failure: true # - name: Build app # uses: pguyot/arm-runner-action@v2.6.5 # with: # base_image: ${{ matrix.base_image }} # cpu: ${{ matrix.cpu }} # bind_mount_repository: true # image_additional_mb: 10240 # optimize_image: no # #exit_on_fail: no # commands: | # # Prevent Rust from complaining about $HOME not matching eid home # export HOME=/root # # Workaround to CI worker being stuck on Updating crates.io index # export CARGO_REGISTRIES_CRATES_IO_PROTOCOL=sparse # # Install setup prerequisites # apt-get update -y --allow-releaseinfo-change # apt-get autoremove -y # apt-get install -y --no-install-recommends --no-install-suggests curl libwebkit2gtk-4.1-dev build-essential libssl-dev libgtk-3-dev libayatana-appindicator3-dev librsvg2-dev patchelf libfuse2 file # curl https://sh.rustup.rs -sSf | sh -s -- -y # . "$HOME/.cargo/env" # # Install Node.js # curl -fsSL https://deb.nodesource.com/setup_lts.x | bash # apt-get install -y nodejs # # Install frontend dependencies # npm i -g pnpm # pnpm i # # Build the application # pnpm tauri:build # - name: Upload # run: | # gh release upload ${{ inputs.release_tag }} app/src-tauri/target/release/bundle/*.{deb,rpm,AppImage} --clobber # env: # GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} bump-aur-version: needs: publish-tauri runs-on: ubuntu-latest if: inputs.aur_package_name != '' steps: - uses: actions/checkout@v4 - name: Setup Node uses: actions/setup-node@v4 with: node-version: 24 - name: Setup AUR private key run: | mkdir -p ~/.ssh echo "${{ secrets.AUR_SSH_PRIVATE_KEY }}" > ~/.ssh/id_${{ inputs.aur_key_algorithm }} chmod 600 ~/.ssh/id_${{ inputs.aur_key_algorithm }} ssh-keyscan -t "${{ inputs.aur_key_algorithm }}" aur.archlinux.org >> ~/.ssh/known_hosts - name: Clone AUR repository run: git clone ssh://aur@aur.archlinux.org/${{ inputs.aur_package_name }}.git ./aurpackage - name: Update version in PKGBUILD and .SRCINFO env: repo: ${{ github.repository }} GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} run: | cd aurpackage node ../.github/scripts/generate-pkgbuild.mjs ${{ inputs.aur_package_name }} ${{ inputs.aur_version }} ${{ needs.publish-tauri.outputs.hash }} - name: Commit and push changes run: | cd aurpackage git config user.name "github-actions[bot]" git config user.email "41898282+github-actions[bot]@users.noreply.github.com" git add PKGBUILD .SRCINFO git commit -m "Bump version to ${{ inputs.app_version }}" git push origin master ================================================ FILE: .github/workflows/release.yml ================================================ name: "Release" run-name: "v${{ inputs.version }}" on: workflow_dispatch: inputs: version: description: "应用版本 (x.y.z)" required: true prerelease: type: boolean description: "Is pre-release" required: false default: false delete_release: type: boolean description: "删除以前的release" required: false default: false jobs: build: permissions: contents: write uses: ./.github/workflows/publish.yml with: android_key_alias: "upload" android_key_path: "upload.jks" app_version: ${{ inputs.version }} app_version_android: ${{ inputs.version }} aur_version: ${{ inputs.version }} aur_key_algorithm: "ed25519" aur_package_name: "project-graph-bin" delete_release: ${{ inputs.delete_release }} prerelease: ${{ inputs.prerelease }} release_name: "v${{ inputs.version }}" release_tag: "v${{ inputs.version }}" task_build: build:ci # task_build_android: "tauri:build:android" secrets: ANDROID_KEYSTORE: ${{ secrets.ANDROID_RELEASE_KEYSTORE }} ANDROID_KEYSTORE_PASSWORD: ${{ secrets.ANDROID_RELEASE_PASSWORD }} AUR_SSH_PRIVATE_KEY: ${{ secrets.AUR_SSH_PRIVATE_KEY }} BUILD_ENV: | LR_API_BASE_URL=${{ secrets.ENV_API_BASE_URL }} LR_GITHUB_CLIENT_SECRET=${{ secrets.ENV_GITHUB_CLIENT_SECRET }} TAURI_SIGNING_PRIVATE_KEY: ${{ secrets.TAURI_SIGNING_PRIVATE_KEY }} TAURI_SIGNING_PRIVATE_KEY_PASSWORD: ${{ secrets.TAURI_SIGNING_PRIVATE_KEY_PASSWORD }} GEMINI_API_KEY: ${{ secrets.GEMINI_API_KEY }} ================================================ FILE: .github/workflows/render-docs-svg.yml ================================================ name: Render files in ./docs-pg to SVG on: push: branches: - master paths: - "docs-pg/**" workflow_dispatch: jobs: render-svg: runs-on: ubuntu-latest permissions: contents: write steps: - uses: actions/checkout@v2 - name: Install Project Graph run: | gh release download -p "*.deb" -O project-graph.deb --clobber sudo apt-get update sudo apt-get install -y ./project-graph.deb rm -rf ./project-graph.deb env: GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} - name: Install xvfb run: sudo apt-get install -y xvfb - name: Render SVG files run: | cd docs-pg for file in *.json; do echo "Rendering $file" xvfb-run -a project-graph "$file" -o "${file%.json}.svg" done - name: Commit files run: | git add . git config --local user.email "41898282+github-actions[bot]@users.noreply.github.com" git config --local user.name "github-actions[bot]" git commit -a -m "📝 Render SVG files" git pull - name: Push changes uses: ad-m/github-push-action@master with: github_token: ${{ secrets.GITHUB_TOKEN }} branch: ${{ github.ref }} ================================================ FILE: .gitignore ================================================ node_modules dist .env .idea storybook-static .swc docs/src/.vitepress/dist docs/src/.vitepress/cache docs/src/.vitepress/.temp # pg早期的备份文件 *.backup # 自动保存导致产生的文件 app/src-tauri/Project Graph backup_projectGraphTips *.backup.json # 省略文件夹 backup_* .turbo # mac下开发需要忽略 .DS_Store .nx/cache .nx/workspace-data .cursor/rules/nx-rules.mdc .github/instructions/nx.instructions.md ================================================ FILE: .husky/pre-commit ================================================ pnpm lint-staged ================================================ FILE: .lintstagedrc ================================================ { "*.{ts,tsx}": ["eslint --fix"], "*.{json,md,yaml,yml,ts,tsx}": ["prettier --write"] } ================================================ FILE: .prettierignore ================================================ #app/src-tauri # 防止翻译总是被格式化 app/src/locales/*.yml # 这个基本不会被手动修改 router.ts vite-env.d.ts # prettier不支持mdx3.0 # *.mdx dist .next out LICENSE app/src-tauri/gen app/src-tauri/target app/src/css/theme.pcss ================================================ FILE: .prettierrc ================================================ { "plugins": ["prettier-plugin-tailwindcss"], "printWidth": 120 } ================================================ FILE: .trae/documents/plan_20251223_165257.md ================================================ 1. **添加upgradeNAnyToNLatest函数**: - 在ProjectUpgrader namespace中添加upgradeNAnyToNLatest函数 - 该函数用于升级N版本的prg文件到最新版本 - 内部调用convertN1toN2等转换函数 2. **添加convertN1toN2转换函数**: - 该函数用于将N1版本升级到N2版本 - 为LineEdge添加lineType属性,默认值为'solid' - 确保升级逻辑正确处理所有实体 3. **在prg文件中增加metadata.msgpack**: - 修改保存prg文件的逻辑,添加metadata.msgpack - metadata.msgpack中包含dataVersion和dataVersionType字段 - dataVersion初始值为2(N2版本),dataVersionType为'N' - 在升级时更新dataVersion字段 4. **更新相关调用**: - 确保在保存和加载prg文件时正确处理metadata - 在升级过程中更新dataVersion字段 5. **测试和验证**: - 确保升级逻辑正确 - 确保metadata.msgpack被正确添加到prg文件中 - 确保lineType属性被正确处理 ================================================ FILE: .trae/documents/plan_20260101_170503.md ================================================ 1. **修改现有的重置按钮** * 添加确认弹窗,用户确认后才执行重置 * 更新按钮文本,添加提醒信息 * 确保重置时同时重置快捷键值和启用状态 2. **添加两个新的重置按钮** * 只重置启用状态的按钮 * 只重置快捷键值的按钮 * 同样添加确认弹窗 * 更新按钮显示,添加明确的功能说明 3. **实现重置功能的细分** * 修改`KeyBindsUI`命名空间,添加两个新的重置方法: * `resetAllKeyBindsEnabledState()`:仅重置启用状态 * `resetAllKeyBindsValues()`:仅重置快捷键值 * 确保现有`resetAllKeyBinds()`方法同时重置两者 4. **更新UI界面** * 重新布局重置按钮区域 * 使用清晰的文本和图标区分三个重置按钮 * 添加适当的样式和间距 5. **测试功能** * 测试所有三个重置按钮的功能 * 验证确认弹窗的显示和交互 * 检查重置后的数据状态是否正确 **预期效果**: * 快捷键设置页面左侧分类栏底部会显示三个重置按钮 * 每个按钮都有明确的功能说明和提醒 * 点击任何重置按钮都会先显示确认弹窗 * 重置后页面数据会立即更新 * 用户可以根据需要选择不同的重置选项 ================================================ FILE: .trae/documents/为LineEdge添加虚线形态属性.md ================================================ 1. 在LineEdge类中添加线条类型属性: - 在LineEdge.tsx中添加`@serializable`装饰的`lineType`属性,使用字符串枚举类型 - 支持的值:'solid'(实线)和'dashed'(虚线),后续可扩展 - 在构造函数中初始化该属性为'solid' - 更新相关类型定义 2. 更新渲染逻辑: - 在StraightEdgeRenderer.tsx中修改renderNormalState和renderShiftingState方法,根据lineType属性选择调用renderSolidLine或renderDashedLine - 确保其他渲染器(如SymmetryCurveEdgeRenderer和VerticalPolyEdgeRenderer)也支持虚线渲染 3. 更新序列化和反序列化: - 确保lineType属性能够被正确序列化和反序列化 - 在convertVAnyToN1函数中,为LineEdge添加lineType属性,默认值为'solid' 4. 测试和验证: - 确保新属性能够被正确保存和加载 - 测试实线和虚线的渲染效果 - 确保现有功能不受影响 ================================================ FILE: .trae/documents/为RecentFilesWindow添加独立的隐私模式功能.md ================================================ ## 计划概述 为 RecentFilesWindow 页面添加独立的隐私模式开关,当开启时对文件夹名和文件名进行凯撒移位加密显示。 ## 实施步骤 1. **添加本地隐私模式状态** - 在组件中添加 `isLocalPrivacyMode` 状态 - 添加切换按钮到工具栏 2. **创建凯撒移位加密函数** - 复用现有的 `replaceTextWhenProtect` 函数,但强制使用凯撒模式 - 或者创建专用的文件名加密函数 3. **修改显示逻辑** - 在平铺视图中对文件名应用加密 - 在嵌套视图的文件夹名和文件名上应用加密 - 只影响显示,不改变实际数据 4. **UI优化** - 添加隐私模式切换按钮,图标使用遮罩或眼睛图标 - 按钮状态反映当前是否开启隐私模式 ## 技术要点 - 使用凯撒移位加密(字符后移一位) - 复用现有的加密逻辑 - 只在前端渲染层面做改变,不影响数据存储 - 支持中英文字符的合理加密处理 ================================================ FILE: .trae/documents/优化Tab键和反斜杠键创建节点的字体大小.md ================================================ # 优化Tab键和反斜杠键创建节点的字体大小 ## 一、问题分析 当前Tab键和反斜杠键创建节点时,新节点的字体大小总是使用默认值(fontScaleLevel = 0),而没有考虑兄弟节点的字体大小。根据需求,新创建的节点应该: 1. 查看同方向兄弟节点的字体大小 2. 如果兄弟节点大小一致,新节点使用相同大小 3. 如果兄弟节点大小不一致,使用父节点大小。 4. 只考虑同方向的兄弟节点(上、下、左、右四个方向) ## 二、实现思路 1. **获取同方向兄弟节点**:根据节点的出边方向,将子节点分为四个方向组 2. **检查兄弟节点字体大小一致性**:遍历同方向兄弟节点,检查它们的fontScaleLevel是否相同 3. **设置新节点字体大小**:如果兄弟节点大小一致,新节点使用相同大小;否则使用父节点大小或默认值 4. **修改两个创建节点的方法**:`onDeepGenerateNode`(Tab键)和`onBroadGenerateNode`(反斜杠键) ## 三、关键修改点 ### 1. 修改 `onDeepGenerateNode` 方法(Tab键深度创建节点) **文件路径**:`/Volumes/移动固态1/project-graph-1/app/src/core/service/controlService/keyboardOnlyEngine/keyboardOnlyTreeEngine.tsx` **修改内容**: - 在创建新节点之前,获取父节点的出边 - 根据预方向过滤出同方向的兄弟节点 - 检查这些兄弟节点的字体大小是否一致 - 为新节点设置合适的fontScaleLevel ### 2. 修改 `onBroadGenerateNode` 方法(反斜杠键广度创建节点) **文件路径**:`/Volumes/移动固态1/project-graph-1/app/src/core/service/controlService/keyboardOnlyEngine/keyboardOnlyTreeEngine.tsx` **修改内容**: - 在创建新节点之前,获取父节点的出边 - 根据预方向过滤出同方向的兄弟节点 - 检查这些兄弟节点的字体大小是否一致 - 为新节点设置合适的fontScaleLevel ### 3. 辅助函数(可选) 可以考虑添加一个辅助函数,用于获取同方向兄弟节点并检查字体大小一致性,以避免代码重复。 ## 四、实现步骤 1. **在** **`onDeepGenerateNode`** **方法中**: - 获取父节点的出边 - 根据预方向过滤出同方向的兄弟节点 - 检查兄弟节点的字体大小一致性 - 为新节点设置合适的fontScaleLevel 2. **在** **`onBroadGenerateNode`** **方法中**: - 获取父节点的出边 - 根据预方向过滤出同方向的兄弟节点 - 检查兄弟节点的字体大小一致性 - 为新节点设置合适的fontScaleLevel 3. **测试验证**: - 创建树形结构,为不同方向的子节点设置不同的字体大小 - 使用Tab键和反斜杠键创建新节点 - 验证新节点的字体大小是否符合预期 ## 五、预期效果 1. 当使用Tab键或反斜杠键创建新节点时,新节点的字体大小会与同方向兄弟节点保持一致 2. 如果没有同方向兄弟节点,新节点使用父节点的字体大小 3. 只考虑同方向的兄弟节点,不同方向的节点不影响 4. 保持原有功能不变,只优化字体大小设置 ## 六、注意事项 1. 确保代码兼容性,不破坏现有功能 2. 处理边界情况,如没有兄弟节点、兄弟节点字体大小不一致等 3. 保持代码风格一致,遵循现有代码的设计模式 4. 考虑性能影响,避免不必要的计算 ================================================ FILE: .trae/documents/优化嫁接操作与添加反向操作.md ================================================ # 优化嫁接操作与添加反向操作 ## 1. 优化嫁接操作(insertNodeToTree) **问题**:当前嫁接操作创建的新连线总是使用默认的中心点连接,没有保持原连线的方向。 **解决方案**: - 修改 `TextNodeSmartTools.insertNodeToTree` 方法 - 保存原碰撞连线的 `sourceRectangleRate` 和 `targetRectangleRate` 属性 - 在创建新连线时使用这些属性,保持原连线的方向 - 对于向右的连线,确保新连线从源头右侧发出,目标左侧接收 ## 2. 实现反向操作(removeNodeFromTree) **功能**:将选中的节点从树中移除,并重新连接其前后节点。 **实现步骤**: - 在 `TextNodeSmartTools` 命名空间中添加 `removeNodeFromTree` 方法 - 逻辑: 1. 检查选中节点数量(必须为1) 2. 找到选中节点的所有入边和出边 3. 删除这些边 4. 将入边的源节点直接连接到出边的目标节点 5. 删除选中的节点 6. 记录操作历史 ## 3. 添加快捷键 **快捷键设置**: - 嫁接操作:`1 e` - 摘除操作:`1 r` **实现**:在 `shortcutKeysRegister.tsx` 中添加两个新的快捷键注册: - 嫁接:`id: "graftNodeToTree", defaultKey: "1 e"` - 摘除:`id: "removeNodeFromTree", defaultKey: "1 r"` ## 4. 新增快捷键分类 **分类设置**: - 名称:"node"(节点相关) - 图标:`` - 包含快捷键:`["graftNodeToTree", "removeNodeFromTree"]` **实现**:在 `keybinds.tsx` 的 `shortcutKeysGroups` 数组中添加新分类。 ## 5. 文件修改清单 1. `textNodeSmartTools.tsx`: - 优化 `insertNodeToTree` 方法 - 添加 `removeNodeFromTree` 方法 2. `shortcutKeysRegister.tsx`: - 注册两个新快捷键 3. `keybinds.tsx`: - 添加新的快捷键分类 4. `locales/zh_CN.yml`(可选): - 添加新快捷键的国际化标题和描述 ## 6. 预期效果 - 嫁接操作:保持原连线方向,特别是向右的连线会从源头右侧发出,目标左侧接收 - 摘除操作:快速将节点从树中移除,自动重新连接前后节点 - 快捷键:方便的 "1 e" 和 "1 r" 组合键 - 快捷键分类:更清晰的快捷键管理,新分类 "节点相关" 包含这两个操作 ================================================ FILE: .trae/documents/优化文本节点渲染判断逻辑.md ================================================ ### 问题分析 当前文本节点的文字渲染判断是基于固定的摄像机缩放阈值 `Settings.ignoreTextNodeTextRenderLessThanCameraScale`,当摄像机缩放比例小于这个阈值时,所有文本节点的文字都不会被渲染。这导致大字体的文本节点在宏观视野下更容易被看不见,因为它们的文字可能在摄像机缩放比例还比较大的时候就已经被隐藏了。 ### 解决方案 1. 将设置项 `ignoreTextNodeTextRenderLessThanCameraScale` 重命名为 `ignoreTextNodeTextRenderLessThanFontSize`,以更准确地反映其功能 2. 改为基于实际渲染字体大小的动态判断:根据文本节点的字体大小和当前摄像机缩放比例,计算出实际渲染的字体大小,然后判断这个实际字体大小是否大于设置的最小可见字体大小,只有当实际字体大小大于这个值时,才渲染文字 ### 实现方案 #### 1. 重命名设置项 **1.1 Settings.tsx** - 将 `ignoreTextNodeTextRenderLessThanCameraScale` 重命名为 `ignoreTextNodeTextRenderLessThanFontSize` - 设置合理的默认值和范围:`z.number().min(1).max(15).default(10)` **1.2 SettingsIcons.tsx** - 更新相关图标配置,将 `ignoreTextNodeTextRenderLessThanCameraScale` 改为 `ignoreTextNodeTextRenderLessThanFontSize` **1.3 语言文件** - 在所有语言文件中,将 `ignoreTextNodeTextRenderLessThanCameraScale` 重命名为 `ignoreTextNodeTextRenderLessThanFontSize` - 更新描述,说明它现在表示最小可见字体大小(像素) **1.4 settings.tsx** - 更新设置项,将 `ignoreTextNodeTextRenderLessThanCameraScale` 改为 `ignoreTextNodeTextRenderLessThanFontSize` #### 2. 修改渲染逻辑 **2.1 TextNodeRenderer.tsx** - **第25行**:将基于摄像机缩放比例的透明背景判断改为基于实际渲染字体大小 - **第52行**:将基于摄像机缩放比例的文字渲染判断改为基于实际渲染字体大小 - 计算实际渲染字体大小:`const renderedFontSize = node.getFontSize() * this.project.camera.currentScale` - 使用新的设置项:`renderedFontSize < Settings.ignoreTextNodeTextRenderLessThanFontSize` **2.2 EntityRenderer.tsx** - 修改使用 `ignoreTextNodeTextRenderLessThanCameraScale` 的渲染逻辑,改为使用 `ignoreTextNodeTextRenderLessThanFontSize` 并基于实际渲染字体大小 **2.3 SectionRenderer.tsx** - 修改使用 `ignoreTextNodeTextRenderLessThanCameraScale` 的渲染逻辑,改为使用 `ignoreTextNodeTextRenderLessThanFontSize` 并基于实际渲染字体大小 **2.4 MultiTargetUndirectedEdgeRenderer.tsx** - 修改使用 `ignoreTextNodeTextRenderLessThanCameraScale` 的渲染逻辑,改为使用 `ignoreTextNodeTextRenderLessThanFontSize` 并基于实际渲染字体大小 ### 预期效果 - 大字体的文本节点在宏观视野下会比小字体的文本节点更晚消失 - 所有文本节点的文字在视觉上达到相同的清晰度阈值时才会消失 - 提高了宏观视野下的可读性,用户可以在更远的距离看到重要的大字体文本 - 优化了渲染性能,只渲染在当前缩放级别下可见的文字 - 设置项范围合理,用户可以在1-15像素之间调整最小可见字体大小 ### 实施步骤 1. 在 `Settings.tsx` 中重命名设置项并设置范围:`z.number().min(1).max(15).default(10)` 2. 更新 `SettingsIcons.tsx` 中的配置 3. 更新所有语言文件中的设置项名称和描述 4. 更新 `settings.tsx` 中的设置项 5. 修改 `TextNodeRenderer.tsx` 中的渲染逻辑 6. 修改其他相关文件中的渲染逻辑 7. 测试不同字体大小的文本节点在不同摄像机缩放级别下的渲染效果 8. 验证设置调整是否生效 ================================================ FILE: .trae/documents/修复Ctrl+T快捷键只能触发一个功能的问题.md ================================================ ## 问题分析 1. **现象**:用户按下Ctrl+T快捷键时,只有一个功能被触发,而不是三个绑定了该快捷键的功能都被触发 2. **原因**:在`KeyBindsUI.tsx`的`check`函数中,当第一个匹配的快捷键执行后,会立即调用`userEventQueue.clear()`清空事件队列,导致后续绑定了相同快捷键的功能无法匹配到事件 3. **涉及文件**: - `app/src/core/service/controlService/shortcutKeysEngine/KeyBindsUI.tsx` - 快捷键处理核心逻辑 - `app/src/core/service/controlService/shortcutKeysEngine/shortcutKeysRegister.tsx` - 快捷键注册定义 ## 解决方案 修改`KeyBindsUI.tsx`中的`check`函数,调整事件队列清空的时机,确保所有匹配的快捷键都能被执行: 1. 移除在单个快捷键执行后立即清空队列的逻辑 2. 收集所有匹配的快捷键,执行完所有匹配的快捷键后再清空队列 3. 或者保持队列清空逻辑,但确保每个快捷键都能检查到匹配的事件 ## 具体修改步骤 1. 打开`KeyBindsUI.tsx`文件 2. 修改`check`函数,将`userEventQueue.clear()`移到所有快捷键检查完成之后 3. 确保所有匹配的快捷键都能被执行 4. 测试修改效果,确认按下Ctrl+T时三个功能都能被触发 ## 预期效果 - 按下Ctrl+T时,会依次执行: - `folderSection` - 切换/折叠章节 - `reverseEdges` - 反转选中的边 - `reverseSelectedNodeEdge` - 反转选中节点的边 - 所有绑定了相同快捷键的功能都能正常触发 - 不影响其他快捷键的正常工作 ================================================ FILE: .trae/documents/修复引用块转换时连线悬空问题.md ================================================ ## 问题分析 当文本节点转换为引用块时,如果该文本节点已经有连线连接,这些连线会变成"架空"状态,无法删除。 ### 根本原因 1. `changeTextNodeToReferenceBlock` 函数直接调用 `StageManager.delete(selectedNode)` 删除原文本节点 2. `StageManager.delete()` 只是简单地从数组中移除对象,没有处理关联的连线 3. 虽然 `DeleteManager` 有 `deleteEntityAfterClearAssociation` 方法来清理节点删除后的连线,但该方法只在 `DeleteManager.deleteEntities()` 中被调用 4. 转换过程中创建了新的引用块节点,但没有处理原节点的连线关系 ## 解决方案 修改 `changeTextNodeToReferenceBlock` 函数,在转换节点时正确处理连线关系: 1. 在删除原文本节点前,获取所有与该节点相关的连线 2. 创建新的引用块节点 3. 将原节点的连线更新为连接到新的引用块节点 4. 最后删除原文本节点 ## 实施步骤 1. 查看 `changeTextNodeToReferenceBlock` 函数的完整实现 2. 修改该函数,添加连线处理逻辑 3. 测试修复效果 ## 预期结果 - 文本节点转换为引用块时,原节点的连线会自动转移到新的引用块节点 - 不会出现"架空"的连线 - 转换后的引用块节点可以正常与其他节点连接 ## 代码修改点 - `/Users/littlefean/Desktop/Projects/project-graph/app/src/core/service/dataManageService/textNodeSmartTools.tsx`:修改 `changeTextNodeToReferenceBlock` 函数 ## 具体修改思路 1. 在删除原节点前,遍历所有关联,找出与原节点相关的连线 2. 创建新的引用块节点 3. 更新这些连线的源/目标为新的引用块节点 4. 删除原节点 这样可以确保连线关系被正确转移,不会出现悬空的连线。 ================================================ FILE: .trae/documents/全局快捷键重构方案.md ================================================ ## 计划概述 为 RecentFilesWindow 页面添加独立的隐私模式开关,当开启时对文件夹名和文件名进行凯撒移位加密显示。 ## 实施步骤 1. **添加本地隐私模式状态** - 在组件中添加 `isLocalPrivacyMode` 状态 - 添加切换按钮到工具栏 2. **创建凯撒移位加密函数** - 复用现有的 `replaceTextWhenProtect` 函数,但强制使用凯撒模式 - 或者创建专用的文件名加密函数 3. **修改显示逻辑** - 在平铺视图中对文件名应用加密 - 在嵌套视图的文件夹名和文件名上应用加密 - 只影响显示,不改变实际数据 4. **UI优化** - 添加隐私模式切换按钮,图标使用遮罩或眼睛图标 - 按钮状态反映当前是否开启隐私模式 ## 技术要点 - 使用凯撒移位加密(字符后移一位) - 复用现有的加密逻辑 - 只在前端渲染层面做改变,不影响数据存储 - 支持中英文字符的合理加密处理 ================================================ FILE: .trae/documents/在快捷键设置页面添加重置所有快捷键按钮.md ================================================ 1. **修改`keybinds.tsx`文件**,在左侧快捷键分类栏底部添加分割线和重置所有快捷键按钮 - 在`SidebarMenu`组件中,所有分类项之后添加一个分割线 - 分割线使用合适的样式,与现有UI设计保持一致 - 在分割线下方添加重置按钮 - 按钮使用合适的图标和文字 - 绑定点击事件处理函数 2. **实现重置按钮点击事件** - 调用`KeyBindsUI.resetAllKeyBinds()`方法重置所有快捷键 - 更新页面数据状态 - 显示重置成功提示 3. **更新UI界面** - 确保按钮样式与现有分类项一致 - 按钮位置在分类栏最底部,分割线下方 - 添加适当的视觉区分 4. **测试功能** - 点击重置按钮,验证所有快捷键是否恢复默认值 - 检查页面显示是否更新 - 验证提示信息是否正确显示 **预期效果**: - 快捷键设置页面左侧分类栏底部会显示一个分割线 - 分割线下方显示"重置所有快捷键"按钮 - 点击按钮后,所有快捷键将恢复为默认值 - 页面会更新显示,同时显示重置成功的提示信息 - 重置功能与顶部导航栏的重置按钮功能一致 ================================================ FILE: .trae/documents/实现 Section 的 isHidden 属性功能.md ================================================ # 实现 Section 的 isHidden 属性功能 ## 功能需求 1. **isHidden 属性**:控制 section 内部细节的隐藏状态 2. **移动限制**:隐藏后内部物体不能移动(包括跳跃式移动、普通拖拽、ctrl 拖拽) 3. **删除限制**:隐藏后内部物体不能删除(包括劈砍删除和 del 删除) 4. **跳跃式移动限制**:内部物体不能跳出去,外部物体不能跳进来 5. **操作方式**:右键菜单添加"隐藏 Section 内部细节"项 6. **渲染形态**:隐藏的 section 框显示斜着的线性阴影状态 7. **详细注释**:为 isHidden 属性添加详细注释 ## 实现步骤 ### 1. 修改 Section.tsx - 为 isHidden 属性添加详细注释,说明其功能是隐藏内部细节并实现内部锁定效果 - 确保 isHidden 属性在构造函数中正确初始化 ### 2. 修改右键菜单 - 在 `context-menu-content.tsx` 中添加"隐藏 Section 内部细节"菜单项 - 实现菜单项的点击逻辑,切换 section 的 isHidden 状态 ### 3. 修改移动控制 - **跳跃式移动**:在 `ControllerEntityLayerMoving.tsx` 和 `StageEntityMoveManager.tsx` 中添加 isHidden 检查 - **普通移动**:在 `ControllerEntityClickSelectAndMove.tsx` 中添加 isHidden 检查 - **移动限制逻辑**:检查实体是否在 isHidden 为 true 的 section 内 ### 4. 修改删除控制 - **劈砍删除**:在 `ControllerCutting.tsx` 中添加 isHidden 检查 - **del 删除**:在 `StageManager.tsx` 的 deleteSelectedStageObjects 方法中添加 isHidden 检查 ### 5. 修改渲染逻辑 - 在 `SectionRenderer.tsx` 中添加隐藏状态的特殊渲染逻辑 - 为隐藏的 section 框添加斜着的线性阴影效果 - 确保隐藏状态下的 section 框有清晰的视觉标识 ### 6. 测试验证 - 测试右键菜单的隐藏功能 - 测试隐藏后内部物体的移动限制 - 测试隐藏后内部物体的删除限制 - 测试跳跃式移动的限制 - 测试隐藏 section 的斜线性阴影渲染效果 ## 技术要点 - 使用现有的 isHidden 属性,无需添加新属性 - 确保所有移动和删除操作都检查实体是否在隐藏的 section 内 - 为隐藏的 section 添加斜着的线性阴影效果作为视觉标识 - 添加详细的代码注释,便于其他开发者理解 ================================================ FILE: .trae/documents/实现Section框大标题相机缩放阈值控制.md ================================================ 1. **添加设置项**:在`Settings.tsx`的`settingsSchema`中添加新的设置项`sectionBigTitleCameraScaleThreshold`,类型为number,范围0.01到1,步长0.01,默认值0.5 2. **添加图标**:在`SettingsIcons.tsx`中为新设置项添加合适的图标 3. **添加翻译**:在中文翻译文件`zh_CN.yml`中添加新设置项的标题和描述 4. **修改渲染逻辑**: - 在`SectionRenderer.tsx`的`renderBigCoveredTitle`和`renderTopTitle`方法中,添加相机缩放阈值判断 - 在`EntityRenderer.tsx`的`renderAllSectionsBigTitle`方法中,添加相机缩放阈值判断 5. **确保设置项显示**:确认新设置项在设置界面中正确显示 ================================================ FILE: .trae/documents/实现关闭软件前的未保存文件警告.md ================================================ ## 问题分析 当用户点击关闭软件按钮时,系统会遍历所有项目并调用 `closeProject` 函数,对每个未保存的项目弹出保存询问。然而,这种方式存在风险:保存操作是异步的,可能在保存完成前软件就已关闭,导致文件损坏或丢失。 ## 解决方案 在关闭窗口前,先检查是否有未保存的项目,如果有则弹出一个统一的警告对话框,告知用户有未保存文件,建议先手动保存,避免自动保存可能出现的问题。 ## 实现步骤 1. **修改关闭窗口事件处理逻辑**: - 在 `App.tsx` 的 `onCloseRequested` 事件处理中,添加未保存项目检查 - 如果存在未保存项目,弹出统一警告对话框 - 根据用户选择决定是否继续关闭流程 2. **检查未保存项目**: - 遍历所有项目,检查其状态是否为 `ProjectState.Unsaved` 或 `ProjectState.Stashed` - 统计未保存项目数量 3. **弹出警告对话框**: - 使用现有的 `Dialog` 组件创建警告对话框 - 显示未保存项目数量和警告信息 - 提供 "继续关闭" 和 "取消" 两个选项 4. **处理用户选择**: - 如果用户选择 "继续关闭",则执行原有的关闭流程 - 如果用户选择 "取消",则中止关闭流程 ## 核心修改点 - 文件:`/Volumes/移动固态1/project-graph-1/app/src/App.tsx` - 函数:`onCloseRequested` 事件处理函数(第262-280行) - 新增逻辑:未保存项目检查和统一警告对话框 ## 预期效果 - 当用户关闭软件时,如果有未保存文件,会先看到一个统一的警告 - 用户可以选择继续关闭(执行原有保存流程)或取消关闭(手动保存文件) - 减少文件保存不完整的风险,提高用户数据安全性 - 增强用户体验,让用户更清楚当前的文件状态 ================================================ FILE: .trae/documents/实现图片节点拖拽缩放功能.md ================================================ # 实现图片节点拖拽缩放功能 ## 1. 实现目标 - 选中图片节点后,在右下角显示缩放控制点 - 拖拽控制点可等比例缩放图片 - 保持现有的等比例缩放特性 - 性能优化:只在选中时显示控制点 ## 2. 实现步骤 ### 步骤1:让ImageNode实现ResizeAble接口 - 修改`ImageNode.tsx`,让其实现`ResizeAble`接口 - 添加`getResizeHandleRect()`方法,返回右下角缩放控制点矩形 - 添加`resizeHandle()`方法,根据拖拽距离计算新缩放比例 ### 步骤2:修改EntityRenderer渲染缩放控制点 - 修改`EntityRenderer.tsx`中的`renderImageNode`方法 - 选中状态下,调用`shapeRenderer.renderRect()`绘制缩放控制点 - 控制点位置:右下角,大小随相机缩放 ### 步骤3:确保ControllerEntityResize支持ImageNode - 检查`ControllerEntityResize.tsx`是否能处理ImageNode - 确保`utilsControl.tsx`中`isClickedResizeRect`能正确检测ImageNode的缩放控制点 ### 步骤4:移除旧的提示文字 - 在`EntityRenderer.tsx`的`renderImageNode`方法中,移除"ctrl+滚轮缩放大小"提示 - 保持Ctrl+滚轮缩放功能不变,增加拖拽缩放作为补充 ### 步骤5:性能优化 - 复用现有的渲染逻辑,避免额外性能开销 - 只在节点选中且相机缩放足够大时绘制控制点 - 使用与TextNode相同的缩放控制点样式,保持一致性 ## 3. 技术细节 ### 缩放控制点设计 - 位置:图片右下角 - 大小:固定像素大小,随相机缩放 - 样式:与TextNode缩放控制点一致 - 颜色:使用`stageStyleManager.currentStyle.CollideBoxSelected` ### 缩放逻辑 - 保持等比例缩放,根据拖拽距离计算新的缩放比例 - 缩放范围:0.1 - 10(与现有逻辑一致) - 拖拽时实时更新碰撞箱 ### 交互流程 1. 选中图片节点 2. 右下角显示缩放控制点 3. 鼠标悬停控制点时,鼠标样式变为缩放样式 4. 拖拽控制点,图片等比例缩放 5. 释放鼠标,完成缩放 ## 4. 代码修改点 1. **`ImageNode.tsx`**:实现ResizeAble接口,添加缩放相关方法 2. **`EntityRenderer.tsx`**:渲染缩放控制点,移除旧提示 3. **`ControllerEntityResize.tsx`**:确保支持ImageNode(如果需要) 4. **`utilsControl.tsx`**:确保能检测ImageNode的缩放控制点(如果需要) ## 5. 预期效果 - 选中图片节点后,右下角显示缩放控制点 - 拖拽控制点可流畅地等比例缩放图片 - 保持现有Ctrl+滚轮缩放功能不变 - 性能良好,不影响其他操作 - 与现有UI风格保持一致 ================================================ FILE: .trae/documents/实现引用块节点的精准连线定位.md ================================================ ### 实现引用块节点的精准连线定位 #### 问题分析 图片节点在连线时有一个特性:当鼠标拖拽连线时,会根据鼠标位置精准定位连线的箭头位置,无论是从图片节点发出还是连接到图片节点,都能精准定位到图片内部的具体位置。现在需要让引用块节点也具有相同的特性。 #### 实现方案 需要修改以下几个文件: 1. **ControllerNodeConnection.tsx** - 在 `onMouseDown` 方法中添加对 `ReferenceBlockNode` 的支持,记录起始点在引用块上的精确位置 - 在 `mouseUp` 方法中添加对 `ReferenceBlockNode` 的支持,记录结束点在引用块上的精确位置 - 在 `dragMultiConnect` 方法中添加对 `ReferenceBlockNode` 的支持,使用精确位置计算连线起点和终点 2. **Edge.tsx** - 在 `bodyLine` getter 方法中添加对 `ReferenceBlockNode` 的支持,当连线连接到引用块节点且使用精确位置时,直接使用内部位置 3. **SymmetryCurveEdgeRenderer.tsx** - 在 `renderNormalState` 方法中添加对 `ReferenceBlockNode` 的支持,检查是否是引用块节点的精确位置,并使用相应的法线向量计算方式 #### 实现思路 1. 在处理图片节点的地方,同时添加对引用块节点的检查 2. 复用现有的精确位置计算逻辑 3. 确保引用块节点在连线时能像图片节点一样精准定位 #### 预期效果 引用块节点在进行连线操作时,无论是作为连线的起点还是终点,都能根据鼠标位置精准定位连线的箭头位置,就像图片节点一样。 ================================================ FILE: .trae/documents/实现快捷键开关功能.md ================================================ # 实现快捷键开关功能 ## 核心需求 - 为每个快捷键添加开关功能,支持自定义默认状态 - 在设置页面的快捷键页面中显示开关控件 - 支持开关状态的持久化存储 - 修改相关代码以支持开关状态的触发控制 ## 实现步骤 ### 1. 修改快捷键定义接口 - 修改 `shortcutKeysRegister.tsx` 中的 `KeyBindItem` 接口,添加 `defaultEnabled: boolean` 属性 - 为所有现有快捷键添加默认 `defaultEnabled: true` - 支持后续修改特定快捷键的默认启用状态 ### 2. 设计持久化存储方案 - **方案选择**:使用现有 `keybinds2.json` 文件,扩展数据结构 - **数据结构设计**: ```json { "shortcutId": { "key": "C-z", "isEnabled": true } } ``` - **向后兼容**:未设置的快捷键使用 `defaultEnabled` 值 ### 3. 扩展快捷键管理系统 - 修改 `KeyBinds.tsx` 和 `KeyBindsUI.tsx`,添加开关状态管理 - 更新 `create` 方法,支持初始化开关状态 - 添加 `toggleEnabled` 方法,支持切换开关状态 - 修改 `get` 和 `set` 方法,支持获取和设置完整的快捷键配置 ### 4. 修改快捷键触发逻辑 - 在 `KeyBinds.tsx` 的 `check` 方法中,添加开关状态检查 - 在 `KeyBindsUI.tsx` 的 `check` 方法中,添加开关状态检查 - 只有 `isEnabled` 为 `true` 的快捷键才会被触发 ### 5. 更新设置页面组件 - 修改 `keybinds.tsx`,在每个快捷键项中添加开关控件 - 引入 `Switch` 组件(假设已有或从UI库中引入) - 添加开关状态的保存和加载逻辑 - 支持实时更新开关状态 ### 6. 修改快捷键组件 - 更新 `KeyBind` 组件,支持显示和操作开关状态 - 在组件中集成开关控件 - 支持开关状态的回调通知 ## 文件修改清单 1. `shortcutKeysRegister.tsx` - 扩展快捷键定义,添加 `defaultEnabled` 属性 2. `KeyBinds.tsx` - 支持项目级快捷键开关管理 3. `KeyBindsUI.tsx` - 支持UI级快捷键开关管理 4. `keybinds.tsx` - 添加设置页面开关控件 5. `KeyBind.tsx` - 更新快捷键组件,集成开关功能 ## 技术要点 - 使用现有的Tauri Store进行持久化存储 - 采用扩展数据结构而非新增文件,简化管理 - 保持向后兼容性,旧配置自动迁移 - 实时更新开关状态,无需重启应用 - 支持自定义默认启用状态 ## 预期效果 - 每个快捷键都有独立的开关控制 - 设置页面直观显示所有快捷键的开关状态 - 关闭的快捷键不会响应键盘事件 - 开关状态持久化保存,重启应用后保持 - 支持通过修改 `defaultEnabled` 调整默认启用状态 ## 风险评估 - 需确保所有现有快捷键都正确添加 `defaultEnabled` 属性 - 需测试快捷键触发逻辑,确保关闭状态的快捷键不会被触发 - 需确保设置页面的开关控件正常工作 - 需确保数据结构扩展后与现有代码兼容 ## 测试计划 1. 验证所有快捷键默认开启 2. 测试单个快捷键开关功能 3. 测试多个快捷键批量开关 4. 测试开关状态持久化 5. 测试关闭状态的快捷键是否被正确忽略 6. 测试设置页面开关控件的交互体验 7. 测试修改 `defaultEnabled` 后新配置的效果 ## 优化建议 - 考虑添加"全选"和"反选"功能,方便批量管理快捷键开关 - 考虑添加快捷键分组开关,方便按组管理 - 考虑添加重置开关状态到默认值的功能 ## 实现细节 - 使用 `isEnabled` 表示当前启用状态,`defaultEnabled` 表示默认启用状态 - 存储时只保存与默认值不同的配置,节省存储空间 - 加载时优先使用存储的配置,否则使用默认值 - 开关状态与快捷键键位独立管理,允许单独修改 ================================================ FILE: .trae/documents/实现搜索范围选项.md ================================================ # 实现搜索范围选项 ## 需求分析 需要在搜索功能中添加两个搜索范围选项: 1. 只搜索所有选中的内容(选中的节点) 2. 只搜索所有选中内容的外接矩形范围内的所有实体 ## 实现思路 1. **修改搜索引擎核心** - 在`ContentSearch`类中添加搜索范围枚举和相关属性 - 修改`startSearch`方法,根据搜索范围过滤搜索对象 - 添加获取选中对象外接矩形的方法 2. **增强搜索面板UI** - 在`FindWindow`中添加搜索范围选择控件 - 实现UI与搜索引擎的状态同步 - 添加相应的图标和提示 3. **实现搜索范围逻辑** - 实现"只搜索选中内容"逻辑:过滤出选中的对象进行搜索 - 实现"搜索外接矩形范围"逻辑:计算选中对象的外接矩形,然后搜索该范围内的所有对象 ## 实现步骤 1. **修改`contentSearchEngine.tsx`** - 添加`SearchScope`枚举类型 - 在`ContentSearch`类中添加`searchScope`属性 - 修改`startSearch`方法,根据搜索范围过滤搜索对象 - 添加`getSelectedObjectsBounds`方法,计算选中对象的外接矩形 - 添加`isObjectInBounds`方法,判断对象是否在指定范围内 2. **修改`FindWindow.tsx`** - 添加搜索范围状态管理 - 在UI中添加搜索范围选择按钮 - 实现搜索范围切换逻辑 - 同步UI状态到搜索引擎 3. **测试验证** - 测试不同搜索范围下的搜索结果 - 验证UI控件的交互和状态显示 - 确保原有功能不受影响 ## 文件修改 - `app/src/core/service/dataManageService/contentSearchEngine/contentSearchEngine.tsx` - `app/src/sub/FindWindow.tsx` ================================================ FILE: .trae/documents/实现背景图片功能和背景管理器.md ================================================ # 实现背景图片功能和背景管理器 ## 1. 为ImageNode添加背景图片属性 - 在ImageNode类中添加`isBackground`属性,用于标记图片是否为背景图片 - 确保该属性可序列化,以便保存到项目文件中 ## 2. 修改选择和删除逻辑 - 修改StageManager中的选择相关方法(如`findEntityByLocation`、`findImageNodeByLocation`等),跳过背景图片 - 修改删除相关方法(如`deleteEntities`、`deleteSelectedStageObjects`等),跳过背景图片 - 修改框选逻辑,确保背景图片不被框选选中 ## 3. 添加右键菜单项 - 在context-menu-content.tsx中为图片节点添加"转化为背景图片"菜单项 - 为背景图片添加"取消背景化"菜单项 - 实现对应的处理函数 ## 4. 创建背景管理器窗口 - 创建BackgroundManagerWindow组件 - 实现显示所有背景化图片的功能 - 实现单独取消背景化的功能 ## 5. 在右侧工具栏添加背景管理器入口 - 在右侧工具栏中添加背景管理器的按钮 - 实现点击按钮打开背景管理器窗口的功能 ## 6. 测试和优化 - 测试背景图片的选择、删除和背景化功能 - 测试背景管理器的功能 - 优化用户体验 ## 技术要点 - 确保背景图片在渲染时位于底层 - 确保背景图片不响应鼠标事件 - 确保背景图片的状态正确保存和加载 - 确保背景管理器能够正确显示和管理所有背景图片 ================================================ FILE: .trae/documents/引用块节点精准连线定位功能问题记录.md ================================================ # 引用块节点精准连线定位功能问题记录 ## 问题现象 在实现引用块节点(ReferenceBlockNode)的精准连线定位功能时,应用在启动时出现窗口无法弹出的问题。 ## 问题原因 经过分析,问题是由于循环依赖导致的。当我们在以下文件中导入ReferenceBlockNode类时,形成了循环依赖: 1. `ControllerNodeConnection.tsx` 2. `Edge.tsx` 3. `SymmetryCurveEdgeRenderer.tsx` 循环依赖导致应用在启动时无法正确加载模块,从而导致窗口无法弹出。 ## 解决方法 1. **移除ReferenceBlockNode的导入语句**:在所有相关文件中移除ReferenceBlockNode的导入语句,避免循环依赖。 2. **使用构造函数名称检查替代直接类型检查**:在需要检查对象是否为ReferenceBlockNode类型的地方,使用`constructor.name === 'ReferenceBlockNode'`来替代直接的`instanceof`检查。 3. **具体修改文件**: - `ControllerNodeConnection.tsx`:移除导入,使用构造函数名称检查来记录起始点和结束点的精确位置 - `Edge.tsx`:移除导入,使用构造函数名称检查来处理引用块节点的精确位置 - `SymmetryCurveEdgeRenderer.tsx`:移除导入,使用构造函数名称检查来处理引用块节点的法线向量计算 4. **修复后的效果**:应用可以正常启动,窗口能够弹出,同时引用块节点可以实现精准连线定位功能。 ## 代码修改示例 ```typescript // 修复前 if (clickedConnectableEntity instanceof ImageNode || clickedConnectableEntity instanceof ReferenceBlockNode) { // 处理逻辑 } // 修复后 if ( clickedConnectableEntity instanceof ImageNode || clickedConnectableEntity.constructor.name === "ReferenceBlockNode" ) { // 处理逻辑 } ``` ## 总结 通过移除循环依赖,使用构造函数名称检查替代直接类型检查,我们成功解决了窗口无法弹出的问题,同时实现了引用块节点的精准连线定位功能。这种方法可以避免循环依赖问题,同时保持代码的可读性和可维护性。 ================================================ FILE: .trae/documents/文本节点自定义文字大小功能设计方案.md ================================================ # 文本节点自定义文字大小功能设计方案 ## 一、需求分析 1. **功能需求**: - 为文本节点添加自定义文字大小功能 - 支持通过快捷键(放大/缩小)调整字体大小 - 采用指数形式缩放(例如:2 → 4 → 8 → 16 → 32) 2. **技术约束**: - 当前所有文本节点共享 `Renderer.FONT_SIZE = 32` 常量 - 渲染时字体大小会乘以相机缩放比例 - 已有完整的快捷键系统 ## 二、方案对比 ### 方案1:存储缩放级别(整数) **设计**: - 在 `TextNode` 类中添加 `fontScaleLevel` 字段,类型为整数 - 基准值为0,对应默认字体大小(32px) - 计算公式:`finalFontSize = Renderer.FONT_SIZE * Math.pow(2, fontScaleLevel)` - 快捷键操作:每次按放大键 `fontScaleLevel++`,按缩小键 `fontScaleLevel--` **优点**: - 存储值范围小,占用空间少 - 缩放逻辑清晰,符合用户期望的指数增长 - 便于实现快捷键操作(只需增减整数) - 支持正负值,可放大可缩小 **缺点**: - 需要额外计算才能得到实际像素值 - 无法直接表示非2的幂次的字体大小 ### 方案2:直接存储像素值 **设计**: - 在 `TextNode` 类中添加 `fontSize` 字段,类型为数值 - 默认值为 `Renderer.FONT_SIZE`(32px) - 快捷键操作:根据当前值计算指数缩放后的新值 **优点**: - 直接存储最终使用的像素值,无需计算 - 支持任意字体大小,灵活性更高 - 直观易懂,便于调试 **缺点**: - 存储值范围大,占用空间多 - 快捷键操作需要复杂计算(需要记录缩放次数或反向计算当前缩放级别) - 缩放逻辑不直观,用户难以预测下一次缩放后的大小 ## 三、推荐方案 ### 推荐方案:存储缩放级别(方案1的改进版) **设计**: 1. **字段设计**: - 在 `TextNode` 类中添加 `fontScale` 字段,类型为数值(支持小数) - 默认值为1.0,对应默认字体大小 - 计算公式:`finalFontSize = Renderer.FONT_SIZE * fontScale` 2. **缩放逻辑**: - 快捷键放大:`fontScale *= 2` - 快捷键缩小:`fontScale /= 2` - 支持直接设置特定缩放比例(如1.5、0.5等) 3. **实现细节**: - 添加 `increaseFontSize()` 和 `decreaseFontSize()` 方法 - 在快捷键注册中添加对应绑定 - 更新渲染逻辑,使用节点自身的 `fontScale` 计算最终字体大小 - 确保新字段支持序列化和反序列化 **优势**: - 结合了方案1和方案2的优点 - 缩放逻辑清晰,符合指数增长预期 - 支持精确调整字体大小 - 存储空间合理 - 便于实现快捷键操作 ## 四、实现步骤 1. **修改 `TextNode` 类**: - 添加 `@serializable` 装饰的 `fontScale` 字段 - 添加字体大小调整方法 2. **更新渲染逻辑**: - 在 `TextNodeRenderer` 中使用节点的 `fontScale` 计算字体大小 - 更新 `getMultiLineTextSize` 等相关方法 3. **添加快捷键支持**: - 在 `shortcutKeysRegister.tsx` 中注册放大/缩小快捷键 - 实现快捷键回调函数 4. **数据升级**: - 在 `ProjectUpgrader.tsx` 中添加升级逻辑,为旧节点设置默认 `fontScale` 5. **测试验证**: - 测试新建节点的默认字体大小 - 测试快捷键放大缩小功能 - 测试不同缩放级别的节点渲染效果 - 测试数据保存和加载功能 ## 五、预期效果 - 新创建的文本节点使用默认字体大小(32px) - 选中文本节点后,按放大键(如 `+`)字体大小翻倍 - 按缩小键(如 `-`)字体大小减半 - 不同节点可以有不同的字体大小 - 保存和加载后字体大小保持不变 ## 六、扩展考虑 - 未来可添加字体大小输入框,支持直接输入像素值 - 可添加字体大小范围限制(最小/最大) - 可支持批量调整多个节点的字体大小 该方案既满足了用户期望的指数缩放效果,又保持了良好的灵活性和可扩展性。 ================================================ FILE: .trae/documents/添加大标题遮罩透明度设置.md ================================================ 1. **添加设置项**:在 `Settings.tsx` 中添加一个新的设置项 `sectionBigTitleOpacity`,类型为 `z.number().min(0).max(1).default(0.5)`,用于控制大标题遮罩的透明度 2. **更新图标映射**:在 `SettingsIcons.tsx` 中为 `sectionBigTitleOpacity` 添加合适的图标,建议使用 `Blend` 图标,与其他透明度相关设置保持一致 3. **添加翻译**:在三个翻译文件中添加对应的标题和描述: - `zh_CN.yml`:标题为"框的缩略大标题透明度",描述为"控制半透明覆盖大标题的透明度,取值范围0-1" - `zh_TW.yml`:标题为"框的縮略大標題透明度",描述为"控制半透明覆蓋大標題的透明度,取值範圍0-1" - `en.yml`:标题为"Section Big Title Opacity",描述为"Control the opacity of the semi-transparent cover big title, range 0-1" 4. **修改渲染逻辑**:在 `SectionRenderer.tsx` 中,将硬编码的 `0.5` 透明度替换为使用 `Settings.sectionBigTitleOpacity` 值,确保设置项生效 5. **测试验证**:确保新设置项能够正确保存和应用,并且在广视野下能够看到大标题遮罩透明度的变化 ================================================ FILE: .trae/documents/添加快捷键冲突检测和提醒功能.md ================================================ # 快捷键冲突检测和提醒功能实现计划 ## 1. 功能需求分析 - 在快捷键设置页面中,为每个快捷键添加冲突检测 - 当快捷键重复时,显示警告色提示并说明与多少个快捷键冲突 - 点击提示可以查看具体与哪一个快捷键冲突 - 没有冲突时不显示任何内容,不占用额外视觉空间 ## 2. 实现方案 ### 2.1 添加冲突检测函数 - 在 `KeyBindsPage` 组件中添加 `detectKeyConflicts` 函数 - 该函数接收一个快捷键值,返回与该快捷键冲突的所有快捷键信息 - 冲突检测逻辑:检查所有启用的快捷键,找出具有相同键值的项 ### 2.2 修改快捷键设置项渲染 - 修改 `renderKeyFields` 函数,为每个快捷键设置项添加冲突检测 - 当检测到冲突时,在 `Field` 组件下方添加冲突提示元素 - 冲突提示元素使用警告色样式,显示冲突数量 ### 2.3 添加冲突详情对话框 - 添加一个对话框组件,用于显示冲突的快捷键详情 - 当用户点击冲突提示时,打开对话框并列出所有冲突的快捷键 - 对话框中显示冲突快捷键的名称、当前键值和所属分组 ### 2.4 优化用户体验 - 实时检测:当用户修改快捷键时,立即更新冲突状态 - 视觉反馈:使用明显的警告色和图标,让用户快速识别冲突 - 交互便捷:点击提示即可查看详情,无需额外操作 ## 3. 技术实现要点 ### 3.1 冲突检测逻辑 ```typescript const detectKeyConflicts = (targetKey: string, targetId: string) => { return data.filter((item) => item.key === targetKey && item.id !== targetId && item.isEnabled); }; ``` ### 3.2 冲突提示组件 - 使用 `Badge` 或自定义元素显示冲突数量 - 添加点击事件处理函数,打开详情对话框 - 应用适当的样式,确保警告效果明显 ### 3.3 对话框实现 - 使用现有的 `Dialog` 组件 - 动态生成冲突列表,显示每个冲突快捷键的详细信息 - 添加关闭按钮,确保用户可以方便地关闭对话框 ## 4. 具体修改文件 - `/Volumes/移动固态1/project-graph-1/app/src/sub/SettingsWindow/keybinds.tsx`:主修改文件,添加冲突检测和提醒功能 ## 5. 预期效果 - 用户在设置快捷键时,能够实时看到冲突提示 - 点击提示可以查看具体冲突的快捷键,便于调整 - 界面简洁,没有冲突时不显示额外元素,保持原有布局美观 ================================================ FILE: .trae/documents/粘贴bug崩溃报告.txt ================================================ ------------------------------------- Translated Report (Full Report Below) ------------------------------------- Process: project-graph [68049] Path: /Applications/Project Graph.app/Contents/MacOS/project-graph Identifier: liren.project-graph Version: 2.9.13 (2.9.13) Code Type: ARM-64 (Native) Role: Foreground Parent Process: launchd [1] Coalition: liren.project-graph [1342] User ID: 501 Date/Time: 2026-02-13 15:56:44.8734 +0800 Launch Time: 2026-02-13 09:40:05.9876 +0800 Hardware Model: Mac16,12 OS Version: macOS 26.1 (25B78) Release Type: User Crash Reporter Key: B6C57097-5B06-A3FA-7F07-E57289B4D2B6 Incident Identifier: 2CD58038-FC0A-4005-9C57-8CF12FA876D5 Sleep/Wake UUID: 5946CB7E-C783-40E2-ABF2-93A7C8E35F2C Time Awake Since Boot: 240000 seconds Time Since Wake: 23429 seconds System Integrity Protection: enabled Triggered by Thread: 0 main, Dispatch Queue: com.apple.main-thread Exception Type: EXC_BAD_ACCESS (SIGSEGV) Exception Subtype: KERN_INVALID_ADDRESS at 0x003aea405a1445a0 Exception Codes: 0x0000000000000001, 0x003aea405a1445a0 Termination Reason: Namespace SIGNAL, Code 11, Segmentation fault: 11 Terminating Process: exc handler [68049] VM Region Info: 0x6a405a1445a0 is not in any region. REGION TYPE START - END [ VSIZE] PRT/MAX SHRMOD REGION DETAIL UNUSED SPACE AT START ---> UNUSED SPACE AT END Thread 0 Crashed:: main Dispatch queue: com.apple.main-thread 0 libobjc.A.dylib 0x18848d820 objc_msgSend + 32 1 AppKit 0x18cdd812c -[NSPasteboard _updateTypeCacheIfNeeded] + 1064 2 AppKit 0x18d776820 -[NSPasteboard _typesAtIndex:combinesItems:] + 36 3 WebCore 0x1af2ccaec WebCore::PlatformPasteboard::informationForItemAtIndex(unsigned long, long long) + 172 4 WebCore 0x1aefb36b4 WebCore::PlatformPasteboard::allPasteboardItemInfo(long long) + 204 5 WebKit 0x1b250b57c WebKit::WebPasteboardProxy::grantAccessToCurrentData(WebKit::WebProcessProxy&, WTF::String const&, WTF::CompletionHandler&&) + 92 6 WebKit 0x1b24b97a4 WebKit::WebPageProxy::grantAccessToCurrentPasteboardData(WTF::String const&, WTF::CompletionHandler&&, std::__1::optional, unsigned long long>>) + 120 7 WebKit 0x1b267eeac WebKit::WebPageProxy::willPerformPasteCommand(WebCore::DOMPasteAccessCategory, WTF::CompletionHandler&&, std::__1::optional, unsigned long long>>) + 96 8 WebKit 0x1b27e0990 WebKit::WebPageProxy::executeEditCommand(WTF::String const&, WTF::String const&) + 352 9 WebKit 0x1b2693628 WebKit::WebViewImpl::executeEditCommandForSelector(objc_selector*, WTF::String const&) + 56 10 WebKit 0x1b23b7c28 -[WKWebView(WKImplementationMac) paste:] + 44 11 AppKit 0x18d852104 -[NSApplication(NSResponder) sendAction:to:from:] + 560 12 AppKit 0x18d6bc344 -[NSMenuItem _corePerformAction:] + 540 13 AppKit 0x18d880e7c _NSMenuPerformActionWithHighlighting + 160 14 AppKit 0x18d6a3424 -[NSMenu _performKeyEquivalentForItemAtIndex:] + 172 15 AppKit 0x18d6a3068 -[NSMenu performKeyEquivalent:] + 356 16 AppKit 0x18d850a9c routeKeyEquivalent + 444 17 AppKit 0x18d84ecd0 -[NSApplication(NSEventRouting) sendEvent:] + 1844 18 project-graph 0x104f4df94 0x104b58000 + 4153236 19 WebKit 0x1b269d1a8 WebKit::WebViewImpl::doneWithKeyEvent(NSEvent*, bool) + 168 20 WebKit 0x1b1dc409c WebKit::PageClientImpl::doneWithKeyEvent(WebKit::NativeWebKeyboardEvent const&, bool) + 56 21 WebKit 0x1b2808228 WebKit::WebPageProxy::didReceiveEvent(IPC::Connection*, WebKit::WebEventType, bool, std::__1::optional&&) + 1168 22 WebKit 0x1b2293088 WebKit::WebPageProxy::didReceiveMessage(IPC::Connection&, IPC::Decoder&) + 7124 23 WebKit 0x1b2ea8dd8 IPC::MessageReceiverMap::dispatchMessage(IPC::Connection&, IPC::Decoder&) + 264 24 WebKit 0x1b28878b0 WebKit::WebProcessProxy::dispatchMessage(IPC::Connection&, IPC::Decoder&) + 40 25 WebKit 0x1b22b2614 WebKit::WebProcessProxy::didReceiveMessage(IPC::Connection&, IPC::Decoder&) + 1620 26 WebKit 0x1b2e824dc IPC::Connection::dispatchMessage(WTF::UniqueRef) + 300 27 WebKit 0x1b2e82a0c IPC::Connection::dispatchIncomingMessages() + 536 28 JavaScriptCore 0x1a9e971d8 WTF::RunLoop::performWork() + 552 29 JavaScriptCore 0x1a9e98bd0 WTF::RunLoop::performWork(void*) + 36 30 CoreFoundation 0x1889789e8 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 28 31 CoreFoundation 0x18897897c __CFRunLoopDoSource0 + 172 32 CoreFoundation 0x1889786e8 __CFRunLoopDoSources0 + 232 33 CoreFoundation 0x188977378 __CFRunLoopRun + 820 34 CoreFoundation 0x188a3135c _CFRunLoopRunSpecificWithOptions + 532 35 HIToolbox 0x195434768 RunCurrentEventLoopInMode + 316 36 HIToolbox 0x195437a90 ReceiveNextEventCommon + 488 37 HIToolbox 0x1955c1308 _BlockUntilNextEventMatchingListInMode + 48 38 AppKit 0x18d2883c0 _DPSBlockUntilNextEventMatchingListInMode + 236 39 AppKit 0x18cd81e34 _DPSNextEvent + 588 40 AppKit 0x18d84ff44 -[NSApplication(NSEventRouting) _nextEventMatchingEventMask:untilDate:inMode:dequeue:] + 688 41 AppKit 0x18d84fc50 -[NSApplication(NSEventRouting) nextEventMatchingMask:untilDate:inMode:dequeue:] + 72 42 AppKit 0x18cd7a780 -[NSApplication run] + 368 43 project-graph 0x104cb392c 0x104b58000 + 1423660 44 project-graph 0x104cb37b4 0x104b58000 + 1423284 45 project-graph 0x104cb37a8 0x104b58000 + 1423272 46 project-graph 0x104cb364c 0x104b58000 + 1422924 47 project-graph 0x104cb072c 0x104b58000 + 1410860 48 project-graph 0x104b59010 0x104b58000 + 4112 49 project-graph 0x104b59350 0x104b58000 + 4944 50 dyld 0x188511d54 start + 7184 Thread 1:: com.apple.NSEventThread 0 libsystem_kernel.dylib 0x188896c34 mach_msg2_trap + 8 1 libsystem_kernel.dylib 0x1888a9028 mach_msg2_internal + 76 2 libsystem_kernel.dylib 0x18889f98c mach_msg_overwrite + 484 3 libsystem_kernel.dylib 0x188896fb4 mach_msg + 24 4 CoreFoundation 0x188978b90 __CFRunLoopServiceMachPort + 160 5 CoreFoundation 0x1889774e8 __CFRunLoopRun + 1188 6 CoreFoundation 0x188a3135c _CFRunLoopRunSpecificWithOptions + 532 7 AppKit 0x18ce11cb4 _NSEventThread + 184 8 libsystem_pthread.dylib 0x1888d9c08 _pthread_start + 136 9 libsystem_pthread.dylib 0x1888d4ba8 thread_start + 8 Thread 2: 0 libsystem_kernel.dylib 0x18889a4f8 __psynch_cvwait + 8 1 libsystem_pthread.dylib 0x1888da0dc _pthread_cond_wait + 984 2 project-graph 0x104fc9404 0x104b58000 + 4658180 3 project-graph 0x105023e50 0x104b58000 + 5029456 4 project-graph 0x105023b8c 0x104b58000 + 5028748 5 project-graph 0x104e22e8c 0x104b58000 + 2928268 6 project-graph 0x104e22bc0 0x104b58000 + 2927552 7 project-graph 0x104f379b4 0x104b58000 + 4061620 8 libsystem_pthread.dylib 0x1888d9c08 _pthread_start + 136 9 libsystem_pthread.dylib 0x1888d4ba8 thread_start + 8 Thread 3: 0 libsystem_kernel.dylib 0x18889a4f8 __psynch_cvwait + 8 1 libsystem_pthread.dylib 0x1888da0dc _pthread_cond_wait + 984 2 project-graph 0x104fc9404 0x104b58000 + 4658180 3 project-graph 0x105023e50 0x104b58000 + 5029456 4 project-graph 0x105023b8c 0x104b58000 + 5028748 5 project-graph 0x104e22e8c 0x104b58000 + 2928268 6 project-graph 0x104e22bc0 0x104b58000 + 2927552 7 project-graph 0x104f379b4 0x104b58000 + 4061620 8 libsystem_pthread.dylib 0x1888d9c08 _pthread_start + 136 9 libsystem_pthread.dylib 0x1888d4ba8 thread_start + 8 Thread 4: 0 libsystem_kernel.dylib 0x18889a4f8 __psynch_cvwait + 8 1 libsystem_pthread.dylib 0x1888da0dc _pthread_cond_wait + 984 2 project-graph 0x104fc9404 0x104b58000 + 4658180 3 project-graph 0x105023e50 0x104b58000 + 5029456 4 project-graph 0x105023b8c 0x104b58000 + 5028748 5 project-graph 0x104e22e8c 0x104b58000 + 2928268 6 project-graph 0x104e22bc0 0x104b58000 + 2927552 7 project-graph 0x104f379b4 0x104b58000 + 4061620 8 libsystem_pthread.dylib 0x1888d9c08 _pthread_start + 136 9 libsystem_pthread.dylib 0x1888d4ba8 thread_start + 8 Thread 5: 0 libsystem_kernel.dylib 0x18889a4f8 __psynch_cvwait + 8 1 libsystem_pthread.dylib 0x1888da0dc _pthread_cond_wait + 984 2 project-graph 0x104fc9404 0x104b58000 + 4658180 3 project-graph 0x105023e50 0x104b58000 + 5029456 4 project-graph 0x105023b8c 0x104b58000 + 5028748 5 project-graph 0x104e22e8c 0x104b58000 + 2928268 6 project-graph 0x104e22bc0 0x104b58000 + 2927552 7 project-graph 0x104f379b4 0x104b58000 + 4061620 8 libsystem_pthread.dylib 0x1888d9c08 _pthread_start + 136 9 libsystem_pthread.dylib 0x1888d4ba8 thread_start + 8 Thread 6: 0 libsystem_kernel.dylib 0x18889a4f8 __psynch_cvwait + 8 1 libsystem_pthread.dylib 0x1888da0dc _pthread_cond_wait + 984 2 project-graph 0x104fc9404 0x104b58000 + 4658180 3 project-graph 0x105023e50 0x104b58000 + 5029456 4 project-graph 0x105023b8c 0x104b58000 + 5028748 5 project-graph 0x104e22e8c 0x104b58000 + 2928268 6 project-graph 0x104e22bc0 0x104b58000 + 2927552 7 project-graph 0x104f379b4 0x104b58000 + 4061620 8 libsystem_pthread.dylib 0x1888d9c08 _pthread_start + 136 9 libsystem_pthread.dylib 0x1888d4ba8 thread_start + 8 Thread 7: 0 libsystem_kernel.dylib 0x18889a4f8 __psynch_cvwait + 8 1 libsystem_pthread.dylib 0x1888da0dc _pthread_cond_wait + 984 2 project-graph 0x104fc9404 0x104b58000 + 4658180 3 project-graph 0x105023e50 0x104b58000 + 5029456 4 project-graph 0x105023b8c 0x104b58000 + 5028748 5 project-graph 0x104e22e8c 0x104b58000 + 2928268 6 project-graph 0x104e22bc0 0x104b58000 + 2927552 7 project-graph 0x104f379b4 0x104b58000 + 4061620 8 libsystem_pthread.dylib 0x1888d9c08 _pthread_start + 136 9 libsystem_pthread.dylib 0x1888d4ba8 thread_start + 8 Thread 8: 0 libsystem_kernel.dylib 0x18889a4f8 __psynch_cvwait + 8 1 libsystem_pthread.dylib 0x1888da0dc _pthread_cond_wait + 984 2 project-graph 0x104fc9404 0x104b58000 + 4658180 3 project-graph 0x105023e50 0x104b58000 + 5029456 4 project-graph 0x105023b8c 0x104b58000 + 5028748 5 project-graph 0x104e22e8c 0x104b58000 + 2928268 6 project-graph 0x104e22bc0 0x104b58000 + 2927552 7 project-graph 0x104f379b4 0x104b58000 + 4061620 8 libsystem_pthread.dylib 0x1888d9c08 _pthread_start + 136 9 libsystem_pthread.dylib 0x1888d4ba8 thread_start + 8 Thread 9: 0 libsystem_kernel.dylib 0x18889a4f8 __psynch_cvwait + 8 1 libsystem_pthread.dylib 0x1888da0dc _pthread_cond_wait + 984 2 project-graph 0x104fc9404 0x104b58000 + 4658180 3 project-graph 0x105023e50 0x104b58000 + 5029456 4 project-graph 0x105023b8c 0x104b58000 + 5028748 5 project-graph 0x104e22e8c 0x104b58000 + 2928268 6 project-graph 0x104e22bc0 0x104b58000 + 2927552 7 project-graph 0x104f379b4 0x104b58000 + 4061620 8 libsystem_pthread.dylib 0x1888d9c08 _pthread_start + 136 9 libsystem_pthread.dylib 0x1888d4ba8 thread_start + 8 Thread 10: 0 libsystem_kernel.dylib 0x18889a4f8 __psynch_cvwait + 8 1 libsystem_pthread.dylib 0x1888da0dc _pthread_cond_wait + 984 2 project-graph 0x104fc9404 0x104b58000 + 4658180 3 project-graph 0x105023e50 0x104b58000 + 5029456 4 project-graph 0x105023b8c 0x104b58000 + 5028748 5 project-graph 0x104e22e8c 0x104b58000 + 2928268 6 project-graph 0x104e22bc0 0x104b58000 + 2927552 7 project-graph 0x104f379b4 0x104b58000 + 4061620 8 libsystem_pthread.dylib 0x1888d9c08 _pthread_start + 136 9 libsystem_pthread.dylib 0x1888d4ba8 thread_start + 8 Thread 11: 0 libsystem_kernel.dylib 0x18889a4f8 __psynch_cvwait + 8 1 libsystem_pthread.dylib 0x1888da0dc _pthread_cond_wait + 984 2 project-graph 0x104fc9404 0x104b58000 + 4658180 3 project-graph 0x105023e50 0x104b58000 + 5029456 4 project-graph 0x105023b8c 0x104b58000 + 5028748 5 project-graph 0x104e22e8c 0x104b58000 + 2928268 6 project-graph 0x104e22bc0 0x104b58000 + 2927552 7 project-graph 0x104f379b4 0x104b58000 + 4061620 8 libsystem_pthread.dylib 0x1888d9c08 _pthread_start + 136 9 libsystem_pthread.dylib 0x1888d4ba8 thread_start + 8 Thread 12:: WebCore: Scrolling 0 libsystem_kernel.dylib 0x188896c34 mach_msg2_trap + 8 1 libsystem_kernel.dylib 0x1888a9028 mach_msg2_internal + 76 2 libsystem_kernel.dylib 0x18889f98c mach_msg_overwrite + 484 3 libsystem_kernel.dylib 0x188896fb4 mach_msg + 24 4 CoreFoundation 0x188978b90 __CFRunLoopServiceMachPort + 160 5 CoreFoundation 0x1889774e8 __CFRunLoopRun + 1188 6 CoreFoundation 0x188a3135c _CFRunLoopRunSpecificWithOptions + 532 7 CoreFoundation 0x1889caa30 CFRunLoopRun + 64 8 JavaScriptCore 0x1a9e98198 WTF::Detail::CallableWrapper::call() + 244 9 JavaScriptCore 0x1a9edae5c WTF::Thread::entryPoint(WTF::Thread::NewThreadContext*) + 260 10 JavaScriptCore 0x1a9ca5490 WTF::wtfThreadEntryPoint(void*) + 16 11 libsystem_pthread.dylib 0x1888d9c08 _pthread_start + 136 12 libsystem_pthread.dylib 0x1888d4ba8 thread_start + 8 Thread 13:: Log work queue 0 libsystem_kernel.dylib 0x188896bb0 semaphore_wait_trap + 8 1 WebKit 0x1b2eae6b4 IPC::StreamConnectionWorkQueue::startProcessingThread()::$_0::operator()() + 44 2 JavaScriptCore 0x1a9edae5c WTF::Thread::entryPoint(WTF::Thread::NewThreadContext*) + 260 3 JavaScriptCore 0x1a9ca5490 WTF::wtfThreadEntryPoint(void*) + 16 4 libsystem_pthread.dylib 0x1888d9c08 _pthread_start + 136 5 libsystem_pthread.dylib 0x1888d4ba8 thread_start + 8 Thread 14:: tokio-runtime-worker 0 libsystem_kernel.dylib 0x18889a4f8 __psynch_cvwait + 8 1 libsystem_pthread.dylib 0x1888da0dc _pthread_cond_wait + 984 2 project-graph 0x104fc9404 0x104b58000 + 4658180 3 project-graph 0x104fc8830 0x104b58000 + 4655152 4 project-graph 0x104fce4ec 0x104b58000 + 4678892 5 project-graph 0x104fcb0a4 0x104b58000 + 4665508 6 project-graph 0x104fcaef8 0x104b58000 + 4665080 7 project-graph 0x104f379b4 0x104b58000 + 4061620 8 libsystem_pthread.dylib 0x1888d9c08 _pthread_start + 136 9 libsystem_pthread.dylib 0x1888d4ba8 thread_start + 8 Thread 15:: tokio-runtime-worker 0 libsystem_kernel.dylib 0x18889cf30 kevent + 8 1 project-graph 0x104fca0a8 0x104b58000 + 4661416 2 project-graph 0x104fc95c4 0x104b58000 + 4658628 3 project-graph 0x104fc8780 0x104b58000 + 4654976 4 project-graph 0x104fce4ec 0x104b58000 + 4678892 5 project-graph 0x104fcb0a4 0x104b58000 + 4665508 6 project-graph 0x104fcaef8 0x104b58000 + 4665080 7 project-graph 0x104f379b4 0x104b58000 + 4061620 8 libsystem_pthread.dylib 0x1888d9c08 _pthread_start + 136 9 libsystem_pthread.dylib 0x1888d4ba8 thread_start + 8 Thread 16:: tokio-runtime-worker 0 libsystem_kernel.dylib 0x18889a4f8 __psynch_cvwait + 8 1 libsystem_pthread.dylib 0x1888da0dc _pthread_cond_wait + 984 2 project-graph 0x104fc9404 0x104b58000 + 4658180 3 project-graph 0x104fc8830 0x104b58000 + 4655152 4 project-graph 0x104fce4ec 0x104b58000 + 4678892 5 project-graph 0x104fcb0a4 0x104b58000 + 4665508 6 project-graph 0x104fcaef8 0x104b58000 + 4665080 7 project-graph 0x104f379b4 0x104b58000 + 4061620 8 libsystem_pthread.dylib 0x1888d9c08 _pthread_start + 136 9 libsystem_pthread.dylib 0x1888d4ba8 thread_start + 8 Thread 17:: tokio-runtime-worker 0 libsystem_kernel.dylib 0x18889a4f8 __psynch_cvwait + 8 1 libsystem_pthread.dylib 0x1888da0dc _pthread_cond_wait + 984 2 project-graph 0x104fc9404 0x104b58000 + 4658180 3 project-graph 0x104fc8830 0x104b58000 + 4655152 4 project-graph 0x104fce4ec 0x104b58000 + 4678892 5 project-graph 0x104fcb0a4 0x104b58000 + 4665508 6 project-graph 0x104fcaef8 0x104b58000 + 4665080 7 project-graph 0x104f379b4 0x104b58000 + 4061620 8 libsystem_pthread.dylib 0x1888d9c08 _pthread_start + 136 9 libsystem_pthread.dylib 0x1888d4ba8 thread_start + 8 Thread 18:: tokio-runtime-worker 0 libsystem_kernel.dylib 0x18889a4f8 __psynch_cvwait + 8 1 libsystem_pthread.dylib 0x1888da0dc _pthread_cond_wait + 984 2 project-graph 0x104fc9404 0x104b58000 + 4658180 3 project-graph 0x104fc8830 0x104b58000 + 4655152 4 project-graph 0x104fce4ec 0x104b58000 + 4678892 5 project-graph 0x104fcb0a4 0x104b58000 + 4665508 6 project-graph 0x104fcaef8 0x104b58000 + 4665080 7 project-graph 0x104f379b4 0x104b58000 + 4061620 8 libsystem_pthread.dylib 0x1888d9c08 _pthread_start + 136 9 libsystem_pthread.dylib 0x1888d4ba8 thread_start + 8 Thread 19:: tokio-runtime-worker 0 libsystem_kernel.dylib 0x18889a4f8 __psynch_cvwait + 8 1 libsystem_pthread.dylib 0x1888da0dc _pthread_cond_wait + 984 2 project-graph 0x104fc9404 0x104b58000 + 4658180 3 project-graph 0x104fc8830 0x104b58000 + 4655152 4 project-graph 0x104fce4ec 0x104b58000 + 4678892 5 project-graph 0x104fcb0a4 0x104b58000 + 4665508 6 project-graph 0x104fcaef8 0x104b58000 + 4665080 7 project-graph 0x104f379b4 0x104b58000 + 4061620 8 libsystem_pthread.dylib 0x1888d9c08 _pthread_start + 136 9 libsystem_pthread.dylib 0x1888d4ba8 thread_start + 8 Thread 20:: tokio-runtime-worker 0 libsystem_kernel.dylib 0x18889a4f8 __psynch_cvwait + 8 1 libsystem_pthread.dylib 0x1888da0dc _pthread_cond_wait + 984 2 project-graph 0x104fc9404 0x104b58000 + 4658180 3 project-graph 0x104fc8830 0x104b58000 + 4655152 4 project-graph 0x104fce4ec 0x104b58000 + 4678892 5 project-graph 0x104fcb0a4 0x104b58000 + 4665508 6 project-graph 0x104fcaef8 0x104b58000 + 4665080 7 project-graph 0x104f379b4 0x104b58000 + 4061620 8 libsystem_pthread.dylib 0x1888d9c08 _pthread_start + 136 9 libsystem_pthread.dylib 0x1888d4ba8 thread_start + 8 Thread 21:: tokio-runtime-worker 0 libsystem_kernel.dylib 0x18889a4f8 __psynch_cvwait + 8 1 libsystem_pthread.dylib 0x1888da0dc _pthread_cond_wait + 984 2 project-graph 0x104fc9404 0x104b58000 + 4658180 3 project-graph 0x104fc8830 0x104b58000 + 4655152 4 project-graph 0x104fce4ec 0x104b58000 + 4678892 5 project-graph 0x104fcb0a4 0x104b58000 + 4665508 6 project-graph 0x104fcaef8 0x104b58000 + 4665080 7 project-graph 0x104f379b4 0x104b58000 + 4061620 8 libsystem_pthread.dylib 0x1888d9c08 _pthread_start + 136 9 libsystem_pthread.dylib 0x1888d4ba8 thread_start + 8 Thread 22:: tokio-runtime-worker Dispatch queue: Client CFPasteboard-Apple CFPasteboard general 0 libsystem_kernel.dylib 0x188896b2c _kernelrpc_mach_port_construct_trap + 8 1 libsystem_kernel.dylib 0x188897eb8 mach_port_construct + 40 2 libxpc.dylib 0x1885dd05c _xpc_try_mach_port_construct + 64 3 libxpc.dylib 0x1885dd0a8 _xpc_mach_port_construct + 28 4 libxpc.dylib 0x1885b5544 _xpc_mach_port_allocate + 36 5 libxpc.dylib 0x1885b9bf0 xpc_connection_send_message_with_reply + 160 6 CoreFoundation 0x188a25778 -[_CFPasteboardEntry requestDataForPasteboard:generation:immediatelyAvailableResult:] + 1520 7 CoreFoundation 0x18897587c __CFPasteboardCopyData_block_invoke + 152 8 CoreFoundation 0x188a26824 ____CFPasteboardPerformOnQueue_block_invoke + 292 9 libdispatch.dylib 0x188721e1c _dispatch_block_sync_invoke + 240 10 libdispatch.dylib 0x188736ac4 _dispatch_client_callout + 16 11 libdispatch.dylib 0x18872c940 _dispatch_lane_barrier_sync_invoke_and_complete + 56 12 libdispatch.dylib 0x188723138 _dispatch_sync_block_with_privdata + 452 13 CoreFoundation 0x188975074 CFPasteboardCopyData + 652 14 AppKit 0x18d776ad4 -[NSPasteboard _dataWithoutConversionForTypeIdentifier:index:securityScoped:] + 432 15 AppKit 0x18d77734c -[NSPasteboard _dataForType:index:usesPboardTypes:combinesItems:securityScoped:] + 272 16 AppKit 0x18dc4fea0 -[NSPasteboardItem __dataForType:async:completionHandler:] + 316 17 AppKit 0x18dc4ffac -[NSPasteboardItem stringForType:] + 28 18 project-graph 0x104ddc3f0 0x104b58000 + 2638832 19 project-graph 0x104ddca18 0x104b58000 + 2640408 20 project-graph 0x104fc8c0c 0x104b58000 + 4656140 21 project-graph 0x104fce078 0x104b58000 + 4677752 22 project-graph 0x104fcb0a4 0x104b58000 + 4665508 23 project-graph 0x104fcaef8 0x104b58000 + 4665080 24 project-graph 0x104f379b4 0x104b58000 + 4061620 25 libsystem_pthread.dylib 0x1888d9c08 _pthread_start + 136 26 libsystem_pthread.dylib 0x1888d4ba8 thread_start + 8 Thread 23:: tokio-runtime-worker 0 libsystem_kernel.dylib 0x18889a4f8 __psynch_cvwait + 8 1 libsystem_pthread.dylib 0x1888da0dc _pthread_cond_wait + 984 2 project-graph 0x104fc9404 0x104b58000 + 4658180 3 project-graph 0x104fc8830 0x104b58000 + 4655152 4 project-graph 0x104fce4ec 0x104b58000 + 4678892 5 project-graph 0x104fcb0a4 0x104b58000 + 4665508 6 project-graph 0x104fcaef8 0x104b58000 + 4665080 7 project-graph 0x104f379b4 0x104b58000 + 4061620 8 libsystem_pthread.dylib 0x1888d9c08 _pthread_start + 136 9 libsystem_pthread.dylib 0x1888d4ba8 thread_start + 8 Thread 24:: JavaScriptCore libpas scavenger 0 libsystem_kernel.dylib 0x18889a4f8 __psynch_cvwait + 8 1 libsystem_pthread.dylib 0x1888da0dc _pthread_cond_wait + 984 2 JavaScriptCore 0x1ab59be78 scavenger_thread_main + 1440 3 libsystem_pthread.dylib 0x1888d9c08 _pthread_start + 136 4 libsystem_pthread.dylib 0x1888d4ba8 thread_start + 8 Thread 25:: CVDisplayLink 0 libsystem_kernel.dylib 0x18889a4f8 __psynch_cvwait + 8 1 libsystem_pthread.dylib 0x1888da108 _pthread_cond_wait + 1028 2 CoreVideo 0x192ee9b3c CVDisplayLink::waitUntil(unsigned long long) + 336 3 CoreVideo 0x192ee8c24 CVDisplayLink::runIOThread() + 500 4 libsystem_pthread.dylib 0x1888d9c08 _pthread_start + 136 5 libsystem_pthread.dylib 0x1888d4ba8 thread_start + 8 Thread 26: Thread 27: Thread 28: Thread 29: Thread 0 crashed with ARM Thread State (64-bit): x0: 0x000000080c0228b0 x1: 0x00000002034a58e8 x2: 0x000000016b2a1320 x3: 0x000000016b2a13a0 x4: 0x0000000000000010 x5: 0x0000000000000000 x6: 0xffffffffbfc007ff x7: 0xfffff0003ffff800 x8: 0x3d2d25f44434003c x9: 0x0000000202feace8 x10: 0x6ae100080c0228b0 x11: 0x000000000000007f x12: 0x0000000000000031 x13: 0x000000080dc25b00 x14: 0x4d3aea405a144595 x15: 0x003aea405a144590 x16: 0x003aea405a144590 x17: 0x00000001f6895ca0 x18: 0x0000000000000000 x19: 0x000000080d0d03c0 x20: 0x0000000000000001 x21: 0x0000000000000000 x22: 0x000000080c0228b0 x23: 0x000000080c0228b0 x24: 0x000000080c0223d0 x25: 0x0000000000000001 x26: 0x00000001f6900978 x27: 0x0000000000000001 x28: 0x0000000100000002 fp: 0x000000016b2a1480 lr: 0x000000018cdd812c sp: 0x000000016b2a12f0 pc: 0x000000018848d820 cpsr: 0x20000000 far: 0x003aea405a1445a0 esr: 0x92000004 (Data Abort) byte read Translation fault Binary Images: 0x104b58000 - 0x1053dffff liren.project-graph (2.9.13) <946c435c-f6bb-3969-9092-d73ba4a59315> /Applications/Project Graph.app/Contents/MacOS/project-graph 0x1171b4000 - 0x1171bffff libobjc-trampolines.dylib (*) /usr/lib/libobjc-trampolines.dylib 0x1191b8000 - 0x1199dffff com.apple.AGXMetalG16G-B0 (341.11) /System/Library/Extensions/AGXMetalG16G_B0.bundle/Contents/MacOS/AGXMetalG16G_B0 0x118760000 - 0x1187c3fff com.apple.AppleMetalOpenGLRenderer (1.0) <7fba6cd5-06ae-37aa-aa67-580c920ea69d> /System/Library/Extensions/AppleMetalOpenGLRenderer.bundle/Contents/MacOS/AppleMetalOpenGLRenderer 0x188484000 - 0x1884d748b libobjc.A.dylib (*) <5a0aab4e-0c1a-3680-82c9-43dc4007a6e7> /usr/lib/libobjc.A.dylib 0x18cd62000 - 0x18e48eb9f com.apple.AppKit (6.9) <3c0949bb-e361-369a-80b7-17440eb09e98> /System/Library/Frameworks/AppKit.framework/Versions/C/AppKit 0x1adf91000 - 0x1b16a45df com.apple.WebCore (21622) /System/Library/Frameworks/WebKit.framework/Versions/A/Frameworks/WebCore.framework/Versions/A/WebCore 0x1b1d8c000 - 0x1b32a68bf com.apple.WebKit (21622) <3b55482a-efe2-35a7-b1c9-3f41a823a30b> /System/Library/Frameworks/WebKit.framework/Versions/A/WebKit 0x1a9c9e000 - 0x1ab7bce7f com.apple.JavaScriptCore (21622) /System/Library/Frameworks/JavaScriptCore.framework/Versions/A/JavaScriptCore 0x188919000 - 0x188e5fabf com.apple.CoreFoundation (6.9) <3c4a3add-9e48-33da-82ee-80520e6cbe3b> /System/Library/Frameworks/CoreFoundation.framework/Versions/A/CoreFoundation 0x195373000 - 0x1956757ff com.apple.HIToolbox (2.1.1) <9ab64c08-0685-3a0d-9a7e-83e7a1e9ebb4> /System/Library/Frameworks/Carbon.framework/Versions/A/Frameworks/HIToolbox.framework/Versions/A/HIToolbox 0x188509000 - 0x1885a7f63 dyld (*) /usr/lib/dyld 0x0 - 0xffffffffffffffff ??? (*) <00000000-0000-0000-0000-000000000000> ??? 0x188896000 - 0x1888d249f libsystem_kernel.dylib (*) <9fe7c84d-0c2b-363f-bee5-6fd76d67a227> /usr/lib/system/libsystem_kernel.dylib 0x1888d3000 - 0x1888dfabb libsystem_pthread.dylib (*) /usr/lib/system/libsystem_pthread.dylib 0x1885ac000 - 0x188600f7f libxpc.dylib (*) <8346be50-de08-3606-9fb6-9a352975661d> /usr/lib/system/libxpc.dylib 0x18871b000 - 0x188761e9f libdispatch.dylib (*) <8fb392ae-401f-399a-96ae-41531cf91162> /usr/lib/system/libdispatch.dylib 0x192ee6000 - 0x192f69fff com.apple.CoreVideo (1.8) /System/Library/Frameworks/CoreVideo.framework/Versions/A/CoreVideo External Modification Summary: Calls made by other processes targeting this process: task_for_pid: 0 thread_create: 0 thread_set_state: 0 Calls made by this process: task_for_pid: 0 thread_create: 0 thread_set_state: 0 Calls made by all processes on this machine: task_for_pid: 0 thread_create: 0 thread_set_state: 0 VM Region Summary: ReadOnly portion of Libraries: Total=1.8G resident=0K(0%) swapped_out_or_unallocated=1.8G(100%) Writable regions: Total=4.7G written=1841K(0%) resident=945K(0%) swapped_out=896K(0%) unallocated=4.7G(100%) VIRTUAL REGION REGION TYPE SIZE COUNT (non-coalesced) =========== ======= ======= Activity Tracing 256K 1 ColorSync 32K 2 CoreAnimation 912K 57 CoreGraphics 64K 4 CoreUI image data 240K 2 Foundation 48K 2 Kernel Alloc Once 32K 1 MALLOC 268.9M 32 MALLOC guard page 3120K 4 STACK GUARD 464K 29 Stack 53.4M 30 Stack Guard 56.0M 1 VM_ALLOCATE 4880K 41 VM_ALLOCATE (reserved) 4.0G 21 reserved VM address space (unallocated) WebKit Malloc 400.2M 9 __AUTH 5853K 652 __AUTH_CONST 88.8M 1037 __CTF 824 1 __DATA 30.0M 988 __DATA_CONST 33.2M 1046 __DATA_DIRTY 8836K 898 __FONT_DATA 2352 1 __GLSLBUILTINS 5174K 1 __INFO_FILTER 8 1 __LINKEDIT 594.2M 5 __OBJC_RO 78.3M 1 __OBJC_RW 2567K 1 __TEXT 1.2G 1069 __TPRO_CONST 128K 2 mapped file 600.6M 75 page table in kernel 945K 1 shared memory 912K 15 =========== ======= ======= TOTAL 7.4G 6030 TOTAL, minus reserved VM space 3.4G 6030 ----------- Full Report ----------- {"app_name":"project-graph","timestamp":"2026-02-13 15:56:49.00 +0800","app_version":"2.9.13","slice_uuid":"946c435c-f6bb-3969-9092-d73ba4a59315","build_version":"2.9.13","platform":1,"bundleID":"liren.project-graph","share_with_app_devs":0,"is_first_party":0,"bug_type":"309","os_version":"macOS 26.1 (25B78)","roots_installed":0,"name":"project-graph","incident_id":"2CD58038-FC0A-4005-9C57-8CF12FA876D5"} { "uptime" : 240000, "procRole" : "Foreground", "version" : 2, "userID" : 501, "deployVersion" : 210, "modelCode" : "Mac16,12", "coalitionID" : 1342, "osVersion" : { "train" : "macOS 26.1", "build" : "25B78", "releaseType" : "User" }, "captureTime" : "2026-02-13 15:56:44.8734 +0800", "codeSigningMonitor" : 2, "incident" : "2CD58038-FC0A-4005-9C57-8CF12FA876D5", "pid" : 68049, "translated" : false, "cpuType" : "ARM-64", "roots_installed" : 0, "bug_type" : "309", "procLaunch" : "2026-02-13 09:40:05.9876 +0800", "procStartAbsTime" : 5425199234391, "procExitAbsTime" : 5967573695900, "procName" : "project-graph", "procPath" : "\/Applications\/Project Graph.app\/Contents\/MacOS\/project-graph", "bundleInfo" : {"CFBundleShortVersionString":"2.9.13","CFBundleVersion":"2.9.13","CFBundleIdentifier":"liren.project-graph"}, "storeInfo" : {"deviceIdentifierForVendor":"78F3C8D6-5DAC-5F0A-85D3-F7225CCAD22B","thirdParty":true}, "parentProc" : "launchd", "parentPid" : 1, "coalitionName" : "liren.project-graph", "crashReporterKey" : "B6C57097-5B06-A3FA-7F07-E57289B4D2B6", "appleIntelligenceStatus" : {"reasons":["regionIneligible","countryBillingIneligible","countryLocationIneligible"],"state":"unavailable"}, "developerMode" : 1, "codeSigningID" : "project_graph-908b4450466f1c40", "codeSigningTeamID" : "", "codeSigningFlags" : 570556929, "codeSigningValidationCategory" : 10, "codeSigningTrustLevel" : 4294967295, "codeSigningAuxiliaryInfo" : 0, "instructionByteStream" : {"beforePC":"HyAD1R8gA9UfAADx7QMAVA4AQPnQzX2S6gMAqipc7fJQGcHa7wMQqg==","atPC":"CgpA+Uv9cNNKvUCSLBxByowBCwpNEQyLsSX\/qD8BAeuBAABUSgEByg=="}, "bootSessionUUID" : "56C16D5F-59C7-4085-A8AE-12AE71F4376E", "wakeTime" : 23429, "sleepWakeUUID" : "5946CB7E-C783-40E2-ABF2-93A7C8E35F2C", "sip" : "enabled", "vmRegionInfo" : "0x6a405a1445a0 is not in any region. \n REGION TYPE START - END [ VSIZE] PRT\/MAX SHRMOD REGION DETAIL\n UNUSED SPACE AT START\n---> \n UNUSED SPACE AT END", "exception" : {"codes":"0x0000000000000001, 0x003aea405a1445a0","rawCodes":[1,16583110759302560],"type":"EXC_BAD_ACCESS","signal":"SIGSEGV","subtype":"KERN_INVALID_ADDRESS at 0x003aea405a1445a0"}, "termination" : {"flags":0,"code":11,"namespace":"SIGNAL","indicator":"Segmentation fault: 11","byProc":"exc handler","byPid":68049}, "vmregioninfo" : "0x6a405a1445a0 is not in any region. \n REGION TYPE START - END [ VSIZE] PRT\/MAX SHRMOD REGION DETAIL\n UNUSED SPACE AT START\n---> \n UNUSED SPACE AT END", "extMods" : {"caller":{"thread_create":0,"thread_set_state":0,"task_for_pid":0},"system":{"thread_create":0,"thread_set_state":0,"task_for_pid":0},"targeted":{"thread_create":0,"thread_set_state":0,"task_for_pid":0},"warnings":0}, "faultingThread" : 0, "threads" : [{"threadState":{"x":[{"value":34561206448},{"value":8645138664,"objc-selector":"countByEnumeratingWithState:objects:count:"},{"value":6092886816},{"value":6092886944},{"value":16},{"value":0},{"value":18446744072631617535},{"value":18446726482597246976},{"value":4408221341312090172},{"value":8640179432,"objc-selector":"retain"},{"value":7701436872341465264},{"value":127},{"value":49},{"value":34590579456},{"value":5565017851679753621},{"value":16583110759302544},{"value":16583110759302544},{"value":8431164576},{"value":0},{"value":34578695104},{"value":1},{"value":0},{"value":34561206448},{"value":34561206448},{"value":34561205200},{"value":1},{"value":8431602040},{"value":1},{"value":4294967298}],"flavor":"ARM_THREAD_STATE64","lr":{"value":6658294060},"cpsr":{"value":536870912},"fp":{"value":6092887168},"sp":{"value":6092886768},"esr":{"value":2449473540,"description":"(Data Abort) byte read Translation fault"},"pc":{"value":6581442592,"matchesCrashFrame":1},"far":{"value":16583110759302560}},"id":6246490,"triggered":true,"name":"main","queue":"com.apple.main-thread","frames":[{"imageOffset":38944,"symbol":"objc_msgSend","symbolLocation":32,"imageIndex":4},{"imageOffset":483628,"symbol":"-[NSPasteboard _updateTypeCacheIfNeeded]","symbolLocation":1064,"imageIndex":5},{"imageOffset":10569760,"symbol":"-[NSPasteboard _typesAtIndex:combinesItems:]","symbolLocation":36,"imageIndex":5},{"imageOffset":20167404,"symbol":"WebCore::PlatformPasteboard::informationForItemAtIndex(unsigned long, long long)","symbolLocation":172,"imageIndex":6},{"imageOffset":16918196,"symbol":"WebCore::PlatformPasteboard::allPasteboardItemInfo(long long)","symbolLocation":204,"imageIndex":6},{"imageOffset":7861628,"symbol":"WebKit::WebPasteboardProxy::grantAccessToCurrentData(WebKit::WebProcessProxy&, WTF::String const&, WTF::CompletionHandler&&)","symbolLocation":92,"imageIndex":7},{"imageOffset":7526308,"symbol":"WebKit::WebPageProxy::grantAccessToCurrentPasteboardData(WTF::String const&, WTF::CompletionHandler&&, std::__1::optional, unsigned long long>>)","symbolLocation":120,"imageIndex":7},{"imageOffset":9383596,"symbol":"WebKit::WebPageProxy::willPerformPasteCommand(WebCore::DOMPasteAccessCategory, WTF::CompletionHandler&&, std::__1::optional, unsigned long long>>)","symbolLocation":96,"imageIndex":7},{"imageOffset":10832272,"symbol":"WebKit::WebPageProxy::executeEditCommand(WTF::String const&, WTF::String const&)","symbolLocation":352,"imageIndex":7},{"imageOffset":9467432,"symbol":"WebKit::WebViewImpl::executeEditCommandForSelector(objc_selector*, WTF::String const&)","symbolLocation":56,"imageIndex":7},{"imageOffset":6470696,"symbol":"-[WKWebView(WKImplementationMac) paste:]","symbolLocation":44,"imageIndex":7},{"imageOffset":11469060,"symbol":"-[NSApplication(NSResponder) sendAction:to:from:]","symbolLocation":560,"imageIndex":5},{"imageOffset":9806660,"symbol":"-[NSMenuItem _corePerformAction:]","symbolLocation":540,"imageIndex":5},{"imageOffset":11660924,"symbol":"_NSMenuPerformActionWithHighlighting","symbolLocation":160,"imageIndex":5},{"imageOffset":9704484,"symbol":"-[NSMenu _performKeyEquivalentForItemAtIndex:]","symbolLocation":172,"imageIndex":5},{"imageOffset":9703528,"symbol":"-[NSMenu performKeyEquivalent:]","symbolLocation":356,"imageIndex":5},{"imageOffset":11463324,"symbol":"routeKeyEquivalent","symbolLocation":444,"imageIndex":5},{"imageOffset":11455696,"symbol":"-[NSApplication(NSEventRouting) sendEvent:]","symbolLocation":1844,"imageIndex":5},{"imageOffset":4153236,"imageIndex":0},{"imageOffset":9507240,"symbol":"WebKit::WebViewImpl::doneWithKeyEvent(NSEvent*, bool)","symbolLocation":168,"imageIndex":7},{"imageOffset":229532,"symbol":"WebKit::PageClientImpl::doneWithKeyEvent(WebKit::NativeWebKeyboardEvent const&, bool)","symbolLocation":56,"imageIndex":7},{"imageOffset":10994216,"symbol":"WebKit::WebPageProxy::didReceiveEvent(IPC::Connection*, WebKit::WebEventType, bool, std::__1::optional&&)","symbolLocation":1168,"imageIndex":7},{"imageOffset":5271688,"symbol":"WebKit::WebPageProxy::didReceiveMessage(IPC::Connection&, IPC::Decoder&)","symbolLocation":7124,"imageIndex":7},{"imageOffset":17944024,"symbol":"IPC::MessageReceiverMap::dispatchMessage(IPC::Connection&, IPC::Decoder&)","symbolLocation":264,"imageIndex":7},{"imageOffset":11516080,"symbol":"WebKit::WebProcessProxy::dispatchMessage(IPC::Connection&, IPC::Decoder&)","symbolLocation":40,"imageIndex":7},{"imageOffset":5400084,"symbol":"WebKit::WebProcessProxy::didReceiveMessage(IPC::Connection&, IPC::Decoder&)","symbolLocation":1620,"imageIndex":7},{"imageOffset":17786076,"symbol":"IPC::Connection::dispatchMessage(WTF::UniqueRef)","symbolLocation":300,"imageIndex":7},{"imageOffset":17787404,"symbol":"IPC::Connection::dispatchIncomingMessages()","symbolLocation":536,"imageIndex":7},{"imageOffset":2068952,"symbol":"WTF::RunLoop::performWork()","symbolLocation":552,"imageIndex":8},{"imageOffset":2075600,"symbol":"WTF::RunLoop::performWork(void*)","symbolLocation":36,"imageIndex":8},{"imageOffset":391656,"symbol":"__CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__","symbolLocation":28,"imageIndex":9},{"imageOffset":391548,"symbol":"__CFRunLoopDoSource0","symbolLocation":172,"imageIndex":9},{"imageOffset":390888,"symbol":"__CFRunLoopDoSources0","symbolLocation":232,"imageIndex":9},{"imageOffset":385912,"symbol":"__CFRunLoopRun","symbolLocation":820,"imageIndex":9},{"imageOffset":1147740,"symbol":"_CFRunLoopRunSpecificWithOptions","symbolLocation":532,"imageIndex":9},{"imageOffset":792424,"symbol":"RunCurrentEventLoopInMode","symbolLocation":316,"imageIndex":10},{"imageOffset":805520,"symbol":"ReceiveNextEventCommon","symbolLocation":488,"imageIndex":10},{"imageOffset":2417416,"symbol":"_BlockUntilNextEventMatchingListInMode","symbolLocation":48,"imageIndex":10},{"imageOffset":5399488,"symbol":"_DPSBlockUntilNextEventMatchingListInMode","symbolLocation":236,"imageIndex":5},{"imageOffset":130612,"symbol":"_DPSNextEvent","symbolLocation":588,"imageIndex":5},{"imageOffset":11460420,"symbol":"-[NSApplication(NSEventRouting) _nextEventMatchingEventMask:untilDate:inMode:dequeue:]","symbolLocation":688,"imageIndex":5},{"imageOffset":11459664,"symbol":"-[NSApplication(NSEventRouting) nextEventMatchingMask:untilDate:inMode:dequeue:]","symbolLocation":72,"imageIndex":5},{"imageOffset":100224,"symbol":"-[NSApplication run]","symbolLocation":368,"imageIndex":5},{"imageOffset":1423660,"imageIndex":0},{"imageOffset":1423284,"imageIndex":0},{"imageOffset":1423272,"imageIndex":0},{"imageOffset":1422924,"imageIndex":0},{"imageOffset":1410860,"imageIndex":0},{"imageOffset":4112,"imageIndex":0},{"imageOffset":4944,"imageIndex":0},{"imageOffset":36180,"symbol":"start","symbolLocation":7184,"imageIndex":11}]},{"id":6246504,"name":"com.apple.NSEventThread","threadState":{"x":[{"value":268451845},{"value":21592279046},{"value":8589934592},{"value":98968931401728},{"value":0},{"value":98968931401728},{"value":2},{"value":4294967295},{"value":0},{"value":17179869184},{"value":0},{"value":2},{"value":0},{"value":0},{"value":23043},{"value":0},{"value":18446744073709551569},{"value":8431213296},{"value":0},{"value":4294967295},{"value":2},{"value":98968931401728},{"value":0},{"value":98968931401728},{"value":6095184008},{"value":8589934592},{"value":21592279046},{"value":18446744073709550527},{"value":4412409862}],"flavor":"ARM_THREAD_STATE64","lr":{"value":6585749544},"cpsr":{"value":0},"fp":{"value":6095183856},"sp":{"value":6095183776},"esr":{"value":1442840704,"description":"(Syscall)"},"pc":{"value":6585674804},"far":{"value":0}},"frames":[{"imageOffset":3124,"symbol":"mach_msg2_trap","symbolLocation":8,"imageIndex":13},{"imageOffset":77864,"symbol":"mach_msg2_internal","symbolLocation":76,"imageIndex":13},{"imageOffset":39308,"symbol":"mach_msg_overwrite","symbolLocation":484,"imageIndex":13},{"imageOffset":4020,"symbol":"mach_msg","symbolLocation":24,"imageIndex":13},{"imageOffset":392080,"symbol":"__CFRunLoopServiceMachPort","symbolLocation":160,"imageIndex":9},{"imageOffset":386280,"symbol":"__CFRunLoopRun","symbolLocation":1188,"imageIndex":9},{"imageOffset":1147740,"symbol":"_CFRunLoopRunSpecificWithOptions","symbolLocation":532,"imageIndex":9},{"imageOffset":720052,"symbol":"_NSEventThread","symbolLocation":184,"imageIndex":5},{"imageOffset":27656,"symbol":"_pthread_start","symbolLocation":136,"imageIndex":14},{"imageOffset":7080,"symbol":"thread_start","symbolLocation":8,"imageIndex":14}]},{"id":6246508,"frames":[{"imageOffset":17656,"symbol":"__psynch_cvwait","symbolLocation":8,"imageIndex":13},{"imageOffset":28892,"symbol":"_pthread_cond_wait","symbolLocation":984,"imageIndex":14},{"imageOffset":4658180,"imageIndex":0},{"imageOffset":5029456,"imageIndex":0},{"imageOffset":5028748,"imageIndex":0},{"imageOffset":2928268,"imageIndex":0},{"imageOffset":2927552,"imageIndex":0},{"imageOffset":4061620,"imageIndex":0},{"imageOffset":27656,"symbol":"_pthread_start","symbolLocation":136,"imageIndex":14},{"imageOffset":7080,"symbol":"thread_start","symbolLocation":8,"imageIndex":14}],"threadState":{"x":[{"value":260},{"value":0},{"value":256},{"value":0},{"value":0},{"value":160},{"value":0},{"value":0},{"value":6097332792},{"value":0},{"value":0},{"value":2},{"value":2},{"value":0},{"value":0},{"value":0},{"value":305},{"value":8431211416},{"value":0},{"value":34570813760},{"value":34574244080},{"value":6097334496},{"value":0},{"value":0},{"value":256},{"value":257},{"value":512},{"value":0},{"value":4389625392}],"flavor":"ARM_THREAD_STATE64","lr":{"value":6585950428},"cpsr":{"value":1610612736},"fp":{"value":6097332912},"sp":{"value":6097332768},"esr":{"value":1442840704,"description":"(Syscall)"},"pc":{"value":6585689336},"far":{"value":0}}},{"id":6246509,"frames":[{"imageOffset":17656,"symbol":"__psynch_cvwait","symbolLocation":8,"imageIndex":13},{"imageOffset":28892,"symbol":"_pthread_cond_wait","symbolLocation":984,"imageIndex":14},{"imageOffset":4658180,"imageIndex":0},{"imageOffset":5029456,"imageIndex":0},{"imageOffset":5028748,"imageIndex":0},{"imageOffset":2928268,"imageIndex":0},{"imageOffset":2927552,"imageIndex":0},{"imageOffset":4061620,"imageIndex":0},{"imageOffset":27656,"symbol":"_pthread_start","symbolLocation":136,"imageIndex":14},{"imageOffset":7080,"symbol":"thread_start","symbolLocation":8,"imageIndex":14}],"threadState":{"x":[{"value":260},{"value":0},{"value":256},{"value":0},{"value":0},{"value":160},{"value":0},{"value":0},{"value":6099479096},{"value":0},{"value":0},{"value":2},{"value":2},{"value":0},{"value":0},{"value":0},{"value":305},{"value":8431211416},{"value":0},{"value":34570813952},{"value":34574244224},{"value":6099480800},{"value":0},{"value":0},{"value":256},{"value":257},{"value":512},{"value":3},{"value":4389625392}],"flavor":"ARM_THREAD_STATE64","lr":{"value":6585950428},"cpsr":{"value":1610612736},"fp":{"value":6099479216},"sp":{"value":6099479072},"esr":{"value":1442840704,"description":"(Syscall)"},"pc":{"value":6585689336},"far":{"value":0}}},{"id":6246510,"frames":[{"imageOffset":17656,"symbol":"__psynch_cvwait","symbolLocation":8,"imageIndex":13},{"imageOffset":28892,"symbol":"_pthread_cond_wait","symbolLocation":984,"imageIndex":14},{"imageOffset":4658180,"imageIndex":0},{"imageOffset":5029456,"imageIndex":0},{"imageOffset":5028748,"imageIndex":0},{"imageOffset":2928268,"imageIndex":0},{"imageOffset":2927552,"imageIndex":0},{"imageOffset":4061620,"imageIndex":0},{"imageOffset":27656,"symbol":"_pthread_start","symbolLocation":136,"imageIndex":14},{"imageOffset":7080,"symbol":"thread_start","symbolLocation":8,"imageIndex":14}],"threadState":{"x":[{"value":260},{"value":0},{"value":0},{"value":0},{"value":0},{"value":160},{"value":0},{"value":0},{"value":6101625400},{"value":0},{"value":0},{"value":2},{"value":2},{"value":0},{"value":0},{"value":0},{"value":305},{"value":8431211416},{"value":0},{"value":34570814016},{"value":34575026144},{"value":6101627104},{"value":0},{"value":0},{"value":0},{"value":1},{"value":256},{"value":2},{"value":4389625392}],"flavor":"ARM_THREAD_STATE64","lr":{"value":6585950428},"cpsr":{"value":1610612736},"fp":{"value":6101625520},"sp":{"value":6101625376},"esr":{"value":1442840704,"description":"(Syscall)"},"pc":{"value":6585689336},"far":{"value":0}}},{"id":6246511,"frames":[{"imageOffset":17656,"symbol":"__psynch_cvwait","symbolLocation":8,"imageIndex":13},{"imageOffset":28892,"symbol":"_pthread_cond_wait","symbolLocation":984,"imageIndex":14},{"imageOffset":4658180,"imageIndex":0},{"imageOffset":5029456,"imageIndex":0},{"imageOffset":5028748,"imageIndex":0},{"imageOffset":2928268,"imageIndex":0},{"imageOffset":2927552,"imageIndex":0},{"imageOffset":4061620,"imageIndex":0},{"imageOffset":27656,"symbol":"_pthread_start","symbolLocation":136,"imageIndex":14},{"imageOffset":7080,"symbol":"thread_start","symbolLocation":8,"imageIndex":14}],"threadState":{"x":[{"value":260},{"value":0},{"value":0},{"value":0},{"value":0},{"value":160},{"value":0},{"value":0},{"value":6103771704},{"value":0},{"value":0},{"value":2},{"value":2},{"value":0},{"value":0},{"value":0},{"value":305},{"value":8431211416},{"value":0},{"value":34570814080},{"value":34575025664},{"value":6103773408},{"value":0},{"value":0},{"value":0},{"value":1},{"value":256},{"value":5},{"value":4389625392}],"flavor":"ARM_THREAD_STATE64","lr":{"value":6585950428},"cpsr":{"value":1610612736},"fp":{"value":6103771824},"sp":{"value":6103771680},"esr":{"value":1442840704,"description":"(Syscall)"},"pc":{"value":6585689336},"far":{"value":0}}},{"id":6246512,"frames":[{"imageOffset":17656,"symbol":"__psynch_cvwait","symbolLocation":8,"imageIndex":13},{"imageOffset":28892,"symbol":"_pthread_cond_wait","symbolLocation":984,"imageIndex":14},{"imageOffset":4658180,"imageIndex":0},{"imageOffset":5029456,"imageIndex":0},{"imageOffset":5028748,"imageIndex":0},{"imageOffset":2928268,"imageIndex":0},{"imageOffset":2927552,"imageIndex":0},{"imageOffset":4061620,"imageIndex":0},{"imageOffset":27656,"symbol":"_pthread_start","symbolLocation":136,"imageIndex":14},{"imageOffset":7080,"symbol":"thread_start","symbolLocation":8,"imageIndex":14}],"threadState":{"x":[{"value":260},{"value":0},{"value":512},{"value":0},{"value":0},{"value":160},{"value":0},{"value":0},{"value":6105918008},{"value":0},{"value":512},{"value":2199023256066},{"value":2199023256066},{"value":512},{"value":0},{"value":2199023256064},{"value":305},{"value":8431211416},{"value":0},{"value":34570949440},{"value":34574242928},{"value":6105919712},{"value":0},{"value":0},{"value":512},{"value":513},{"value":768},{"value":3},{"value":4389625392}],"flavor":"ARM_THREAD_STATE64","lr":{"value":6585950428},"cpsr":{"value":1610612736},"fp":{"value":6105918128},"sp":{"value":6105917984},"esr":{"value":1442840704,"description":"(Syscall)"},"pc":{"value":6585689336},"far":{"value":0}}},{"id":6246513,"frames":[{"imageOffset":17656,"symbol":"__psynch_cvwait","symbolLocation":8,"imageIndex":13},{"imageOffset":28892,"symbol":"_pthread_cond_wait","symbolLocation":984,"imageIndex":14},{"imageOffset":4658180,"imageIndex":0},{"imageOffset":5029456,"imageIndex":0},{"imageOffset":5028748,"imageIndex":0},{"imageOffset":2928268,"imageIndex":0},{"imageOffset":2927552,"imageIndex":0},{"imageOffset":4061620,"imageIndex":0},{"imageOffset":27656,"symbol":"_pthread_start","symbolLocation":136,"imageIndex":14},{"imageOffset":7080,"symbol":"thread_start","symbolLocation":8,"imageIndex":14}],"threadState":{"x":[{"value":260},{"value":0},{"value":256},{"value":0},{"value":0},{"value":160},{"value":0},{"value":0},{"value":6108064312},{"value":0},{"value":0},{"value":2},{"value":2},{"value":0},{"value":0},{"value":0},{"value":305},{"value":8431211416},{"value":0},{"value":34570814144},{"value":34575025808},{"value":6108066016},{"value":0},{"value":0},{"value":256},{"value":257},{"value":512},{"value":8},{"value":4389625392}],"flavor":"ARM_THREAD_STATE64","lr":{"value":6585950428},"cpsr":{"value":1610612736},"fp":{"value":6108064432},"sp":{"value":6108064288},"esr":{"value":1442840704,"description":"(Syscall)"},"pc":{"value":6585689336},"far":{"value":0}}},{"id":6246514,"frames":[{"imageOffset":17656,"symbol":"__psynch_cvwait","symbolLocation":8,"imageIndex":13},{"imageOffset":28892,"symbol":"_pthread_cond_wait","symbolLocation":984,"imageIndex":14},{"imageOffset":4658180,"imageIndex":0},{"imageOffset":5029456,"imageIndex":0},{"imageOffset":5028748,"imageIndex":0},{"imageOffset":2928268,"imageIndex":0},{"imageOffset":2927552,"imageIndex":0},{"imageOffset":4061620,"imageIndex":0},{"imageOffset":27656,"symbol":"_pthread_start","symbolLocation":136,"imageIndex":14},{"imageOffset":7080,"symbol":"thread_start","symbolLocation":8,"imageIndex":14}],"threadState":{"x":[{"value":260},{"value":0},{"value":256},{"value":0},{"value":0},{"value":160},{"value":0},{"value":0},{"value":6110210616},{"value":0},{"value":256},{"value":1099511628034},{"value":1099511628034},{"value":256},{"value":0},{"value":1099511628032},{"value":305},{"value":8431211416},{"value":0},{"value":34570814208},{"value":34575026096},{"value":6110212320},{"value":0},{"value":0},{"value":256},{"value":257},{"value":512},{"value":1},{"value":4389625392}],"flavor":"ARM_THREAD_STATE64","lr":{"value":6585950428},"cpsr":{"value":1610612736},"fp":{"value":6110210736},"sp":{"value":6110210592},"esr":{"value":1442840704,"description":"(Syscall)"},"pc":{"value":6585689336},"far":{"value":0}}},{"id":6246515,"frames":[{"imageOffset":17656,"symbol":"__psynch_cvwait","symbolLocation":8,"imageIndex":13},{"imageOffset":28892,"symbol":"_pthread_cond_wait","symbolLocation":984,"imageIndex":14},{"imageOffset":4658180,"imageIndex":0},{"imageOffset":5029456,"imageIndex":0},{"imageOffset":5028748,"imageIndex":0},{"imageOffset":2928268,"imageIndex":0},{"imageOffset":2927552,"imageIndex":0},{"imageOffset":4061620,"imageIndex":0},{"imageOffset":27656,"symbol":"_pthread_start","symbolLocation":136,"imageIndex":14},{"imageOffset":7080,"symbol":"thread_start","symbolLocation":8,"imageIndex":14}],"threadState":{"x":[{"value":260},{"value":0},{"value":256},{"value":0},{"value":0},{"value":160},{"value":0},{"value":0},{"value":6112356920},{"value":0},{"value":0},{"value":2},{"value":2},{"value":0},{"value":0},{"value":0},{"value":305},{"value":8431211416},{"value":0},{"value":34570814272},{"value":34575025856},{"value":6112358624},{"value":0},{"value":0},{"value":256},{"value":257},{"value":512},{"value":2},{"value":4389625392}],"flavor":"ARM_THREAD_STATE64","lr":{"value":6585950428},"cpsr":{"value":1610612736},"fp":{"value":6112357040},"sp":{"value":6112356896},"esr":{"value":1442840704,"description":"(Syscall)"},"pc":{"value":6585689336},"far":{"value":0}}},{"id":6246516,"frames":[{"imageOffset":17656,"symbol":"__psynch_cvwait","symbolLocation":8,"imageIndex":13},{"imageOffset":28892,"symbol":"_pthread_cond_wait","symbolLocation":984,"imageIndex":14},{"imageOffset":4658180,"imageIndex":0},{"imageOffset":5029456,"imageIndex":0},{"imageOffset":5028748,"imageIndex":0},{"imageOffset":2928268,"imageIndex":0},{"imageOffset":2927552,"imageIndex":0},{"imageOffset":4061620,"imageIndex":0},{"imageOffset":27656,"symbol":"_pthread_start","symbolLocation":136,"imageIndex":14},{"imageOffset":7080,"symbol":"thread_start","symbolLocation":8,"imageIndex":14}],"threadState":{"x":[{"value":260},{"value":0},{"value":0},{"value":0},{"value":0},{"value":160},{"value":0},{"value":0},{"value":6114503224},{"value":0},{"value":0},{"value":2},{"value":2},{"value":0},{"value":0},{"value":0},{"value":305},{"value":8431211416},{"value":0},{"value":34570814336},{"value":34575026192},{"value":6114504928},{"value":0},{"value":0},{"value":0},{"value":1},{"value":256},{"value":5},{"value":4389625392}],"flavor":"ARM_THREAD_STATE64","lr":{"value":6585950428},"cpsr":{"value":1610612736},"fp":{"value":6114503344},"sp":{"value":6114503200},"esr":{"value":1442840704,"description":"(Syscall)"},"pc":{"value":6585689336},"far":{"value":0}}},{"id":6246517,"frames":[{"imageOffset":17656,"symbol":"__psynch_cvwait","symbolLocation":8,"imageIndex":13},{"imageOffset":28892,"symbol":"_pthread_cond_wait","symbolLocation":984,"imageIndex":14},{"imageOffset":4658180,"imageIndex":0},{"imageOffset":5029456,"imageIndex":0},{"imageOffset":5028748,"imageIndex":0},{"imageOffset":2928268,"imageIndex":0},{"imageOffset":2927552,"imageIndex":0},{"imageOffset":4061620,"imageIndex":0},{"imageOffset":27656,"symbol":"_pthread_start","symbolLocation":136,"imageIndex":14},{"imageOffset":7080,"symbol":"thread_start","symbolLocation":8,"imageIndex":14}],"threadState":{"x":[{"value":260},{"value":0},{"value":256},{"value":0},{"value":0},{"value":160},{"value":0},{"value":0},{"value":6116649528},{"value":0},{"value":1024},{"value":4398046512130},{"value":4398046512130},{"value":1024},{"value":0},{"value":4398046512128},{"value":305},{"value":8431211416},{"value":0},{"value":34570814400},{"value":34575025952},{"value":6116651232},{"value":0},{"value":0},{"value":256},{"value":257},{"value":512},{"value":8},{"value":4389625392}],"flavor":"ARM_THREAD_STATE64","lr":{"value":6585950428},"cpsr":{"value":1610612736},"fp":{"value":6116649648},"sp":{"value":6116649504},"esr":{"value":1442840704,"description":"(Syscall)"},"pc":{"value":6585689336},"far":{"value":0}}},{"id":6246544,"name":"WebCore: Scrolling","threadState":{"x":[{"value":268451845},{"value":21592279046},{"value":8589934592},{"value":329866373234688},{"value":0},{"value":329866373234688},{"value":2},{"value":4294967295},{"value":0},{"value":17179869184},{"value":0},{"value":2},{"value":0},{"value":0},{"value":76803},{"value":0},{"value":18446744073709551569},{"value":8431213296},{"value":0},{"value":4294967295},{"value":2},{"value":329866373234688},{"value":0},{"value":329866373234688},{"value":6118940616},{"value":8589934592},{"value":21592279046},{"value":18446744073709550527},{"value":4412409862}],"flavor":"ARM_THREAD_STATE64","lr":{"value":6585749544},"cpsr":{"value":0},"fp":{"value":6118940464},"sp":{"value":6118940384},"esr":{"value":1442840704,"description":"(Syscall)"},"pc":{"value":6585674804},"far":{"value":0}},"frames":[{"imageOffset":3124,"symbol":"mach_msg2_trap","symbolLocation":8,"imageIndex":13},{"imageOffset":77864,"symbol":"mach_msg2_internal","symbolLocation":76,"imageIndex":13},{"imageOffset":39308,"symbol":"mach_msg_overwrite","symbolLocation":484,"imageIndex":13},{"imageOffset":4020,"symbol":"mach_msg","symbolLocation":24,"imageIndex":13},{"imageOffset":392080,"symbol":"__CFRunLoopServiceMachPort","symbolLocation":160,"imageIndex":9},{"imageOffset":386280,"symbol":"__CFRunLoopRun","symbolLocation":1188,"imageIndex":9},{"imageOffset":1147740,"symbol":"_CFRunLoopRunSpecificWithOptions","symbolLocation":532,"imageIndex":9},{"imageOffset":727600,"symbol":"CFRunLoopRun","symbolLocation":64,"imageIndex":9},{"imageOffset":2072984,"symbol":"WTF::Detail::CallableWrapper::call()","symbolLocation":244,"imageIndex":8},{"imageOffset":2346588,"symbol":"WTF::Thread::entryPoint(WTF::Thread::NewThreadContext*)","symbolLocation":260,"imageIndex":8},{"imageOffset":29840,"symbol":"WTF::wtfThreadEntryPoint(void*)","symbolLocation":16,"imageIndex":8},{"imageOffset":27656,"symbol":"_pthread_start","symbolLocation":136,"imageIndex":14},{"imageOffset":7080,"symbol":"thread_start","symbolLocation":8,"imageIndex":14}]},{"id":6246578,"name":"Log work queue","threadState":{"x":[{"value":14},{"value":4917346528},{"value":0},{"value":6124099888},{"value":8373513120,"symbolLocation":0,"symbol":"_os_log_current_test_callback"},{"value":20},{"value":0},{"value":0},{"value":0},{"value":0},{"value":0},{"value":0},{"value":0},{"value":1498952},{"value":8408172592,"symbolLocation":0,"symbol":"OBJC_CLASS_$_OS_os_log"},{"value":8408172592,"symbolLocation":0,"symbol":"OBJC_CLASS_$_OS_os_log"},{"value":18446744073709551580},{"value":8431215768},{"value":0},{"value":4915725184},{"value":4915725224},{"value":6124105728},{"value":0},{"value":0},{"value":4915725312},{"value":0},{"value":0},{"value":0},{"value":0}],"flavor":"ARM_THREAD_STATE64","lr":{"value":7296706228},"cpsr":{"value":2147483648},"fp":{"value":6124105552},"sp":{"value":6124105536},"esr":{"value":1442840704,"description":"(Syscall)"},"pc":{"value":6585674672},"far":{"value":0}},"frames":[{"imageOffset":2992,"symbol":"semaphore_wait_trap","symbolLocation":8,"imageIndex":13},{"imageOffset":17966772,"symbol":"IPC::StreamConnectionWorkQueue::startProcessingThread()::$_0::operator()()","symbolLocation":44,"imageIndex":7},{"imageOffset":2346588,"symbol":"WTF::Thread::entryPoint(WTF::Thread::NewThreadContext*)","symbolLocation":260,"imageIndex":8},{"imageOffset":29840,"symbol":"WTF::wtfThreadEntryPoint(void*)","symbolLocation":16,"imageIndex":8},{"imageOffset":27656,"symbol":"_pthread_start","symbolLocation":136,"imageIndex":14},{"imageOffset":7080,"symbol":"thread_start","symbolLocation":8,"imageIndex":14}]},{"id":6246619,"name":"tokio-runtime-worker","threadState":{"x":[{"value":260},{"value":0},{"value":768},{"value":0},{"value":0},{"value":160},{"value":0},{"value":0},{"value":6126250792},{"value":0},{"value":0},{"value":2},{"value":2},{"value":0},{"value":0},{"value":0},{"value":305},{"value":8431211416},{"value":0},{"value":34563165440},{"value":34563271600},{"value":6126252256},{"value":0},{"value":0},{"value":768},{"value":769},{"value":1024},{"value":3},{"value":34562640160}],"flavor":"ARM_THREAD_STATE64","lr":{"value":6585950428},"cpsr":{"value":1610612736},"fp":{"value":6126250912},"sp":{"value":6126250768},"esr":{"value":1442840704,"description":"(Syscall)"},"pc":{"value":6585689336},"far":{"value":0}},"frames":[{"imageOffset":17656,"symbol":"__psynch_cvwait","symbolLocation":8,"imageIndex":13},{"imageOffset":28892,"symbol":"_pthread_cond_wait","symbolLocation":984,"imageIndex":14},{"imageOffset":4658180,"imageIndex":0},{"imageOffset":4655152,"imageIndex":0},{"imageOffset":4678892,"imageIndex":0},{"imageOffset":4665508,"imageIndex":0},{"imageOffset":4665080,"imageIndex":0},{"imageOffset":4061620,"imageIndex":0},{"imageOffset":27656,"symbol":"_pthread_start","symbolLocation":136,"imageIndex":14},{"imageOffset":7080,"symbol":"thread_start","symbolLocation":8,"imageIndex":14}]},{"id":6246620,"name":"tokio-runtime-worker","threadState":{"x":[{"value":4},{"value":0},{"value":0},{"value":34590130176},{"value":1024},{"value":0},{"value":0},{"value":0},{"value":0},{"value":6128397048},{"value":0},{"value":2},{"value":0},{"value":0},{"value":0},{"value":4},{"value":363},{"value":8431213136},{"value":0},{"value":34589889304},{"value":34590130176},{"value":1000000000},{"value":34571335216},{"value":0},{"value":1000000000},{"value":34586341936},{"value":0},{"value":8},{"value":34562644000}],"flavor":"ARM_THREAD_STATE64","lr":{"value":4378632360},"cpsr":{"value":1610612736},"fp":{"value":6128397152},"sp":{"value":6128397008},"esr":{"value":1442840704,"description":"(Syscall)"},"pc":{"value":6585700144},"far":{"value":0}},"frames":[{"imageOffset":28464,"symbol":"kevent","symbolLocation":8,"imageIndex":13},{"imageOffset":4661416,"imageIndex":0},{"imageOffset":4658628,"imageIndex":0},{"imageOffset":4654976,"imageIndex":0},{"imageOffset":4678892,"imageIndex":0},{"imageOffset":4665508,"imageIndex":0},{"imageOffset":4665080,"imageIndex":0},{"imageOffset":4061620,"imageIndex":0},{"imageOffset":27656,"symbol":"_pthread_start","symbolLocation":136,"imageIndex":14},{"imageOffset":7080,"symbol":"thread_start","symbolLocation":8,"imageIndex":14}]},{"id":6246621,"name":"tokio-runtime-worker","threadState":{"x":[{"value":260},{"value":0},{"value":504320},{"value":0},{"value":0},{"value":160},{"value":0},{"value":0},{"value":6130543400},{"value":0},{"value":0},{"value":2},{"value":2},{"value":0},{"value":0},{"value":0},{"value":305},{"value":8431211416},{"value":0},{"value":34563172928},{"value":34563270736},{"value":6130544864},{"value":0},{"value":0},{"value":504320},{"value":504321},{"value":504576},{"value":9},{"value":34562643616}],"flavor":"ARM_THREAD_STATE64","lr":{"value":6585950428},"cpsr":{"value":1610612736},"fp":{"value":6130543520},"sp":{"value":6130543376},"esr":{"value":1442840704,"description":"(Syscall)"},"pc":{"value":6585689336},"far":{"value":0}},"frames":[{"imageOffset":17656,"symbol":"__psynch_cvwait","symbolLocation":8,"imageIndex":13},{"imageOffset":28892,"symbol":"_pthread_cond_wait","symbolLocation":984,"imageIndex":14},{"imageOffset":4658180,"imageIndex":0},{"imageOffset":4655152,"imageIndex":0},{"imageOffset":4678892,"imageIndex":0},{"imageOffset":4665508,"imageIndex":0},{"imageOffset":4665080,"imageIndex":0},{"imageOffset":4061620,"imageIndex":0},{"imageOffset":27656,"symbol":"_pthread_start","symbolLocation":136,"imageIndex":14},{"imageOffset":7080,"symbol":"thread_start","symbolLocation":8,"imageIndex":14}]},{"id":6246622,"name":"tokio-runtime-worker","threadState":{"x":[{"value":260},{"value":0},{"value":2816},{"value":0},{"value":0},{"value":160},{"value":0},{"value":0},{"value":6132689704},{"value":0},{"value":0},{"value":2},{"value":2},{"value":0},{"value":0},{"value":0},{"value":305},{"value":8431211416},{"value":0},{"value":34570828544},{"value":34575026240},{"value":6132691168},{"value":0},{"value":0},{"value":2816},{"value":2817},{"value":3072},{"value":9},{"value":34562642464}],"flavor":"ARM_THREAD_STATE64","lr":{"value":6585950428},"cpsr":{"value":1610612736},"fp":{"value":6132689824},"sp":{"value":6132689680},"esr":{"value":1442840704,"description":"(Syscall)"},"pc":{"value":6585689336},"far":{"value":0}},"frames":[{"imageOffset":17656,"symbol":"__psynch_cvwait","symbolLocation":8,"imageIndex":13},{"imageOffset":28892,"symbol":"_pthread_cond_wait","symbolLocation":984,"imageIndex":14},{"imageOffset":4658180,"imageIndex":0},{"imageOffset":4655152,"imageIndex":0},{"imageOffset":4678892,"imageIndex":0},{"imageOffset":4665508,"imageIndex":0},{"imageOffset":4665080,"imageIndex":0},{"imageOffset":4061620,"imageIndex":0},{"imageOffset":27656,"symbol":"_pthread_start","symbolLocation":136,"imageIndex":14},{"imageOffset":7080,"symbol":"thread_start","symbolLocation":8,"imageIndex":14}]},{"id":6246623,"name":"tokio-runtime-worker","threadState":{"x":[{"value":260},{"value":0},{"value":113664},{"value":0},{"value":0},{"value":160},{"value":0},{"value":0},{"value":6134836008},{"value":0},{"value":0},{"value":2},{"value":2},{"value":0},{"value":0},{"value":0},{"value":305},{"value":8431211416},{"value":0},{"value":34570828480},{"value":34575027056},{"value":6134837472},{"value":0},{"value":0},{"value":113664},{"value":113665},{"value":113920},{"value":5},{"value":34562644768}],"flavor":"ARM_THREAD_STATE64","lr":{"value":6585950428},"cpsr":{"value":1610612736},"fp":{"value":6134836128},"sp":{"value":6134835984},"esr":{"value":1442840704,"description":"(Syscall)"},"pc":{"value":6585689336},"far":{"value":0}},"frames":[{"imageOffset":17656,"symbol":"__psynch_cvwait","symbolLocation":8,"imageIndex":13},{"imageOffset":28892,"symbol":"_pthread_cond_wait","symbolLocation":984,"imageIndex":14},{"imageOffset":4658180,"imageIndex":0},{"imageOffset":4655152,"imageIndex":0},{"imageOffset":4678892,"imageIndex":0},{"imageOffset":4665508,"imageIndex":0},{"imageOffset":4665080,"imageIndex":0},{"imageOffset":4061620,"imageIndex":0},{"imageOffset":27656,"symbol":"_pthread_start","symbolLocation":136,"imageIndex":14},{"imageOffset":7080,"symbol":"thread_start","symbolLocation":8,"imageIndex":14}]},{"id":6246624,"name":"tokio-runtime-worker","threadState":{"x":[{"value":260},{"value":0},{"value":0},{"value":0},{"value":0},{"value":160},{"value":0},{"value":0},{"value":6136982312},{"value":0},{"value":0},{"value":2},{"value":2},{"value":0},{"value":0},{"value":0},{"value":305},{"value":8431211416},{"value":0},{"value":34570827520},{"value":34575027728},{"value":6136983776},{"value":0},{"value":0},{"value":0},{"value":1},{"value":256},{"value":1},{"value":34562645152}],"flavor":"ARM_THREAD_STATE64","lr":{"value":6585950428},"cpsr":{"value":1610612736},"fp":{"value":6136982432},"sp":{"value":6136982288},"esr":{"value":1442840704,"description":"(Syscall)"},"pc":{"value":6585689336},"far":{"value":0}},"frames":[{"imageOffset":17656,"symbol":"__psynch_cvwait","symbolLocation":8,"imageIndex":13},{"imageOffset":28892,"symbol":"_pthread_cond_wait","symbolLocation":984,"imageIndex":14},{"imageOffset":4658180,"imageIndex":0},{"imageOffset":4655152,"imageIndex":0},{"imageOffset":4678892,"imageIndex":0},{"imageOffset":4665508,"imageIndex":0},{"imageOffset":4665080,"imageIndex":0},{"imageOffset":4061620,"imageIndex":0},{"imageOffset":27656,"symbol":"_pthread_start","symbolLocation":136,"imageIndex":14},{"imageOffset":7080,"symbol":"thread_start","symbolLocation":8,"imageIndex":14}]},{"id":6246625,"name":"tokio-runtime-worker","threadState":{"x":[{"value":260},{"value":0},{"value":625408},{"value":0},{"value":0},{"value":160},{"value":0},{"value":0},{"value":6139128616},{"value":0},{"value":0},{"value":2},{"value":2},{"value":0},{"value":0},{"value":0},{"value":305},{"value":8431211416},{"value":0},{"value":34563165568},{"value":34563271696},{"value":6139130080},{"value":0},{"value":0},{"value":625408},{"value":625409},{"value":625664},{"value":6},{"value":34562645536}],"flavor":"ARM_THREAD_STATE64","lr":{"value":6585950428},"cpsr":{"value":1610612736},"fp":{"value":6139128736},"sp":{"value":6139128592},"esr":{"value":1442840704,"description":"(Syscall)"},"pc":{"value":6585689336},"far":{"value":0}},"frames":[{"imageOffset":17656,"symbol":"__psynch_cvwait","symbolLocation":8,"imageIndex":13},{"imageOffset":28892,"symbol":"_pthread_cond_wait","symbolLocation":984,"imageIndex":14},{"imageOffset":4658180,"imageIndex":0},{"imageOffset":4655152,"imageIndex":0},{"imageOffset":4678892,"imageIndex":0},{"imageOffset":4665508,"imageIndex":0},{"imageOffset":4665080,"imageIndex":0},{"imageOffset":4061620,"imageIndex":0},{"imageOffset":27656,"symbol":"_pthread_start","symbolLocation":136,"imageIndex":14},{"imageOffset":7080,"symbol":"thread_start","symbolLocation":8,"imageIndex":14}]},{"id":6246626,"name":"tokio-runtime-worker","threadState":{"x":[{"value":260},{"value":0},{"value":0},{"value":0},{"value":0},{"value":160},{"value":0},{"value":0},{"value":6141274920},{"value":0},{"value":0},{"value":2},{"value":2},{"value":0},{"value":0},{"value":0},{"value":305},{"value":8431211416},{"value":0},{"value":34570826496},{"value":34575025712},{"value":6141276384},{"value":0},{"value":0},{"value":0},{"value":1},{"value":256},{"value":0},{"value":34562645920}],"flavor":"ARM_THREAD_STATE64","lr":{"value":6585950428},"cpsr":{"value":1610612736},"fp":{"value":6141275040},"sp":{"value":6141274896},"esr":{"value":1442840704,"description":"(Syscall)"},"pc":{"value":6585689336},"far":{"value":0}},"frames":[{"imageOffset":17656,"symbol":"__psynch_cvwait","symbolLocation":8,"imageIndex":13},{"imageOffset":28892,"symbol":"_pthread_cond_wait","symbolLocation":984,"imageIndex":14},{"imageOffset":4658180,"imageIndex":0},{"imageOffset":4655152,"imageIndex":0},{"imageOffset":4678892,"imageIndex":0},{"imageOffset":4665508,"imageIndex":0},{"imageOffset":4665080,"imageIndex":0},{"imageOffset":4061620,"imageIndex":0},{"imageOffset":27656,"symbol":"_pthread_start","symbolLocation":136,"imageIndex":14},{"imageOffset":7080,"symbol":"thread_start","symbolLocation":8,"imageIndex":14}]},{"threadState":{"x":[{"value":0},{"value":6143414984},{"value":0},{"value":6143414956},{"value":0},{"value":0},{"value":18446744072631617535},{"value":18446726482597246976},{"value":0},{"value":8408210216,"symbolLocation":0,"symbol":"_current_pid"},{"value":2},{"value":1099511627776},{"value":4294967293},{"value":0},{"value":0},{"value":0},{"value":18446744073709551592},{"value":8431213360},{"value":0},{"value":6143414956},{"value":0},{"value":6143414984},{"value":515},{"value":8408210344,"symbolLocation":0,"symbol":"mach_task_self_"},{"value":34561206448},{"value":687865929},{"value":34561200832},{"value":34561209952},{"value":34591780288}],"flavor":"ARM_THREAD_STATE64","lr":{"value":6585679544},"cpsr":{"value":536870912},"fp":{"value":6143414864},"sp":{"value":6143414832},"esr":{"value":1442840704,"description":"(Syscall)"},"pc":{"value":6585674540},"far":{"value":0}},"id":6246627,"name":"tokio-runtime-worker","queue":"Client CFPasteboard-Apple CFPasteboard general","frames":[{"imageOffset":2860,"symbol":"_kernelrpc_mach_port_construct_trap","symbolLocation":8,"imageIndex":13},{"imageOffset":7864,"symbol":"mach_port_construct","symbolLocation":40,"imageIndex":13},{"imageOffset":200796,"symbol":"_xpc_try_mach_port_construct","symbolLocation":64,"imageIndex":15},{"imageOffset":200872,"symbol":"_xpc_mach_port_construct","symbolLocation":28,"imageIndex":15},{"imageOffset":38212,"symbol":"_xpc_mach_port_allocate","symbolLocation":36,"imageIndex":15},{"imageOffset":56304,"symbol":"xpc_connection_send_message_with_reply","symbolLocation":160,"imageIndex":15},{"imageOffset":1099640,"symbol":"-[_CFPasteboardEntry requestDataForPasteboard:generation:immediatelyAvailableResult:]","symbolLocation":1520,"imageIndex":9},{"imageOffset":379004,"symbol":"__CFPasteboardCopyData_block_invoke","symbolLocation":152,"imageIndex":9},{"imageOffset":1103908,"symbol":"____CFPasteboardPerformOnQueue_block_invoke","symbolLocation":292,"imageIndex":9},{"imageOffset":28188,"symbol":"_dispatch_block_sync_invoke","symbolLocation":240,"imageIndex":16},{"imageOffset":113348,"symbol":"_dispatch_client_callout","symbolLocation":16,"imageIndex":16},{"imageOffset":72000,"symbol":"_dispatch_lane_barrier_sync_invoke_and_complete","symbolLocation":56,"imageIndex":16},{"imageOffset":33080,"symbol":"_dispatch_sync_block_with_privdata","symbolLocation":452,"imageIndex":16},{"imageOffset":376948,"symbol":"CFPasteboardCopyData","symbolLocation":652,"imageIndex":9},{"imageOffset":10570452,"symbol":"-[NSPasteboard _dataWithoutConversionForTypeIdentifier:index:securityScoped:]","symbolLocation":432,"imageIndex":5},{"imageOffset":10572620,"symbol":"-[NSPasteboard _dataForType:index:usesPboardTypes:combinesItems:securityScoped:]","symbolLocation":272,"imageIndex":5},{"imageOffset":15654560,"symbol":"-[NSPasteboardItem __dataForType:async:completionHandler:]","symbolLocation":316,"imageIndex":5},{"imageOffset":15654828,"symbol":"-[NSPasteboardItem stringForType:]","symbolLocation":28,"imageIndex":5},{"imageOffset":2638832,"imageIndex":0},{"imageOffset":2640408,"imageIndex":0},{"imageOffset":4656140,"imageIndex":0},{"imageOffset":4677752,"imageIndex":0},{"imageOffset":4665508,"imageIndex":0},{"imageOffset":4665080,"imageIndex":0},{"imageOffset":4061620,"imageIndex":0},{"imageOffset":27656,"symbol":"_pthread_start","symbolLocation":136,"imageIndex":14},{"imageOffset":7080,"symbol":"thread_start","symbolLocation":8,"imageIndex":14}]},{"id":6246628,"name":"tokio-runtime-worker","threadState":{"x":[{"value":260},{"value":0},{"value":723456},{"value":0},{"value":0},{"value":160},{"value":0},{"value":0},{"value":6145567528},{"value":0},{"value":0},{"value":2},{"value":2},{"value":0},{"value":0},{"value":0},{"value":305},{"value":8431211416},{"value":0},{"value":34563165504},{"value":34563271744},{"value":6145568992},{"value":0},{"value":0},{"value":723456},{"value":723457},{"value":723712},{"value":7},{"value":34562646688}],"flavor":"ARM_THREAD_STATE64","lr":{"value":6585950428},"cpsr":{"value":1610612736},"fp":{"value":6145567648},"sp":{"value":6145567504},"esr":{"value":1442840704,"description":"(Syscall)"},"pc":{"value":6585689336},"far":{"value":0}},"frames":[{"imageOffset":17656,"symbol":"__psynch_cvwait","symbolLocation":8,"imageIndex":13},{"imageOffset":28892,"symbol":"_pthread_cond_wait","symbolLocation":984,"imageIndex":14},{"imageOffset":4658180,"imageIndex":0},{"imageOffset":4655152,"imageIndex":0},{"imageOffset":4678892,"imageIndex":0},{"imageOffset":4665508,"imageIndex":0},{"imageOffset":4665080,"imageIndex":0},{"imageOffset":4061620,"imageIndex":0},{"imageOffset":27656,"symbol":"_pthread_start","symbolLocation":136,"imageIndex":14},{"imageOffset":7080,"symbol":"thread_start","symbolLocation":8,"imageIndex":14}]},{"id":6548446,"name":"JavaScriptCore libpas scavenger","threadState":{"x":[{"value":260},{"value":0},{"value":21455104},{"value":0},{"value":0},{"value":160},{"value":0},{"value":100000000},{"value":6093467304},{"value":0},{"value":256},{"value":1099511628034},{"value":1099511628034},{"value":256},{"value":0},{"value":1099511628032},{"value":305},{"value":8431211416},{"value":0},{"value":4764985408},{"value":4764985472},{"value":6093467872},{"value":100000000},{"value":0},{"value":21455104},{"value":44261633},{"value":44261888},{"value":8381325312,"symbolLocation":2744,"symbol":"WTF::RefLogSingleton::s_buffer"},{"value":8410828800,"symbolLocation":1816,"symbol":"bmalloc_common_primitive_heap_support"}],"flavor":"ARM_THREAD_STATE64","lr":{"value":6585950428},"cpsr":{"value":1610612736},"fp":{"value":6093467424},"sp":{"value":6093467280},"esr":{"value":1442840704,"description":"(Syscall)"},"pc":{"value":6585689336},"far":{"value":0}},"frames":[{"imageOffset":17656,"symbol":"__psynch_cvwait","symbolLocation":8,"imageIndex":13},{"imageOffset":28892,"symbol":"_pthread_cond_wait","symbolLocation":984,"imageIndex":14},{"imageOffset":26205816,"symbol":"scavenger_thread_main","symbolLocation":1440,"imageIndex":8},{"imageOffset":27656,"symbol":"_pthread_start","symbolLocation":136,"imageIndex":14},{"imageOffset":7080,"symbol":"thread_start","symbolLocation":8,"imageIndex":14}]},{"id":6770305,"name":"CVDisplayLink","threadState":{"x":[{"value":260},{"value":0},{"value":0},{"value":0},{"value":0},{"value":65704},{"value":0},{"value":15638083},{"value":270710273},{"value":0},{"value":0},{"value":2},{"value":2},{"value":0},{"value":0},{"value":0},{"value":305},{"value":8431211416},{"value":0},{"value":34574594104},{"value":34574594168},{"value":1},{"value":15638083},{"value":0},{"value":0},{"value":270710273},{"value":270710528},{"value":5967573841783},{"value":0}],"flavor":"ARM_THREAD_STATE64","lr":{"value":6585950472},"cpsr":{"value":2684354560},"fp":{"value":6094040496},"sp":{"value":6094040352},"esr":{"value":1442840704,"description":"(Syscall)"},"pc":{"value":6585689336},"far":{"value":0}},"frames":[{"imageOffset":17656,"symbol":"__psynch_cvwait","symbolLocation":8,"imageIndex":13},{"imageOffset":28936,"symbol":"_pthread_cond_wait","symbolLocation":1028,"imageIndex":14},{"imageOffset":15164,"symbol":"CVDisplayLink::waitUntil(unsigned long long)","symbolLocation":336,"imageIndex":17},{"imageOffset":11300,"symbol":"CVDisplayLink::runIOThread()","symbolLocation":500,"imageIndex":17},{"imageOffset":27656,"symbol":"_pthread_start","symbolLocation":136,"imageIndex":14},{"imageOffset":7080,"symbol":"thread_start","symbolLocation":8,"imageIndex":14}]},{"id":6835598,"frames":[],"threadState":{"x":[{"value":6118371328},{"value":124343},{"value":6117834752},{"value":0},{"value":409604},{"value":18446744073709551615},{"value":0},{"value":0},{"value":0},{"value":0},{"value":0},{"value":0},{"value":0},{"value":0},{"value":0},{"value":0},{"value":0},{"value":0},{"value":0},{"value":0},{"value":0},{"value":0},{"value":0},{"value":0},{"value":0},{"value":0},{"value":0},{"value":0},{"value":0}],"flavor":"ARM_THREAD_STATE64","lr":{"value":0},"cpsr":{"value":0},"fp":{"value":0},"sp":{"value":6118371328},"esr":{"value":1442840704,"description":"(Syscall)"},"pc":{"value":6585928596},"far":{"value":0}}},{"id":6837987,"frames":[],"threadState":{"x":[{"value":6094614528},{"value":37483},{"value":6094077952},{"value":0},{"value":409604},{"value":18446744073709551615},{"value":0},{"value":0},{"value":0},{"value":0},{"value":0},{"value":0},{"value":0},{"value":0},{"value":0},{"value":0},{"value":0},{"value":0},{"value":0},{"value":0},{"value":0},{"value":0},{"value":0},{"value":0},{"value":0},{"value":0},{"value":0},{"value":0},{"value":0}],"flavor":"ARM_THREAD_STATE64","lr":{"value":0},"cpsr":{"value":0},"fp":{"value":0},"sp":{"value":6094614528},"esr":{"value":1442840704,"description":"(Syscall)"},"pc":{"value":6585928596},"far":{"value":0}}},{"id":6837989,"frames":[],"threadState":{"x":[{"value":6117797888},{"value":103203},{"value":6117261312},{"value":0},{"value":409604},{"value":18446744073709551615},{"value":0},{"value":0},{"value":0},{"value":0},{"value":0},{"value":0},{"value":0},{"value":0},{"value":0},{"value":0},{"value":0},{"value":0},{"value":0},{"value":0},{"value":0},{"value":0},{"value":0},{"value":0},{"value":0},{"value":0},{"value":0},{"value":0},{"value":0}],"flavor":"ARM_THREAD_STATE64","lr":{"value":0},"cpsr":{"value":0},"fp":{"value":0},"sp":{"value":6117797888},"esr":{"value":1442840704,"description":"(Syscall)"},"pc":{"value":6585928596},"far":{"value":0}}},{"id":6838119,"frames":[],"threadState":{"x":[{"value":6119518208},{"value":106279},{"value":6118981632},{"value":0},{"value":409604},{"value":18446744073709551615},{"value":0},{"value":0},{"value":0},{"value":0},{"value":0},{"value":0},{"value":0},{"value":0},{"value":0},{"value":0},{"value":0},{"value":0},{"value":0},{"value":0},{"value":0},{"value":0},{"value":0},{"value":0},{"value":0},{"value":0},{"value":0},{"value":0},{"value":0}],"flavor":"ARM_THREAD_STATE64","lr":{"value":0},"cpsr":{"value":0},"fp":{"value":0},"sp":{"value":6119518208},"esr":{"value":1442840704,"description":"(Syscall)"},"pc":{"value":6585928596},"far":{"value":0}}}], "usedImages" : [ { "source" : "P", "arch" : "arm64", "base" : 4373970944, "CFBundleShortVersionString" : "2.9.13", "CFBundleIdentifier" : "liren.project-graph", "size" : 8945664, "uuid" : "946c435c-f6bb-3969-9092-d73ba4a59315", "path" : "\/Applications\/Project Graph.app\/Contents\/MacOS\/project-graph", "name" : "project-graph", "CFBundleVersion" : "2.9.13" }, { "source" : "P", "arch" : "arm64e", "base" : 4682629120, "size" : 49152, "uuid" : "f8bd9069-8c4f-37ea-af9a-2b1060f54e4f", "path" : "\/usr\/lib\/libobjc-trampolines.dylib", "name" : "libobjc-trampolines.dylib" }, { "source" : "P", "arch" : "arm64e", "base" : 4716199936, "CFBundleShortVersionString" : "341.11", "CFBundleIdentifier" : "com.apple.AGXMetalG16G-B0", "size" : 8552448, "uuid" : "a22549f3-d4f5-3b88-af18-e06837f0d352", "path" : "\/System\/Library\/Extensions\/AGXMetalG16G_B0.bundle\/Contents\/MacOS\/AGXMetalG16G_B0", "name" : "AGXMetalG16G_B0", "CFBundleVersion" : "341.11" }, { "source" : "P", "arch" : "arm64e", "base" : 4705353728, "CFBundleShortVersionString" : "1.0", "CFBundleIdentifier" : "com.apple.AppleMetalOpenGLRenderer", "size" : 409600, "uuid" : "7fba6cd5-06ae-37aa-aa67-580c920ea69d", "path" : "\/System\/Library\/Extensions\/AppleMetalOpenGLRenderer.bundle\/Contents\/MacOS\/AppleMetalOpenGLRenderer", "name" : "AppleMetalOpenGLRenderer", "CFBundleVersion" : "1" }, { "source" : "P", "arch" : "arm64e", "base" : 6581403648, "size" : 341132, "uuid" : "5a0aab4e-0c1a-3680-82c9-43dc4007a6e7", "path" : "\/usr\/lib\/libobjc.A.dylib", "name" : "libobjc.A.dylib" }, { "source" : "P", "arch" : "arm64e", "base" : 6657810432, "CFBundleShortVersionString" : "6.9", "CFBundleIdentifier" : "com.apple.AppKit", "size" : 24300448, "uuid" : "3c0949bb-e361-369a-80b7-17440eb09e98", "path" : "\/System\/Library\/Frameworks\/AppKit.framework\/Versions\/C\/AppKit", "name" : "AppKit", "CFBundleVersion" : "2685.20.119" }, { "source" : "P", "arch" : "arm64e", "base" : 7213748224, "CFBundleShortVersionString" : "21622", "CFBundleIdentifier" : "com.apple.WebCore", "size" : 57751008, "uuid" : "ccd2dfa6-ae82-311f-b824-a9aad0a6f12e", "path" : "\/System\/Library\/Frameworks\/WebKit.framework\/Versions\/A\/Frameworks\/WebCore.framework\/Versions\/A\/WebCore", "name" : "WebCore", "CFBundleVersion" : "21622.2.11.11.9" }, { "source" : "P", "arch" : "arm64e", "base" : 7278739456, "CFBundleShortVersionString" : "21622", "CFBundleIdentifier" : "com.apple.WebKit", "size" : 22128832, "uuid" : "3b55482a-efe2-35a7-b1c9-3f41a823a30b", "path" : "\/System\/Library\/Frameworks\/WebKit.framework\/Versions\/A\/WebKit", "name" : "WebKit", "CFBundleVersion" : "21622.2.11.11.9" }, { "source" : "P", "arch" : "arm64e", "base" : 7143546880, "CFBundleShortVersionString" : "21622", "CFBundleIdentifier" : "com.apple.JavaScriptCore", "size" : 28438144, "uuid" : "c79071c9-db50-3264-a316-94abd0d3b9a9", "path" : "\/System\/Library\/Frameworks\/JavaScriptCore.framework\/Versions\/A\/JavaScriptCore", "name" : "JavaScriptCore", "CFBundleVersion" : "21622.2.11.11.9" }, { "source" : "P", "arch" : "arm64e", "base" : 6586208256, "CFBundleShortVersionString" : "6.9", "CFBundleIdentifier" : "com.apple.CoreFoundation", "size" : 5532352, "uuid" : "3c4a3add-9e48-33da-82ee-80520e6cbe3b", "path" : "\/System\/Library\/Frameworks\/CoreFoundation.framework\/Versions\/A\/CoreFoundation", "name" : "CoreFoundation", "CFBundleVersion" : "4109.1.401" }, { "source" : "P", "arch" : "arm64e", "base" : 6798389248, "CFBundleShortVersionString" : "2.1.1", "CFBundleIdentifier" : "com.apple.HIToolbox", "size" : 3155968, "uuid" : "9ab64c08-0685-3a0d-9a7e-83e7a1e9ebb4", "path" : "\/System\/Library\/Frameworks\/Carbon.framework\/Versions\/A\/Frameworks\/HIToolbox.framework\/Versions\/A\/HIToolbox", "name" : "HIToolbox" }, { "source" : "P", "arch" : "arm64e", "base" : 6581948416, "size" : 651108, "uuid" : "b50f5a1a-be81-3068-92e1-3554f2be478a", "path" : "\/usr\/lib\/dyld", "name" : "dyld" }, { "size" : 0, "source" : "A", "base" : 0, "uuid" : "00000000-0000-0000-0000-000000000000" }, { "source" : "P", "arch" : "arm64e", "base" : 6585671680, "size" : 246944, "uuid" : "9fe7c84d-0c2b-363f-bee5-6fd76d67a227", "path" : "\/usr\/lib\/system\/libsystem_kernel.dylib", "name" : "libsystem_kernel.dylib" }, { "source" : "P", "arch" : "arm64e", "base" : 6585921536, "size" : 51900, "uuid" : "e95973b8-824c-361e-adf4-390747c40897", "path" : "\/usr\/lib\/system\/libsystem_pthread.dylib", "name" : "libsystem_pthread.dylib" }, { "source" : "P", "arch" : "arm64e", "base" : 6582616064, "size" : 348032, "uuid" : "8346be50-de08-3606-9fb6-9a352975661d", "path" : "\/usr\/lib\/system\/libxpc.dylib", "name" : "libxpc.dylib" }, { "source" : "P", "arch" : "arm64e", "base" : 6584119296, "size" : 290464, "uuid" : "8fb392ae-401f-399a-96ae-41531cf91162", "path" : "\/usr\/lib\/system\/libdispatch.dylib", "name" : "libdispatch.dylib" }, { "source" : "P", "arch" : "arm64e", "base" : 6760062976, "CFBundleShortVersionString" : "1.8", "CFBundleIdentifier" : "com.apple.CoreVideo", "size" : 540672, "uuid" : "d8605842-8c6c-36d7-820d-2132d91e0c06", "path" : "\/System\/Library\/Frameworks\/CoreVideo.framework\/Versions\/A\/CoreVideo", "name" : "CoreVideo", "CFBundleVersion" : "726.2" } ], "sharedCache" : { "base" : 6580862976, "size" : 5609635840, "uuid" : "b69ff43c-dbfd-3fb1-b4fe-a8fe32ea1062" }, "vmSummary" : "ReadOnly portion of Libraries: Total=1.8G resident=0K(0%) swapped_out_or_unallocated=1.8G(100%)\nWritable regions: Total=4.7G written=1841K(0%) resident=945K(0%) swapped_out=896K(0%) unallocated=4.7G(100%)\n\n VIRTUAL REGION \nREGION TYPE SIZE COUNT (non-coalesced) \n=========== ======= ======= \nActivity Tracing 256K 1 \nColorSync 32K 2 \nCoreAnimation 912K 57 \nCoreGraphics 64K 4 \nCoreUI image data 240K 2 \nFoundation 48K 2 \nKernel Alloc Once 32K 1 \nMALLOC 268.9M 32 \nMALLOC guard page 3120K 4 \nSTACK GUARD 464K 29 \nStack 53.4M 30 \nStack Guard 56.0M 1 \nVM_ALLOCATE 4880K 41 \nVM_ALLOCATE (reserved) 4.0G 21 reserved VM address space (unallocated)\nWebKit Malloc 400.2M 9 \n__AUTH 5853K 652 \n__AUTH_CONST 88.8M 1037 \n__CTF 824 1 \n__DATA 30.0M 988 \n__DATA_CONST 33.2M 1046 \n__DATA_DIRTY 8836K 898 \n__FONT_DATA 2352 1 \n__GLSLBUILTINS 5174K 1 \n__INFO_FILTER 8 1 \n__LINKEDIT 594.2M 5 \n__OBJC_RO 78.3M 1 \n__OBJC_RW 2567K 1 \n__TEXT 1.2G 1069 \n__TPRO_CONST 128K 2 \nmapped file 600.6M 75 \npage table in kernel 945K 1 \nshared memory 912K 15 \n=========== ======= ======= \nTOTAL 7.4G 6030 \nTOTAL, minus reserved VM space 3.4G 6030 \n", "legacyInfo" : { "threadTriggered" : { "name" : "main", "queue" : "com.apple.main-thread" } }, "logWritingSignature" : "be58563517ee84a143ff0fa4d7387166d5414db0", "trialInfo" : { "rollouts" : [ { "rolloutId" : "64628732bf2f5257dedc8988", "factorPackIds" : [ ], "deploymentId" : 240000001 }, { "rolloutId" : "6246d6a916a70b047e454124", "factorPackIds" : [ ], "deploymentId" : 240000010 } ], "experiments" : [ ] } } Model: Mac16,12, BootROM 13822.41.1, proc 10:4:6 processors, 24 GB, SMC Graphics: Apple M4, Apple M4, Built-In Display: Mi Monitor, 3840 x 2160 (2160p/4K UHD 1 - Ultra High Definition), Main, MirrorOff, Online Display: Color LCD, 2560 x 1664 Retina, MirrorOff, Online Memory Module: LPDDR5, Hynix AirPort: spairport_wireless_card_type_wifi (0x14E4, 0x4388), wl0: Oct 3 2025 00:48:50 version 23.41.7.0.41.51.200 FWID 01-8b09c4e0 IO80211_driverkit-1530.16 "IO80211_driverkit-1530.16" Oct 10 2025 22:56:35 AirPort: Bluetooth: Version (null), 0 services, 0 devices, 0 incoming serial ports Network Service: Wi-Fi, AirPort, en0 Thunderbolt Bus: MacBook Air, Apple Inc. Thunderbolt Bus: MacBook Air, Apple Inc. ================================================ FILE: .trae/skills/create-keybind/SKILL.md ================================================ --- name: create-keybind description: 指导如何在 Project Graph 项目中创建新的快捷键。当用户需要添加新的快捷键、修改快捷键绑定或需要了解快捷键系统的实现方式时使用此技能。 --- # 创建新的快捷键功能 本技能指导如何在 Project Graph 项目中创建新的快捷键。 ## 创建快捷键的步骤 创建新快捷键需要完成以下 4 个步骤: ### 1. 在 shortcutKeysRegister.tsx 中注册快捷键 在 `app/src/core/service/controlService/shortcutKeysEngine/shortcutKeysRegister.tsx` 文件的 `allKeyBinds` 数组中添加新的快捷键定义。 **快捷键定义结构:** ```typescript { id: "uniqueKeybindId", // 唯一标识符,使用驼峰命名 defaultKey: "A-S-m", // 默认快捷键组合 onPress: (project?: Project) => void, // 按下时的回调函数 onRelease?: (project?: Project) => void, // 松开时的回调函数(可选) isGlobal?: boolean, // 是否为全局快捷键(可选,默认 false) isUI?: boolean, // 是否为 UI 级别快捷键(可选,默认 false) defaultEnabled?: boolean, // 默认是否启用(可选,默认 true) } ``` **快捷键键位格式:** - `C-` = Ctrl (Windows/Linux) 或 Command (macOS) - `A-` = Alt (Windows/Linux) 或 Option (macOS) - `S-` = Shift - `M-` = Meta (macOS 上等同于 Command) - `F11`, `F12` 等 = 功能键 - `arrowup`, `arrowdown`, `arrowleft`, `arrowright` = 方向键 - `home`, `end`, `pageup`, `pagedown` = 导航键 - `space`, `enter`, `escape` = 特殊键 - 普通字母直接写,如 `m`, `t`, `k` 等 - 多个按键用空格分隔,如 `"t t t"` 表示连续按三次 t **注意:** Mac 系统会自动将 `C-` 和 `M-` 互换,所以不需要手动处理平台差异。 **示例:** ```typescript { id: "setWindowToMiniSize", defaultKey: "A-S-m", // Alt+Shift+M onPress: async () => { const window = getCurrentWindow(); // 执行操作 await window.setSize(new LogicalSize(width, height)); }, isUI: true, // UI 级别快捷键,不需要项目上下文 }, ``` **快捷键类型说明:** - **项目级快捷键(默认)**:需要项目上下文,`onPress` 会接收 `project` 参数 - **UI 级别快捷键(`isUI: true`)**:不需要项目上下文,可以在没有打开项目时使用 - **全局快捷键(`isGlobal: true`)**:使用 Tauri 全局快捷键系统,即使应用不在焦点也能触发 **使用 Tauri API 时的类型处理:** 如果快捷键需要使用 Tauri 窗口 API(如 `setSize`),需要导入正确的类型: ```typescript import { getCurrentWindow } from "@tauri-apps/api/window"; import { LogicalSize } from "@tauri-apps/api/dpi"; // 或 PhysicalSize // 使用 LogicalSize(推荐,会自动处理 DPI 缩放) await window.setSize(new LogicalSize(width, height)); // 或使用 PhysicalSize(物理像素) await window.setSize(new PhysicalSize(width, height)); ``` ### 2. 将快捷键添加到分组中 在 `app/src/sub/SettingsWindow/keybinds.tsx` 文件的 `shortcutKeysGroups` 数组中,将新快捷键的 `id` 添加到相应的分组数组中。 **分组结构:** ```typescript export const shortcutKeysGroups: ShortcutKeysGroup[] = [ { title: "basic", // 分组标识符(对应翻译文件中的 key) icon: , // 分组图标 keys: [ // 该分组包含的快捷键 ID 列表 "saveFile", "openFile", "undo", "redo", // ... ], }, { title: "ui", // UI 控制分组 icon: , keys: [ "closeAllSubWindows", "toggleFullscreen", "setWindowToMiniSize", // 添加新快捷键 // ... ], }, // ... 其他分组 ]; ``` **可用分组:** - `basic` - 基础快捷键(撤销、重做、保存、打开等) - `camera` - 摄像机控制(移动、缩放、重置视野等) - `app` - 应用控制(切换项目、切换模式等) - `ui` - UI 控制(关闭窗口、全屏、窗口大小等) - `draw` - 涂鸦相关 - `select` - 切换选择 - `moveEntity` - 移动实体 - `generateTextNodeInTree` - 生长节点 - `generateTextNodeRoundedSelectedNode` - 在选中节点周围生成节点 - `aboutTextNode` - 关于文本节点(分割、合并、创建等) - `section` - Section 框相关 - `edge` - 连线相关 - `color` - 颜色相关 - `node` - 节点相关 **分组选择指南:** - **UI 控制(`ui`)**:窗口管理、界面切换、全屏、窗口大小等 - **基础快捷键(`basic`)**:文件操作、编辑操作(撤销、重做、复制、粘贴等) - **摄像机控制(`camera`)**:视野移动、缩放、重置等 - **应用控制(`app`)**:项目切换、模式切换等 - **文本节点相关(`aboutTextNode`)**:节点创建、分割、合并、编辑等 - **其他**:根据功能特性选择最合适的分组 **注意:** 如果快捷键不属于任何现有分组,可以: 1. 添加到最接近的现有分组 2. 创建新的分组(需要同时更新翻译文件) ### 3. 添加翻译文本 在所有语言文件中添加翻译: - `app/src/locales/zh_CN.yml` - 简体中文 - `app/src/locales/zh_TW.yml` - 繁体中文 - `app/src/locales/en.yml` - 英文 - `app/src/locales/zh_TWC.yml` - 繁体中文(台湾) **翻译结构:** 在 `keyBinds` 部分添加: ```yaml keyBinds: keybindId: title: "快捷键标题" description: | 快捷键的详细描述 可以多行 说明快捷键的功能和使用场景 ``` **示例:** ```yaml keyBinds: setWindowToMiniSize: title: 设置窗口为迷你大小 description: | 将窗口大小设置为设置中配置的迷你窗口宽度和高度。 ``` **翻译文件位置:** - 简体中文:`app/src/locales/zh_CN.yml` - 繁体中文:`app/src/locales/zh_TW.yml` - 繁体中文(台湾):`app/src/locales/zh_TWC.yml` - 英文:`app/src/locales/en.yml` **注意:** - 翻译键名(`keybindId`)必须与快捷键定义中的 `id` 完全一致 - 所有语言文件都需要添加翻译,否则会显示默认值或键名 ### 4. 更新分组翻译(如果需要创建新分组) 如果创建了新的快捷键分组,需要在所有语言文件的 `keyBindsGroup` 部分添加分组翻译: ```yaml keyBindsGroup: newGroupName: title: "新分组标题" description: | 分组的详细描述 说明该分组包含哪些类型的快捷键 ``` **示例:** ```yaml keyBindsGroup: ui: title: UI控制 description: | 用于控制UI的一些功能 ``` ## 快捷键类型详解 ### 项目级快捷键(默认) 项目级快捷键需要项目上下文,`onPress` 函数会接收 `project` 参数: ```typescript { id: "myKeybind", defaultKey: "C-k", onPress: (project) => { if (!project) { toast.warning("请先打开工程文件"); return; } // 使用 project 进行操作 project.stageManager.doSomething(); }, } ``` ### UI 级别快捷键 UI 级别快捷键不需要项目上下文,可以在没有打开项目时使用: ```typescript { id: "myUIKeybind", defaultKey: "A-S-m", onPress: async () => { // 不需要 project 参数 const window = getCurrentWindow(); await window.setSize(new LogicalSize(300, 300)); }, isUI: true, // 标记为 UI 级别 } ``` ### 全局快捷键 全局快捷键使用 Tauri 全局快捷键系统,即使应用不在焦点也能触发: ```typescript { id: "myGlobalKeybind", defaultKey: "CommandOrControl+Shift+G", onPress: () => { // 全局快捷键逻辑 }, isGlobal: true, // 标记为全局快捷键 } ``` **注意:** 全局快捷键的键位格式与普通快捷键不同,使用 `CommandOrControl+Shift+G` 格式。 ## 访问快捷键配置 在代码中访问快捷键配置: ```typescript import { KeyBindsUI } from "@/core/service/controlService/shortcutKeysEngine/KeyBindsUI"; // 获取快捷键配置 const config = await KeyBindsUI.get("keybindId"); // 修改快捷键 await KeyBindsUI.changeOneUIKeyBind("keybindId", "new-key-combination"); // 重置所有快捷键 await KeyBindsUI.resetAllKeyBinds(); ``` ## 注意事项 1. **快捷键 ID 命名规范:** 使用驼峰命名法(camelCase),如 `setWindowToMiniSize` 2. **唯一性:** 快捷键 ID 必须唯一,不能与现有快捷键重复 3. **默认键位:** 选择不冲突的默认键位组合 4. **类型安全:** TypeScript 会自动推断类型,确保类型一致性 5. **翻译键名:** 翻译文件中的键名必须与快捷键的 `id` 完全一致 6. **分组必须:** 所有快捷键都必须添加到 `shortcutKeysGroups` 中的相应分组,否则不会在设置页面中显示 7. **分组选择:** 根据快捷键的功能特性选择合适的分组,保持设置页面的逻辑清晰 8. **Tauri API 类型:** 使用窗口 API 时,需要使用 `LogicalSize` 或 `PhysicalSize` 类型,不能直接使用普通对象 9. **Mac 兼容性:** Mac 系统会自动将 `C-` 和 `M-` 互换,无需手动处理 10. **UI vs 项目级:** 根据快捷键是否需要项目上下文选择合适的类型 ## 完整示例 假设要添加一个"设置窗口为迷你大小"的快捷键: **1. shortcutKeysRegister.tsx - 注册快捷键:** ```typescript import { getCurrentWindow } from "@tauri-apps/api/window"; import { LogicalSize } from "@tauri-apps/api/dpi"; import { Settings } from "@/core/service/Settings"; export const allKeyBinds: KeyBindItem[] = [ // ... 其他快捷键 { id: "setWindowToMiniSize", defaultKey: "A-S-m", onPress: async () => { const window = getCurrentWindow(); // 如果当前是最大化状态,先取消最大化 if (await window.isMaximized()) { await window.unmaximize(); store.set(isWindowMaxsizedAtom, false); } // 如果当前是全屏状态,先退出全屏 if (await window.isFullscreen()) { await window.setFullscreen(false); } // 设置窗口大小为设置中的迷你窗口大小 const width = Settings.windowCollapsingWidth; const height = Settings.windowCollapsingHeight; await window.setSize(new LogicalSize(width, height)); }, isUI: true, }, // ... 其他快捷键 ]; ``` **2. keybinds.tsx - 添加到分组:** ```typescript export const shortcutKeysGroups: ShortcutKeysGroup[] = [ // ... 其他分组 { title: "ui", icon: , keys: [ "closeAllSubWindows", "toggleFullscreen", "setWindowToMiniSize", // 添加到 UI 控制分组 // ... ], }, // ... 其他分组 ]; ``` **3. zh_CN.yml - 添加翻译:** ```yaml keyBinds: setWindowToMiniSize: title: 设置窗口为迷你大小 description: | 将窗口大小设置为设置中配置的迷你窗口宽度和高度。 ``` **4. 其他语言文件也需要添加相应翻译** ## 快捷键键位格式参考 **修饰键:** - `C-` = Ctrl/Command - `A-` = Alt/Option - `S-` = Shift - `M-` = Meta (macOS) **特殊键:** - `F1` - `F12` = 功能键 - `arrowup`, `arrowdown`, `arrowleft`, `arrowright` = 方向键 - `home`, `end`, `pageup`, `pagedown` = 导航键 - `space`, `enter`, `escape`, `tab`, `backspace`, `delete` = 特殊键 **组合示例:** - `"C-s"` = Ctrl+S - `"A-S-m"` = Alt+Shift+M - `"C-A-S-t"` = Ctrl+Alt+Shift+T - `"F11"` = F11 - `"C-F11"` = Ctrl+F11 - `"t t t"` = 连续按三次 T - `"arrowup"` = 上方向键 - `"S-arrowup"` = Shift+上方向键 ## 快捷键设置页面 快捷键添加到分组后,会在设置页面的"快捷键绑定"标签页中自动显示: 1. 用户可以在设置页面查看所有快捷键 2. 用户可以自定义快捷键键位 3. 用户可以启用/禁用快捷键 4. 用户可以重置快捷键为默认值 快捷键会自动保存到 `keybinds2.json` 文件中,并在应用重启后恢复。 ================================================ FILE: .trae/skills/create-setting-item/SKILL.md ================================================ --- name: create-setting-item description: 指导如何在 Project Graph 项目中创建新的设置项。当用户需要添加新的设置项、配置选项或需要了解设置系统的实现方式时使用此技能。 --- # 创建新的设置项功能 本技能指导如何在 Project Graph 项目中创建新的设置项。 ## 创建设置项的步骤 创建新设置项需要完成以下 5 个步骤: ### 1. 在 Settings.tsx 中添加 Schema 定义 在 `app/src/core/service/Settings.tsx` 文件的 `settingsSchema` 对象中添加新的设置项定义。 **支持的 Zod 类型:** - `z.boolean().default(false)` - 布尔值开关 - `z.number().min(x).max(y).default(z)` - 数字(可添加 `.int()` 限制为整数) - `z.string().default("")` - 字符串 - `z.union([z.literal("option1"), z.literal("option2")]).default("option1")` - 枚举选择 - `z.tuple([z.number(), z.number(), z.number(), z.number()]).default([0,0,0,0])` - 元组(如颜色 RGBA) **示例:** ```typescript // 布尔值设置 enableNewFeature: z.boolean().default(false), // 数字范围设置(带滑块) newSliderValue: z.number().min(0).max(100).int().default(50), // 枚举选择设置 newMode: z.union([z.literal("mode1"), z.literal("mode2")]).default("mode1"), ``` ### 2. 在 SettingsIcons.tsx 中添加图标 在 `app/src/core/service/SettingsIcons.tsx` 文件的 `settingsIcons` 对象中添加对应的图标。 **步骤:** 1. 从 `lucide-react` 导入合适的图标组件 2. 在 `settingsIcons` 对象中添加映射:`settingKey: IconComponent` **示例:** ```typescript import { NewIcon } from "lucide-react"; export const settingsIcons = { // ... 其他设置项 enableNewFeature: NewIcon, }; ``` ### 3. 添加翻译文本 在所有语言文件中添加翻译: - `app/src/locales/zh_CN.yml` - 简体中文 - `app/src/locales/zh_TW.yml` - 繁体中文 - `app/src/locales/en.yml` - 英文 - `app/src/locales/zh_TWC.yml` - 接地气繁体中文 **翻译结构:** ```yaml settings: settingKey: title: "设置项标题" description: | 设置项的详细描述 可以多行 options: # 仅枚举类型需要 option1: "选项1显示文本" option2: "选项2显示文本" ``` **示例:** ```yaml settings: enableNewFeature: title: "启用新功能" description: | 开启后将启用新功能特性。 此功能可能会影响性能。 newMode: title: "新模式" description: "选择新的模式选项" options: mode1: "模式一" mode2: "模式二" ``` ### 4. 将设置项添加到分组中 在 `app/src/sub/SettingsWindow/settings.tsx` 文件的 `categories` 对象中,将新设置项的键名添加到相应的分组数组中。 **分组结构:** ```typescript const categories = { visual: { // 一级分类:视觉 basic: [...], // 二级分组:基础 background: [...], // 二级分组:背景 node: [...], // 二级分组:节点样式 // ... }, automation: { // 一级分类:自动化 autoNamer: [...], autoSave: [...], // ... }, control: { // 一级分类:控制 mouse: [...], cameraMove: [...], // ... }, performance: { // 一级分类:性能 memory: [...], cpu: [...], // ... }, ai: { // 一级分类:AI api: [...], }, }; ``` **添加设置项到分组:** ```typescript const categories = { visual: { basic: [ "language", "isClassroomMode", "enableNewFeature", // 添加新设置项 // ... ], }, // ... }; ``` **分组选择指南:** - **visual(视觉)**:界面显示、主题、背景、节点样式、连线样式等 - `basic`: 基础视觉设置 - `background`: 背景相关设置 - `node`: 节点样式设置 - `edge`: 连线样式设置 - `section`: Section 框的样式设置 - `entityDetails`: 实体详情面板设置 - `debug`: 调试相关设置 - `miniWindow`: 迷你窗口设置 - `experimental`: 实验性视觉功能 - **automation(自动化)**:自动保存、自动备份、自动命名等 - `autoNamer`: 自动命名相关 - `autoSave`: 自动保存相关 - `autoBackup`: 自动备份相关 - `autoImport`: 自动导入相关 - **control(控制)**:鼠标、键盘、触摸板、相机控制等 - `mouse`: 鼠标相关设置 - `touchpad`: 触摸板设置 - `cameraMove`: 相机移动设置 - `cameraZoom`: 相机缩放设置 - `objectSelect`: 对象选择设置 - `textNode`: 文本节点编辑设置 - `edge`: 连线操作设置 - `generateNode`: 节点生成设置 - `gamepad`: 游戏手柄设置 - **performance(性能)**:内存、CPU、渲染性能相关 - `memory`: 内存相关设置 - `cpu`: CPU 相关设置 - `render`: 渲染相关设置 - `experimental`: 实验性性能功能 - **ai(AI)**:AI 相关设置 - `api`: AI API 配置 **注意:** 如果设置项不属于任何现有分组,可以: 1. 添加到最接近的现有分组 2. 在相应分类下创建新的分组(需要同时更新翻译文件中的分类结构) ### 5. 在设置页面中使用 SettingField 组件 设置项添加到分组后,会在设置页面的相应分组中自动显示。如果需要手动渲染或添加额外内容,可以使用 `SettingField` 组件: **基本用法:** ```tsx import { SettingField } from "@/components/ui/field"; ; ``` **带额外内容的用法:** ```tsx 额外按钮} /> ``` **注意:** 大多数情况下,只需要将设置项添加到 `categories` 中即可,设置页面会自动渲染。只有在需要特殊布局或额外功能时才需要手动使用 `SettingField` 组件。 ## SettingField 组件的自动类型推断 `SettingField` 组件会根据 schema 定义自动渲染对应的 UI 控件: - **字符串类型** → `Input` 输入框 - **数字类型(有 min/max)** → `Slider` 滑块 + `Input` 数字输入框 - **数字类型(无范围)** → `Input` 数字输入框 - **布尔类型** → `Switch` 开关 - **枚举类型(Union)** → `Select` 下拉选择框 ## 访问设置值 在代码中访问设置值: ```typescript import { Settings } from "@/core/service/Settings"; // 读取设置值 const value = Settings.enableNewFeature; // 修改设置值 Settings.enableNewFeature = true; // 监听设置变化(返回取消监听的函数) const unsubscribe = Settings.watch("enableNewFeature", (newValue) => { console.log("设置已更改:", newValue); }); // React Hook 方式(在组件中使用) const [value, setValue] = Settings.use("enableNewFeature"); ``` ## 注意事项 1. **设置项键名命名规范:** 使用驼峰命名法(camelCase),如 `enableNewFeature` 2. **默认值:** 所有设置项都必须提供默认值(`.default()`) 3. **类型安全:** TypeScript 会自动推断类型,确保类型一致性 4. **持久化:** 设置值会自动保存到 `settings.json` 文件中 5. **翻译键名:** 翻译文件中的键名必须与设置项的键名完全一致 6. **图标可选:** 如果不需要图标,可以不在 `settingsIcons` 中添加,组件会使用 Fragment 7. **分组必须:** 所有设置项都必须添加到 `categories` 对象中的相应分组,否则不会在设置页面中显示 8. **分组选择:** 根据设置项的功能特性选择合适的分类和分组,保持设置页面的逻辑清晰 ## 完整示例 假设要添加一个"启用暗色模式"的设置项: **1. Settings.tsx:** ```typescript export const settingsSchema = z.object({ // ... 其他设置项 enableDarkMode: z.boolean().default(false), }); ``` **2. SettingsIcons.tsx:** ```typescript import { Moon } from "lucide-react"; export const settingsIcons = { // ... 其他设置项 enableDarkMode: Moon, }; ``` **3. zh_CN.yml:** ```yaml settings: enableDarkMode: title: "启用暗色模式" description: "开启后将使用暗色主题界面" ``` **4. settings.tsx - 添加到分组:** ```typescript const categories = { visual: { basic: [ "language", "isClassroomMode", "enableDarkMode", // 添加到基础视觉设置分组 // ... ], // ... }, // ... }; ``` **5. 设置项会自动显示:** 设置项添加到 `categories` 后,会在设置页面的"视觉 > 基础"分组中自动显示,无需手动使用 `SettingField` 组件。 ## 快捷设置栏支持 如果希望设置项出现在快捷设置栏(Quick Settings Toolbar)中,需要: 1. 确保设置项已正确创建(完成上述 4 步) 2. 快捷设置栏会自动显示所有布尔类型的设置项 3. 可以通过 `QuickSettingsManager.addQuickSetting()` 手动添加非布尔类型的设置项 ================================================ FILE: .vscode/extensions.json ================================================ { "recommendations": ["tauri-apps.tauri-vscode", "dbaeumer.vscode-eslint", "esbenp.prettier-vscode"] } ================================================ FILE: .vscode/launch.json ================================================ { // Use IntelliSense to learn about possible attributes. // Hover to view descriptions of existing attributes. // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 "version": "0.2.0", "configurations": [ { "type": "lldb", "request": "launch", "name": "Tauri Development Debug", "cargo": { "args": ["build", "--manifest-path=./src-tauri/Cargo.toml", "--no-default-features"], "cwd": "${workspaceFolder}/app" }, "cwd": "${workspaceFolder}/app", // task for the `beforeDevCommand` if used, must be configured in `.vscode/tasks.json` "preLaunchTask": "ui:dev" }, { "type": "lldb", "request": "launch", "name": "Tauri Production Debug", "cargo": { "args": ["build", "--release", "--manifest-path=./src-tauri/Cargo.toml"], "cwd": "${workspaceFolder}/app" }, "cwd": "${workspaceFolder}/app", // task for the `beforeBuildCommand` if used, must be configured in `.vscode/tasks.json` "preLaunchTask": "ui:build" } ] } ================================================ FILE: .vscode/settings.json ================================================ { "i18n-ally.localesPaths": ["src/locales"], "i18n-ally.keystyle": "nested", "eslint.options": { "overrideConfigFile": "./eslint.config.js" }, "vue.server.includeLanguages": ["vue"], "rust-analyzer.linkedProjects": ["app/src-tauri/Cargo.toml"], "files.associations": { "*.pg-theme": "yaml" }, "todo-tree.tree.disableCompactFolders": false, "todo-tree.tree.scanMode": "workspace only", "typescript.tsdk": "app/node_modules/typescript/lib" } ================================================ FILE: .vscode/tasks.json ================================================ { // See https://go.microsoft.com/fwlink/?LinkId=733558 // for the documentation about the tasks.json format "version": "2.0.0", "tasks": [ { "label": "ui:dev", "type": "shell", // `dev` keeps running in the background // ideally you should also configure a `problemMatcher` // see https://code.visualstudio.com/docs/editor/tasks#_can-a-background-task-be-used-as-a-prelaunchtask-in-launchjson "isBackground": true, // change this to your `beforeDevCommand`: "command": "pnpm", "args": ["dev"] }, { "label": "ui:build", "type": "shell", // change this to your `beforeBuildCommand`: "command": "pnpm", "args": ["build"] } ] } ================================================ FILE: .zed/settings.json ================================================ // Folder-specific settings // // For a full list of overridable settings, and general information on folder-specific settings, // see the documentation: https://zed.dev/docs/configuring-zed#settings-files { "file_types": { "YAML": ["*.pg-theme"] }, "lsp": { "vtsls": { "settings": { "typescript": { "tsdk": "app/node_modules/typescript/lib" } } } } } ================================================ FILE: CODE_OF_CONDUCT.md ================================================ # Contributor Covenant Code of Conduct ## Our Pledge We as members, contributors, and leaders pledge to make participation in our community a harassment-free experience for everyone, regardless of age, body size, visible or invisible disability, ethnicity, sex characteristics, gender identity and expression, level of experience, education, socio-economic status, nationality, personal appearance, race, religion, or sexual identity and orientation. We pledge to act and interact in ways that contribute to an open, welcoming, diverse, inclusive, and healthy community. ## Our Standards Examples of behavior that contributes to a positive environment for our community include: - Demonstrating empathy and kindness toward other people - Being respectful of differing opinions, viewpoints, and experiences - Giving and gracefully accepting constructive feedback - Accepting responsibility and apologizing to those affected by our mistakes, and learning from the experience - Focusing on what is best not just for us as individuals, but for the overall community Examples of unacceptable behavior include: - The use of sexualized language or imagery, and sexual attention or advances of any kind - Trolling, insulting or derogatory comments, and personal or political attacks - Public or private harassment - Publishing others' private information, such as a physical or email address, without their explicit permission - Other conduct which could reasonably be considered inappropriate in a professional setting ## Enforcement Responsibilities Community leaders are responsible for clarifying and enforcing our standards of acceptable behavior and will take appropriate and fair corrective action in response to any behavior that they deem inappropriate, threatening, offensive, or harmful. Community leaders have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, and will communicate reasons for moderation decisions when appropriate. ## Scope This Code of Conduct applies within all community spaces, and also applies when an individual is officially representing the community in public spaces. Examples of representing our community include using an official e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event. ## Enforcement Instances of abusive, harassing, or otherwise unacceptable behavior may be reported to the community leaders responsible for enforcement at support@project-graph.top. All complaints will be reviewed and investigated promptly and fairly. All community leaders are obligated to respect the privacy and security of the reporter of any incident. ## Enforcement Guidelines Community leaders will follow these Community Impact Guidelines in determining the consequences for any action they deem in violation of this Code of Conduct: ### 1. Correction **Community Impact**: Use of inappropriate language or other behavior deemed unprofessional or unwelcome in the community. **Consequence**: A private, written warning from community leaders, providing clarity around the nature of the violation and an explanation of why the behavior was inappropriate. A public apology may be requested. ### 2. Warning **Community Impact**: A violation through a single incident or series of actions. **Consequence**: A warning with consequences for continued behavior. No interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, for a specified period of time. This includes avoiding interactions in community spaces as well as external channels like social media. Violating these terms may lead to a temporary or permanent ban. ### 3. Temporary Ban **Community Impact**: A serious violation of community standards, including sustained inappropriate behavior. **Consequence**: A temporary ban from any sort of interaction or public communication with the community for a specified period of time. No public or private interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, is allowed during this period. Violating these terms may lead to a permanent ban. ### 4. Permanent Ban **Community Impact**: Demonstrating a pattern of violation of community standards, including sustained inappropriate behavior, harassment of an individual, or aggression toward or disparagement of classes of individuals. **Consequence**: A permanent ban from any sort of public interaction within the community. ## Attribution This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 2.0, available at https://www.contributor-covenant.org/version/2/0/code_of_conduct.html. Community Impact Guidelines were inspired by [Mozilla's code of conduct enforcement ladder](https://github.com/mozilla/diversity). [homepage]: https://www.contributor-covenant.org For answers to common questions about this code of conduct, see the FAQ at https://www.contributor-covenant.org/faq. Translations are available at https://www.contributor-covenant.org/translations. ================================================ FILE: CONTRIBUTING.md ================================================ Please refer to [Contributing](https://project-graph.top/docs/contribute) ================================================ FILE: TODO.md ================================================ ================================================ FILE: app/.browserslistrc ================================================ Chrome>=111, Edge>=111, Android>=111, Safari>=16.4 ================================================ FILE: app/LICENSE ================================================ GNU GENERAL PUBLIC LICENSE Version 3, 29 June 2007 Copyright (C) 2007 Free Software Foundation, Inc. Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. Preamble The GNU General Public License is a free, copyleft license for software and other kinds of works. The licenses for most software and other practical works are designed to take away your freedom to share and change the works. By contrast, the GNU General Public License is intended to guarantee your freedom to share and change all versions of a program--to make sure it remains free software for all its users. We, the Free Software Foundation, use the GNU General Public License for most of our software; it applies also to any other work released this way by its authors. You can apply it to your programs, too. When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for them if you wish), that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs, and that you know you can do these things. To protect your rights, we need to prevent others from denying you these rights or asking you to surrender the rights. Therefore, you have certain responsibilities if you distribute copies of the software, or if you modify it: responsibilities to respect the freedom of others. For example, if you distribute copies of such a program, whether gratis or for a fee, you must pass on to the recipients the same freedoms that you received. You must make sure that they, too, receive or can get the source code. And you must show them these terms so they know their rights. Developers that use the GNU GPL protect your rights with two steps: (1) assert copyright on the software, and (2) offer you this License giving you legal permission to copy, distribute and/or modify it. For the developers' and authors' protection, the GPL clearly explains that there is no warranty for this free software. For both users' and authors' sake, the GPL requires that modified versions be marked as changed, so that their problems will not be attributed erroneously to authors of previous versions. Some devices are designed to deny users access to install or run modified versions of the software inside them, although the manufacturer can do so. This is fundamentally incompatible with the aim of protecting users' freedom to change the software. The systematic pattern of such abuse occurs in the area of products for individuals to use, which is precisely where it is most unacceptable. Therefore, we have designed this version of the GPL to prohibit the practice for those products. If such problems arise substantially in other domains, we stand ready to extend this provision to those domains in future versions of the GPL, as needed to protect the freedom of users. Finally, every program is threatened constantly by software patents. States should not allow patents to restrict development and use of software on general-purpose computers, but in those that do, we wish to avoid the special danger that patents applied to a free program could make it effectively proprietary. To prevent this, the GPL assures that patents cannot be used to render the program non-free. The precise terms and conditions for copying, distribution and modification follow. TERMS AND CONDITIONS 0. Definitions. "This License" refers to version 3 of the GNU General Public License. "Copyright" also means copyright-like laws that apply to other kinds of works, such as semiconductor masks. "The Program" refers to any copyrightable work licensed under this License. Each licensee is addressed as "you". "Licensees" and "recipients" may be individuals or organizations. To "modify" a work means to copy from or adapt all or part of the work in a fashion requiring copyright permission, other than the making of an exact copy. The resulting work is called a "modified version" of the earlier work or a work "based on" the earlier work. A "covered work" means either the unmodified Program or a work based on the Program. To "propagate" a work means to do anything with it that, without permission, would make you directly or secondarily liable for infringement under applicable copyright law, except executing it on a computer or modifying a private copy. Propagation includes copying, distribution (with or without modification), making available to the public, and in some countries other activities as well. To "convey" a work means any kind of propagation that enables other parties to make or receive copies. Mere interaction with a user through a computer network, with no transfer of a copy, is not conveying. An interactive user interface displays "Appropriate Legal Notices" to the extent that it includes a convenient and prominently visible feature that (1) displays an appropriate copyright notice, and (2) tells the user that there is no warranty for the work (except to the extent that warranties are provided), that licensees may convey the work under this License, and how to view a copy of this License. If the interface presents a list of user commands or options, such as a menu, a prominent item in the list meets this criterion. 1. Source Code. The "source code" for a work means the preferred form of the work for making modifications to it. "Object code" means any non-source form of a work. A "Standard Interface" means an interface that either is an official standard defined by a recognized standards body, or, in the case of interfaces specified for a particular programming language, one that is widely used among developers working in that language. The "System Libraries" of an executable work include anything, other than the work as a whole, that (a) is included in the normal form of packaging a Major Component, but which is not part of that Major Component, and (b) serves only to enable use of the work with that Major Component, or to implement a Standard Interface for which an implementation is available to the public in source code form. A "Major Component", in this context, means a major essential component (kernel, window system, and so on) of the specific operating system (if any) on which the executable work runs, or a compiler used to produce the work, or an object code interpreter used to run it. The "Corresponding Source" for a work in object code form means all the source code needed to generate, install, and (for an executable work) run the object code and to modify the work, including scripts to control those activities. However, it does not include the work's System Libraries, or general-purpose tools or generally available free programs which are used unmodified in performing those activities but which are not part of the work. For example, Corresponding Source includes interface definition files associated with source files for the work, and the source code for shared libraries and dynamically linked subprograms that the work is specifically designed to require, such as by intimate data communication or control flow between those subprograms and other parts of the work. The Corresponding Source need not include anything that users can regenerate automatically from other parts of the Corresponding Source. The Corresponding Source for a work in source code form is that same work. 2. Basic Permissions. All rights granted under this License are granted for the term of copyright on the Program, and are irrevocable provided the stated conditions are met. This License explicitly affirms your unlimited permission to run the unmodified Program. The output from running a covered work is covered by this License only if the output, given its content, constitutes a covered work. This License acknowledges your rights of fair use or other equivalent, as provided by copyright law. You may make, run and propagate covered works that you do not convey, without conditions so long as your license otherwise remains in force. You may convey covered works to others for the sole purpose of having them make modifications exclusively for you, or provide you with facilities for running those works, provided that you comply with the terms of this License in conveying all material for which you do not control copyright. Those thus making or running the covered works for you must do so exclusively on your behalf, under your direction and control, on terms that prohibit them from making any copies of your copyrighted material outside their relationship with you. Conveying under any other circumstances is permitted solely under the conditions stated below. Sublicensing is not allowed; section 10 makes it unnecessary. 3. Protecting Users' Legal Rights From Anti-Circumvention Law. No covered work shall be deemed part of an effective technological measure under any applicable law fulfilling obligations under article 11 of the WIPO copyright treaty adopted on 20 December 1996, or similar laws prohibiting or restricting circumvention of such measures. When you convey a covered work, you waive any legal power to forbid circumvention of technological measures to the extent such circumvention is effected by exercising rights under this License with respect to the covered work, and you disclaim any intention to limit operation or modification of the work as a means of enforcing, against the work's users, your or third parties' legal rights to forbid circumvention of technological measures. 4. Conveying Verbatim Copies. You may convey verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice; keep intact all notices stating that this License and any non-permissive terms added in accord with section 7 apply to the code; keep intact all notices of the absence of any warranty; and give all recipients a copy of this License along with the Program. You may charge any price or no price for each copy that you convey, and you may offer support or warranty protection for a fee. 5. Conveying Modified Source Versions. You may convey a work based on the Program, or the modifications to produce it from the Program, in the form of source code under the terms of section 4, provided that you also meet all of these conditions: a) The work must carry prominent notices stating that you modified it, and giving a relevant date. b) The work must carry prominent notices stating that it is released under this License and any conditions added under section 7. This requirement modifies the requirement in section 4 to "keep intact all notices". c) You must license the entire work, as a whole, under this License to anyone who comes into possession of a copy. This License will therefore apply, along with any applicable section 7 additional terms, to the whole of the work, and all its parts, regardless of how they are packaged. This License gives no permission to license the work in any other way, but it does not invalidate such permission if you have separately received it. d) If the work has interactive user interfaces, each must display Appropriate Legal Notices; however, if the Program has interactive interfaces that do not display Appropriate Legal Notices, your work need not make them do so. A compilation of a covered work with other separate and independent works, which are not by their nature extensions of the covered work, and which are not combined with it such as to form a larger program, in or on a volume of a storage or distribution medium, is called an "aggregate" if the compilation and its resulting copyright are not used to limit the access or legal rights of the compilation's users beyond what the individual works permit. Inclusion of a covered work in an aggregate does not cause this License to apply to the other parts of the aggregate. 6. Conveying Non-Source Forms. You may convey a covered work in object code form under the terms of sections 4 and 5, provided that you also convey the machine-readable Corresponding Source under the terms of this License, in one of these ways: a) Convey the object code in, or embodied in, a physical product (including a physical distribution medium), accompanied by the Corresponding Source fixed on a durable physical medium customarily used for software interchange. b) Convey the object code in, or embodied in, a physical product (including a physical distribution medium), accompanied by a written offer, valid for at least three years and valid for as long as you offer spare parts or customer support for that product model, to give anyone who possesses the object code either (1) a copy of the Corresponding Source for all the software in the product that is covered by this License, on a durable physical medium customarily used for software interchange, for a price no more than your reasonable cost of physically performing this conveying of source, or (2) access to copy the Corresponding Source from a network server at no charge. c) Convey individual copies of the object code with a copy of the written offer to provide the Corresponding Source. This alternative is allowed only occasionally and noncommercially, and only if you received the object code with such an offer, in accord with subsection 6b. d) Convey the object code by offering access from a designated place (gratis or for a charge), and offer equivalent access to the Corresponding Source in the same way through the same place at no further charge. You need not require recipients to copy the Corresponding Source along with the object code. If the place to copy the object code is a network server, the Corresponding Source may be on a different server (operated by you or a third party) that supports equivalent copying facilities, provided you maintain clear directions next to the object code saying where to find the Corresponding Source. Regardless of what server hosts the Corresponding Source, you remain obligated to ensure that it is available for as long as needed to satisfy these requirements. e) Convey the object code using peer-to-peer transmission, provided you inform other peers where the object code and Corresponding Source of the work are being offered to the general public at no charge under subsection 6d. A separable portion of the object code, whose source code is excluded from the Corresponding Source as a System Library, need not be included in conveying the object code work. A "User Product" is either (1) a "consumer product", which means any tangible personal property which is normally used for personal, family, or household purposes, or (2) anything designed or sold for incorporation into a dwelling. In determining whether a product is a consumer product, doubtful cases shall be resolved in favor of coverage. For a particular product received by a particular user, "normally used" refers to a typical or common use of that class of product, regardless of the status of the particular user or of the way in which the particular user actually uses, or expects or is expected to use, the product. A product is a consumer product regardless of whether the product has substantial commercial, industrial or non-consumer uses, unless such uses represent the only significant mode of use of the product. "Installation Information" for a User Product means any methods, procedures, authorization keys, or other information required to install and execute modified versions of a covered work in that User Product from a modified version of its Corresponding Source. The information must suffice to ensure that the continued functioning of the modified object code is in no case prevented or interfered with solely because modification has been made. If you convey an object code work under this section in, or with, or specifically for use in, a User Product, and the conveying occurs as part of a transaction in which the right of possession and use of the User Product is transferred to the recipient in perpetuity or for a fixed term (regardless of how the transaction is characterized), the Corresponding Source conveyed under this section must be accompanied by the Installation Information. But this requirement does not apply if neither you nor any third party retains the ability to install modified object code on the User Product (for example, the work has been installed in ROM). The requirement to provide Installation Information does not include a requirement to continue to provide support service, warranty, or updates for a work that has been modified or installed by the recipient, or for the User Product in which it has been modified or installed. Access to a network may be denied when the modification itself materially and adversely affects the operation of the network or violates the rules and protocols for communication across the network. Corresponding Source conveyed, and Installation Information provided, in accord with this section must be in a format that is publicly documented (and with an implementation available to the public in source code form), and must require no special password or key for unpacking, reading or copying. 7. Additional Terms. "Additional permissions" are terms that supplement the terms of this License by making exceptions from one or more of its conditions. Additional permissions that are applicable to the entire Program shall be treated as though they were included in this License, to the extent that they are valid under applicable law. If additional permissions apply only to part of the Program, that part may be used separately under those permissions, but the entire Program remains governed by this License without regard to the additional permissions. When you convey a copy of a covered work, you may at your option remove any additional permissions from that copy, or from any part of it. (Additional permissions may be written to require their own removal in certain cases when you modify the work.) You may place additional permissions on material, added by you to a covered work, for which you have or can give appropriate copyright permission. Notwithstanding any other provision of this License, for material you add to a covered work, you may (if authorized by the copyright holders of that material) supplement the terms of this License with terms: a) Disclaiming warranty or limiting liability differently from the terms of sections 15 and 16 of this License; or b) Requiring preservation of specified reasonable legal notices or author attributions in that material or in the Appropriate Legal Notices displayed by works containing it; or c) Prohibiting misrepresentation of the origin of that material, or requiring that modified versions of such material be marked in reasonable ways as different from the original version; or d) Limiting the use for publicity purposes of names of licensors or authors of the material; or e) Declining to grant rights under trademark law for use of some trade names, trademarks, or service marks; or f) Requiring indemnification of licensors and authors of that material by anyone who conveys the material (or modified versions of it) with contractual assumptions of liability to the recipient, for any liability that these contractual assumptions directly impose on those licensors and authors. All other non-permissive additional terms are considered "further restrictions" within the meaning of section 10. If the Program as you received it, or any part of it, contains a notice stating that it is governed by this License along with a term that is a further restriction, you may remove that term. If a license document contains a further restriction but permits relicensing or conveying under this License, you may add to a covered work material governed by the terms of that license document, provided that the further restriction does not survive such relicensing or conveying. If you add terms to a covered work in accord with this section, you must place, in the relevant source files, a statement of the additional terms that apply to those files, or a notice indicating where to find the applicable terms. Additional terms, permissive or non-permissive, may be stated in the form of a separately written license, or stated as exceptions; the above requirements apply either way. 8. Termination. You may not propagate or modify a covered work except as expressly provided under this License. Any attempt otherwise to propagate or modify it is void, and will automatically terminate your rights under this License (including any patent licenses granted under the third paragraph of section 11). However, if you cease all violation of this License, then your license from a particular copyright holder is reinstated (a) provisionally, unless and until the copyright holder explicitly and finally terminates your license, and (b) permanently, if the copyright holder fails to notify you of the violation by some reasonable means prior to 60 days after the cessation. Moreover, your license from a particular copyright holder is reinstated permanently if the copyright holder notifies you of the violation by some reasonable means, this is the first time you have received notice of violation of this License (for any work) from that copyright holder, and you cure the violation prior to 30 days after your receipt of the notice. Termination of your rights under this section does not terminate the licenses of parties who have received copies or rights from you under this License. If your rights have been terminated and not permanently reinstated, you do not qualify to receive new licenses for the same material under section 10. 9. Acceptance Not Required for Having Copies. You are not required to accept this License in order to receive or run a copy of the Program. Ancillary propagation of a covered work occurring solely as a consequence of using peer-to-peer transmission to receive a copy likewise does not require acceptance. However, nothing other than this License grants you permission to propagate or modify any covered work. These actions infringe copyright if you do not accept this License. Therefore, by modifying or propagating a covered work, you indicate your acceptance of this License to do so. 10. Automatic Licensing of Downstream Recipients. Each time you convey a covered work, the recipient automatically receives a license from the original licensors, to run, modify and propagate that work, subject to this License. You are not responsible for enforcing compliance by third parties with this License. An "entity transaction" is a transaction transferring control of an organization, or substantially all assets of one, or subdividing an organization, or merging organizations. If propagation of a covered work results from an entity transaction, each party to that transaction who receives a copy of the work also receives whatever licenses to the work the party's predecessor in interest had or could give under the previous paragraph, plus a right to possession of the Corresponding Source of the work from the predecessor in interest, if the predecessor has it or can get it with reasonable efforts. You may not impose any further restrictions on the exercise of the rights granted or affirmed under this License. For example, you may not impose a license fee, royalty, or other charge for exercise of rights granted under this License, and you may not initiate litigation (including a cross-claim or counterclaim in a lawsuit) alleging that any patent claim is infringed by making, using, selling, offering for sale, or importing the Program or any portion of it. 11. Patents. A "contributor" is a copyright holder who authorizes use under this License of the Program or a work on which the Program is based. The work thus licensed is called the contributor's "contributor version". A contributor's "essential patent claims" are all patent claims owned or controlled by the contributor, whether already acquired or hereafter acquired, that would be infringed by some manner, permitted by this License, of making, using, or selling its contributor version, but do not include claims that would be infringed only as a consequence of further modification of the contributor version. For purposes of this definition, "control" includes the right to grant patent sublicenses in a manner consistent with the requirements of this License. Each contributor grants you a non-exclusive, worldwide, royalty-free patent license under the contributor's essential patent claims, to make, use, sell, offer for sale, import and otherwise run, modify and propagate the contents of its contributor version. In the following three paragraphs, a "patent license" is any express agreement or commitment, however denominated, not to enforce a patent (such as an express permission to practice a patent or covenant not to sue for patent infringement). To "grant" such a patent license to a party means to make such an agreement or commitment not to enforce a patent against the party. If you convey a covered work, knowingly relying on a patent license, and the Corresponding Source of the work is not available for anyone to copy, free of charge and under the terms of this License, through a publicly available network server or other readily accessible means, then you must either (1) cause the Corresponding Source to be so available, or (2) arrange to deprive yourself of the benefit of the patent license for this particular work, or (3) arrange, in a manner consistent with the requirements of this License, to extend the patent license to downstream recipients. "Knowingly relying" means you have actual knowledge that, but for the patent license, your conveying the covered work in a country, or your recipient's use of the covered work in a country, would infringe one or more identifiable patents in that country that you have reason to believe are valid. If, pursuant to or in connection with a single transaction or arrangement, you convey, or propagate by procuring conveyance of, a covered work, and grant a patent license to some of the parties receiving the covered work authorizing them to use, propagate, modify or convey a specific copy of the covered work, then the patent license you grant is automatically extended to all recipients of the covered work and works based on it. A patent license is "discriminatory" if it does not include within the scope of its coverage, prohibits the exercise of, or is conditioned on the non-exercise of one or more of the rights that are specifically granted under this License. You may not convey a covered work if you are a party to an arrangement with a third party that is in the business of distributing software, under which you make payment to the third party based on the extent of your activity of conveying the work, and under which the third party grants, to any of the parties who would receive the covered work from you, a discriminatory patent license (a) in connection with copies of the covered work conveyed by you (or copies made from those copies), or (b) primarily for and in connection with specific products or compilations that contain the covered work, unless you entered into that arrangement, or that patent license was granted, prior to 28 March 2007. Nothing in this License shall be construed as excluding or limiting any implied license or other defenses to infringement that may otherwise be available to you under applicable patent law. 12. No Surrender of Others' Freedom. If conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot convey a covered work so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not convey it at all. For example, if you agree to terms that obligate you to collect a royalty for further conveying from those to whom you convey the Program, the only way you could satisfy both those terms and this License would be to refrain entirely from conveying the Program. 13. Use with the GNU Affero General Public License. Notwithstanding any other provision of this License, you have permission to link or combine any covered work with a work licensed under version 3 of the GNU Affero General Public License into a single combined work, and to convey the resulting work. The terms of this License will continue to apply to the part which is the covered work, but the special requirements of the GNU Affero General Public License, section 13, concerning interaction through a network will apply to the combination as such. 14. Revised Versions of this License. The Free Software Foundation may publish revised and/or new versions of the GNU General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. Each version is given a distinguishing version number. If the Program specifies that a certain numbered version of the GNU General Public License "or any later version" applies to it, you have the option of following the terms and conditions either of that numbered version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of the GNU General Public License, you may choose any version ever published by the Free Software Foundation. If the Program specifies that a proxy can decide which future versions of the GNU General Public License can be used, that proxy's public statement of acceptance of a version permanently authorizes you to choose that version for the Program. Later license versions may give you additional or different permissions. However, no additional obligations are imposed on any author or copyright holder as a result of your choosing to follow a later version. 15. Disclaimer of Warranty. THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 16. Limitation of Liability. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. 17. Interpretation of Sections 15 and 16. If the disclaimer of warranty and limitation of liability provided above cannot be given local legal effect according to their terms, reviewing courts shall apply local law that most closely approximates an absolute waiver of all civil liability in connection with the Program, unless a warranty or assumption of liability accompanies a copy of the Program in return for a fee. END OF TERMS AND CONDITIONS How to Apply These Terms to Your New Programs If you develop a new program, and you want it to be of the greatest possible use to the public, the best way to achieve this is to make it free software which everyone can redistribute and change under these terms. To do so, attach the following notices to the program. It is safest to attach them to the start of each source file to most effectively state the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found. Copyright (C) This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see . Also add information on how to contact you by electronic and paper mail. If the program does terminal interaction, make it output a short notice like this when it starts in an interactive mode: Copyright (C) This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. This is free software, and you are welcome to redistribute it under certain conditions; type `show c' for details. The hypothetical commands `show w' and `show c' should show the appropriate parts of the General Public License. Of course, your program's commands might be different; for a GUI interface, you would use an "about box". You should also get your employer (if you work as a programmer) or school, if any, to sign a "copyright disclaimer" for the program, if necessary. For more information on this, and how to apply and follow the GNU GPL, see . The GNU General Public License does not permit incorporating your program into proprietary programs. If your program is a subroutine library, you may consider it more useful to permit linking proprietary applications with the library. If this is what you want to do, use the GNU Lesser General Public License instead of this License. But first, please read . ================================================ FILE: app/README.md ================================================
banner

Project Graph

![License](https://img.shields.io/badge/License-MIT%20and%20GPL%203.0-green.svg) [![website](https://img.shields.io/badge/website-project--graph.top-purple)](https://project-graph.top) --- Project Graph 是一款专注于快速绘制节点图的桌面工具,旨在帮助用户高效地创建项目拓扑图和进行头脑风暴。用户可以通过简单的拖拽操作来创建和连接节点,从而轻松构建复杂的图结构。该工具还具备层级清晰的结构,能够直观地呈现项目关系或数据关系。 ## 功能亮点 - 🚀 基于 [Pixi.js](https://pixijs.com/) 构建,性能卓越,支持大规模节点图的绘制 - 🎨 快速简单的操作方法 - 💻 跨平台支持,适用于 Windows、macOS 和 Linux - 📁 特有的文件格式 `.prg` (Media Type: `application/vnd.project-graph`),便于存储和分享 ## 社区 加入社群: https://project-graph.top/docs/app/community 贡献代码: https://project-graph.top/docs/contribute ## 鸣谢 ![contributors](https://contrib.rocks/image?repo=LiRenTech/project-graph) 所有捐赠的用户([见此处](https://github.com/graphif/project-graph/blob/master/app/src/sub/SettingsWindow/credits.tsx#L15)) ### 服务器提供商 [慕乐云](https://muleyun.com/aff/HLONILNH) [YXVM](https://yxvm.com/) [ZMTO](https://console.zmto.com/?affid=1574) ![ZMTO Logo](https://console.zmto.com/templates/2019/dist/images/logo_white.svg) [DartNode](https://dartnode.com) [![Powered by DartNode](https://dartnode.com/branding/DN-Open-Source-sm.png)](https://dartnode.com "Powered by DartNode - Free VPS for Open Source") ================================================ FILE: app/components.json ================================================ { "$schema": "https://ui.shadcn.com/schema.json", "style": "new-york", "rsc": false, "tsx": true, "tailwind": { "config": "", "css": "src/css/index.css", "baseColor": "neutral", "cssVariables": true, "prefix": "" }, "aliases": { "components": "@/components", "utils": "@/utils/cn", "ui": "@/components/ui", "lib": "@/utils", "hooks": "@/hooks" }, "iconLibrary": "lucide" } ================================================ FILE: app/index.html ================================================ Project Graph
================================================ FILE: app/package.json ================================================ { "name": "@graphif/project-graph", "private": true, "version": "0.0.0", "type": "module", "license": "GPL-3.0-only", "scripts": { "dev": "vite", "build": "vite build", "type-check": "tsc --noEmit", "preview": "vite preview", "tauri": "tauri", "tauri:dev": "tauri dev", "tauri:build": "node ./scripts/tauri_build.js", "sync-locales": "tsx ./scripts/sync-locales.ts" }, "dependencies": { "@ariakit/react": "^0.4.18", "@emoji-mart/data": "1.2.1", "@graphif/data-structures": "workspace:*", "@graphif/serializer": "workspace:*", "@graphif/shapes": "workspace:*", "@headlessui/react": "^2.2.4", "@modyfi/vite-plugin-yaml": "^1.1.1", "@msgpack/msgpack": "^3.1.2", "@octokit/rest": "^22.0.0", "@platejs/ai": "^49.2.14", "@platejs/basic-nodes": "^49.0.0", "@platejs/basic-styles": "^49.0.0", "@platejs/callout": "^49.0.0", "@platejs/caption": "^49.0.0", "@platejs/code-block": "^49.0.0", "@platejs/combobox": "^49.0.0", "@platejs/comment": "^49.0.0", "@platejs/core": "^49.2.12", "@platejs/date": "^49.0.2", "@platejs/dnd": "^49.2.10", "@platejs/emoji": "^49.0.0", "@platejs/floating": "^49.0.0", "@platejs/indent": "^49.0.0", "@platejs/layout": "^49.2.1", "@platejs/link": "^49.1.1", "@platejs/list": "^49.2.0", "@platejs/markdown": "^49.2.14", "@platejs/math": "^49.0.0", "@platejs/media": "^49.0.0", "@platejs/mention": "^49.0.0", "@platejs/resizable": "^49.0.0", "@platejs/selection": "^49.2.4", "@platejs/slate": "^49.2.4", "@platejs/suggestion": "^49.0.0", "@platejs/table": "^49.1.13", "@platejs/toc": "^49.0.0", "@platejs/toggle": "^49.0.0", "@platejs/utils": "^49.2.12", "@radix-ui/react-alert-dialog": "^1.1.15", "@radix-ui/react-avatar": "^1.1.10", "@radix-ui/react-checkbox": "^1.3.3", "@radix-ui/react-collapsible": "^1.1.11", "@radix-ui/react-context-menu": "^2.2.15", "@radix-ui/react-dialog": "^1.1.14", "@radix-ui/react-dropdown-menu": "^2.1.16", "@radix-ui/react-menu": "^2.1.15", "@radix-ui/react-menubar": "^1.1.15", "@radix-ui/react-popover": "^1.1.15", "@radix-ui/react-popper": "^1.2.7", "@radix-ui/react-primitive": "^2.1.3", "@radix-ui/react-progress": "^1.1.7", "@radix-ui/react-roving-focus": "^1.1.11", "@radix-ui/react-select": "^2.2.5", "@radix-ui/react-separator": "^1.1.7", "@radix-ui/react-slider": "^1.3.5", "@radix-ui/react-slot": "^1.2.3", "@radix-ui/react-switch": "^1.2.5", "@radix-ui/react-tabs": "^1.1.12", "@radix-ui/react-toggle-group": "^1.1.11", "@radix-ui/react-toolbar": "^1.1.11", "@radix-ui/react-tooltip": "^1.2.7", "@react-scan/vite-plugin-react-scan": "^0.1.8", "@swc-jotai/react-refresh": "^0.3.0", "@tailwindcss/vite": "^4.1.11", "@tauri-apps/api": "^2.6.0", "@tauri-apps/cli": "^2.6.2", "@tauri-apps/plugin-cli": "~2.4.0", "@tauri-apps/plugin-clipboard-manager": "^2.3.0", "@tauri-apps/plugin-dialog": "^2.3.0", "@tauri-apps/plugin-fs": "~2.4.0", "@tauri-apps/plugin-global-shortcut": "^2.3.0", "@tauri-apps/plugin-http": "^2.5.0", "@tauri-apps/plugin-os": "^2.3.0", "@tauri-apps/plugin-process": "~2.3.0", "@tauri-apps/plugin-shell": "2.3.0", "@tauri-apps/plugin-store": "^2.3.0", "@tauri-apps/plugin-updater": "~2.9.0", "@tauri-apps/plugin-window-state": "^2.3.0", "@types/lodash": "^4.17.20", "@types/markdown-it": "^14.1.2", "@types/md5": "^2.3.5", "@types/react": "^19.1.8", "@types/react-dom": "^19.1.6", "@types/uuid": "^10.0.0", "@udecode/cn": "^49.0.15", "@udecode/react-hotkeys": "^37.0.0", "@udecode/react-utils": "^49.0.15", "@udecode/utils": "^47.2.7", "@vitejs/plugin-react-oxc": "^0.2.2", "@zip.js/zip.js": "^2.7.63", "bcrypt": "^6.0.0", "class-variance-authority": "^0.7.1", "clsx": "^2.1.1", "cmdk": "^1.1.1", "date-fns": "^4.1.0", "decimal.js": "^10.5.0", "driver.js": "^1.3.6", "events": "^3.3.0", "fuse.js": "^7.1.0", "html2canvas-pro": "^1.5.11", "i18next": "^25.3.1", "jotai": "catalog:", "jsdom": "^26.1.0", "jsondiffpatch": "^0.7.3", "lodash": "^4.17.21", "lowlight": "^3.3.0", "lucide-react": "^0.525.0", "md5": "^2.3.0", "mime": "^4.0.7", "motion": "^12.23.22", "next-themes": "^0.4.6", "openai": "^5.8.2", "pdf-lib": "^1.17.1", "platejs": "^49.2.12", "react": "catalog:", "react-day-picker": "^9.9.0", "react-dom": "catalog:", "react-i18next": "^15.6.0", "react-lite-youtube-embed": "^2.5.3", "react-player": "3.3.1", "react-scan": "^0.4.3", "react-textarea-autosize": "^8.5.9", "reflect-metadata": "^0.2.2", "rehype-katex": "^7.0.1", "rehype-react": "^8.0.0", "remark": "^15.0.1", "remark-breaks": "^4.0.0", "remark-gfm": "^4.0.1", "remark-math": "^6.0.0", "remark-parse": "^11.0.0", "remark-rehype": "^11.1.2", "sonner": "^2.0.7", "tailwind-merge": "^3.3.1", "tailwind-scrollbar-hide": "^4.0.0", "tailwindcss": "^4.1.11", "tauri-plugin-system-info-api": "^2.0.10", "tw-animate-css": "^1.3.6", "typescript": "catalog:", "unified": "^11.0.5", "unplugin-operator-overload": "^1.0.0", "unplugin-original-class-name": "^1.0.0", "use-file-picker": "2.1.2", "uuid": "^11.1.0", "valibot": "^1.1.0", "vconsole": "^3.15.1", "vditor": "^3.11.1", "vite": "^7.0.2", "vite-plugin-svgr": "^4.3.0", "vitest": "3.2.4", "vscode-uri": "^3.1.0", "yaml": "^2.8.0", "zod": "^3.25.74" }, "devDependencies": { "opencc-js": "^1.0.5", "tsx": "^4.21.0" } } ================================================ FILE: app/scripts/sync-locales.ts ================================================ import * as OpenCC from "opencc-js"; import fs from "node:fs"; import path from "node:path"; import { fileURLToPath } from "node:url"; const __filename = fileURLToPath(import.meta.url); const __dirname = path.dirname(__filename); const zhCNPath = path.resolve(__dirname, "../src/locales/zh_CN.yml"); const zhTWPath = path.resolve(__dirname, "../src/locales/zh_TW.yml"); const converter = OpenCC.Converter({ from: "cn", to: "tw" }); function convert() { try { if (!fs.existsSync(zhCNPath)) { console.error(`Source file not found: ${zhCNPath}`); return; } const content = fs.readFileSync(zhCNPath, "utf-8"); const converted = converter(content); fs.writeFileSync(zhTWPath, converted, "utf-8"); console.log(`Successfully updated zh_TW.yml from zh_CN.yml`); } catch (error) { console.error(`Error during conversion:`, error); } } convert(); ================================================ FILE: app/scripts/tauri_build.js ================================================ /* eslint-disable */ import { spawn } from "child_process"; // 从环境变量获取参数并分割成数组 const tauriBuildArgs = process.env.TAURI_BUILD_ARGS ? process.env.TAURI_BUILD_ARGS.split(" ") : []; // 构造完整命令参数 const args = ["tauri", "build", ...tauriBuildArgs]; const pnpmBin = process.env.npm_execpath; let child; // 使用 spawn 执行命令 if (pnpmBin.endsWith("js")) { child = spawn("node", [pnpmBin, ...args], { stdio: "inherit", }); } else { child = spawn(pnpmBin, args, { stdio: "inherit", }); } // 处理退出 child.on("exit", (code) => { process.exit(code || 0); }); ================================================ FILE: app/splash.html ================================================ Project Graph Startup
loading...
================================================ FILE: app/src/App.tsx ================================================ import MyContextMenuContent from "@/components/context-menu-content"; import RenderSubWindows from "@/components/render-sub-windows"; import { Button } from "@/components/ui/button"; import { ContextMenu, ContextMenuTrigger } from "@/components/ui/context-menu"; import { Dialog } from "@/components/ui/dialog"; import Welcome from "@/components/welcome-page"; import { Project, ProjectState } from "@/core/Project"; import { GlobalMenu } from "@/core/service/GlobalMenu"; import { Settings } from "@/core/service/Settings"; import { Telemetry } from "@/core/service/Telemetry"; import { Themes } from "@/core/service/Themes"; import { globalShortcutManager } from "@/core/service/controlService/shortcutKeysEngine/GlobalShortcutManager"; import { activeProjectAtom, isClassroomModeAtom, isClickThroughEnabledAtom, isWindowAlwaysOnTopAtom, isWindowMaxsizedAtom, projectsAtom, } from "@/state"; import { getVersion } from "@tauri-apps/api/app"; import { getAllWindows, getCurrentWindow } from "@tauri-apps/api/window"; import { arch, platform, version } from "@tauri-apps/plugin-os"; import { restoreStateCurrent, saveWindowState, StateFlags } from "@tauri-apps/plugin-window-state"; import { useAtom } from "jotai"; import { ChevronsLeftRight, Copy, Minus, Pin, PinOff, Square, X } from "lucide-react"; import { useCallback, useEffect, useRef, useState } from "react"; import { toast } from "sonner"; import { cpuInfo } from "tauri-plugin-system-info-api"; import { DragFileIntoStageEngine } from "./core/service/dataManageService/dragFileIntoStageEngine/dragFileIntoStageEngine"; import { cn } from "./utils/cn"; import { isMac, isWindows } from "./utils/platform"; import { KeyBindsUI } from "./core/service/controlService/shortcutKeysEngine/KeyBindsUI"; import { checkAndFixShortcutStorage } from "./core/service/controlService/shortcutKeysEngine/ShortcutKeyFixer"; import { ProjectTabs } from "./ProjectTabs"; import { DropWindowCover } from "./DropWindowCover"; import ToolbarContent from "./components/toolbar-content"; import RightToolbar from "./components/right-toolbar"; import ThemeModeSwitch from "@/components/theme-mode-switch"; export default function App() { // eslint-disable-next-line @typescript-eslint/no-unused-vars const [_, _setMaximized] = useAtom(isWindowMaxsizedAtom); const [projects, setProjects] = useAtom(projectsAtom); const [activeProject, setActiveProject] = useAtom(activeProjectAtom); const canvasWrapperRef = useRef(null); // const [isWide, setIsWide] = useState(false); const [telemetryEventSent, setTelemetryEventSent] = useState(false); const [dropMouseLocation, setDropMouseLocation] = useState<"top" | "middle" | "bottom" | "notInWindowZone">( "notInWindowZone", ); const [ignoreMouseEvents, setIgnoreMouseEvents] = useState(false); const [isClassroomMode, setIsClassroomMode] = useAtom(isClassroomModeAtom); const [showQuickSettingsToolbar, setShowQuickSettingsToolbar] = useState(Settings.showQuickSettingsToolbar); const [windowBackgroundAlpha, setWindowBackgroundAlpha] = useState(Settings.windowBackgroundAlpha); const contextMenuTriggerRef = useRef(null); // const { t } = useTranslation("app"); useEffect(() => { // 先修复老用户的快捷键缓存问题(F11快捷键) (async () => { await checkAndFixShortcutStorage(); })(); // 注册UI级别快捷键 KeyBindsUI.registerAllUIKeyBinds(); KeyBindsUI.uiStartListen(); // 修复鼠标拖出窗口后触发上下文菜单的问题 window.addEventListener("contextmenu", (event) => { if ( event.clientX < 0 || event.clientX > window.innerWidth || event.clientY < 0 || event.clientY > window.innerHeight ) event.preventDefault(); }); // 全局错误处理 window.addEventListener("error", (event) => { Telemetry.event("未知错误", String(event.error)); }); // 监听主题样式切换 Settings.watch("theme", (value) => { Themes.applyThemeById(value); }); // 监听主题模式切换 Settings.watch("themeMode", (value) => { const targetTheme = value === "light" ? Settings.lightTheme : Settings.darkTheme; if (Settings.theme !== targetTheme) { Settings.theme = targetTheme; } }); Settings.watch("lightTheme", (value) => { if (Settings.themeMode === "light" && Settings.theme !== value) { Settings.theme = value; } }); Settings.watch("darkTheme", (value) => { if (Settings.themeMode === "dark" && Settings.theme !== value) { Settings.theme = value; } }); // 监听快捷设置工具栏显示设置 const unwatchShowQuickSettingsToolbar = Settings.watch("showQuickSettingsToolbar", (value) => { setShowQuickSettingsToolbar(value); }); // 监听窗口背景不透明度 const unwatchWindowBackgroundAlpha = Settings.watch("windowBackgroundAlpha", (value) => { setWindowBackgroundAlpha(value); }); // 恢复窗口位置大小 restoreStateCurrent(StateFlags.SIZE | StateFlags.POSITION | StateFlags.MAXIMIZED); // setIsWide(window.innerWidth / window.innerHeight > 1.8); const unlisten1 = getCurrentWindow().onResized(() => { if (!isOnResizedDisabled.current) { isMaximizedWorkaround(); } // setIsWide(window.innerWidth / window.innerHeight > 1.8); }); if (!telemetryEventSent) { setTelemetryEventSent(true); (async () => { const cpu = await cpuInfo(); await Telemetry.event("启动应用", { version: await getVersion(), os: platform(), arch: arch(), osVersion: version(), cpu: cpu.cpus[0].brand, cpuCount: cpu.cpu_count, }); })(); } // 加载完成了,显示窗口 getCurrentWindow().show(); // 关闭splash getAllWindows().then((windows) => { const splash = windows.find((w) => w.label === "splash"); if (splash) { splash.close(); } }); // 初始化全局快捷键管理 globalShortcutManager.init(); return () => { unlisten1?.then((f) => f()); KeyBindsUI.uiStopListen(); // 清理全局快捷键资源 unwatchShowQuickSettingsToolbar(); unwatchWindowBackgroundAlpha(); globalShortcutManager.dispose(); }; }, []); useEffect(() => { setIsClassroomMode(Settings.isClassroomMode); }, [Settings.isClassroomMode]); // https://github.com/tauri-apps/tauri/issues/5812 const isOnResizedDisabled = useRef(false); function isMaximizedWorkaround() { isOnResizedDisabled.current = true; getCurrentWindow() .isMaximized() .then((isMaximized) => { isOnResizedDisabled.current = false; // your stuff _setMaximized(isMaximized); }); } useEffect(() => { if (!canvasWrapperRef.current) return; if (!activeProject) return; activeProject.canvas.mount(canvasWrapperRef.current); activeProject.loop(); projects.filter((p) => p.uri.toString() !== activeProject.uri.toString()).forEach((p) => p.pause()); activeProject.canvas.element.addEventListener("pointerdown", () => { setIgnoreMouseEvents(true); }); activeProject.canvas.element.addEventListener("pointerup", () => { setIgnoreMouseEvents(false); }); const unlisten2 = getCurrentWindow().onDragDropEvent(async (event) => { // Mac 上 event.payload.position 为逻辑像素,而 outerSize() 返回物理像素, // 需用 scaleFactor 换算;Windows 上两者单位一致,不需要换算。 const size = await getCurrentWindow().outerSize(); const logicalHeight = isMac ? size.height / (await getCurrentWindow().scaleFactor()) : size.height; if (event.payload.type === "over") { if (event.payload.position.y <= logicalHeight / 3) { setDropMouseLocation("top"); } else if (event.payload.position.y <= (logicalHeight / 3) * 2) { setDropMouseLocation("middle"); } else { setDropMouseLocation("bottom"); } } else if (event.payload.type === "leave") { setDropMouseLocation("notInWindowZone"); } else if (event.payload.type === "drop") { setDropMouseLocation("notInWindowZone"); if (event.payload.position.y <= logicalHeight / 3) { DragFileIntoStageEngine.handleDrop(activeProject, event.payload.paths); } else if (event.payload.position.y <= (logicalHeight / 3) * 2) { DragFileIntoStageEngine.handleDropFileRelativePath(activeProject, event.payload.paths); } else { DragFileIntoStageEngine.handleDropFileAbsolutePath(activeProject, event.payload.paths); } } }); return () => { unlisten2?.then((f) => f()); }; }, [activeProject]); /** * 首次启动时显示欢迎页面 */ // const navigate = useNavigate(); // useEffect(() => { // if (LastLaunch.isFirstLaunch) { // navigate("/welcome"); // } // }, []); useEffect(() => { let unlisten1: () => void; /** * 关闭窗口时的事件监听 */ getCurrentWindow() .onCloseRequested(async (e) => { e.preventDefault(); // 检查是否有未保存的项目 const unsavedProjects = projects.filter( (project) => project.state === ProjectState.Unsaved || project.state === ProjectState.Stashed, ); if (unsavedProjects.length > 0) { // 弹出警告对话框 const response = await Dialog.buttons( "检测到未保存文件", `当前有 ${unsavedProjects.length} 个未保存的文件。直接关闭可能有文件被清空的风险,建议先手动保存文件。`, [ { id: "cancel", label: "取消", variant: "ghost" }, { id: "continue", label: "继续关闭", variant: "destructive" }, ], ); if (response === "cancel") { // 用户选择取消关闭,返回 return; } // 用户选择继续关闭,执行原有关闭流程 } try { for (const project of projects) { console.log("尝试关闭", project); await closeProject(project); } } catch { Telemetry.event("关闭应用提示是否保存文件选择了取消"); return; } Telemetry.event("关闭应用"); // 保存窗口位置 await saveWindowState(StateFlags.SIZE | StateFlags.POSITION | StateFlags.MAXIMIZED); await getCurrentWindow().destroy(); }) .then((it) => { unlisten1 = it; }); for (const project of projects) { project.on("state-change", () => { // 强制重新渲染一次 setProjects([...projects]); }); project.on("contextmenu", ({ x, y }) => { contextMenuTriggerRef.current?.dispatchEvent( new MouseEvent("contextmenu", { bubbles: true, clientX: x, clientY: y, }), ); setProjects([...projects]); }); } return () => { unlisten1?.(); for (const project of projects) { project.removeAllListeners("state-change"); project.removeAllListeners("contextmenu"); } }; }, [projects.length]); const closeProject = async (project: Project) => { if (project.state === ProjectState.Stashed) { toast("文件还没有保存,但已经暂存,在“最近打开的文件”中可恢复文件"); } else if (project.state === ProjectState.Unsaved) { // 切换到这个文件 setActiveProject(project); const response = await Dialog.buttons("是否保存更改?", decodeURI(project.uri.toString()), [ { id: "cancel", label: "取消", variant: "ghost" }, { id: "discard", label: "不保存", variant: "destructive" }, { id: "save", label: "保存" }, ]); if (response === "save") { await project.save(); } else if (response === "cancel") { throw new Error("取消操作"); } } await project.dispose(); setProjects((projects) => { const result = projects.filter((p) => p.uri.toString() !== project.uri.toString()); // 如果删除了当前标签页,就切换到下一个标签页 if (activeProject?.uri.toString() === project.uri.toString() && result.length > 0) { const activeProjectIndex = projects.findIndex((p) => p.uri.toString() === activeProject?.uri.toString()); if (activeProjectIndex === projects.length - 1) { // 关闭了最后一个标签页 setActiveProject(result[activeProjectIndex - 1]); } else { setActiveProject(result[activeProjectIndex]); } } // 如果删除了唯一一个标签页,就显示欢迎页面 if (result.length === 0) { setActiveProject(undefined); } return result; }); }; const handleTabClick = useCallback((project: Project) => { setActiveProject(project); }, []); const handleTabClose = useCallback( async (project: Project) => { await closeProject(project); }, [closeProject], ); return ( <> {/* 这是一个底层的 div,用于在拖拽改变窗口大小时填充背景,防止窗口出现透明闪烁 */}
e.preventDefault()} > {/* 菜单 | 标签页 | ...移动窗口区域... | 窗口控制按钮 */}
{isMac && }
{!isMac && }
{/* canvas */}
{/* 没有项目处于打开状态时,显示欢迎页面 */} {projects.length === 0 && (
)} {/* 右键菜单 */}
{/* ======= */} {/* */} {/* */} {/* */} {/* 底部工具栏 */} {activeProject && } {/* 右侧工具栏 */} {activeProject && showQuickSettingsToolbar && } {/* 右上角关闭的触发角 */} {isWindows && (
getCurrentWindow().close()} >
)} {dropMouseLocation !== "notInWindowZone" && ( )}
); } /** * 窗口右上角的最小化,最大化,关闭等按钮 */ function WindowButtons() { const [maximized] = useAtom(isWindowMaxsizedAtom); const [isClickThroughEnabled] = useAtom(isClickThroughEnabledAtom); const [isWindowAlwaysOnTop, setIsWindowAlwaysOnTop] = useAtom(isWindowAlwaysOnTopAtom); const checkoutWindowsAlwaysTop = async () => { const tauriWindow = getCurrentWindow(); if (isWindowAlwaysOnTop) { setIsWindowAlwaysOnTop(false); await tauriWindow.setAlwaysOnTop(false); } else { setIsWindowAlwaysOnTop(true); await tauriWindow.setAlwaysOnTop(true); } }; return (
{isClickThroughEnabled && Alt + 2关闭窗口穿透点击} {isMac ? (
getCurrentWindow().close()} >
getCurrentWindow().minimize()} >
{ getCurrentWindow() .isFullscreen() .then((res) => getCurrentWindow().setFullscreen(!res)); }} >
{ e.stopPropagation(); checkoutWindowsAlwaysTop(); }} > {isWindowAlwaysOnTop ? : }
) : ( {/* 钉住 */} {/* 最小化 */} {/* 最大化/还原 */} {maximized ? ( ) : ( )} {/* 关闭 */} )}
); } export function Catch() { return <>; } ================================================ FILE: app/src/DropWindowCover.tsx ================================================ import { cn } from "./utils/cn"; /** * 拖拽鼠标进入舞台时,覆盖一个提示区域 * 用于提示用户在不同位置释放有不同的效果 */ export const DropWindowCover = ({ dropMouseLocation, isDraft, }: { dropMouseLocation: "top" | "middle" | "bottom" | "notInWindowZone"; isDraft: boolean; }) => { // return (

拖拽到这里:追加到舞台

如果是图片文件(png/jpg/jpeg/webp),则追加到舞台,如果是prg工程文件,则打开标签页

拖拽到这里:以 相对路径 生成文本节点到舞台

{isDraft && (草稿文件无路径,无法使用相对路径)}

拖拽到这里:以 绝对路径 生成文本节点到舞台

这样就可以构建外部文件链接,选中路径为内容的文本节点,直接调用系统默认方式打开此文件了
); }; ================================================ FILE: app/src/ProjectTabs.tsx ================================================ import { memo, useCallback, useEffect, useRef, useState } from "react"; import { Project, ProjectState } from "./core/Project"; import { cn } from "@udecode/cn"; import { Button } from "./components/ui/button"; import { CircleAlert, CloudUpload, X } from "lucide-react"; import { Tooltip, TooltipContent, TooltipTrigger } from "./components/ui/tooltip"; import { SoundService } from "./core/service/feedbackService/SoundService"; import { toast } from "sonner"; import { Settings } from "./core/service/Settings"; import { replaceTextWhenProtect } from "./utils/font"; // 将 ProjectTabs 移出 App 组件,作为独立组件 export const ProjectTabs = memo(function ProjectTabs({ projects, activeProject, onTabClick, onTabClose, isClassroomMode, ignoreMouseEvents, }: { projects: Project[]; activeProject: Project | undefined; onTabClick: (project: Project) => void; onTabClose: (project: Project) => void; isClassroomMode: boolean; ignoreMouseEvents: boolean; }) { const tabsContainerRef = useRef(null); const scrollPositionRef = useRef(0); const [protectingPrivacy, setProtectingPrivacy] = useState(Settings.protectingPrivacy); useEffect(() => { const unwatch = Settings.watch("protectingPrivacy", setProtectingPrivacy); return unwatch; }, []); // 保存滚动位置 const saveScrollPosition = useCallback(() => { if (tabsContainerRef.current) { scrollPositionRef.current = tabsContainerRef.current.scrollLeft; } }, []); // 恢复滚动位置 const restoreScrollPosition = useCallback(() => { if (tabsContainerRef.current) { tabsContainerRef.current.scrollLeft = scrollPositionRef.current; } }, []); // 处理标签点击 const handleTabClick = useCallback( (project: Project) => { saveScrollPosition(); onTabClick(project); // 微任务中恢复滚动位置 Promise.resolve().then(restoreScrollPosition); }, [onTabClick, saveScrollPosition, restoreScrollPosition], ); // 处理标签关闭 const handleTabClose = useCallback( async (project: Project, e: React.MouseEvent) => { e.stopPropagation(); saveScrollPosition(); await onTabClose(project); Promise.resolve().then(restoreScrollPosition); }, [onTabClose, saveScrollPosition, restoreScrollPosition], ); // 监听滚动 const handleScroll = useCallback(() => { saveScrollPosition(); }, [saveScrollPosition]); return (
{projects.map((project) => ( ))}
); }); ================================================ FILE: app/src/assets/versions.json ================================================ [ { "version": "0.0.0-dev", "name": "筑梦空间", "name_en": "Development Build" }, { "version": "0.0.0-nightly", "name": "夜筑新梦", "name_en": "Nightly Build" }, { "version": "1.0", "name": "风起云涌之刻", "name_en": "Whirlwind Ascension" }, { "version": "1.1", "name": "地动山摇之时", "name_en": "Momentous Rupture" }, { "version": "1.2", "name": "2025年新纪元", "name_en": "The Great River" }, { "version": "1.3", "name": "层峦叠嶂之绘", "name_en": "Layered Peaks" }, { "version": "1.4", "name": "寰宇重塑之业", "name_en": "Cosmic Reform" }, { "version": "1.5", "name": "云程发轫之势", "name_en": "Promising Start" }, { "version": "1.6", "name": "贝塞流光之幕", "name_en": "Bézier Luminescence" }, { "version": "1.7", "name": "控弦绘影之织", "name_en": "CR Precision Weave" }, { "version": "1.8", "name": "视界纵横之窗", "name_en": "Panoramic Weave" }, { "version": "2.0", "name": "零钥", "name_en": "Nullkey" } ] ================================================ FILE: app/src/cli.tsx ================================================ import { writeStdout } from "@/utils/otherApi"; import { CliMatches } from "@tauri-apps/plugin-cli"; export async function runCli(matches: CliMatches) { if (matches.args.help?.occurrences > 0) { writeStdout(cliHelpText); return; } if (matches.args.output?.occurrences > 0) { const outputPath = matches.args.output?.value as string; const outputFormat = outputPath.endsWith(".svg") || outputPath === "-" ? "svg" : ""; if (outputFormat === "svg") { // const result = StageExportSvg.dumpStageToSVGString(); // if (outputPath === "-") { // writeStdout(result); // } else { // await writeTextFile(outputPath, result); // } } else { throw new Error("Invalid output format. Only SVG format is supported."); } } } const cliHelpText = ` ____ _ __ ______ __ / __ \\_________ (_)__ _____/ \\/ ____/________ _____ / /_ / /_/ / ___/ __ \\ / / _ \\/ ___/ __\\/ __/ ___/ __ \\/ __ \\/ __ \\ / ____/ / / /_/ / / / __/ /__/ /_/ \\/_/ / / / /_/ / /_/ / / / / /_/ /_/ \\____/_/ /\\___/\\___/\\__\\/____/_/ \\__,_/ .___/_/ /_/ /___/ /_/ https://project-graph.top/zh/features/cli `; ================================================ FILE: app/src/components/context-menu-content.tsx ================================================ import { Button } from "@/components/ui/button"; import { ContextMenuContent, ContextMenuItem, ContextMenuSub, ContextMenuSubContent, ContextMenuSubTrigger, } from "@/components/ui/context-menu"; import { Dialog } from "@/components/ui/dialog"; import { MouseLocation } from "@/core/service/controlService/MouseLocation"; import { ColorSmartTools } from "@/core/service/dataManageService/colorSmartTools"; import { ConnectNodeSmartTools } from "@/core/service/dataManageService/connectNodeSmartTools"; import { TextNodeSmartTools } from "@/core/service/dataManageService/textNodeSmartTools"; import { ColorManager } from "@/core/service/feedbackService/ColorManager"; import { Settings } from "@/core/service/Settings"; import { ConnectableEntity } from "@/core/stage/stageObject/abstract/ConnectableEntity"; import { Edge } from "@/core/stage/stageObject/association/Edge"; import { MultiTargetUndirectedEdge } from "@/core/stage/stageObject/association/MutiTargetUndirectedEdge"; import { ImageNode } from "@/core/stage/stageObject/entity/ImageNode"; import { ReferenceBlockNode } from "@/core/stage/stageObject/entity/ReferenceBlockNode"; import { Section } from "@/core/stage/stageObject/entity/Section"; import { TextNode } from "@/core/stage/stageObject/entity/TextNode"; import { activeProjectAtom, contextMenuTooltipWordsAtom } from "@/state"; import ColorPaletteWindow from "@/sub/ColorPaletteWindow"; import ColorWindow from "@/sub/ColorWindow"; import { Direction } from "@/types/directions"; import { parseEmacsKey } from "@/utils/emacs"; import { openBrowserOrFile } from "@/utils/externalOpen"; import { exportImagesToProjectDirectory } from "@/utils/imageExport"; import { Color, Vector } from "@graphif/data-structures"; import { Image as TauriImage } from "@tauri-apps/api/image"; import { writeImage } from "@tauri-apps/plugin-clipboard-manager"; import { useAtom } from "jotai"; import { AlignCenterHorizontal, AlignCenterVertical, AlignEndHorizontal, AlignEndVertical, AlignHorizontalJustifyStart, AlignHorizontalSpaceBetween, AlignStartHorizontal, AlignStartVertical, AlignVerticalJustifyStart, AlignVerticalSpaceBetween, ArrowDownUp, ArrowLeftFromLine, ArrowLeftRight, ArrowRightFromLine, ArrowUpRight, ArrowUpToLine, Asterisk, Box, Check, ChevronDown, ChevronsRightLeft, ChevronUp, Clipboard, Code, Copy, CornerUpRight, Dot, Ellipsis, Equal, ExternalLink, GitPullRequestCreateArrow, Grip, Images, LayoutDashboard, LayoutPanelTop, ListEnd, Lock, Maximize2, Minimize2, MoveDown, MoveHorizontal, MoveRight, MoveUp, MoveUpRight, Network, Package, PaintBucket, Palette, Rabbit, RefreshCcw, RefreshCcwDot, Repeat2, Save, Slash, Spline, SquareDashedBottomCode, SquareDot, SquareRoundCorner, SquareSplitHorizontal, SquareSquare, SquaresUnite, Sun, SunDim, TextSelect, Trash, Undo, Workflow, } from "lucide-react"; import { ReactNode, useEffect, useState } from "react"; import { useTranslation } from "react-i18next"; import { toast } from "sonner"; import tailwindColors from "tailwindcss/colors"; import KeyTooltip from "./key-tooltip"; const Content = ContextMenuContent; const Item = ContextMenuItem; const Sub = ContextMenuSub; const SubTrigger = ContextMenuSubTrigger; const SubContent = ContextMenuSubContent; // const Separator = ContextMenuSeparator; /** * 右键菜单 * @returns */ export default function MyContextMenuContent() { const [p] = useAtom(activeProjectAtom); const [contextMenuTooltipWords] = useAtom(contextMenuTooltipWordsAtom); const { t } = useTranslation("contextMenu"); if (!p) return <>; const isSelectedTreeRoots = () => { const selectedEntities = p.stageManager.getSelectedEntities(); if (selectedEntities.length === 0) return false; return selectedEntities.every((entity) => { return entity instanceof ConnectableEntity && p.graphMethods.isTree(entity); }); }; // 简化判断,只要选中了两个及以上的节点就显示按钮 const hasMultipleSelectedEntities = () => { const selectedEntities = p.stageManager.getSelectedEntities(); return selectedEntities.length >= 2 && selectedEntities.every((entity) => entity instanceof ConnectableEntity); }; return ( {/* 第一行 Ctrl+c/v/x del */} {p.stageManager.getSelectedStageObjects().length > 0 && ( )} {/* 先不放cut,感觉不常用,可能还很容易出bug */} {/* */} {/* 对齐面板 */} {p.stageManager.getSelectedEntities().length >= 2 && (
)} {p.stageManager.getSelectedEntities().length >= 2 && (
)} {/* 树形面板 */} {isSelectedTreeRoots() && ( )} {/* DAG面板 */} {hasMultipleSelectedEntities() && ( )}

{contextMenuTooltipWords || "暂无提示"}

{/* 存在选中实体 */} {p.stageManager.getSelectedStageObjects().length > 0 && p.stageManager.getSelectedStageObjects().some((it) => "color" in it) && ( <> {/* 更改更简单的颜色 */} {/* 更改更详细的颜色 */} {t("changeColor")} p.stageObjectColorManager.setSelectedStageObjectColor(Color.Transparent)}> {t("resetColor")} {Object.values(tailwindColors) .filter((it) => typeof it !== "string") .slice(4) .flatMap((it) => Object.values(it).map(Color.fromCss)) .map((color, index) => (
p.stageObjectColorManager.setSelectedStageObjectColor(color)} /> ))} p.stageObjectColorManager.setSelectedStageObjectColor(new Color(11, 45, 14, 0))}> 改为强制特殊透明色 { ColorWindow.open(); }} > 打开调色板 { ColorPaletteWindow.open(); }} > 打开舞台颜色分布表 )} {/* 存在两个及以上选中实体 */} {p.stageManager.getSelectedEntities().length >= 2 && ( <> p.stageManager.packEntityToSectionBySelected()}> {t("packToSection")} { const selectedNodes = p.stageManager .getSelectedEntities() .filter((node) => node instanceof ConnectableEntity); if (selectedNodes.length <= 1) { toast.error("至少选择两个可连接节点"); return; } const edge = MultiTargetUndirectedEdge.createFromSomeEntity(p, selectedNodes); p.stageManager.add(edge); }} > {t("createMTUEdgeLine")} { const selectedNodes = p.stageManager .getSelectedEntities() .filter((node) => node instanceof ConnectableEntity); if (selectedNodes.length <= 1) { toast.error("至少选择两个可连接节点"); return; } const edge = MultiTargetUndirectedEdge.createFromSomeEntity(p, selectedNodes); edge.renderType = "convex"; p.stageManager.add(edge); }} > {t("createMTUEdgeConvex")} )} {/* 没有选中实体,提示用户可以创建实体 */} {p.stageManager.getSelectedStageObjects().length === 0 && ( <> p.controllerUtils.addTextNodeByLocation(p.renderer.transformView2World(MouseLocation.vector()), true) } > {t("createTextNode")} p.controllerUtils.createConnectPoint(p.renderer.transformView2World(MouseLocation.vector()))} > {t("createConnectPoint")} )} {/* 存在选中 TextNode */} {p.stageManager.getSelectedEntities().filter((it) => it instanceof TextNode).length > 0 && ( <> { const selectedTextNodes = p.stageManager.getSelectedEntities().filter((it) => it instanceof TextNode); for (const textNode of selectedTextNodes) { textNode.increaseFontSize(); } p.historyManager.recordStep(); }} > 放大字体 { const selectedTextNodes = p.stageManager.getSelectedEntities().filter((it) => it instanceof TextNode); for (const textNode of selectedTextNodes) { textNode.decreaseFontSize(); } p.historyManager.recordStep(); }} > 缩小字体 文本节点 巧妙操作 TextNodeSmartTools.ttt(p)}> 切换换行模式 [t, t, t] TextNodeSmartTools.rua(p)}> ruá成一个 [r, u, a] TextNodeSmartTools.kei(p)}> kēi成多个 [k, e, i] TextNodeSmartTools.exchangeTextAndDetails(p)}> 详略交换 [e, e, e, e, e] TextNodeSmartTools.removeFirstCharFromSelectedTextNodes(p)}> 削头 [ctrl+backspace] TextNodeSmartTools.removeLastCharFromSelectedTextNodes(p)}> 剃尾 [ctrl+delete] TextNodeSmartTools.okk(p)}> 打勾勾 [o, k, k] p.stageManager .getSelectedEntities() .filter((it) => it instanceof TextNode) .map((it) => p.sectionPackManager.targetTextNodeToSection(it, false, true)) } > {t("convertToSection")} [ctrl+shift+G] 连接相关 ConnectNodeSmartTools.insertNodeToTree(p)}> 嫁接到连线中 [q, e] ConnectNodeSmartTools.removeNodeFromTree(p)}> 从连线中摘除 [q, r] ConnectNodeSmartTools.connectDown(p)}> 向下连一串 [-, -, d, o, w, n] ConnectNodeSmartTools.connectRight(p)}> 向右连一串 [-, -, r, i, g, h, t] ConnectNodeSmartTools.connectAll(p)}> 全连接 [-, -, a, l, l] 颜色相关 ColorSmartTools.increaseBrightness(p)}> 增加亮度 [b, .] ColorSmartTools.decreaseBrightness(p)}> 降低亮度 [b, ,] ColorSmartTools.changeColorHueUp(p)}> 增加色相值 [Alt+Shift+⬆] ColorSmartTools.changeColorHueDown(p)}> 降低色相值 [Alt+Shift+⬇] ColorSmartTools.changeColorHueMajorUp(p)}> 大幅度增加色相值 [Alt+Shift+Home] ColorSmartTools.changeColorHueMajorDown(p)}> 大幅度降低色相值 [Alt+Shift+End] 其他 TextNodeSmartTools.changeTextNodeToReferenceBlock(p)}> 将选中的文本节点转换为引用块 openBrowserOrFile(p)}> 将内容视为路径并打开 )} {/* 存在选中 Section */} {p.stageManager.getSelectedEntities().filter((it) => it instanceof Section).length > 0 && ( <> p.stageManager.sectionSwitchCollapse()}> {t("toggleSectionCollapse")} { const selectedSections = p.stageManager.getSelectedEntities().filter((it) => it instanceof Section); for (const section of selectedSections) { section.locked = !section.locked; p.sectionRenderer.render(section); } // 记录历史步骤 p.historyManager.recordStep(); }} > 锁定/解锁 section 框 )} {/* 存在选中 引用块 */} {p.stageManager.getSelectedEntities().filter((it) => it instanceof ReferenceBlockNode).length > 0 && ( <> { p.stageManager .getSelectedEntities() .filter((it) => it instanceof ReferenceBlockNode) .filter((it) => it.isSelected) .forEach((it) => { it.refresh(); }); }} > 刷新引用块 { p.stageManager .getSelectedEntities() .filter((it) => it instanceof ReferenceBlockNode) .filter((it) => it.isSelected) .forEach((it) => { it.goToSource(); }); }} > 进入该引用块所在的源头位置 )} {/* 存在选中的 Edge */} {p.stageManager.getSelectedAssociations().filter((it) => it instanceof Edge).length > 0 && ( <> { p.stageManager.switchEdgeToUndirectedEdge(); p.historyManager.recordStep(); }} > 转换为无向边 线条类型 { p.stageManager.setSelectedEdgeLineType("solid"); p.historyManager.recordStep(); }} > 实线 { p.stageManager.setSelectedEdgeLineType("dashed"); p.historyManager.recordStep(); }} > 虚线 { p.stageManager.setSelectedEdgeLineType("double"); p.historyManager.recordStep(); }} > 双实线
)} {/* 存在选中的 MTUEdge */} {p.stageManager.getSelectedAssociations().filter((it) => it instanceof MultiTargetUndirectedEdge).length > 0 && ( <> {t("switchMTUEdgeArrow")} { const selectedMTUEdges = p.stageManager .getSelectedAssociations() .filter((edge) => edge instanceof MultiTargetUndirectedEdge); for (const multi_target_undirected_edge of selectedMTUEdges) { multi_target_undirected_edge.arrow = "outer"; } p.historyManager.recordStep(); }} > {t("mtuEdgeArrowOuter")} { const selectedMTUEdges = p.stageManager .getSelectedAssociations() .filter((edge) => edge instanceof MultiTargetUndirectedEdge); for (const multi_target_undirected_edge of selectedMTUEdges) { multi_target_undirected_edge.arrow = "inner"; } p.historyManager.recordStep(); }} > {t("mtuEdgeArrowInner")} { const selectedMTUEdges = p.stageManager .getSelectedAssociations() .filter((edge) => edge instanceof MultiTargetUndirectedEdge); for (const multi_target_undirected_edge of selectedMTUEdges) { multi_target_undirected_edge.arrow = "none"; } p.historyManager.recordStep(); }} > {t("mtuEdgeArrowNone")} { const selectedMTUEdge = p.stageManager .getSelectedAssociations() .filter((edge) => edge instanceof MultiTargetUndirectedEdge); for (const multi_target_undirected_edge of selectedMTUEdge) { if (multi_target_undirected_edge.renderType === "line") { multi_target_undirected_edge.renderType = "convex"; } else if (multi_target_undirected_edge.renderType === "convex") { multi_target_undirected_edge.renderType = "circle"; } else if (multi_target_undirected_edge.renderType === "circle") { multi_target_undirected_edge.renderType = "line"; } } p.historyManager.recordStep(); }} > {t("switchMTUEdgeRenderType")} { // 重置所有选中无向边的端点位置到中心 const selectedMTUEdges = p.stageManager .getSelectedAssociations() .filter((edge) => edge instanceof MultiTargetUndirectedEdge); for (const multi_target_undirected_edge of selectedMTUEdges) { // 重置中心位置到中心 multi_target_undirected_edge.centerRate = Vector.same(0.5); // 重置每个节点的连接点位置到中心 multi_target_undirected_edge.rectRates = multi_target_undirected_edge.associationList.map(() => Vector.same(0.5), ); } p.historyManager.recordStep(); }} > 重置端点位置到中心 { p.stageManager.switchUndirectedEdgeToEdge(); p.historyManager.recordStep(); }} > {t("convertToDirectedEdge")} )} {/* 涂鸦模式增加修改画笔颜色 */} {Settings.mouseLeftMode === "draw" && ( 改变画笔颜色 (Settings.autoFillPenStrokeColor = Color.Transparent.toArray())}> {t("resetColor")} {Object.values(tailwindColors) .filter((it) => typeof it !== "string") .flatMap((it) => Object.values(it).map(Color.fromCss)) .map((color, index) => (
(Settings.autoFillPenStrokeColor = color.toArray())} /> ))} )} {/* 存在选中 ImageNode */} {p.stageManager.getSelectedEntities().filter((it) => it instanceof ImageNode).length > 0 && ( <> { // 获取所有选中的 ImageNode const selectedImageNodes = p.stageManager .getSelectedEntities() .filter((it) => it instanceof ImageNode) as ImageNode[]; if (selectedImageNodes.length === 0) { toast.error("请选中图片节点"); return; } // 复制第一张图片到剪贴板(如果有多张图片,只复制第一张) const imageNode = selectedImageNodes[0]; const blob = p.attachments.get(imageNode.attachmentId); if (blob) { try { const arrayBuffer = await blob.arrayBuffer(); const tauriImage = await TauriImage.fromBytes(new Uint8Array(arrayBuffer)); await writeImage(tauriImage); if (selectedImageNodes.length === 1) { toast.success("已将选中的图片复制到系统剪贴板"); } else { toast.success(`已将第1张图片复制到系统剪贴板(共${selectedImageNodes.length}张)`); } } catch (error) { console.error("复制图片到剪贴板失败:", error); toast.error("复制图片到剪贴板失败"); } } else { toast.error("无法获取图片数据"); } }} > 复制图片到系统剪贴板 { // 获取所有选中的 ImageNode const selectedImageNodes = p.stageManager .getSelectedEntities() .filter((it) => it instanceof ImageNode) as ImageNode[]; if (selectedImageNodes.length === 0) { toast.error("请选中图片节点"); return; } // 对每张图片进行红蓝通道对调 for (const imageNode of selectedImageNodes) { imageNode.swapRedBlueChannels(); } // 记录历史步骤 p.historyManager.recordStep(); // 显示提示信息 if (selectedImageNodes.length === 1) { toast.success("已对调图片的红蓝通道"); } else { toast.success(`已对调 ${selectedImageNodes.length} 张图片的红蓝通道`); } }} > 对调图片红蓝通道 { // 获取所有选中的 ImageNode const selectedImageNodes = p.stageManager .getSelectedEntities() .filter((it) => it instanceof ImageNode) as ImageNode[]; if (selectedImageNodes.length === 0) { toast.error("请选中图片节点"); return; } // 将选中的图片转化为背景图片 for (const imageNode of selectedImageNodes) { imageNode.isBackground = true; } // 记录历史步骤 p.historyManager.recordStep(); // 显示提示信息 if (selectedImageNodes.length === 1) { toast.success("已将图片转化为背景图片"); } else { toast.success(`已将 ${selectedImageNodes.length} 张图片转化为背景图片`); } }} > 转化为背景图片 { // 获取所有选中的 ImageNode const selectedImageNodes = p.stageManager .getSelectedEntities() .filter((it) => it instanceof ImageNode) as ImageNode[]; if (selectedImageNodes.length === 0) { toast.error("请选中图片节点"); return; } // 取消背景化 for (const imageNode of selectedImageNodes) { imageNode.isBackground = false; } // 记录历史步骤 p.historyManager.recordStep(); // 显示提示信息 if (selectedImageNodes.length === 1) { toast.success("已取消图片的背景化"); } else { toast.success(`已取消 ${selectedImageNodes.length} 张图片的背景化`); } }} > 取消背景化 { // 检查是否是草稿模式 if (p.isDraft) { toast.error("请先保存项目后再导出图片"); return; } // 获取所有选中的 ImageNode const selectedImageNodes = p.stageManager .getSelectedEntities() .filter((it) => it instanceof ImageNode) as ImageNode[]; if (selectedImageNodes.length === 0) { toast.error("请选中图片节点"); return; } // 根据图片数量决定提示信息 const isBatch = selectedImageNodes.length > 1; const promptMessage = isBatch ? `请输入文件名(不含扩展名,将为 ${selectedImageNodes.length} 张图片添加数字后缀)` : `请输入文件名(不含扩展名,将自动添加扩展名)`; // 弹出输入框 - 只弹出一次 const fileName = await Dialog.input("另存图片", promptMessage, { placeholder: "image", }); if (!fileName) { return; // 用户取消 } // 验证文件名是否合法 const invalidChars = /[/\\:*?"<>|]/; if (invalidChars.test(fileName)) { toast.error('文件名包含非法字符:/ \\ : * ? " < > |'); return; } // 调用工具函数导出图片 const { successCount, failedCount } = await exportImagesToProjectDirectory( selectedImageNodes, p.uri.fsPath, p.attachments, fileName, ); // 显示结果提示 if (successCount > 0 && failedCount === 0) { toast.success(`成功保存 ${successCount} 张图片`); } else if (successCount > 0 && failedCount > 0) { toast.warning(`成功保存 ${successCount} 张图片,${failedCount} 张失败`); } else { toast.error(`保存失败,请检查文件名或文件权限`); } }} > 另存图片到当前prg所在目录下 )} ); } function ContextMenuTooltip({ keyId, children = <> }: { keyId: string; children: ReactNode }) { const [keySeq, setKeySeq] = useState[number][]>(); const [activeProject] = useAtom(activeProjectAtom); // eslint-disable-next-line @typescript-eslint/no-unused-vars const [_, setContextMenuTooltipWords] = useAtom(contextMenuTooltipWordsAtom); const { t } = useTranslation("keyBinds"); useEffect(() => { activeProject?.keyBinds.get(keyId)?.then((key) => { if (key) { const keyStr = typeof key === "string" ? key : key.key; const parsed = parseEmacsKey(keyStr); if (parsed.length > 0) { setKeySeq(parsed); } else { setKeySeq(undefined); } } else { setKeySeq(undefined); } }); }, [keyId, activeProject]); const onMouseEnter = () => { const title = t(`${keyId}.title`); let keyTips = ""; if (keySeq) { keyTips = keySeq .map((seq) => { let res = ""; if (seq.control) { res += "Ctrl+"; } if (seq.meta) { res += "Meta+"; } if (seq.shift) { res += "Shift+"; } if (seq.alt) { res += "Alt+"; } return res + seq.key.toUpperCase(); }) .join(","); } else { keyTips = "未绑定快捷键"; } setContextMenuTooltipWords(`${title} [${keyTips}]`); }; const onMouseLeave = () => { setContextMenuTooltipWords(""); }; return ( {children} ); } const ColorLine: React.FC = () => { const [currentColors, setCurrentColors] = useState([]); const [project] = useAtom(activeProjectAtom); useEffect(() => { ColorManager.getUserEntityFillColors().then((colors) => { setCurrentColors(colors); }); }, []); const handleChangeColor = (color: Color) => { project?.stageObjectColorManager.setSelectedStageObjectColor(color); }; return (
{currentColors.map((color) => { return (
{ handleChangeColor(color); }} /> ); })}
); }; ================================================ FILE: app/src/components/editor/editor-base-kit.tsx ================================================ import { BaseAlignKit } from "./plugins/align-base-kit"; import { BaseBasicBlocksKit } from "./plugins/basic-blocks-base-kit"; import { BaseBasicMarksKit } from "./plugins/basic-marks-base-kit"; import { BaseCalloutKit } from "./plugins/callout-base-kit"; import { BaseCodeBlockKit } from "./plugins/code-block-base-kit"; import { BaseColumnKit } from "./plugins/column-base-kit"; import { BaseCommentKit } from "./plugins/comment-base-kit"; import { BaseDateKit } from "./plugins/date-base-kit"; import { BaseFontKit } from "./plugins/font-base-kit"; import { BaseLineHeightKit } from "./plugins/line-height-base-kit"; import { BaseLinkKit } from "./plugins/link-base-kit"; import { BaseListKit } from "./plugins/list-base-kit"; import { MarkdownKit } from "./plugins/markdown-kit"; import { BaseMathKit } from "./plugins/math-base-kit"; import { BaseMediaKit } from "./plugins/media-base-kit"; import { BaseMentionKit } from "./plugins/mention-base-kit"; import { BaseSuggestionKit } from "./plugins/suggestion-base-kit"; import { BaseTableKit } from "./plugins/table-base-kit"; import { BaseTocKit } from "./plugins/toc-base-kit"; import { BaseToggleKit } from "./plugins/toggle-base-kit"; export const BaseEditorKit = [ ...BaseBasicBlocksKit, ...BaseCodeBlockKit, ...BaseTableKit, ...BaseToggleKit, ...BaseTocKit, ...BaseMediaKit, ...BaseCalloutKit, ...BaseColumnKit, ...BaseMathKit, ...BaseDateKit, ...BaseLinkKit, ...BaseMentionKit, ...BaseBasicMarksKit, ...BaseFontKit, ...BaseListKit, ...BaseAlignKit, ...BaseLineHeightKit, ...BaseCommentKit, ...BaseSuggestionKit, ...MarkdownKit, ]; ================================================ FILE: app/src/components/editor/plugins/align-base-kit.tsx ================================================ import { BaseTextAlignPlugin } from "@platejs/basic-styles"; import { KEYS } from "platejs"; export const BaseAlignKit = [ BaseTextAlignPlugin.configure({ inject: { nodeProps: { defaultNodeValue: "start", nodeKey: "align", styleKey: "textAlign", validNodeValues: ["start", "left", "center", "right", "end", "justify"], }, targetPlugins: [...KEYS.heading, KEYS.p, KEYS.img, KEYS.mediaEmbed], }, }), ]; ================================================ FILE: app/src/components/editor/plugins/basic-blocks-base-kit.tsx ================================================ import { BaseBlockquotePlugin, BaseH1Plugin, BaseH2Plugin, BaseH3Plugin, BaseH4Plugin, BaseH5Plugin, BaseH6Plugin, BaseHorizontalRulePlugin, } from "@platejs/basic-nodes"; import { BaseParagraphPlugin } from "platejs"; import { BlockquoteElementStatic } from "@/components/ui/blockquote-node-static"; import { H1ElementStatic, H2ElementStatic, H3ElementStatic, H4ElementStatic, H5ElementStatic, H6ElementStatic, } from "@/components/ui/heading-node-static"; import { HrElementStatic } from "@/components/ui/hr-node-static"; import { ParagraphElementStatic } from "@/components/ui/paragraph-node-static"; export const BaseBasicBlocksKit = [ BaseParagraphPlugin.withComponent(ParagraphElementStatic), BaseH1Plugin.withComponent(H1ElementStatic), BaseH2Plugin.withComponent(H2ElementStatic), BaseH3Plugin.withComponent(H3ElementStatic), BaseH4Plugin.withComponent(H4ElementStatic), BaseH5Plugin.withComponent(H5ElementStatic), BaseH6Plugin.withComponent(H6ElementStatic), BaseBlockquotePlugin.withComponent(BlockquoteElementStatic), BaseHorizontalRulePlugin.withComponent(HrElementStatic), ]; ================================================ FILE: app/src/components/editor/plugins/basic-blocks-kit.tsx ================================================ "use client"; import { BlockquotePlugin, H1Plugin, H2Plugin, H3Plugin, H4Plugin, H5Plugin, H6Plugin, HorizontalRulePlugin, } from "@platejs/basic-nodes/react"; import { ParagraphPlugin } from "platejs/react"; import { BlockquoteElement } from "@/components/ui/blockquote-node"; import { H1Element, H2Element, H3Element, H4Element, H5Element, H6Element } from "@/components/ui/heading-node"; import { HrElement } from "@/components/ui/hr-node"; import { ParagraphElement } from "@/components/ui/paragraph-node"; export const BasicBlocksKit = [ ParagraphPlugin.withComponent(ParagraphElement), H1Plugin.configure({ node: { component: H1Element, }, rules: { break: { empty: "reset" }, }, shortcuts: { toggle: { keys: "mod+alt+1" } }, }), H2Plugin.configure({ node: { component: H2Element, }, rules: { break: { empty: "reset" }, }, shortcuts: { toggle: { keys: "mod+alt+2" } }, }), H3Plugin.configure({ node: { component: H3Element, }, rules: { break: { empty: "reset" }, }, shortcuts: { toggle: { keys: "mod+alt+3" } }, }), H4Plugin.configure({ node: { component: H4Element, }, rules: { break: { empty: "reset" }, }, shortcuts: { toggle: { keys: "mod+alt+4" } }, }), H5Plugin.configure({ node: { component: H5Element, }, rules: { break: { empty: "reset" }, }, shortcuts: { toggle: { keys: "mod+alt+5" } }, }), H6Plugin.configure({ node: { component: H6Element, }, rules: { break: { empty: "reset" }, }, shortcuts: { toggle: { keys: "mod+alt+6" } }, }), BlockquotePlugin.configure({ node: { component: BlockquoteElement }, shortcuts: { toggle: { keys: "mod+shift+period" } }, }), HorizontalRulePlugin.withComponent(HrElement), ]; ================================================ FILE: app/src/components/editor/plugins/basic-marks-base-kit.tsx ================================================ import { BaseBoldPlugin, BaseCodePlugin, BaseHighlightPlugin, BaseItalicPlugin, BaseKbdPlugin, BaseStrikethroughPlugin, BaseSubscriptPlugin, BaseSuperscriptPlugin, BaseUnderlinePlugin, } from "@platejs/basic-nodes"; import { CodeLeafStatic } from "@/components/ui/code-node-static"; import { HighlightLeafStatic } from "@/components/ui/highlight-node-static"; import { KbdLeafStatic } from "@/components/ui/kbd-node-static"; export const BaseBasicMarksKit = [ BaseBoldPlugin, BaseItalicPlugin, BaseUnderlinePlugin, BaseCodePlugin.withComponent(CodeLeafStatic), BaseStrikethroughPlugin, BaseSubscriptPlugin, BaseSuperscriptPlugin, BaseHighlightPlugin.withComponent(HighlightLeafStatic), BaseKbdPlugin.withComponent(KbdLeafStatic), ]; ================================================ FILE: app/src/components/editor/plugins/basic-marks-kit.tsx ================================================ "use client"; import { BoldPlugin, CodePlugin, HighlightPlugin, ItalicPlugin, KbdPlugin, StrikethroughPlugin, SubscriptPlugin, SuperscriptPlugin, UnderlinePlugin, } from "@platejs/basic-nodes/react"; import { CodeLeaf } from "@/components/ui/code-node"; import { HighlightLeaf } from "@/components/ui/highlight-node"; import { KbdLeaf } from "@/components/ui/kbd-node"; export const BasicMarksKit = [ BoldPlugin, ItalicPlugin, UnderlinePlugin, CodePlugin.configure({ node: { component: CodeLeaf }, shortcuts: { toggle: { keys: "mod+e" } }, }), StrikethroughPlugin.configure({ shortcuts: { toggle: { keys: "mod+shift+x" } }, }), SubscriptPlugin.configure({ shortcuts: { toggle: { keys: "mod+comma" } }, }), SuperscriptPlugin.configure({ shortcuts: { toggle: { keys: "mod+period" } }, }), HighlightPlugin.configure({ node: { component: HighlightLeaf }, shortcuts: { toggle: { keys: "mod+shift+h" } }, }), KbdPlugin.withComponent(KbdLeaf), ]; ================================================ FILE: app/src/components/editor/plugins/callout-base-kit.tsx ================================================ import { BaseCalloutPlugin } from "@platejs/callout"; import { CalloutElementStatic } from "@/components/ui/callout-node-static"; export const BaseCalloutKit = [BaseCalloutPlugin.withComponent(CalloutElementStatic)]; ================================================ FILE: app/src/components/editor/plugins/code-block-base-kit.tsx ================================================ import { BaseCodeBlockPlugin, BaseCodeLinePlugin, BaseCodeSyntaxPlugin } from "@platejs/code-block"; import { all, createLowlight } from "lowlight"; import { CodeBlockElementStatic, CodeLineElementStatic, CodeSyntaxLeafStatic, } from "@/components/ui/code-block-node-static"; const lowlight = createLowlight(all); export const BaseCodeBlockKit = [ BaseCodeBlockPlugin.configure({ node: { component: CodeBlockElementStatic }, options: { lowlight }, }), BaseCodeLinePlugin.withComponent(CodeLineElementStatic), BaseCodeSyntaxPlugin.withComponent(CodeSyntaxLeafStatic), ]; ================================================ FILE: app/src/components/editor/plugins/code-block-kit.tsx ================================================ "use client"; import { CodeBlockPlugin, CodeLinePlugin, CodeSyntaxPlugin } from "@platejs/code-block/react"; import { all, createLowlight } from "lowlight"; import { CodeBlockElement, CodeLineElement, CodeSyntaxLeaf } from "@/components/ui/code-block-node"; const lowlight = createLowlight(all); export const CodeBlockKit = [ CodeBlockPlugin.configure({ node: { component: CodeBlockElement }, options: { lowlight }, shortcuts: { toggle: { keys: "mod+alt+8" } }, }), CodeLinePlugin.withComponent(CodeLineElement), CodeSyntaxPlugin.withComponent(CodeSyntaxLeaf), ]; ================================================ FILE: app/src/components/editor/plugins/column-base-kit.tsx ================================================ import { BaseColumnItemPlugin, BaseColumnPlugin } from "@platejs/layout"; import { ColumnElementStatic, ColumnGroupElementStatic } from "@/components/ui/column-node-static"; export const BaseColumnKit = [ BaseColumnPlugin.withComponent(ColumnGroupElementStatic), BaseColumnItemPlugin.withComponent(ColumnElementStatic), ]; ================================================ FILE: app/src/components/editor/plugins/comment-base-kit.tsx ================================================ import { BaseCommentPlugin } from "@platejs/comment"; import { CommentLeafStatic } from "@/components/ui/comment-node-static"; export const BaseCommentKit = [BaseCommentPlugin.withComponent(CommentLeafStatic)]; ================================================ FILE: app/src/components/editor/plugins/comment-kit.tsx ================================================ "use client"; import type { ExtendConfig, Path } from "platejs"; import { type BaseCommentConfig, BaseCommentPlugin, getDraftCommentKey } from "@platejs/comment"; import { isSlateString } from "platejs"; import { toTPlatePlugin } from "platejs/react"; import { CommentLeaf } from "@/components/ui/comment-node"; type CommentConfig = ExtendConfig< BaseCommentConfig, { activeId: string | null; commentingBlock: Path | null; hoverId: string | null; uniquePathMap: Map; } >; export const commentPlugin = toTPlatePlugin(BaseCommentPlugin, { handlers: { onClick: ({ api, event, setOption, type }) => { let leaf = event.target as HTMLElement; let isSet = false; const unsetActiveSuggestion = () => { setOption("activeId", null); isSet = true; }; if (!isSlateString(leaf)) unsetActiveSuggestion(); while (leaf.parentElement) { if (leaf.classList.contains(`slate-${type}`)) { const commentsEntry = api.comment!.node(); if (!commentsEntry) { unsetActiveSuggestion(); break; } const id = api.comment!.nodeId(commentsEntry[0]); setOption("activeId", id ?? null); isSet = true; break; } leaf = leaf.parentElement; } if (!isSet) unsetActiveSuggestion(); }, }, options: { activeId: null, commentingBlock: null, hoverId: null, uniquePathMap: new Map(), }, }) .extendTransforms( ({ editor, setOption, tf: { comment: { setDraft }, }, }) => ({ setDraft: () => { if (editor.api.isCollapsed()) { editor.tf.select(editor.api.block()![1]); } setDraft(); editor.tf.collapse(); setOption("activeId", getDraftCommentKey()); setOption("commentingBlock", editor.selection!.focus.path.slice(0, 1)); }, }), ) .configure({ node: { component: CommentLeaf }, shortcuts: { setDraft: { keys: "mod+shift+m" }, }, }); export const CommentKit = [commentPlugin]; ================================================ FILE: app/src/components/editor/plugins/date-base-kit.tsx ================================================ import { BaseDatePlugin } from "@platejs/date"; import { DateElementStatic } from "@/components/ui/date-node-static"; export const BaseDateKit = [BaseDatePlugin.withComponent(DateElementStatic)]; ================================================ FILE: app/src/components/editor/plugins/discussion-kit.tsx ================================================ "use client"; import type { TComment } from "@/components/ui/comment"; import { createPlatePlugin } from "platejs/react"; import { BlockDiscussion } from "@/components/ui/block-discussion"; export interface TDiscussion { id: string; comments: TComment[]; createdAt: Date; isResolved: boolean; userId: string; documentContent?: string; } const discussionsData: TDiscussion[] = [ { id: "discussion1", comments: [ { id: "comment1", contentRich: [ { children: [ { text: "Comments are a great way to provide feedback and discuss changes.", }, ], type: "p", }, ], createdAt: new Date(Date.now() - 600_000), discussionId: "discussion1", isEdited: false, userId: "charlie", }, { id: "comment2", contentRich: [ { children: [ { text: "Agreed! The link to the docs makes it easy to learn more.", }, ], type: "p", }, ], createdAt: new Date(Date.now() - 500_000), discussionId: "discussion1", isEdited: false, userId: "bob", }, ], createdAt: new Date(), documentContent: "comments", isResolved: false, userId: "charlie", }, { id: "discussion2", comments: [ { id: "comment1", contentRich: [ { children: [ { text: "Nice demonstration of overlapping annotations with both comments and suggestions!", }, ], type: "p", }, ], createdAt: new Date(Date.now() - 300_000), discussionId: "discussion2", isEdited: false, userId: "bob", }, { id: "comment2", contentRich: [ { children: [ { text: "This helps users understand how powerful the editor can be.", }, ], type: "p", }, ], createdAt: new Date(Date.now() - 200_000), discussionId: "discussion2", isEdited: false, userId: "charlie", }, ], createdAt: new Date(), documentContent: "overlapping", isResolved: false, userId: "bob", }, ]; const avatarUrl = (seed: string) => `https://api.dicebear.com/9.x/glass/svg?seed=${seed}`; const usersData: Record = { alice: { id: "alice", avatarUrl: avatarUrl("alice6"), name: "Alice", }, bob: { id: "bob", avatarUrl: avatarUrl("bob4"), name: "Bob", }, charlie: { id: "charlie", avatarUrl: avatarUrl("charlie2"), name: "Charlie", }, }; // This plugin is purely UI. It's only used to store the discussions and users data export const discussionPlugin = createPlatePlugin({ key: "discussion", options: { currentUserId: "alice", discussions: discussionsData, users: usersData, }, }) .configure({ render: { aboveNodes: BlockDiscussion }, }) .extendSelectors(({ getOption }) => ({ currentUser: () => getOption("users")[getOption("currentUserId")], user: (id: string) => getOption("users")[id], })); export const DiscussionKit = [discussionPlugin]; ================================================ FILE: app/src/components/editor/plugins/fixed-toolbar-kit.tsx ================================================ "use client"; import { createPlatePlugin } from "platejs/react"; import { FixedToolbar } from "@/components/ui/fixed-toolbar"; import { FixedToolbarButtons } from "@/components/ui/fixed-toolbar-buttons"; export const FixedToolbarKit = [ createPlatePlugin({ key: "fixed-toolbar", render: { beforeEditable: () => (
), }, }), ]; ================================================ FILE: app/src/components/editor/plugins/floating-toolbar-kit.tsx ================================================ "use client"; import { createPlatePlugin } from "platejs/react"; import { FloatingToolbar } from "@/components/ui/floating-toolbar"; import { FloatingToolbarButtons } from "@/components/ui/floating-toolbar-buttons"; export const FloatingToolbarKit = [ createPlatePlugin({ key: "floating-toolbar", render: { afterEditable: () => ( ), }, }), ]; ================================================ FILE: app/src/components/editor/plugins/font-base-kit.tsx ================================================ import type { SlatePluginConfig } from "platejs"; import { BaseFontBackgroundColorPlugin, BaseFontColorPlugin, BaseFontFamilyPlugin, BaseFontSizePlugin, } from "@platejs/basic-styles"; import { KEYS } from "platejs"; const options = { inject: { targetPlugins: [KEYS.p] }, } satisfies SlatePluginConfig; export const BaseFontKit = [ BaseFontColorPlugin.configure(options), BaseFontBackgroundColorPlugin.configure(options), BaseFontSizePlugin.configure(options), BaseFontFamilyPlugin.configure(options), ]; ================================================ FILE: app/src/components/editor/plugins/font-kit.tsx ================================================ "use client"; import type { PlatePluginConfig } from "platejs/react"; import { FontBackgroundColorPlugin, FontColorPlugin, FontFamilyPlugin, FontSizePlugin, } from "@platejs/basic-styles/react"; import { KEYS } from "platejs"; const options = { inject: { targetPlugins: [KEYS.p] }, } satisfies PlatePluginConfig; export const FontKit = [ FontColorPlugin.configure({ inject: { ...options.inject, nodeProps: { defaultNodeValue: "black", }, }, }), FontBackgroundColorPlugin.configure(options), FontSizePlugin.configure(options), FontFamilyPlugin.configure(options), ]; ================================================ FILE: app/src/components/editor/plugins/indent-base-kit.tsx ================================================ import { BaseIndentPlugin } from "@platejs/indent"; import { KEYS } from "platejs"; export const BaseIndentKit = [ BaseIndentPlugin.configure({ inject: { targetPlugins: [...KEYS.heading, KEYS.p, KEYS.blockquote, KEYS.codeBlock, KEYS.toggle], }, options: { offset: 24, }, }), ]; ================================================ FILE: app/src/components/editor/plugins/indent-kit.tsx ================================================ "use client"; import { IndentPlugin } from "@platejs/indent/react"; import { KEYS } from "platejs"; export const IndentKit = [ IndentPlugin.configure({ inject: { targetPlugins: [...KEYS.heading, KEYS.p, KEYS.blockquote, KEYS.codeBlock, KEYS.toggle, KEYS.img], }, options: { offset: 24, }, }), ]; ================================================ FILE: app/src/components/editor/plugins/line-height-base-kit.tsx ================================================ import { BaseLineHeightPlugin } from "@platejs/basic-styles"; import { KEYS } from "platejs"; export const BaseLineHeightKit = [ BaseLineHeightPlugin.configure({ inject: { nodeProps: { defaultNodeValue: 1.5, validNodeValues: [1, 1.2, 1.5, 2, 3], }, targetPlugins: [...KEYS.heading, KEYS.p], }, }), ]; ================================================ FILE: app/src/components/editor/plugins/link-base-kit.tsx ================================================ import { BaseLinkPlugin } from "@platejs/link"; import { LinkElementStatic } from "@/components/ui/link-node-static"; export const BaseLinkKit = [BaseLinkPlugin.withComponent(LinkElementStatic)]; ================================================ FILE: app/src/components/editor/plugins/link-kit.tsx ================================================ "use client"; import { LinkPlugin } from "@platejs/link/react"; import { LinkElement } from "@/components/ui/link-node"; import { LinkFloatingToolbar } from "@/components/ui/link-toolbar"; export const LinkKit = [ LinkPlugin.configure({ render: { node: LinkElement, afterEditable: () => , }, }), ]; ================================================ FILE: app/src/components/editor/plugins/list-base-kit.tsx ================================================ import { BaseListPlugin } from "@platejs/list"; import { KEYS } from "platejs"; import { BaseIndentKit } from "@/components/editor/plugins/indent-base-kit"; import { BlockListStatic } from "@/components/ui/block-list-static"; export const BaseListKit = [ ...BaseIndentKit, BaseListPlugin.configure({ inject: { targetPlugins: [...KEYS.heading, KEYS.p, KEYS.blockquote, KEYS.codeBlock, KEYS.toggle], }, render: { belowNodes: BlockListStatic, }, }), ]; ================================================ FILE: app/src/components/editor/plugins/list-kit.tsx ================================================ "use client"; import { ListPlugin } from "@platejs/list/react"; import { KEYS } from "platejs"; import { IndentKit } from "@/components/editor/plugins/indent-kit"; import { BlockList } from "@/components/ui/block-list"; export const ListKit = [ ...IndentKit, ListPlugin.configure({ inject: { targetPlugins: [...KEYS.heading, KEYS.p, KEYS.blockquote, KEYS.codeBlock, KEYS.toggle, KEYS.img], }, render: { belowNodes: BlockList, }, }), ]; ================================================ FILE: app/src/components/editor/plugins/markdown-kit.tsx ================================================ import { MarkdownPlugin, remarkMdx, remarkMention } from "@platejs/markdown"; import { KEYS } from "platejs"; import remarkGfm from "remark-gfm"; import remarkMath from "remark-math"; export const MarkdownKit = [ MarkdownPlugin.configure({ options: { disallowedNodes: [KEYS.suggestion], remarkPlugins: [remarkMath, remarkGfm, remarkMdx, remarkMention], }, }), ]; ================================================ FILE: app/src/components/editor/plugins/math-base-kit.tsx ================================================ import { BaseEquationPlugin, BaseInlineEquationPlugin } from "@platejs/math"; import { EquationElementStatic, InlineEquationElementStatic } from "@/components/ui/equation-node-static"; export const BaseMathKit = [ BaseInlineEquationPlugin.withComponent(InlineEquationElementStatic), BaseEquationPlugin.withComponent(EquationElementStatic), ]; ================================================ FILE: app/src/components/editor/plugins/math-kit.tsx ================================================ "use client"; import { EquationPlugin, InlineEquationPlugin } from "@platejs/math/react"; import { EquationElement, InlineEquationElement } from "@/components/ui/equation-node"; export const MathKit = [ InlineEquationPlugin.withComponent(InlineEquationElement), EquationPlugin.withComponent(EquationElement), ]; ================================================ FILE: app/src/components/editor/plugins/media-base-kit.tsx ================================================ import { BaseCaptionPlugin } from "@platejs/caption"; import { BaseAudioPlugin, BaseFilePlugin, BaseImagePlugin, BaseMediaEmbedPlugin, BasePlaceholderPlugin, BaseVideoPlugin, } from "@platejs/media"; import { KEYS } from "platejs"; import { AudioElementStatic } from "@/components/ui/media-audio-node-static"; import { FileElementStatic } from "@/components/ui/media-file-node-static"; import { ImageElementStatic } from "@/components/ui/media-image-node-static"; import { VideoElementStatic } from "@/components/ui/media-video-node-static"; export const BaseMediaKit = [ BaseImagePlugin.withComponent(ImageElementStatic), BaseVideoPlugin.withComponent(VideoElementStatic), BaseAudioPlugin.withComponent(AudioElementStatic), BaseFilePlugin.withComponent(FileElementStatic), BaseCaptionPlugin.configure({ options: { query: { allow: [KEYS.img, KEYS.video, KEYS.audio, KEYS.file, KEYS.mediaEmbed], }, }, }), BaseMediaEmbedPlugin, BasePlaceholderPlugin, ]; ================================================ FILE: app/src/components/editor/plugins/mention-base-kit.tsx ================================================ import { BaseMentionPlugin } from "@platejs/mention"; import { MentionElementStatic } from "@/components/ui/mention-node-static"; export const BaseMentionKit = [BaseMentionPlugin.withComponent(MentionElementStatic)]; ================================================ FILE: app/src/components/editor/plugins/suggestion-base-kit.tsx ================================================ import { BaseSuggestionPlugin } from "@platejs/suggestion"; import { SuggestionLeafStatic } from "@/components/ui/suggestion-node-static"; export const BaseSuggestionKit = [BaseSuggestionPlugin.withComponent(SuggestionLeafStatic)]; ================================================ FILE: app/src/components/editor/plugins/suggestion-kit.tsx ================================================ "use client"; import { type BaseSuggestionConfig, BaseSuggestionPlugin } from "@platejs/suggestion"; import { type ExtendConfig, type Path, isSlateEditor, isSlateElement, isSlateString } from "platejs"; import { toTPlatePlugin } from "platejs/react"; import { BlockSuggestion } from "@/components/ui/block-suggestion"; import { SuggestionLeaf, SuggestionLineBreak } from "@/components/ui/suggestion-node"; import { discussionPlugin } from "./discussion-kit"; export type SuggestionConfig = ExtendConfig< BaseSuggestionConfig, { activeId: string | null; hoverId: string | null; uniquePathMap: Map; } >; export const suggestionPlugin = toTPlatePlugin(BaseSuggestionPlugin, ({ editor }) => ({ options: { activeId: null, currentUserId: editor.getOption(discussionPlugin, "currentUserId"), hoverId: null, uniquePathMap: new Map(), }, })).configure({ handlers: { // unset active suggestion when clicking outside of suggestion onClick: ({ api, event, setOption, type }) => { let leaf = event.target as HTMLElement; let isSet = false; const unsetActiveSuggestion = () => { setOption("activeId", null); isSet = true; }; if (!isSlateString(leaf)) unsetActiveSuggestion(); while (leaf.parentElement && !isSlateElement(leaf.parentElement) && !isSlateEditor(leaf.parentElement)) { if (leaf.classList.contains(`slate-${type}`)) { const suggestionEntry = api.suggestion!.node({ isText: true }); if (!suggestionEntry) { unsetActiveSuggestion(); break; } const id = api.suggestion!.nodeId(suggestionEntry[0]); setOption("activeId", id ?? null); isSet = true; break; } leaf = leaf.parentElement; } if (!isSet) unsetActiveSuggestion(); }, }, render: { belowNodes: SuggestionLineBreak as any, node: SuggestionLeaf, belowRootNodes: ({ api, element }) => { if (!api.suggestion!.isBlockSuggestion(element)) { return null; } return ; }, }, }); export const SuggestionKit = [suggestionPlugin]; ================================================ FILE: app/src/components/editor/plugins/table-base-kit.tsx ================================================ import { BaseTableCellHeaderPlugin, BaseTableCellPlugin, BaseTablePlugin, BaseTableRowPlugin } from "@platejs/table"; import { TableCellElementStatic, TableCellHeaderElementStatic, TableElementStatic, TableRowElementStatic, } from "@/components/ui/table-node-static"; export const BaseTableKit = [ BaseTablePlugin.withComponent(TableElementStatic), BaseTableRowPlugin.withComponent(TableRowElementStatic), BaseTableCellPlugin.withComponent(TableCellElementStatic), BaseTableCellHeaderPlugin.withComponent(TableCellHeaderElementStatic), ]; ================================================ FILE: app/src/components/editor/plugins/table-kit.tsx ================================================ "use client"; import { TableCellHeaderPlugin, TableCellPlugin, TablePlugin, TableRowPlugin } from "@platejs/table/react"; import { TableCellElement, TableCellHeaderElement, TableElement, TableRowElement } from "@/components/ui/table-node"; export const TableKit = [ TablePlugin.withComponent(TableElement), TableRowPlugin.withComponent(TableRowElement), TableCellPlugin.withComponent(TableCellElement), TableCellHeaderPlugin.withComponent(TableCellHeaderElement), ]; ================================================ FILE: app/src/components/editor/plugins/toc-base-kit.tsx ================================================ import { BaseTocPlugin } from "@platejs/toc"; import { TocElementStatic } from "@/components/ui/toc-node-static"; export const BaseTocKit = [BaseTocPlugin.withComponent(TocElementStatic)]; ================================================ FILE: app/src/components/editor/plugins/toggle-base-kit.tsx ================================================ import { BaseTogglePlugin } from "@platejs/toggle"; import { ToggleElementStatic } from "@/components/ui/toggle-node-static"; export const BaseToggleKit = [BaseTogglePlugin.withComponent(ToggleElementStatic)]; ================================================ FILE: app/src/components/editor/transforms.ts ================================================ "use client"; import type { PlateEditor } from "platejs/react"; import { insertCallout } from "@platejs/callout"; import { insertCodeBlock, toggleCodeBlock } from "@platejs/code-block"; import { insertDate } from "@platejs/date"; import { insertColumnGroup, toggleColumnGroup } from "@platejs/layout"; import { triggerFloatingLink } from "@platejs/link/react"; import { insertEquation, insertInlineEquation } from "@platejs/math"; import { insertAudioPlaceholder, insertFilePlaceholder, insertMedia, insertVideoPlaceholder } from "@platejs/media"; import { SuggestionPlugin } from "@platejs/suggestion/react"; import { TablePlugin } from "@platejs/table/react"; import { insertToc } from "@platejs/toc"; import { type NodeEntry, type Path, type TElement, KEYS, PathApi } from "platejs"; const ACTION_THREE_COLUMNS = "action_three_columns"; const insertList = (editor: PlateEditor, type: string) => { editor.tf.insertNodes( editor.api.create.block({ indent: 1, listStyleType: type, }), { select: true }, ); }; const insertBlockMap: Record void> = { [KEYS.listTodo]: insertList, [KEYS.ol]: insertList, [KEYS.ul]: insertList, [ACTION_THREE_COLUMNS]: (editor) => insertColumnGroup(editor, { columns: 3, select: true }), [KEYS.audio]: (editor) => insertAudioPlaceholder(editor, { select: true }), [KEYS.callout]: (editor) => insertCallout(editor, { select: true }), [KEYS.codeBlock]: (editor) => insertCodeBlock(editor, { select: true }), [KEYS.equation]: (editor) => insertEquation(editor, { select: true }), [KEYS.file]: (editor) => insertFilePlaceholder(editor, { select: true }), [KEYS.img]: (editor) => insertMedia(editor, { select: true, type: KEYS.img, }), [KEYS.mediaEmbed]: (editor) => insertMedia(editor, { select: true, type: KEYS.mediaEmbed, }), [KEYS.table]: (editor) => editor.getTransforms(TablePlugin).insert.table({}, { select: true }), [KEYS.toc]: (editor) => insertToc(editor, { select: true }), [KEYS.video]: (editor) => insertVideoPlaceholder(editor, { select: true }), }; const insertInlineMap: Record void> = { [KEYS.date]: (editor) => insertDate(editor, { select: true }), [KEYS.inlineEquation]: (editor) => insertInlineEquation(editor, "", { select: true }), [KEYS.link]: (editor) => triggerFloatingLink(editor, { focused: true }), }; export const insertBlock = (editor: PlateEditor, type: string) => { editor.tf.withoutNormalizing(() => { const block = editor.api.block(); if (!block) return; if (type in insertBlockMap) { insertBlockMap[type](editor, type); } else { editor.tf.insertNodes(editor.api.create.block({ type }), { at: PathApi.next(block[1]), select: true, }); } if (getBlockType(block[0]) !== type) { editor.getApi(SuggestionPlugin).suggestion.withoutSuggestions(() => { editor.tf.removeNodes({ previousEmptyBlock: true }); }); } }); }; export const insertInlineElement = (editor: PlateEditor, type: string) => { if (insertInlineMap[type]) { insertInlineMap[type](editor, type); } }; const setList = (editor: PlateEditor, type: string, entry: NodeEntry) => { editor.tf.setNodes( editor.api.create.block({ indent: 1, listStyleType: type, }), { at: entry[1], }, ); }; const setBlockMap: Record) => void> = { [KEYS.listTodo]: setList, [KEYS.ol]: setList, [KEYS.ul]: setList, [ACTION_THREE_COLUMNS]: (editor) => toggleColumnGroup(editor, { columns: 3 }), [KEYS.codeBlock]: (editor) => toggleCodeBlock(editor), }; export const setBlockType = (editor: PlateEditor, type: string, { at }: { at?: Path } = {}) => { editor.tf.withoutNormalizing(() => { const setEntry = (entry: NodeEntry) => { const [node, path] = entry; if (node[KEYS.listType]) { editor.tf.unsetNodes([KEYS.listType, "indent"], { at: path }); } if (type in setBlockMap) { return setBlockMap[type](editor, type, entry); } if (node.type !== type) { editor.tf.setNodes({ type }, { at: path }); } }; if (at) { const entry = editor.api.node(at); if (entry) { setEntry(entry); return; } } const entries = editor.api.blocks({ mode: "lowest" }); entries.forEach((entry) => setEntry(entry)); }); }; export const getBlockType = (block: TElement) => { if (block[KEYS.listType]) { if (block[KEYS.listType] === KEYS.ol) { return KEYS.ol; } else if (block[KEYS.listType] === KEYS.listTodo) { return KEYS.listTodo; } else { return KEYS.ul; } } return block.type; }; ================================================ FILE: app/src/components/key-tooltip.tsx ================================================ import { Tooltip, TooltipContent, TooltipTrigger } from "@/components/ui/tooltip"; import { activeProjectAtom } from "@/state"; import { parseEmacsKey } from "@/utils/emacs"; import { useAtom } from "jotai"; import { ReactNode, useEffect, useState } from "react"; import { useTranslation } from "react-i18next"; import { RenderKey } from "./ui/key-bind"; export default function KeyTooltip({ keyId, children = <> }: { keyId: string; children: ReactNode }) { const [keySeq, setKeySeq] = useState[number][]>(); const [activeProject] = useAtom(activeProjectAtom); const { t } = useTranslation("keyBinds"); useEffect(() => { activeProject?.keyBinds.get(keyId)?.then((key) => { if (key) { const keyStr = typeof key === "string" ? key : key.key; const parsed = parseEmacsKey(keyStr); if (parsed.length > 0) { setKeySeq(parsed); } else { setKeySeq(undefined); } } else { setKeySeq(undefined); } }); }, [keyId, activeProject]); return ( {children} {/* 给下面的组件加属性,sideOffset={12},可以缓解右键菜单按钮比较密集的tooltip遮挡的问题 */} {t(`${keyId}.title`)}
{keySeq ? keySeq.map((data, index) => ) : "[未绑定快捷键]"}
); } ================================================ FILE: app/src/components/render-sub-windows.tsx ================================================ import { SimpleCard } from "@/components/ui/card"; import { SubWindow } from "@/core/service/SubWindow"; import { cn } from "@/utils/cn"; import { Vector } from "@graphif/data-structures"; import { Rectangle } from "@graphif/shapes"; import { Transition } from "@headlessui/react"; import { X } from "lucide-react"; /** * 这个组件中管理了所有的 子窗口 * @returns */ export default function RenderSubWindows() { const subWindows = SubWindow.use(); const onClickInner = (win: SubWindow.Window) => { if (win.closeWhenClickInside) { SubWindow.close(win.id); } }; return (
{subWindows.map((win: SubWindow.Window) => ( // transition 组件可以让关闭流程更平滑 onClickInner(win)} onMouseDown={(e) => { SubWindow.focus(win.id); // 如果按到的元素的父元素都没有data-pg-drag-region属性,就不移动窗口 if (!(e.target as HTMLElement).closest("[data-pg-drag-region]")) { return; } const start = new Vector(e.clientX, e.clientY); const onMouseUp = () => { window.removeEventListener("mouseup", onMouseUp); window.removeEventListener("mousemove", onMouseMove); }; const onMouseMove = (e: MouseEvent) => { const delta = new Vector(e.clientX, e.clientY).subtract(start); const newRect = win.rect.translate(delta); SubWindow.update(win.id, { rect: newRect }); }; window.addEventListener("mouseup", onMouseUp); window.addEventListener("mousemove", onMouseMove); }} onTouchStart={(e) => { SubWindow.focus(win.id); if (e.touches.length > 1) return; const touch = e.touches[0]; // 如果按到的元素的父元素都没有data-pg-drag-region属性,就不移动窗口 if (!(e.target as HTMLElement).closest("[data-pg-drag-region]")) { return; } const start = new Vector(touch.clientX, touch.clientY); const onTouchEnd = () => { window.removeEventListener("touchend", onTouchEnd); window.removeEventListener("touchmove", onTouchMove); }; const onTouchMove = (e: TouchEvent) => { if (e.touches.length > 1) return; const touch = e.touches[0]; const delta = new Vector(touch.clientX, touch.clientY).subtract(start); const newRect = win.rect.translate(delta); SubWindow.update(win.id, { rect: newRect }); }; window.addEventListener("touchend", onTouchEnd); window.addEventListener("touchmove", onTouchMove); }} >
{win.title}
{win.closable && ( { SubWindow.close(win.id); }} /> )}
{win.children && win.children instanceof Object && "props" in win.children ? { ...win.children, props: { ...(win.children.props || {}), winId: win.id, }, } : win.children}
{/* 添加一个可调整大小的边缘,这里以右下角为例 */}
{ const start = new Vector(e.clientX, e.clientY); const onMouseUp = () => { window.removeEventListener("mouseup", onMouseUp); window.removeEventListener("mousemove", onMouseMove); }; const onMouseMove = (e: MouseEvent) => { const delta = new Vector(e.clientX, e.clientY).subtract(start); SubWindow.update(win.id, { rect: new Rectangle(win.rect.location, win.rect.size.add(delta)), }); }; window.addEventListener("mouseup", onMouseUp); window.addEventListener("mousemove", onMouseMove); }} onTouchStart={(e) => { if (e.touches.length > 1) return; const touch = e.touches[0]; const start = new Vector(touch.clientX, touch.clientY); const onTouchEnd = () => { window.removeEventListener("touchend", onTouchEnd); window.removeEventListener("touchmove", onTouchMove); }; const onTouchMove = (e: TouchEvent) => { if (e.touches.length > 1) return; const touch = e.touches[0]; const delta = new Vector(touch.clientX, touch.clientY).subtract(start); SubWindow.update(win.id, { rect: new Rectangle(win.rect.location, win.rect.size.add(delta)), }); }; window.addEventListener("touchend", onTouchEnd); window.addEventListener("touchmove", onTouchMove); }} /> {/* 左下角 */}
{ const start = new Vector(e.clientX, e.clientY); const onMouseUp = () => { window.removeEventListener("mouseup", onMouseUp); window.removeEventListener("mousemove", onMouseMove); }; const onMouseMove = (e: MouseEvent) => { const delta = new Vector(e.clientX, e.clientY).subtract(start); SubWindow.update(win.id, { rect: new Rectangle( new Vector(win.rect.left + delta.x, win.rect.top), new Vector(win.rect.width - delta.x, win.rect.height + delta.y), ), }); }; window.addEventListener("mouseup", onMouseUp); window.addEventListener("mousemove", onMouseMove); }} onTouchStart={(e) => { if (e.touches.length > 1) return; const touch = e.touches[0]; const start = new Vector(touch.clientX, touch.clientY); const onTouchEnd = () => { window.removeEventListener("touchend", onTouchEnd); window.removeEventListener("touchmove", onTouchMove); }; const onTouchMove = (e: TouchEvent) => { if (e.touches.length > 1) return; const touch = e.touches[0]; const delta = new Vector(touch.clientX, touch.clientY).subtract(start); SubWindow.update(win.id, { rect: new Rectangle( new Vector(win.rect.left + delta.x, win.rect.top), new Vector(win.rect.width - delta.x, win.rect.height + delta.y), ), }); }; window.addEventListener("touchend", onTouchEnd); window.addEventListener("touchmove", onTouchMove); }} /> ))}
); } ================================================ FILE: app/src/components/right-toolbar.tsx ================================================ import { Settings, settingsSchema } from "@/core/service/Settings"; import { QuickSettingsManager } from "@/core/service/QuickSettingsManager"; import { settingsIcons } from "@/core/service/SettingsIcons"; import { Button } from "./ui/button"; import { Switch } from "./ui/switch"; import { Toolbar } from "./ui/toolbar"; import { Tooltip, TooltipContent, TooltipTrigger } from "./ui/tooltip"; import { Dialog, DialogContent, DialogDescription, DialogHeader, DialogTitle } from "./ui/dialog"; import { useTranslation } from "react-i18next"; import { useEffect, useState } from "react"; import { cn } from "@/utils/cn"; import { Fragment } from "react"; import { useAtom } from "jotai"; import { isClassroomModeAtom } from "@/state"; /** * 单个快捷设置项按钮 */ function QuickSettingButton({ settingKey, isHovered, }: { settingKey: keyof ReturnType; isHovered: boolean; }) { const { t } = useTranslation("settings"); const [value, setValue] = useState(Settings[settingKey] as boolean); const [showDialog, setShowDialog] = useState(false); useEffect(() => { const unwatch = Settings.watch(settingKey, (newValue) => { if (typeof newValue === "boolean") { setValue(newValue); } }); return unwatch; }, [settingKey]); const handleToggle = () => { const currentValue = Settings[settingKey]; if (typeof currentValue === "boolean") { // @ts-expect-error 设置值 Settings[settingKey] = !currentValue; } }; const handleIconClick = () => { setShowDialog(true); }; const Icon = settingsIcons[settingKey as keyof typeof settingsIcons] ?? Fragment; const title = t(`${settingKey}.title` as string); const description = t(`${settingKey}.description` as string); if (Icon === Fragment) return null; return ( <>
{title}
{title} {description} ); } /** * 右侧工具栏 * 显示用户自定义的快捷设置项开关 */ export default function RightToolbar() { const [quickSettings, setQuickSettings] = useState([]); const [isHovered, setIsHovered] = useState(false); const [isClassroomMode] = useAtom(isClassroomModeAtom); const loadQuickSettings = async () => { const items = await QuickSettingsManager.getQuickSettings(); setQuickSettings(items); }; useEffect(() => { // 加载快捷设置项列表 loadQuickSettings(); // 定期检查更新(每5秒) const interval = setInterval(() => { loadQuickSettings(); }, 5000); // 监听窗口焦点事件,当窗口重新获得焦点时刷新 const handleFocus = () => { loadQuickSettings(); }; window.addEventListener("focus", handleFocus); return () => { clearInterval(interval); window.removeEventListener("focus", handleFocus); }; }, []); return (
setIsHovered(true)} onMouseLeave={() => setIsHovered(false)} > {quickSettings.map((item) => ( ))}
); } ================================================ FILE: app/src/components/theme-mode-switch.tsx ================================================ import { Settings } from "@/core/service/Settings"; import { Switch } from "./ui/switch"; import { Sun, Moon } from "lucide-react"; import { cn } from "@/utils/cn"; import { Tooltip, TooltipContent, TooltipTrigger } from "./ui/tooltip"; import { useTranslation } from "react-i18next"; export default function ThemeModeSwitch() { const { t } = useTranslation("settings"); const [themeMode] = Settings.use("themeMode"); const isDark = themeMode === "dark"; const handleToggle = () => { Settings.themeMode = isDark ? "light" : "dark"; }; return (
{/* Hidden default thumb */} {/* Custom thumb with icon */} {isDark ? : }
{isDark ? t("themeMode.options.dark") : t("themeMode.options.light")}
); } ================================================ FILE: app/src/components/toolbar-content.tsx ================================================ import { Settings } from "@/core/service/Settings"; import { Button } from "./ui/button"; import { Toolbar } from "./ui/toolbar"; import { MousePointer, Pencil, Waypoints } from "lucide-react"; import { Tooltip } from "./ui/tooltip"; import { TooltipContent, TooltipTrigger } from "@radix-ui/react-tooltip"; import { useTranslation } from "react-i18next"; import { useEffect, useState } from "react"; import { cn } from "@/utils/cn"; import { ColorManager } from "@/core/service/feedbackService/ColorManager"; import { Color } from "@graphif/data-structures"; import { useAtom } from "jotai"; import { isClassroomModeAtom } from "@/state"; /** * 底部工具栏 * @returns */ export default function ToolbarContent() { const { t } = useTranslation("keyBinds"); const [isClassroomMode] = useAtom(isClassroomModeAtom); const [leftMouseMode, setLeftMouseMode] = useState(Settings.mouseLeftMode); useEffect(() => { setLeftMouseMode(Settings.mouseLeftMode); }, [Settings.mouseLeftMode]); return (
{t("checkoutLeftMouseToSelectAndMove.title")} {t("checkoutLeftMouseToDrawing.title")} {t("checkoutLeftMouseToConnectAndCutting.title")} {leftMouseMode === "draw" && (
)}
); } const DrawingColorLine: React.FC = () => { const [userColorList, setUserColorList] = useState([]); const [currentDrawColor, setCurrentDrawColor] = useState(Color.Transparent); useEffect(() => { ColorManager.getUserEntityFillColors().then((colors) => { setUserColorList(colors); }); setCurrentDrawColor(new Color(...Settings.autoFillPenStrokeColor)); }, []); const handleChangeColor = (color: Color) => { Settings.autoFillPenStrokeColor = color.toArray(); setCurrentDrawColor(color.clone()); }; return (
{userColorList.map((color) => { return (
{ handleChangeColor(color); }} /> ); })}
); }; ================================================ FILE: app/src/components/ui/ai-node.tsx ================================================ "use client"; import { AIChatPlugin } from "@platejs/ai/react"; import { type PlateElementProps, type PlateTextProps, PlateElement, PlateText, usePluginOption } from "platejs/react"; import { cn } from "@/utils/cn"; export function AILeaf(props: PlateTextProps) { const streaming = usePluginOption(AIChatPlugin, "streaming"); const streamingLeaf = props.editor.getApi(AIChatPlugin).aiChat.node({ streaming: true }); const isLast = streamingLeaf?.[0] === props.text; return ( ); } export function AIAnchorElement(props: PlateElementProps) { return (
); } ================================================ FILE: app/src/components/ui/ai-toolbar-button.tsx ================================================ // @ts-nocheck "use client"; import * as React from "react"; import { AIChatPlugin } from "@platejs/ai/react"; import { useEditorPlugin } from "platejs/react"; import { ToolbarButton } from "./toolbar"; export function AIToolbarButton(props: React.ComponentProps) { const { api } = useEditorPlugin(AIChatPlugin); return ( { api.aiChat.show(); }} onMouseDown={(e) => { e.preventDefault(); }} /> ); } ================================================ FILE: app/src/components/ui/alert-dialog.tsx ================================================ import * as React from "react"; import * as AlertDialogPrimitive from "@radix-ui/react-alert-dialog"; import { cn } from "@/utils/cn"; import { buttonVariants } from "@/components/ui/button"; function AlertDialog({ ...props }: React.ComponentProps) { return ; } function AlertDialogTrigger({ ...props }: React.ComponentProps) { return ; } function AlertDialogPortal({ ...props }: React.ComponentProps) { return ; } function AlertDialogOverlay({ className, ...props }: React.ComponentProps) { return ( ); } function AlertDialogContent({ className, ...props }: React.ComponentProps) { return ( ); } function AlertDialogHeader({ className, ...props }: React.ComponentProps<"div">) { return (
); } function AlertDialogFooter({ className, ...props }: React.ComponentProps<"div">) { return (
); } function AlertDialogTitle({ className, ...props }: React.ComponentProps) { return ( ); } function AlertDialogDescription({ className, ...props }: React.ComponentProps) { return ( ); } function AlertDialogAction({ className, ...props }: React.ComponentProps) { return ; } function AlertDialogCancel({ className, ...props }: React.ComponentProps) { return ; } export { AlertDialog, AlertDialogPortal, AlertDialogOverlay, AlertDialogTrigger, AlertDialogContent, AlertDialogHeader, AlertDialogFooter, AlertDialogTitle, AlertDialogDescription, AlertDialogAction, AlertDialogCancel, }; ================================================ FILE: app/src/components/ui/alert.tsx ================================================ import * as React from "react"; import { cva, type VariantProps } from "class-variance-authority"; import { cn } from "@/utils/cn"; const alertVariants = cva( "relative w-full rounded-lg border px-4 py-3 text-sm grid has-[>svg]:grid-cols-[calc(var(--spacing)*4)_1fr] grid-cols-[0_1fr] has-[>svg]:gap-x-3 gap-y-0.5 items-start [&>svg]:size-4 [&>svg]:translate-y-0.5 [&>svg]:text-current", { variants: { variant: { default: "bg-card text-card-foreground", destructive: "text-destructive bg-card [&>svg]:text-current *:data-[slot=alert-description]:text-destructive/90", }, }, defaultVariants: { variant: "default", }, }, ); function Alert({ className, variant, ...props }: React.ComponentProps<"div"> & VariantProps) { return
; } function AlertTitle({ className, ...props }: React.ComponentProps<"div">) { return (
); } function AlertDescription({ className, ...props }: React.ComponentProps<"div">) { return (
); } export { Alert, AlertTitle, AlertDescription }; ================================================ FILE: app/src/components/ui/align-toolbar-button.tsx ================================================ "use client"; import * as React from "react"; import type { Alignment } from "@platejs/basic-styles"; import type { DropdownMenuProps } from "@radix-ui/react-dropdown-menu"; import { TextAlignPlugin } from "@platejs/basic-styles/react"; import { AlignCenterIcon, AlignJustifyIcon, AlignLeftIcon, AlignRightIcon } from "lucide-react"; import { useEditorPlugin, useSelectionFragmentProp } from "platejs/react"; import { DropdownMenu, DropdownMenuContent, DropdownMenuRadioGroup, DropdownMenuRadioItem, DropdownMenuTrigger, } from "@/components/ui/dropdown-menu"; import { ToolbarButton } from "./toolbar"; const items = [ { icon: AlignLeftIcon, value: "left", }, { icon: AlignCenterIcon, value: "center", }, { icon: AlignRightIcon, value: "right", }, { icon: AlignJustifyIcon, value: "justify", }, ]; export function AlignToolbarButton(props: DropdownMenuProps) { const { editor, tf } = useEditorPlugin(TextAlignPlugin); const value = useSelectionFragmentProp({ defaultValue: "start", getProp: (node) => node.align, }) ?? "left"; const [open, setOpen] = React.useState(false); const IconValue = items.find((item) => item.value === value)?.icon ?? AlignLeftIcon; return ( { tf.textAlign.setNodes(value as Alignment); editor.tf.focus(); }} > {items.map(({ icon: Icon, value: itemValue }) => ( ))} ); } ================================================ FILE: app/src/components/ui/avatar.tsx ================================================ import * as React from "react"; import * as AvatarPrimitive from "@radix-ui/react-avatar"; import { cn } from "@/utils/cn"; function Avatar({ className, ...props }: React.ComponentProps) { return ( ); } function AvatarImage({ className, ...props }: React.ComponentProps) { return ( ); } function AvatarFallback({ className, ...props }: React.ComponentProps) { return ( ); } export { Avatar, AvatarImage, AvatarFallback }; ================================================ FILE: app/src/components/ui/block-discussion.tsx ================================================ // @ts-nocheck "use client"; import * as React from "react"; import type { PlateElementProps, RenderNodeWrapper } from "platejs/react"; import { getDraftCommentKey } from "@platejs/comment"; import { CommentPlugin } from "@platejs/comment/react"; import { SuggestionPlugin } from "@platejs/suggestion/react"; import { MessageSquareTextIcon, MessagesSquareIcon, PencilLineIcon } from "lucide-react"; import { type AnyPluginConfig, type NodeEntry, type Path, type TCommentText, type TElement, type TSuggestionText, PathApi, TextApi, } from "platejs"; import { useEditorPlugin, useEditorRef, usePluginOption } from "platejs/react"; import { commentPlugin } from "@/components/editor/plugins/comment-kit"; import { type TDiscussion, discussionPlugin } from "@/components/editor/plugins/discussion-kit"; import { suggestionPlugin } from "@/components/editor/plugins/suggestion-kit"; import { Button } from "@/components/ui/button"; import { Popover, PopoverAnchor, PopoverContent, PopoverTrigger } from "@/components/ui/popover"; import { BlockSuggestionCard, isResolvedSuggestion, useResolveSuggestion } from "./block-suggestion"; import { Comment, CommentCreateForm } from "./comment"; export const BlockDiscussion: RenderNodeWrapper = (props) => { const { editor, element } = props; const commentsApi = editor.getApi(CommentPlugin).comment; const blockPath = editor.api.findPath(element); // avoid duplicate in table or column if (!blockPath || blockPath.length > 1) return; const draftCommentNode = commentsApi.node({ at: blockPath, isDraft: true }); const commentNodes = [...commentsApi.nodes({ at: blockPath })]; const suggestionNodes = [...editor.getApi(SuggestionPlugin).suggestion.nodes({ at: blockPath })]; if (commentNodes.length === 0 && suggestionNodes.length === 0 && !draftCommentNode) { return; } return (props) => ( ); }; const BlockCommentContent = ({ blockPath, children, commentNodes, draftCommentNode, suggestionNodes, }: PlateElementProps & { blockPath: Path; commentNodes: NodeEntry[]; draftCommentNode: NodeEntry | undefined; suggestionNodes: NodeEntry[]; }) => { const editor = useEditorRef(); const resolvedSuggestions = useResolveSuggestion(suggestionNodes, blockPath); const resolvedDiscussions = useResolvedDiscussion(commentNodes, blockPath); const suggestionsCount = resolvedSuggestions.length; const discussionsCount = resolvedDiscussions.length; const totalCount = suggestionsCount + discussionsCount; const activeSuggestionId = usePluginOption(suggestionPlugin, "activeId"); const activeSuggestion = activeSuggestionId && resolvedSuggestions.find((s) => s.suggestionId === activeSuggestionId); const commentingBlock = usePluginOption(commentPlugin, "commentingBlock"); const activeCommentId = usePluginOption(commentPlugin, "activeId"); const isCommenting = activeCommentId === getDraftCommentKey(); const activeDiscussion = activeCommentId && resolvedDiscussions.find((d) => d.id === activeCommentId); const noneActive = !activeSuggestion && !activeDiscussion; const sortedMergedData = [...resolvedDiscussions, ...resolvedSuggestions].sort( (a, b) => a.createdAt.getTime() - b.createdAt.getTime(), ); const selected = resolvedDiscussions.some((d) => d.id === activeCommentId) || resolvedSuggestions.some((s) => s.suggestionId === activeSuggestionId); const [_open, setOpen] = React.useState(selected); // in some cases, we may comment the multiple blocks const commentingCurrent = !!commentingBlock && PathApi.equals(blockPath, commentingBlock); const open = _open || selected || (isCommenting && !!draftCommentNode && commentingCurrent); const anchorElement = React.useMemo(() => { let activeNode: NodeEntry | undefined; if (activeSuggestion) { activeNode = suggestionNodes.find( ([node]) => TextApi.isText(node) && editor.getApi(SuggestionPlugin).suggestion.nodeId(node) === activeSuggestion.suggestionId, ); } if (activeCommentId) { if (activeCommentId === getDraftCommentKey()) { activeNode = draftCommentNode; } else { activeNode = commentNodes.find( ([node]) => editor.getApi(commentPlugin).comment.nodeId(node) === activeCommentId, ); } } if (!activeNode) return null; return editor.api.toDOMNode(activeNode[0])!; // eslint-disable-next-line react-hooks/exhaustive-deps }, [open, activeSuggestion, activeCommentId, editor.api, suggestionNodes, draftCommentNode, commentNodes]); if (suggestionsCount + resolvedDiscussions.length === 0 && !draftCommentNode) return
{children}
; return (
{ if (!_open_ && isCommenting && draftCommentNode) { editor.tf.unsetNodes(getDraftCommentKey(), { at: [], mode: "lowest", match: (n) => n[getDraftCommentKey()], }); } setOpen(_open_); }} >
{children}
{anchorElement && } e.preventDefault()} onOpenAutoFocus={(e) => e.preventDefault()} align="center" side="bottom" > {isCommenting ? ( ) : ( {noneActive ? ( sortedMergedData.map((item, index) => isResolvedSuggestion(item) ? ( ) : ( ), ) ) : ( {activeSuggestion && ( )} {activeDiscussion && } )} )} {totalCount > 0 && (
)}
); }; function BlockComment({ discussion, isLast }: { discussion: TDiscussion; isLast: boolean }) { const [editingId, setEditingId] = React.useState(null); return (
{discussion.comments.map((comment, index) => ( ))}
{!isLast &&
} ); } const useResolvedDiscussion = (commentNodes: NodeEntry[], blockPath: Path) => { const { api, getOption, setOption } = useEditorPlugin(commentPlugin); const discussions = usePluginOption(discussionPlugin, "discussions"); commentNodes.forEach(([node]) => { const id = api.comment.nodeId(node); const map = getOption("uniquePathMap"); if (!id) return; const previousPath = map.get(id); // If there are no comment nodes in the corresponding path in the map, then update it. if (PathApi.isPath(previousPath)) { const nodes = api.comment.node({ id, at: previousPath }); if (!nodes) { setOption("uniquePathMap", new Map(map).set(id, blockPath)); return; } return; } // TODO: fix throw error setOption("uniquePathMap", new Map(map).set(id, blockPath)); }); const commentsIds = new Set(commentNodes.map(([node]) => api.comment.nodeId(node)).filter(Boolean)); const resolvedDiscussions = discussions .map((d: TDiscussion) => ({ ...d, createdAt: new Date(d.createdAt), })) .filter((item: TDiscussion) => { /** If comment cross blocks just show it in the first block */ const commentsPathMap = getOption("uniquePathMap"); const firstBlockPath = commentsPathMap.get(item.id); if (!firstBlockPath) return false; if (!PathApi.equals(firstBlockPath, blockPath)) return false; return api.comment.has({ id: item.id }) && commentsIds.has(item.id) && !item.isResolved; }); return resolvedDiscussions; }; ================================================ FILE: app/src/components/ui/block-list-static.tsx ================================================ import * as React from "react"; import type { RenderStaticNodeWrapper, SlateRenderElementProps, TListElement } from "platejs"; import { isOrderedList } from "@platejs/list"; import { CheckIcon } from "lucide-react"; import { cn } from "@/utils/cn"; const config: Record< string, { Li: React.FC; Marker: React.FC; } > = { todo: { Li: TodoLiStatic, Marker: TodoMarkerStatic, }, }; export const BlockListStatic: RenderStaticNodeWrapper = (props) => { if (!props.element.listStyleType) return; return (props) => ; }; function List(props: SlateRenderElementProps) { const { listStart, listStyleType } = props.element as TListElement; const { Li, Marker } = config[listStyleType] ?? {}; const List = isOrderedList(props.element) ? "ol" : "ul"; return ( {Marker && } {Li ?
  • :
  • {props.children}
  • }
    ); } function TodoMarkerStatic(props: SlateRenderElementProps) { const checked = props.element.checked as boolean; return (
    ); } function TodoLiStatic(props: SlateRenderElementProps) { return (
  • {props.children}
  • ); } ================================================ FILE: app/src/components/ui/block-list.tsx ================================================ "use client"; import React from "react"; import type { TListElement } from "platejs"; import { isOrderedList } from "@platejs/list"; import { useTodoListElement, useTodoListElementState } from "@platejs/list/react"; import { type PlateElementProps, type RenderNodeWrapper, useReadOnly } from "platejs/react"; import { Checkbox } from "@/components/ui/checkbox"; import { cn } from "@/utils/cn"; const config: Record< string, { Li: React.FC; Marker: React.FC; } > = { todo: { Li: TodoLi, Marker: TodoMarker, }, }; export const BlockList: RenderNodeWrapper = (props) => { if (!props.element.listStyleType) return; return (props) => ; }; function List(props: PlateElementProps) { const { listStart, listStyleType } = props.element as TListElement; const { Li, Marker } = config[listStyleType] ?? {}; const List = isOrderedList(props.element) ? "ol" : "ul"; return ( {Marker && } {Li ?
  • :
  • {props.children}
  • }
    ); } function TodoMarker(props: PlateElementProps) { const state = useTodoListElementState({ element: props.element }); const { checkboxProps } = useTodoListElement(state); const readOnly = useReadOnly(); return (
    ); } function TodoLi(props: PlateElementProps) { return (
  • {props.children}
  • ); } ================================================ FILE: app/src/components/ui/block-selection.tsx ================================================ // @ts-nocheck "use client"; import { DndPlugin } from "@platejs/dnd"; import { useBlockSelected } from "@platejs/selection/react"; import { cva } from "class-variance-authority"; import { type PlateElementProps, usePluginOption } from "platejs/react"; export const blockSelectionVariants = cva( "pointer-events-none absolute inset-0 z-1 bg-brand/[.13] transition-opacity", { defaultVariants: { active: true, }, variants: { active: { false: "opacity-0", true: "opacity-100", }, }, }, ); export function BlockSelection(props: PlateElementProps) { const isBlockSelected = useBlockSelected(); const isDragging = usePluginOption(DndPlugin, "isDragging"); if (!isBlockSelected || props.plugin.key === "tr" || props.plugin.key === "table") return null; return (
    ); } ================================================ FILE: app/src/components/ui/block-suggestion.tsx ================================================ "use client"; import * as React from "react"; import type { TResolvedSuggestion } from "@platejs/suggestion"; import { acceptSuggestion, getSuggestionKey, keyId2SuggestionId, rejectSuggestion } from "@platejs/suggestion"; import { SuggestionPlugin } from "@platejs/suggestion/react"; import { CheckIcon, XIcon } from "lucide-react"; import { type NodeEntry, type Path, type TElement, type TSuggestionElement, type TSuggestionText, ElementApi, KEYS, PathApi, TextApi, } from "platejs"; import { useEditorPlugin, usePluginOption } from "platejs/react"; import { Avatar, AvatarFallback, AvatarImage } from "@/components/ui/avatar"; import { Button } from "@/components/ui/button"; import { cn } from "@/utils/cn"; import { type TDiscussion, discussionPlugin } from "@/components/editor/plugins/discussion-kit"; import { suggestionPlugin } from "@/components/editor/plugins/suggestion-kit"; import { type TComment, Comment, CommentCreateForm, formatCommentDate } from "./comment"; export interface ResolvedSuggestion extends TResolvedSuggestion { comments: TComment[]; } const BLOCK_SUGGESTION = "__block__"; const TYPE_TEXT_MAP: Record string> = { [KEYS.audio]: () => "Audio", [KEYS.blockquote]: () => "Blockquote", [KEYS.callout]: () => "Callout", [KEYS.codeBlock]: () => "Code Block", [KEYS.column]: () => "Column", [KEYS.equation]: () => "Equation", [KEYS.file]: () => "File", [KEYS.h1]: () => `Heading 1`, [KEYS.h2]: () => `Heading 2`, [KEYS.h3]: () => `Heading 3`, [KEYS.h4]: () => `Heading 4`, [KEYS.h5]: () => `Heading 5`, [KEYS.h6]: () => `Heading 6`, [KEYS.hr]: () => "Horizontal Rule", [KEYS.img]: () => "Image", [KEYS.mediaEmbed]: () => "Media", [KEYS.p]: (node) => { if (node?.[KEYS.listType] === KEYS.listTodo) return "Todo List"; if (node?.[KEYS.listType] === KEYS.ol) return "Ordered List"; if (node?.[KEYS.listType] === KEYS.ul) return "List"; return "Paragraph"; }, [KEYS.table]: () => "Table", [KEYS.toc]: () => "Table of Contents", [KEYS.toggle]: () => "Toggle", [KEYS.video]: () => "Video", }; export function BlockSuggestion({ element }: { element: TSuggestionElement }) { const suggestionData = element.suggestion; if (suggestionData?.isLineBreak) return null; const isRemove = suggestionData?.type === "remove"; return (
    ); } export function BlockSuggestionCard({ idx, isLast, suggestion, }: { idx: number; isLast: boolean; suggestion: ResolvedSuggestion; }) { const { api, editor } = useEditorPlugin(SuggestionPlugin); const userInfo = usePluginOption(discussionPlugin, "user", suggestion.userId); const accept = (suggestion: ResolvedSuggestion) => { api.suggestion.withoutSuggestions(() => { acceptSuggestion(editor, suggestion); }); }; const reject = (suggestion: ResolvedSuggestion) => { api.suggestion.withoutSuggestions(() => { rejectSuggestion(editor, suggestion); }); }; const [hovering, setHovering] = React.useState(false); const suggestionText2Array = (text: string) => { if (text === BLOCK_SUGGESTION) return ["line breaks"]; return text.split(BLOCK_SUGGESTION).filter(Boolean); }; const [editingId, setEditingId] = React.useState(null); return (
    setHovering(true)} onMouseLeave={() => setHovering(false)} >
    {/* Replace to your own backend or refer to potion */} {userInfo?.name?.[0]}

    {userInfo?.name}

    {formatCommentDate(new Date(suggestion.createdAt))}
    {suggestion.type === "remove" && ( {suggestionText2Array(suggestion.text!).map((text, index) => (
    Delete: {text}
    ))}
    )} {suggestion.type === "insert" && ( {suggestionText2Array(suggestion.newText!).map((text, index) => (
    Add: {text || "line breaks"}
    ))}
    )} {suggestion.type === "replace" && (
    {suggestionText2Array(suggestion.newText!).map((text, index) => (
    with: {text || "line breaks"}
    ))} {suggestionText2Array(suggestion.text!).map((text, index) => (
    {index === 0 ? "Replace:" : "Delete:"} {text || "line breaks"}
    ))}
    )} {suggestion.type === "update" && (
    {Object.keys(suggestion.properties).map((key) => ( Un{key} ))} {Object.keys(suggestion.newProperties).map((key) => ( {key.charAt(0).toUpperCase() + key.slice(1)} ))} {suggestion.newText}
    )}
    {suggestion.comments.map((comment, index) => ( ))} {hovering && (
    )}
    {!isLast &&
    }
    ); } export const useResolveSuggestion = (suggestionNodes: NodeEntry[], blockPath: Path) => { const discussions = usePluginOption(discussionPlugin, "discussions"); const { api, editor, getOption, setOption } = useEditorPlugin(suggestionPlugin); suggestionNodes.forEach(([node]) => { const id = api.suggestion.nodeId(node); const map = getOption("uniquePathMap"); if (!id) return; const previousPath = map.get(id); // If there are no suggestion nodes in the corresponding path in the map, then update it. if (PathApi.isPath(previousPath)) { const nodes = api.suggestion.node({ id, at: previousPath, isText: true }); const parentNode = api.node(previousPath); let lineBreakId: string | null = null; if (parentNode && ElementApi.isElement(parentNode[0])) { lineBreakId = api.suggestion.nodeId(parentNode[0]) ?? null; } if (!nodes && lineBreakId !== id) { return setOption("uniquePathMap", new Map(map).set(id, blockPath)); } return; } setOption("uniquePathMap", new Map(map).set(id, blockPath)); }); const resolvedSuggestion: ResolvedSuggestion[] = React.useMemo(() => { const map = getOption("uniquePathMap"); if (suggestionNodes.length === 0) return []; const suggestionIds = new Set( suggestionNodes .flatMap(([node]) => { if (TextApi.isText(node)) { const dataList = api.suggestion.dataList(node); const includeUpdate = dataList.some((data) => data.type === "update"); if (!includeUpdate) return api.suggestion.nodeId(node); return dataList.filter((data) => data.type === "update").map((d) => d.id); } if (ElementApi.isElement(node)) { return api.suggestion.nodeId(node); } }) .filter(Boolean), ); const res: ResolvedSuggestion[] = []; suggestionIds.forEach((id) => { if (!id) return; const path = map.get(id); if (!path || !PathApi.isPath(path)) return; if (!PathApi.equals(path, blockPath)) return; const entries = [ ...editor.api.nodes({ at: [], mode: "all", match: (n) => (n[KEYS.suggestion] && n[getSuggestionKey(id)]) || api.suggestion.nodeId(n as TElement) === id, }), ]; // move line break to the end entries.sort(([, path1], [, path2]) => { return PathApi.isChild(path1, path2) ? -1 : 1; }); let newText = ""; let text = ""; let properties: any = {}; let newProperties: any = {}; // overlapping suggestion entries.forEach(([node]) => { if (TextApi.isText(node)) { const dataList = api.suggestion.dataList(node); dataList.forEach((data) => { if (data.id !== id) return; switch (data.type) { case "insert": { newText += node.text; break; } case "remove": { text += node.text; break; } case "update": { properties = { ...properties, ...data.properties, }; newProperties = { ...newProperties, ...data.newProperties, }; newText += node.text; break; } // No default } }); } else { const lineBreakData = api.suggestion.isBlockSuggestion(node) ? node.suggestion : undefined; if (lineBreakData?.id !== keyId2SuggestionId(id)) return; if (lineBreakData.type === "insert") { newText += lineBreakData.isLineBreak ? BLOCK_SUGGESTION : BLOCK_SUGGESTION + TYPE_TEXT_MAP[node.type](node); } else if (lineBreakData.type === "remove") { text += lineBreakData.isLineBreak ? BLOCK_SUGGESTION : BLOCK_SUGGESTION + TYPE_TEXT_MAP[node.type](node); } } }); if (entries.length === 0) return; const nodeData = api.suggestion.suggestionData(entries[0][0]); if (!nodeData) return; // const comments = data?.discussions.find((d) => d.id === id)?.comments; const comments = discussions.find((s: TDiscussion) => s.id === id)?.comments || []; const createdAt = new Date(nodeData.createdAt); const keyId = getSuggestionKey(id); if (nodeData.type === "update") { return res.push({ comments, createdAt, keyId, newProperties, newText, properties, suggestionId: keyId2SuggestionId(id), type: "update", userId: nodeData.userId, }); } if (newText.length > 0 && text.length > 0) { return res.push({ comments, createdAt, keyId, newText, suggestionId: keyId2SuggestionId(id), text, type: "replace", userId: nodeData.userId, }); } if (newText.length > 0) { return res.push({ comments, createdAt, keyId, newText, suggestionId: keyId2SuggestionId(id), type: "insert", userId: nodeData.userId, }); } if (text.length > 0) { return res.push({ comments, createdAt, keyId, suggestionId: keyId2SuggestionId(id), text, type: "remove", userId: nodeData.userId, }); } }); return res; }, [api.suggestion, blockPath, discussions, editor.api, getOption, suggestionNodes]); return resolvedSuggestion; }; export const isResolvedSuggestion = ( suggestion: ResolvedSuggestion | TDiscussion, ): suggestion is ResolvedSuggestion => { return "suggestionId" in suggestion; }; ================================================ FILE: app/src/components/ui/blockquote-node-static.tsx ================================================ // @ts-nocheck import { type SlateElementProps, SlateElement } from "platejs"; export function BlockquoteElementStatic(props: SlateElementProps) { return ; } ================================================ FILE: app/src/components/ui/blockquote-node.tsx ================================================ "use client"; import { type PlateElementProps, PlateElement } from "platejs/react"; export function BlockquoteElement(props: PlateElementProps) { return ; } ================================================ FILE: app/src/components/ui/button.tsx ================================================ import * as React from "react"; import { Slot } from "@radix-ui/react-slot"; import { cva, type VariantProps } from "class-variance-authority"; import { cn } from "@/utils/cn"; const buttonVariants = cva( "inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium transition-all disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg:not([class*='size-'])]:size-4 shrink-0 [&_svg]:shrink-0 outline-none focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px] aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive", { variants: { variant: { default: "bg-primary text-primary-foreground shadow-xs hover:bg-primary/90", destructive: "bg-destructive text-white shadow-xs hover:bg-destructive/90 focus-visible:ring-destructive/20 dark:focus-visible:ring-destructive/40 dark:bg-destructive/60", outline: "border bg-background shadow-xs hover:bg-accent hover:text-accent-foreground dark:bg-input/30 dark:border-input dark:hover:bg-input/50", secondary: "bg-secondary text-secondary-foreground shadow-xs hover:bg-secondary/80", ghost: "hover:bg-accent hover:text-accent-foreground dark:hover:bg-accent/50", link: "text-primary underline-offset-4 hover:underline", }, size: { default: "h-9 px-4 py-2 has-[>svg]:px-3", sm: "h-8 rounded-md gap-1.5 px-3 has-[>svg]:px-2.5", lg: "h-10 rounded-md px-6 has-[>svg]:px-4", icon: "size-9", }, }, defaultVariants: { variant: "default", size: "default", }, }, ); function Button({ className, variant, size, asChild = false, ...props }: React.ComponentProps<"button"> & VariantProps & { asChild?: boolean; }) { const Comp = asChild ? Slot : "button"; return ; } export { Button, buttonVariants }; ================================================ FILE: app/src/components/ui/calendar.tsx ================================================ "use client"; import * as React from "react"; import { ChevronDownIcon, ChevronLeftIcon, ChevronRightIcon } from "lucide-react"; import { DayButton, DayPicker, getDefaultClassNames } from "react-day-picker"; import { cn } from "@/utils/cn"; import { Button, buttonVariants } from "@/components/ui/button"; function Calendar({ className, classNames, showOutsideDays = true, captionLayout = "label", buttonVariant = "ghost", formatters, components, ...props }: React.ComponentProps & { buttonVariant?: React.ComponentProps["variant"]; }) { const defaultClassNames = getDefaultClassNames(); return ( svg]:rotate-180`, String.raw`rtl:**:[.rdp-button\_previous>svg]:rotate-180`, className, )} captionLayout={captionLayout} formatters={{ formatMonthDropdown: (date) => date.toLocaleString("default", { month: "short" }), ...formatters, }} classNames={{ root: cn("w-fit", defaultClassNames.root), months: cn("flex gap-4 flex-col md:flex-row relative", defaultClassNames.months), month: cn("flex flex-col w-full gap-4", defaultClassNames.month), nav: cn("flex items-center gap-1 w-full absolute top-0 inset-x-0 justify-between", defaultClassNames.nav), button_previous: cn( buttonVariants({ variant: buttonVariant }), "size-(--cell-size) aria-disabled:opacity-50 p-0 select-none", defaultClassNames.button_previous, ), button_next: cn( buttonVariants({ variant: buttonVariant }), "size-(--cell-size) aria-disabled:opacity-50 p-0 select-none", defaultClassNames.button_next, ), month_caption: cn( "flex items-center justify-center h-(--cell-size) w-full px-(--cell-size)", defaultClassNames.month_caption, ), dropdowns: cn( "w-full flex items-center text-sm font-medium justify-center h-(--cell-size) gap-1.5", defaultClassNames.dropdowns, ), dropdown_root: cn( "relative has-focus:border-ring border border-input shadow-xs has-focus:ring-ring/50 has-focus:ring-[3px] rounded-md", defaultClassNames.dropdown_root, ), dropdown: cn("absolute bg-popover inset-0 opacity-0", defaultClassNames.dropdown), caption_label: cn( "select-none font-medium", captionLayout === "label" ? "text-sm" : "rounded-md pl-2 pr-1 flex items-center gap-1 text-sm h-8 [&>svg]:text-muted-foreground [&>svg]:size-3.5", defaultClassNames.caption_label, ), table: "w-full border-collapse", weekdays: cn("flex", defaultClassNames.weekdays), weekday: cn( "text-muted-foreground rounded-md flex-1 font-normal text-[0.8rem] select-none", defaultClassNames.weekday, ), week: cn("flex w-full mt-2", defaultClassNames.week), week_number_header: cn("select-none w-(--cell-size)", defaultClassNames.week_number_header), week_number: cn("text-[0.8rem] select-none text-muted-foreground", defaultClassNames.week_number), day: cn( "relative w-full h-full p-0 text-center [&:first-child[data-selected=true]_button]:rounded-l-md [&:last-child[data-selected=true]_button]:rounded-r-md group/day aspect-square select-none", defaultClassNames.day, ), range_start: cn("rounded-l-md bg-accent", defaultClassNames.range_start), range_middle: cn("rounded-none", defaultClassNames.range_middle), range_end: cn("rounded-r-md bg-accent", defaultClassNames.range_end), today: cn( "bg-accent text-accent-foreground rounded-md data-[selected=true]:rounded-none", defaultClassNames.today, ), outside: cn("text-muted-foreground aria-selected:text-muted-foreground", defaultClassNames.outside), disabled: cn("text-muted-foreground opacity-50", defaultClassNames.disabled), hidden: cn("invisible", defaultClassNames.hidden), ...classNames, }} components={{ Root: ({ className, rootRef, ...props }) => { return
    ; }, Chevron: ({ className, orientation, ...props }) => { if (orientation === "left") { return ; } if (orientation === "right") { return ; } return ; }, DayButton: CalendarDayButton, WeekNumber: ({ children, ...props }) => { return (
    {children}
    ); }, ...components, }} {...props} /> ); } function CalendarDayButton({ className, day, modifiers, ...props }: React.ComponentProps) { const defaultClassNames = getDefaultClassNames(); const ref = React.useRef(null); React.useEffect(() => { if (modifiers.focused) ref.current?.focus(); }, [modifiers.focused]); return ( } >
    {children}
    ); } ================================================ FILE: app/src/components/ui/caption.tsx ================================================ "use client"; import * as React from "react"; import type { VariantProps } from "class-variance-authority"; import { Caption as CaptionPrimitive, CaptionTextarea as CaptionTextareaPrimitive, useCaptionButton, useCaptionButtonState, } from "@platejs/caption/react"; import { createPrimitiveComponent } from "@udecode/cn"; import { cva } from "class-variance-authority"; import { Button } from "@/components/ui/button"; import { cn } from "@/utils/cn"; const captionVariants = cva("max-w-full", { defaultVariants: { align: "center", }, variants: { align: { center: "mx-auto", left: "mr-auto", right: "ml-auto", }, }, }); export function Caption({ align, className, ...props }: React.ComponentProps & VariantProps) { return ; } export function CaptionTextarea(props: React.ComponentProps) { return ( ); } export const CaptionButton = createPrimitiveComponent(Button)({ propsHook: useCaptionButton, stateHook: useCaptionButtonState, }); ================================================ FILE: app/src/components/ui/card.tsx ================================================ import * as React from "react"; import { cn } from "@/utils/cn"; function SimpleCard({ className, ...props }: React.ComponentProps<"div">) { return (
    ); } function Card({ className, ...props }: React.ComponentProps<"div">) { return (
    ); } function CardHeader({ className, ...props }: React.ComponentProps<"div">) { return (
    ); } function CardTitle({ className, ...props }: React.ComponentProps<"div">) { return
    ; } function CardDescription({ className, ...props }: React.ComponentProps<"div">) { return
    ; } function CardAction({ className, ...props }: React.ComponentProps<"div">) { return (
    ); } function CardContent({ className, ...props }: React.ComponentProps<"div">) { return
    ; } function CardFooter({ className, ...props }: React.ComponentProps<"div">) { return (
    ); } export { Card, CardAction, CardContent, CardDescription, CardFooter, CardHeader, CardTitle, SimpleCard }; ================================================ FILE: app/src/components/ui/checkbox.tsx ================================================ import * as React from "react"; import * as CheckboxPrimitive from "@radix-ui/react-checkbox"; import { CheckIcon } from "lucide-react"; import { cn } from "@/utils/cn"; function Checkbox({ className, ...props }: React.ComponentProps) { return ( ); } export { Checkbox }; ================================================ FILE: app/src/components/ui/code-block-node-static.tsx ================================================ // @ts-nocheck import { type SlateElementProps, type SlateLeafProps, type TCodeBlockElement, SlateElement, SlateLeaf } from "platejs"; export function CodeBlockElementStatic(props: SlateElementProps) { return (
              {props.children}
            
    ); } export function CodeLineElementStatic(props: SlateElementProps) { return ; } export function CodeSyntaxLeafStatic(props: SlateLeafProps) { const tokenClassName = props.leaf.className as string; return ; } ================================================ FILE: app/src/components/ui/code-block-node.tsx ================================================ "use client"; import * as React from "react"; import { formatCodeBlock, isLangSupported } from "@platejs/code-block"; import { BracesIcon, Check, CheckIcon, CopyIcon } from "lucide-react"; import { type TCodeBlockElement, type TCodeSyntaxLeaf, NodeApi } from "platejs"; import { type PlateElementProps, type PlateLeafProps, PlateElement, PlateLeaf } from "platejs/react"; import { useEditorRef, useElement, useReadOnly } from "platejs/react"; import { Button } from "@/components/ui/button"; import { Command, CommandEmpty, CommandGroup, CommandInput, CommandItem, CommandList } from "@/components/ui/command"; import { Popover, PopoverContent, PopoverTrigger } from "@/components/ui/popover"; import { cn } from "@/utils/cn"; export function CodeBlockElement(props: PlateElementProps) { const { editor, element } = props; return (
              {props.children}
            
    {isLangSupported(element.lang) && ( )} NodeApi.string(element)} />
    ); } function CodeBlockCombobox() { const [open, setOpen] = React.useState(false); const readOnly = useReadOnly(); const editor = useEditorRef(); const element = useElement(); const value = element.lang || "plaintext"; const [searchValue, setSearchValue] = React.useState(""); const items = React.useMemo( () => languages.filter((language) => !searchValue || language.label.toLowerCase().includes(searchValue.toLowerCase())), [searchValue], ); if (readOnly) return null; return ( setSearchValue("")}> setSearchValue(value)} placeholder="Search language..." /> No language found. {items.map((language) => ( { editor.tf.setNodes({ lang: value }, { at: element }); setSearchValue(value); setOpen(false); }} > {language.label} ))} ); } function CopyButton({ value, ...props }: { value: (() => string) | string } & Omit, "value">) { const [hasCopied, setHasCopied] = React.useState(false); React.useEffect(() => { setTimeout(() => { setHasCopied(false); }, 2000); }, [hasCopied]); return ( ); } export function CodeLineElement(props: PlateElementProps) { return ; } export function CodeSyntaxLeaf(props: PlateLeafProps) { const tokenClassName = props.leaf.className as string; return ; } const languages: { label: string; value: string }[] = [ { label: "Auto", value: "auto" }, { label: "Plain Text", value: "plaintext" }, { label: "ABAP", value: "abap" }, { label: "Agda", value: "agda" }, { label: "Arduino", value: "arduino" }, { label: "ASCII Art", value: "ascii" }, { label: "Assembly", value: "x86asm" }, { label: "Bash", value: "bash" }, { label: "BASIC", value: "basic" }, { label: "BNF", value: "bnf" }, { label: "C", value: "c" }, { label: "C#", value: "csharp" }, { label: "C++", value: "cpp" }, { label: "Clojure", value: "clojure" }, { label: "CoffeeScript", value: "coffeescript" }, { label: "Coq", value: "coq" }, { label: "CSS", value: "css" }, { label: "Dart", value: "dart" }, { label: "Dhall", value: "dhall" }, { label: "Diff", value: "diff" }, { label: "Docker", value: "dockerfile" }, { label: "EBNF", value: "ebnf" }, { label: "Elixir", value: "elixir" }, { label: "Elm", value: "elm" }, { label: "Erlang", value: "erlang" }, { label: "F#", value: "fsharp" }, { label: "Flow", value: "flow" }, { label: "Fortran", value: "fortran" }, { label: "Gherkin", value: "gherkin" }, { label: "GLSL", value: "glsl" }, { label: "Go", value: "go" }, { label: "GraphQL", value: "graphql" }, { label: "Groovy", value: "groovy" }, { label: "Haskell", value: "haskell" }, { label: "HCL", value: "hcl" }, { label: "HTML", value: "html" }, { label: "Idris", value: "idris" }, { label: "Java", value: "java" }, { label: "JavaScript", value: "javascript" }, { label: "JSON", value: "json" }, { label: "Julia", value: "julia" }, { label: "Kotlin", value: "kotlin" }, { label: "LaTeX", value: "latex" }, { label: "Less", value: "less" }, { label: "Lisp", value: "lisp" }, { label: "LiveScript", value: "livescript" }, { label: "LLVM IR", value: "llvm" }, { label: "Lua", value: "lua" }, { label: "Makefile", value: "makefile" }, { label: "Markdown", value: "markdown" }, { label: "Markup", value: "markup" }, { label: "MATLAB", value: "matlab" }, { label: "Mathematica", value: "mathematica" }, { label: "Mermaid", value: "mermaid" }, { label: "Nix", value: "nix" }, { label: "Notion Formula", value: "notion" }, { label: "Objective-C", value: "objectivec" }, { label: "OCaml", value: "ocaml" }, { label: "Pascal", value: "pascal" }, { label: "Perl", value: "perl" }, { label: "PHP", value: "php" }, { label: "PowerShell", value: "powershell" }, { label: "Prolog", value: "prolog" }, { label: "Protocol Buffers", value: "protobuf" }, { label: "PureScript", value: "purescript" }, { label: "Python", value: "python" }, { label: "R", value: "r" }, { label: "Racket", value: "racket" }, { label: "Reason", value: "reasonml" }, { label: "Ruby", value: "ruby" }, { label: "Rust", value: "rust" }, { label: "Sass", value: "scss" }, { label: "Scala", value: "scala" }, { label: "Scheme", value: "scheme" }, { label: "SCSS", value: "scss" }, { label: "Shell", value: "shell" }, { label: "Smalltalk", value: "smalltalk" }, { label: "Solidity", value: "solidity" }, { label: "SQL", value: "sql" }, { label: "Swift", value: "swift" }, { label: "TOML", value: "toml" }, { label: "TypeScript", value: "typescript" }, { label: "VB.Net", value: "vbnet" }, { label: "Verilog", value: "verilog" }, { label: "VHDL", value: "vhdl" }, { label: "Visual Basic", value: "vbnet" }, { label: "WebAssembly", value: "wasm" }, { label: "XML", value: "xml" }, { label: "YAML", value: "yaml" }, ]; ================================================ FILE: app/src/components/ui/code-node-static.tsx ================================================ // @ts-nocheck import type { SlateLeafProps } from "platejs"; import { SlateLeaf } from "platejs"; export function CodeLeafStatic(props: SlateLeafProps) { return ( {props.children} ); } ================================================ FILE: app/src/components/ui/code-node.tsx ================================================ // @ts-nocheck "use client"; import type { PlateLeafProps } from "platejs/react"; import { PlateLeaf } from "platejs/react"; export function CodeLeaf(props: PlateLeafProps) { return ( {props.children} ); } ================================================ FILE: app/src/components/ui/collapsible.tsx ================================================ import { cn } from "@/utils/cn"; import * as CollapsiblePrimitive from "@radix-ui/react-collapsible"; function Collapsible({ ...props }: React.ComponentProps) { return ; } function CollapsibleTrigger({ ...props }: React.ComponentProps) { return ; } type CollapsibleContentProps = React.ComponentProps & { animate?: boolean; }; function CollapsibleContent({ className, animate = true, ...props }: CollapsibleContentProps) { return ( ); } export { Collapsible, CollapsibleContent, CollapsibleTrigger }; ================================================ FILE: app/src/components/ui/column-node-static.tsx ================================================ // @ts-nocheck import type { SlateElementProps, TColumnElement } from "platejs"; import { SlateElement } from "platejs"; export function ColumnElementStatic(props: SlateElementProps) { const { width } = props.element; return (
    {props.children}
    ); } export function ColumnGroupElementStatic(props: SlateElementProps) { return (
    {props.children}
    ); } ================================================ FILE: app/src/components/ui/column-node.tsx ================================================ // @ts-nocheck "use client"; import * as React from "react"; import type { TColumnElement } from "platejs"; import type { PlateElementProps } from "platejs/react"; import { useDraggable, useDropLine } from "@platejs/dnd"; import { setColumns } from "@platejs/layout"; import { ResizableProvider } from "@platejs/resizable"; import { BlockSelectionPlugin } from "@platejs/selection/react"; import { useComposedRef } from "@udecode/cn"; import { GripHorizontal, type LucideProps, Trash2Icon } from "lucide-react"; import { PathApi } from "platejs"; import { PlateElement, useEditorRef, useEditorSelector, useElement, useFocusedLast, usePluginOption, useReadOnly, useRemoveNodeButton, useSelected, withHOC, } from "platejs/react"; import { Button } from "@/components/ui/button"; import { Popover, PopoverAnchor, PopoverContent } from "@/components/ui/popover"; import { Separator } from "@/components/ui/separator"; import { Tooltip, TooltipContent, TooltipProvider, TooltipTrigger } from "@/components/ui/tooltip"; import { cn } from "@/utils/cn"; export const ColumnElement = withHOC( ResizableProvider, function ColumnElement(props: PlateElementProps) { const { width } = props.element; const readOnly = useReadOnly(); const isSelectionAreaVisible = usePluginOption(BlockSelectionPlugin, "isSelectionAreaVisible"); const { isDragging, previewRef, handleRef } = useDraggable({ element: props.element, orientation: "horizontal", type: "column", canDropNode: ({ dragEntry, dropEntry }) => PathApi.equals(PathApi.parent(dragEntry[1]), PathApi.parent(dropEntry[1])), }); return (
    {!readOnly && !isSelectionAreaVisible && (
    )}
    {props.children} {!readOnly && !isSelectionAreaVisible && }
    ); }, ); const ColumnDragHandle = React.memo(function ColumnDragHandle() { return ( Drag to move column ); }); function DropLine() { const { dropLine } = useDropLine({ orientation: "horizontal" }); if (!dropLine) return null; return (
    ); } export function ColumnGroupElement(props: PlateElementProps) { return (
    {props.children}
    ); } function ColumnFloatingToolbar({ children }: React.PropsWithChildren) { const editor = useEditorRef(); const readOnly = useReadOnly(); const element = useElement(); const { props: buttonProps } = useRemoveNodeButton({ element }); const selected = useSelected(); const isCollapsed = useEditorSelector((editor) => editor.api.isCollapsed(), []); const isFocusedLast = useFocusedLast(); const open = isFocusedLast && !readOnly && selected && isCollapsed; const onColumnChange = (widths: string[]) => { setColumns(editor, { at: element, widths, }); }; return ( {children} e.preventDefault()} align="center" side="top" sideOffset={10} >
    ); } const DoubleColumnOutlined = (props: LucideProps) => ( ); const ThreeColumnOutlined = (props: LucideProps) => ( ); const RightSideDoubleColumnOutlined = (props: LucideProps) => ( ); const LeftSideDoubleColumnOutlined = (props: LucideProps) => ( ); const DoubleSideDoubleColumnOutlined = (props: LucideProps) => ( ); ================================================ FILE: app/src/components/ui/command.tsx ================================================ "use client"; import * as React from "react"; import { Command as CommandPrimitive } from "cmdk"; import { SearchIcon } from "lucide-react"; import { cn } from "@/utils/cn"; import { Dialog, DialogContent, DialogDescription, DialogHeader, DialogTitle } from "@/components/ui/dialog"; function Command({ className, ...props }: React.ComponentProps) { return ( ); } function CommandDialog({ title = "Command Palette", description = "Search for a command to run...", children, className, showCloseButton = true, ...props }: React.ComponentProps & { title?: string; description?: string; className?: string; showCloseButton?: boolean; }) { return ( {title} {description} {children} ); } function CommandInput({ className, ...props }: React.ComponentProps) { return (
    ); } function CommandList({ className, ...props }: React.ComponentProps) { return ( ); } function CommandEmpty({ ...props }: React.ComponentProps) { return ; } function CommandGroup({ className, ...props }: React.ComponentProps) { return ( ); } function CommandSeparator({ className, ...props }: React.ComponentProps) { return ( ); } function CommandItem({ className, ...props }: React.ComponentProps) { return ( ); } function CommandShortcut({ className, ...props }: React.ComponentProps<"span">) { return ( ); } export { Command, CommandDialog, CommandInput, CommandList, CommandEmpty, CommandGroup, CommandItem, CommandShortcut, CommandSeparator, }; ================================================ FILE: app/src/components/ui/comment-node-static.tsx ================================================ // @ts-nocheck import * as React from "react"; import type { SlateLeafProps, TCommentText } from "platejs"; import { SlateLeaf } from "platejs"; export function CommentLeafStatic(props: SlateLeafProps) { return ( {props.children} ); } ================================================ FILE: app/src/components/ui/comment-node.tsx ================================================ // @ts-nocheck "use client"; import * as React from "react"; import type { TCommentText } from "platejs"; import type { PlateLeafProps } from "platejs/react"; import { getCommentCount } from "@platejs/comment"; import { PlateLeaf, useEditorPlugin, usePluginOption } from "platejs/react"; import { cn } from "@/utils/cn"; import { commentPlugin } from "@/components/editor/plugins/comment-kit"; export function CommentLeaf(props: PlateLeafProps) { const { children, leaf } = props; const { api, setOption } = useEditorPlugin(commentPlugin); const hoverId = usePluginOption(commentPlugin, "hoverId"); const activeId = usePluginOption(commentPlugin, "activeId"); const isOverlapping = getCommentCount(leaf) > 1; const currentId = api.comment.nodeId(leaf); const isActive = activeId === currentId; const isHover = hoverId === currentId; return ( setOption("activeId", currentId ?? null), onMouseEnter: () => setOption("hoverId", currentId ?? null), onMouseLeave: () => setOption("hoverId", null), }} > {children} ); } ================================================ FILE: app/src/components/ui/comment-toolbar-button.tsx ================================================ // @ts-nocheck "use client"; import * as React from "react"; import { MessageSquareTextIcon } from "lucide-react"; import { useEditorRef } from "platejs/react"; import { commentPlugin } from "@/components/editor/plugins/comment-kit"; import { ToolbarButton } from "./toolbar"; export function CommentToolbarButton() { const editor = useEditorRef(); return ( { editor.getTransforms(commentPlugin).comment.setDraft(); }} data-plate-prevent-overlay tooltip="Comment" > ); } ================================================ FILE: app/src/components/ui/comment.tsx ================================================ // @ts-nocheck "use client"; import * as React from "react"; import type { CreatePlateEditorOptions } from "platejs/react"; import { getCommentKey, getDraftCommentKey } from "@platejs/comment"; import { CommentPlugin, useCommentId } from "@platejs/comment/react"; import { differenceInDays, differenceInHours, differenceInMinutes, format } from "date-fns"; import { ArrowUpIcon, CheckIcon, MoreHorizontalIcon, PencilIcon, TrashIcon, XIcon } from "lucide-react"; import { type Value, KEYS, nanoid, NodeApi } from "platejs"; import { Plate, useEditorPlugin, useEditorRef, usePlateEditor, usePluginOption } from "platejs/react"; import { Avatar, AvatarFallback, AvatarImage } from "@/components/ui/avatar"; import { Button } from "@/components/ui/button"; import { DropdownMenu, DropdownMenuContent, DropdownMenuGroup, DropdownMenuItem, DropdownMenuTrigger, } from "@/components/ui/dropdown-menu"; import { cn } from "@/utils/cn"; import { BasicMarksKit } from "@/components/editor/plugins/basic-marks-kit"; import { type TDiscussion, discussionPlugin } from "@/components/editor/plugins/discussion-kit"; import { Editor, EditorContainer } from "./editor"; export interface TComment { id: string; contentRich: Value; createdAt: Date; discussionId: string; isEdited: boolean; userId: string; } export function Comment(props: { comment: TComment; discussionLength: number; editingId: string | null; index: number; setEditingId: React.Dispatch>; documentContent?: string; showDocumentContent?: boolean; onEditorClick?: () => void; }) { const { comment, discussionLength, documentContent, editingId, index, setEditingId, showDocumentContent = false, onEditorClick, } = props; const editor = useEditorRef(); const userInfo = usePluginOption(discussionPlugin, "user", comment.userId); const currentUserId = usePluginOption(discussionPlugin, "currentUserId"); const resolveDiscussion = async (id: string) => { const updatedDiscussions = editor.getOption(discussionPlugin, "discussions").map((discussion) => { if (discussion.id === id) { return { ...discussion, isResolved: true }; } return discussion; }); editor.setOption(discussionPlugin, "discussions", updatedDiscussions); }; const removeDiscussion = async (id: string) => { const updatedDiscussions = editor .getOption(discussionPlugin, "discussions") .filter((discussion) => discussion.id !== id); editor.setOption(discussionPlugin, "discussions", updatedDiscussions); }; const updateComment = async (input: { id: string; contentRich: Value; discussionId: string; isEdited: boolean }) => { const updatedDiscussions = editor.getOption(discussionPlugin, "discussions").map((discussion) => { if (discussion.id === input.discussionId) { const updatedComments = discussion.comments.map((comment) => { if (comment.id === input.id) { return { ...comment, contentRich: input.contentRich, isEdited: true, updatedAt: new Date(), }; } return comment; }); return { ...discussion, comments: updatedComments }; } return discussion; }); editor.setOption(discussionPlugin, "discussions", updatedDiscussions); }; const { tf } = useEditorPlugin(CommentPlugin); // Replace to your own backend or refer to potion const isMyComment = currentUserId === comment.userId; const initialValue = comment.contentRich; const commentEditor = useCommentEditor( { id: comment.id, value: initialValue, }, [initialValue], ); const onCancel = () => { setEditingId(null); commentEditor.tf.replaceNodes(initialValue, { at: [], children: true, }); }; const onSave = () => { void updateComment({ id: comment.id, contentRich: commentEditor.children, discussionId: comment.discussionId, isEdited: true, }); setEditingId(null); }; const onResolveComment = () => { void resolveDiscussion(comment.discussionId); tf.comment.unsetMark({ id: comment.discussionId }); }; const isFirst = index === 0; const isLast = index === discussionLength - 1; const isEditing = editingId && editingId === comment.id; const [hovering, setHovering] = React.useState(false); const [dropdownOpen, setDropdownOpen] = React.useState(false); return (
    setHovering(true)} onMouseLeave={() => setHovering(false)}>
    {userInfo?.name?.[0]}

    {/* Replace to your own backend or refer to potion */} {userInfo?.name}

    {formatCommentDate(new Date(comment.createdAt))} {comment.isEdited && (edited)}
    {isMyComment && (hovering || dropdownOpen) && (
    {index === 0 && ( )} { setTimeout(() => { commentEditor.tf.focus({ edge: "endEditor" }); }, 0); }} onRemoveComment={() => { if (discussionLength === 1) { tf.comment.unsetMark({ id: comment.discussionId }); void removeDiscussion(comment.discussionId); } }} comment={comment} dropdownOpen={dropdownOpen} setDropdownOpen={setDropdownOpen} setEditingId={setEditingId} />
    )}
    {isFirst && showDocumentContent && (
    {discussionLength > 1 &&
    }
    {documentContent &&
    {documentContent}
    }
    )}
    {!isLast &&
    } onEditorClick?.()} /> {isEditing && (
    )}
    ); } function CommentMoreDropdown(props: { comment: TComment; dropdownOpen: boolean; setDropdownOpen: React.Dispatch>; setEditingId: React.Dispatch>; onCloseAutoFocus?: () => void; onRemoveComment?: () => void; }) { const { comment, dropdownOpen, setDropdownOpen, setEditingId, onCloseAutoFocus, onRemoveComment } = props; const editor = useEditorRef(); const selectedEditCommentRef = React.useRef(false); const onDeleteComment = React.useCallback(() => { if (!comment.id) return alert("You are operating too quickly, please try again later."); // Find and update the discussion const updatedDiscussions = editor.getOption(discussionPlugin, "discussions").map((discussion) => { if (discussion.id !== comment.discussionId) { return discussion; } const commentIndex = discussion.comments.findIndex((c) => c.id === comment.id); if (commentIndex === -1) { return discussion; } return { ...discussion, comments: [...discussion.comments.slice(0, commentIndex), ...discussion.comments.slice(commentIndex + 1)], }; }); // Save back to session storage editor.setOption(discussionPlugin, "discussions", updatedDiscussions); onRemoveComment?.(); }, [comment.discussionId, comment.id, editor, onRemoveComment]); const onEditComment = React.useCallback(() => { selectedEditCommentRef.current = true; if (!comment.id) return alert("You are operating too quickly, please try again later."); setEditingId(comment.id); }, [comment.id, setEditingId]); return ( e.stopPropagation()}> { if (selectedEditCommentRef.current) { onCloseAutoFocus?.(); selectedEditCommentRef.current = false; } return e.preventDefault(); }} > Edit comment Delete comment ); } const useCommentEditor = (options: Omit = {}, deps: any[] = []) => { const commentEditor = usePlateEditor( { id: "comment", plugins: BasicMarksKit, value: [], ...options, }, deps, ); return commentEditor; }; export function CommentCreateForm({ autoFocus = false, className, discussionId: discussionIdProp, focusOnMount = false, }: { autoFocus?: boolean; className?: string; discussionId?: string; focusOnMount?: boolean; }) { const discussions = usePluginOption(discussionPlugin, "discussions"); const editor = useEditorRef(); const commentId = useCommentId(); const discussionId = discussionIdProp ?? commentId; const userInfo = usePluginOption(discussionPlugin, "currentUser"); const [commentValue, setCommentValue] = React.useState(); const commentContent = React.useMemo( () => (commentValue ? NodeApi.string({ children: commentValue, type: KEYS.p }) : ""), [commentValue], ); const commentEditor = useCommentEditor(); React.useEffect(() => { if (commentEditor && focusOnMount) { commentEditor.tf.focus(); } }, [commentEditor, focusOnMount]); const onAddComment = React.useCallback(async () => { if (!commentValue) return; commentEditor.tf.reset(); if (discussionId) { // Get existing discussion const discussion = discussions.find((d) => d.id === discussionId); if (!discussion) { // Mock creating suggestion const newDiscussion: TDiscussion = { id: discussionId, comments: [ { id: nanoid(), contentRich: commentValue, createdAt: new Date(), discussionId, isEdited: false, userId: editor.getOption(discussionPlugin, "currentUserId"), }, ], createdAt: new Date(), isResolved: false, userId: editor.getOption(discussionPlugin, "currentUserId"), }; editor.setOption(discussionPlugin, "discussions", [...discussions, newDiscussion]); return; } // Create reply comment const comment: TComment = { id: nanoid(), contentRich: commentValue, createdAt: new Date(), discussionId, isEdited: false, userId: editor.getOption(discussionPlugin, "currentUserId"), }; // Add reply to discussion comments const updatedDiscussion = { ...discussion, comments: [...discussion.comments, comment], }; // Filter out old discussion and add updated one const updatedDiscussions = discussions.filter((d) => d.id !== discussionId).concat(updatedDiscussion); editor.setOption(discussionPlugin, "discussions", updatedDiscussions); return; } const commentsNodeEntry = editor.getApi(CommentPlugin).comment.nodes({ at: [], isDraft: true }); if (commentsNodeEntry.length === 0) return; const documentContent = commentsNodeEntry.map(([node]) => node.text).join(""); const _discussionId = nanoid(); // Mock creating new discussion const newDiscussion: TDiscussion = { id: _discussionId, comments: [ { id: nanoid(), contentRich: commentValue, createdAt: new Date(), discussionId: _discussionId, isEdited: false, userId: editor.getOption(discussionPlugin, "currentUserId"), }, ], createdAt: new Date(), documentContent, isResolved: false, userId: editor.getOption(discussionPlugin, "currentUserId"), }; editor.setOption(discussionPlugin, "discussions", [...discussions, newDiscussion]); const id = newDiscussion.id; commentsNodeEntry.forEach(([, path]) => { editor.tf.setNodes( { [getCommentKey(id)]: true, }, { at: path, split: true }, ); editor.tf.unsetNodes([getDraftCommentKey()], { at: path }); }); }, [commentValue, commentEditor.tf, discussionId, editor, discussions]); return (
    {/* Replace to your own backend or refer to potion */} {userInfo?.name?.[0]}
    { setCommentValue(value); }} editor={commentEditor} > { if (e.key === "Enter" && !e.shiftKey) { e.preventDefault(); onAddComment(); } }} placeholder="Reply..." autoComplete="off" autoFocus={autoFocus} />
    ); } export const formatCommentDate = (date: Date) => { const now = new Date(); const diffMinutes = differenceInMinutes(now, date); const diffHours = differenceInHours(now, date); const diffDays = differenceInDays(now, date); if (diffMinutes < 60) { return `${diffMinutes}m`; } if (diffHours < 24) { return `${diffHours}h`; } if (diffDays < 2) { return `${diffDays}d`; } return format(date, "MM/dd/yyyy"); }; ================================================ FILE: app/src/components/ui/context-menu.tsx ================================================ import * as ContextMenuPrimitive from "@radix-ui/react-context-menu"; import { CheckIcon, ChevronRightIcon, CircleIcon } from "lucide-react"; import * as React from "react"; import { cn } from "@/utils/cn"; function ContextMenu({ ...props }: React.ComponentProps) { return ; } function ContextMenuTrigger({ ...props }: React.ComponentProps) { return ; } function ContextMenuGroup({ ...props }: React.ComponentProps) { return ; } function ContextMenuPortal({ ...props }: React.ComponentProps) { return ; } function ContextMenuSub({ ...props }: React.ComponentProps) { return ; } function ContextMenuRadioGroup({ ...props }: React.ComponentProps) { return ; } function ContextMenuSubTrigger({ className, inset, children, ...props }: React.ComponentProps & { inset?: boolean; }) { return ( {children} ); } function ContextMenuSubContent({ className, ...props }: React.ComponentProps) { return ( ); } function ContextMenuContent({ className, ...props }: React.ComponentProps) { return ( ); } function ContextMenuItem({ className, inset, variant = "default", ...props }: React.ComponentProps & { inset?: boolean; variant?: "default" | "destructive"; }) { return ( ); } function ContextMenuCheckboxItem({ className, children, checked, ...props }: React.ComponentProps) { return ( {children} ); } function ContextMenuRadioItem({ className, children, ...props }: React.ComponentProps) { return ( {children} ); } function ContextMenuLabel({ className, inset, ...props }: React.ComponentProps & { inset?: boolean; }) { return ( ); } function ContextMenuSeparator({ className, ...props }: React.ComponentProps) { return ( ); } function ContextMenuShortcut({ className, ...props }: React.ComponentProps<"span">) { return ( ); } export { ContextMenu, ContextMenuCheckboxItem, ContextMenuContent, ContextMenuGroup, ContextMenuItem, ContextMenuLabel, ContextMenuPortal, ContextMenuRadioGroup, ContextMenuRadioItem, ContextMenuSeparator, ContextMenuShortcut, ContextMenuSub, ContextMenuSubContent, ContextMenuSubTrigger, ContextMenuTrigger, }; ================================================ FILE: app/src/components/ui/date-node-static.tsx ================================================ // @ts-nocheck import * as React from "react"; import type { SlateElementProps, TDateElement } from "platejs"; import { SlateElement } from "platejs"; export function DateElementStatic(props: SlateElementProps) { const { element } = props; return ( {element.date ? ( (() => { const today = new Date(); const elementDate = new Date(element.date); const isToday = elementDate.getDate() === today.getDate() && elementDate.getMonth() === today.getMonth() && elementDate.getFullYear() === today.getFullYear(); const isYesterday = new Date(today.setDate(today.getDate() - 1)).toDateString() === elementDate.toDateString(); const isTomorrow = new Date(today.setDate(today.getDate() + 2)).toDateString() === elementDate.toDateString(); if (isToday) return "Today"; if (isYesterday) return "Yesterday"; if (isTomorrow) return "Tomorrow"; return elementDate.toLocaleDateString(undefined, { day: "numeric", month: "long", year: "numeric", }); })() ) : ( Pick a date )} {props.children} ); } ================================================ FILE: app/src/components/ui/date-node.tsx ================================================ "use client"; import type { TDateElement } from "platejs"; import type { PlateElementProps } from "platejs/react"; import { PlateElement, useReadOnly } from "platejs/react"; import { Calendar } from "@/components/ui/calendar"; import { Popover, PopoverContent, PopoverTrigger } from "@/components/ui/popover"; import { cn } from "@/utils/cn"; export function DateElement(props: PlateElementProps) { const { editor, element } = props; const readOnly = useReadOnly(); const trigger = ( {element.date ? ( (() => { const today = new Date(); const elementDate = new Date(element.date); const isToday = elementDate.getDate() === today.getDate() && elementDate.getMonth() === today.getMonth() && elementDate.getFullYear() === today.getFullYear(); const isYesterday = new Date(today.setDate(today.getDate() - 1)).toDateString() === elementDate.toDateString(); const isTomorrow = new Date(today.setDate(today.getDate() + 2)).toDateString() === elementDate.toDateString(); if (isToday) return "Today"; if (isYesterday) return "Yesterday"; if (isTomorrow) return "Tomorrow"; return elementDate.toLocaleDateString(undefined, { day: "numeric", month: "long", year: "numeric", }); })() ) : ( Pick a date )} ); if (readOnly) { return trigger; } return ( {trigger} { if (!date) return; editor.tf.setNodes({ date: date.toDateString() }, { at: element }); }} mode="single" initialFocus /> {props.children} ); } ================================================ FILE: app/src/components/ui/dialog.tsx ================================================ import * as DialogPrimitive from "@radix-ui/react-dialog"; import { XIcon } from "lucide-react"; import * as React from "react"; import { Button } from "@/components/ui/button"; import { Input } from "@/components/ui/input"; import { Textarea } from "@/components/ui/textarea"; import { SubWindow } from "@/core/service/SubWindow"; import { cn } from "@/utils/cn"; import { Vector } from "@graphif/data-structures"; import { Rectangle } from "@graphif/shapes"; import { writeText } from "@tauri-apps/plugin-clipboard-manager"; import { toast } from "sonner"; function Dialog({ ...props }: React.ComponentProps) { return ; } function DialogTrigger({ ...props }: React.ComponentProps) { return ; } function DialogPortal({ ...props }: React.ComponentProps) { return ; } function DialogClose({ ...props }: React.ComponentProps) { return ; } function DialogOverlay({ className, ...props }: React.ComponentProps) { return ( ); } function DialogContent({ className, children, showCloseButton = true, ...props }: React.ComponentProps & { showCloseButton?: boolean; }) { return ( {children} {showCloseButton && ( Close )} ); } function DialogHeader({ className, ...props }: React.ComponentProps<"div">) { return (
    ); } function DialogFooter({ className, ...props }: React.ComponentProps<"div">) { return (
    ); } function DialogTitle({ className, ...props }: React.ComponentProps) { return ( ); } function DialogDescription({ className, ...props }: React.ComponentProps) { return ( ); } Dialog.confirm = (title = "你确定?", description = "", { destructive = false } = {}): Promise => { return new Promise((resolve) => { function Component({ winId }: { winId?: string }) { const [open, setOpen] = React.useState(true); return ( {title} {description} ); } SubWindow.create({ titleBarOverlay: true, closable: false, rect: new Rectangle(Vector.same(100), Vector.same(-1)), children: , }); }); }; Dialog.input = ( title = "请输入文本", description = "", { defaultValue = "", placeholder = "...", destructive = false, multiline = false } = {}, ): Promise => { return new Promise((resolve) => { function Component({ winId }: { winId?: string }) { const [open, setOpen] = React.useState(true); const [value, setValue] = React.useState(defaultValue); const InputComponent = multiline ? Textarea : Input; return ( {title} {description} setValue(e.target.value)} placeholder={placeholder} onKeyDown={(e) => { if (e.key === "Enter" && e.shiftKey) { e.preventDefault(); e.stopPropagation(); resolve(value); setOpen(false); setTimeout(() => { SubWindow.close(winId!); }, 500); } else if (e.key === "Escape") { e.preventDefault(); e.stopPropagation(); resolve(undefined); setOpen(false); setTimeout(() => { SubWindow.close(winId!); }, 500); } }} /> ); } SubWindow.create({ titleBarOverlay: true, closable: false, rect: new Rectangle(Vector.same(100), Vector.same(-1)), children: , }); }); }; Dialog.buttons = < const Buttons extends readonly { id: string; label: string; variant?: Parameters[number]["variant"]; }[], >( title: string, description: string, buttons: Buttons, ): Promise => { return new Promise((resolve) => { function Component({ winId }: { winId?: string }) { const [open, setOpen] = React.useState(true); return ( {title} {description} {buttons.map(({ id, label, variant = "default" }) => ( ))} ); } SubWindow.create({ titleBarOverlay: true, closable: false, rect: new Rectangle(Vector.same(100), Vector.same(-1)), children: , }); }); }; Dialog.copy = (title = "导出成功", description = "", value = ""): Promise => { return new Promise((resolve) => { function Component({ winId }: { winId?: string }) { const [open, setOpen] = React.useState(true); return ( {title} {description}
    {value}
    ); } SubWindow.create({ titleBarOverlay: true, closable: false, rect: new Rectangle(Vector.same(100), Vector.same(-1)), children: , }); }); }; export { Dialog, DialogClose, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogOverlay, DialogPortal, DialogTitle, DialogTrigger, }; ================================================ FILE: app/src/components/ui/dropdown-menu.tsx ================================================ import * as React from "react"; import * as DropdownMenuPrimitive from "@radix-ui/react-dropdown-menu"; import { CheckIcon, ChevronRightIcon, CircleIcon } from "lucide-react"; import { cn } from "@/utils/cn"; function DropdownMenu({ ...props }: React.ComponentProps) { return ; } function DropdownMenuPortal({ ...props }: React.ComponentProps) { return ; } function DropdownMenuTrigger({ ...props }: React.ComponentProps) { return ; } function DropdownMenuContent({ className, sideOffset = 4, ...props }: React.ComponentProps) { return ( ); } function DropdownMenuGroup({ ...props }: React.ComponentProps) { return ; } function DropdownMenuItem({ className, inset, variant = "default", ...props }: React.ComponentProps & { inset?: boolean; variant?: "default" | "destructive"; }) { return ( ); } function DropdownMenuCheckboxItem({ className, children, checked, ...props }: React.ComponentProps) { return ( {children} ); } function DropdownMenuRadioGroup({ ...props }: React.ComponentProps) { return ; } function DropdownMenuRadioItem({ className, children, ...props }: React.ComponentProps) { return ( {children} ); } function DropdownMenuLabel({ className, inset, ...props }: React.ComponentProps & { inset?: boolean; }) { return ( ); } function DropdownMenuSeparator({ className, ...props }: React.ComponentProps) { return ( ); } function DropdownMenuShortcut({ className, ...props }: React.ComponentProps<"span">) { return ( ); } function DropdownMenuSub({ ...props }: React.ComponentProps) { return ; } function DropdownMenuSubTrigger({ className, inset, children, ...props }: React.ComponentProps & { inset?: boolean; }) { return ( {children} ); } function DropdownMenuSubContent({ className, ...props }: React.ComponentProps) { return ( ); } export { DropdownMenu, DropdownMenuPortal, DropdownMenuTrigger, DropdownMenuContent, DropdownMenuGroup, DropdownMenuLabel, DropdownMenuItem, DropdownMenuCheckboxItem, DropdownMenuRadioGroup, DropdownMenuRadioItem, DropdownMenuSeparator, DropdownMenuShortcut, DropdownMenuSub, DropdownMenuSubTrigger, DropdownMenuSubContent, }; ================================================ FILE: app/src/components/ui/editor-static.tsx ================================================ // @ts-nocheck import * as React from "react"; import type { VariantProps } from "class-variance-authority"; import { cva } from "class-variance-authority"; import { type PlateStaticProps, PlateStatic } from "platejs"; import { cn } from "@/utils/cn"; export const editorVariants = cva( cn( "group/editor", "relative w-full cursor-text overflow-x-hidden break-words whitespace-pre-wrap select-text", "rounded-md ring-offset-background focus-visible:outline-none", "placeholder:text-muted-foreground/80 **:data-slate-placeholder:top-[auto_!important] **:data-slate-placeholder:text-muted-foreground/80 **:data-slate-placeholder:opacity-100!", "[&_strong]:font-bold", ), { defaultVariants: { variant: "none", }, variants: { disabled: { true: "cursor-not-allowed opacity-50", }, focused: { true: "ring-2 ring-ring ring-offset-2", }, variant: { ai: "w-full px-0 text-base md:text-sm", aiChat: "max-h-[min(70vh,320px)] w-full max-w-[700px] overflow-y-auto px-5 py-3 text-base md:text-sm", default: "size-full px-4 pt-4 pb-72 text-base lg:px-[max(64px,calc(50%-350px))]", demo: "size-full px-4 pt-4 pb-72 text-base lg:px-[max(64px,calc(50%-350px))]", fullWidth: "size-full px-4 pt-4 pb-72 text-base lg:px-24", none: "", select: "px-3 py-2 text-base data-readonly:w-fit", }, }, }, ); export function EditorStatic({ className, variant, ...props }: PlateStaticProps & VariantProps) { return ; } ================================================ FILE: app/src/components/ui/editor.tsx ================================================ "use client"; import * as React from "react"; import type { VariantProps } from "class-variance-authority"; import type { PlateContentProps, PlateViewProps } from "platejs/react"; import { cva } from "class-variance-authority"; import { PlateContainer, PlateContent, PlateView } from "platejs/react"; import { cn } from "@/utils/cn"; const editorContainerVariants = cva( "relative w-full cursor-text overflow-y-auto caret-primary select-text selection:bg-brand/25 focus-visible:outline-none [&_.slate-selection-area]:z-50 [&_.slate-selection-area]:border [&_.slate-selection-area]:border-brand/25 [&_.slate-selection-area]:bg-brand/15", { defaultVariants: { variant: "default", }, variants: { variant: { comment: cn( "flex flex-wrap justify-between gap-1 px-1 py-0.5 text-sm", "rounded-md border-[1.5px] border-transparent bg-transparent", "has-[[data-slate-editor]:focus]:border-brand/50 has-[[data-slate-editor]:focus]:ring-2 has-[[data-slate-editor]:focus]:ring-brand/30", "has-aria-disabled:border-input has-aria-disabled:bg-muted", ), default: "h-full", demo: "h-[650px]", select: cn( "group rounded-md border border-input ring-offset-background focus-within:ring-2 focus-within:ring-ring focus-within:ring-offset-2", "has-data-readonly:w-fit has-data-readonly:cursor-default has-data-readonly:border-transparent has-data-readonly:focus-within:[box-shadow:none]", ), }, }, }, ); export function EditorContainer({ className, variant, ...props }: React.ComponentProps<"div"> & VariantProps) { return ( ); } const editorVariants = cva( cn( "group/editor", "relative w-full cursor-text overflow-x-hidden break-words whitespace-pre-wrap select-text", "rounded-md ring-offset-background focus-visible:outline-none", "placeholder:text-muted-foreground/80 **:data-slate-placeholder:!top-1/2 **:data-slate-placeholder:-translate-y-1/2 **:data-slate-placeholder:text-muted-foreground/80 **:data-slate-placeholder:opacity-100!", "[&_strong]:font-bold", ), { defaultVariants: { variant: "default", }, variants: { disabled: { true: "cursor-not-allowed opacity-50", }, focused: { true: "ring-2 ring-ring ring-offset-2", }, variant: { ai: "w-full px-0 text-base md:text-sm", aiChat: "max-h-[min(70vh,320px)] w-full max-w-[700px] overflow-y-auto px-3 py-2 text-base md:text-sm", comment: cn("rounded-none border-none bg-transparent text-sm"), default: "size-full px-4 pt-4 pb-72 text-base lg:px-[max(64px,calc(50%-350px))]", demo: "size-full px-4 pt-4 pb-72 text-base lg:px-[max(64px,calc(50%-350px))]", fullWidth: "size-full px-4 pt-4 pb-72 text-base lg:px-24", // 详细信息面板⬇️ // 不能有 lg:px-xxx nodeDetails: "size-full px-2 pt-4 text-base", none: "", select: "px-3 py-2 text-base data-readonly:w-fit", }, }, }, ); export type EditorProps = PlateContentProps & VariantProps; export const Editor = React.forwardRef( ({ className, disabled, focused, variant, ...props }, ref) => { return ( ); }, ); Editor.displayName = "Editor"; export function EditorView({ className, variant, ...props }: PlateViewProps & VariantProps) { return ; } EditorView.displayName = "EditorView"; ================================================ FILE: app/src/components/ui/emoji-node.tsx ================================================ "use client"; import * as React from "react"; import type { PlateElementProps } from "platejs/react"; import { EmojiInlineIndexSearch, insertEmoji } from "@platejs/emoji"; import { EmojiPlugin } from "@platejs/emoji/react"; import { PlateElement, usePluginOption } from "platejs/react"; import { useDebounce } from "@/hooks/use-debounce"; import { InlineCombobox, InlineComboboxContent, InlineComboboxEmpty, InlineComboboxGroup, InlineComboboxInput, InlineComboboxItem, } from "./inline-combobox"; export function EmojiInputElement(props: PlateElementProps) { const { children, editor, element } = props; const data = usePluginOption(EmojiPlugin, "data")!; const [value, setValue] = React.useState(""); const debouncedValue = useDebounce(value, 100); const isPending = value !== debouncedValue; const filteredEmojis = React.useMemo(() => { if (debouncedValue.trim().length === 0) return []; return EmojiInlineIndexSearch.getInstance(data).search(debouncedValue.replace(/:$/, "")).get(); }, [data, debouncedValue]); return ( {!isPending && No results} {filteredEmojis.map((emoji) => ( insertEmoji(editor, emoji)}> {emoji.skins[0].native} {emoji.name} ))} {children} ); } ================================================ FILE: app/src/components/ui/emoji-toolbar-button.tsx ================================================ "use client"; import * as React from "react"; import type { Emoji } from "@emoji-mart/data"; import { type EmojiCategoryList, type EmojiIconList, type GridRow, EmojiSettings } from "@platejs/emoji"; import { type EmojiDropdownMenuOptions, type UseEmojiPickerType, useEmojiDropdownMenuState, } from "@platejs/emoji/react"; import * as Popover from "@radix-ui/react-popover"; import { AppleIcon, ClockIcon, CompassIcon, FlagIcon, LeafIcon, LightbulbIcon, MusicIcon, SearchIcon, SmileIcon, StarIcon, XIcon, } from "lucide-react"; import { Button } from "@/components/ui/button"; import { Tooltip, TooltipContent, TooltipProvider, TooltipTrigger } from "@/components/ui/tooltip"; import { cn } from "@/utils/cn"; import { ToolbarButton } from "@/components/ui/toolbar"; export function EmojiToolbarButton({ options, ...props }: { options?: EmojiDropdownMenuOptions; } & React.ComponentPropsWithoutRef) { const { emojiPickerState, isOpen, setIsOpen } = useEmojiDropdownMenuState(options); return ( } isOpen={isOpen} setIsOpen={setIsOpen} > ); } export function EmojiPopover({ children, control, isOpen, setIsOpen, }: { children: React.ReactNode; control: React.ReactNode; isOpen: boolean; setIsOpen: (open: boolean) => void; }) { return ( {control} {children} ); } export function EmojiPicker({ clearSearch, emoji, emojiLibrary, focusedCategory, hasFound, i18n, icons = { categories: emojiCategoryIcons, search: emojiSearchIcons, }, isSearching, refs, searchResult, searchValue, setSearch, settings = EmojiSettings, visibleCategories, handleCategoryClick, onMouseOver, onSelectEmoji, }: Omit & { icons?: EmojiIconList; }) { return (
    ); } const EmojiButton = React.memo(function EmojiButton({ emoji, index, onMouseOver, onSelect, }: { emoji: Emoji; index: number; onMouseOver: (emoji?: Emoji) => void; onSelect: (emoji: Emoji) => void; }) { return ( ); }); const RowOfButtons = React.memo(function RowOfButtons({ emojiLibrary, row, onMouseOver, onSelectEmoji, }: { row: GridRow; } & Pick) { return (
    {row.elements.map((emojiId, index) => ( ))}
    ); }); function EmojiPickerContent({ emojiLibrary, i18n, isSearching = false, refs, searchResult, settings = EmojiSettings, visibleCategories, onMouseOver, onSelectEmoji, }: Pick< UseEmojiPickerType, | "emojiLibrary" | "i18n" | "isSearching" | "onMouseOver" | "onSelectEmoji" | "refs" | "searchResult" | "settings" | "visibleCategories" >) { const getRowWidth = settings.perLine.value * settings.buttonSize.value; const isCategoryVisible = React.useCallback( (categoryId: any) => { return visibleCategories.has(categoryId) ? visibleCategories.get(categoryId) : false; }, [visibleCategories], ); const EmojiList = React.useCallback(() => { return emojiLibrary .getGrid() .sections() .map(({ id: categoryId }) => { const section = emojiLibrary.getGrid().section(categoryId); const { buttonSize } = settings; return (
    {i18n.categories[categoryId]}
    {isCategoryVisible(categoryId) && section .getRows() .map((row: GridRow) => ( ))}
    ); }); }, [emojiLibrary, getRowWidth, i18n.categories, isCategoryVisible, onSelectEmoji, onMouseOver, settings]); const SearchList = React.useCallback(() => { return (
    {i18n.searchResult}
    {searchResult.map((emoji: Emoji, index: number) => ( ))}
    ); }, [emojiLibrary, getRowWidth, i18n.searchResult, searchResult, onSelectEmoji, onMouseOver]); return (
    {isSearching ? SearchList() : EmojiList()}
    ); } function EmojiPickerSearchBar({ children, i18n, searchValue, setSearch, }: { children: React.ReactNode; } & Pick) { return (
    setSearch(event.target.value)} placeholder={i18n.search} aria-label="Search" autoComplete="off" type="text" autoFocus /> {children}
    ); } function EmojiPickerSearchAndClear({ clearSearch, i18n, searchValue, }: Pick) { return (
    {emojiSearchIcons.loupe}
    {searchValue && ( )}
    ); } function EmojiPreview({ emoji }: Pick) { return (
    {emoji?.skins[0].native}
    {emoji?.name}
    {`:${emoji?.id}:`}
    ); } function NoEmoji({ i18n }: Pick) { return (
    😢
    {i18n.searchNoResultsTitle}
    {i18n.searchNoResultsSubtitle}
    ); } function PickAnEmoji({ i18n }: Pick) { return (
    ☝️
    {i18n.pick}
    ); } function EmojiPickerPreview({ emoji, hasFound = true, i18n, isSearching = false, ...props }: Pick) { const showPickEmoji = !emoji && (!isSearching || hasFound); const showNoEmoji = isSearching && !hasFound; const showPreview = emoji && !showNoEmoji && !showNoEmoji; return ( <> {showPreview && } {showPickEmoji && } {showNoEmoji && } ); } function EmojiPickerNavigation({ emojiLibrary, focusedCategory, i18n, icons, onClick, }: { onClick: (id: EmojiCategoryList) => void; } & Pick) { return ( ); } const emojiCategoryIcons: Record< EmojiCategoryList, { outline: React.ReactElement; solid: React.ReactElement; // Needed to add another solid variant - outline will be used for now } > = { activity: { outline: ( ), solid: ( ), }, custom: { outline: , solid: , }, flags: { outline: , solid: , }, foods: { outline: , solid: , }, frequent: { outline: , solid: , }, nature: { outline: , solid: , }, objects: { outline: , solid: , }, people: { outline: , solid: , }, places: { outline: , solid: , }, symbols: { outline: , solid: , }, }; const emojiSearchIcons = { delete: , loupe: , }; ================================================ FILE: app/src/components/ui/equation-node-static.tsx ================================================ // @ts-nocheck import * as React from "react"; import type { SlateElementProps, TEquationElement } from "platejs"; import { getEquationHtml } from "@platejs/math"; import { RadicalIcon } from "lucide-react"; import { SlateElement } from "platejs"; import { cn } from "@/utils/cn"; export function EquationElementStatic(props: SlateElementProps) { const { element } = props; const html = getEquationHtml({ element, options: { displayMode: true, errorColor: "#cc0000", fleqn: false, leqno: false, macros: { "\\f": "#1f(#2)" }, output: "htmlAndMathml", strict: "warn", throwOnError: false, trust: false, }, }); return (
    {element.texExpression.length > 0 ? ( ) : (
    Add a Tex equation
    )}
    {props.children}
    ); } export function InlineEquationElementStatic(props: SlateElementProps) { const html = getEquationHtml({ element: props.element, options: { displayMode: true, errorColor: "#cc0000", fleqn: false, leqno: false, macros: { "\\f": "#1f(#2)" }, output: "htmlAndMathml", strict: "warn", throwOnError: false, trust: false, }, }); return (
    {props.children}
    ); } ================================================ FILE: app/src/components/ui/equation-node.tsx ================================================ // @ts-nocheck "use client"; import * as React from "react"; import TextareaAutosize, { type TextareaAutosizeProps } from "react-textarea-autosize"; import type { TEquationElement } from "platejs"; import type { PlateElementProps } from "platejs/react"; import { useEquationElement, useEquationInput } from "@platejs/math/react"; import { BlockSelectionPlugin } from "@platejs/selection/react"; import { CornerDownLeftIcon, RadicalIcon } from "lucide-react"; import { createPrimitiveComponent, PlateElement, useEditorRef, useEditorSelector, useElement, useReadOnly, useSelected, } from "platejs/react"; import { Button } from "@/components/ui/button"; import { Popover, PopoverContent, PopoverTrigger } from "@/components/ui/popover"; import { cn } from "@/utils/cn"; export function EquationElement(props: PlateElementProps) { const selected = useSelected(); const [open, setOpen] = React.useState(selected); const katexRef = React.useRef(null); useEquationElement({ element: props.element, katexRef: katexRef, options: { displayMode: true, errorColor: "#cc0000", fleqn: false, leqno: false, macros: { "\\f": "#1f(#2)" }, output: "htmlAndMathml", strict: "warn", throwOnError: false, trust: false, }, }); return (
    {props.element.texExpression.length > 0 ? ( ) : (
    Add a Tex equation
    )}
    0 \\\\\n 0, &\\quad x = 0 \\\\\n -x^2, &\\quad x < 0\n\\end{cases}`} isInline={false} setOpen={setOpen} />
    {props.children}
    ); } export function InlineEquationElement(props: PlateElementProps) { const element = props.element; const katexRef = React.useRef(null); const selected = useSelected(); const isCollapsed = useEditorSelector((editor) => editor.api.isCollapsed(), []); const [open, setOpen] = React.useState(selected && isCollapsed); React.useEffect(() => { if (selected && isCollapsed) { setOpen(true); } }, [selected, isCollapsed]); useEquationElement({ element, katexRef: katexRef, options: { displayMode: true, errorColor: "#cc0000", fleqn: false, leqno: false, macros: { "\\f": "#1f(#2)" }, output: "htmlAndMathml", strict: "warn", throwOnError: false, trust: false, }, }); return (
    0 && open) || selected) && "after:bg-brand/15", element.texExpression.length === 0 && "text-muted-foreground after:bg-neutral-500/10", )} contentEditable={false} > {element.texExpression.length === 0 && ( New equation )}
    {props.children}
    ); } const EquationInput = createPrimitiveComponent(TextareaAutosize)({ propsHook: useEquationInput, }); const EquationPopoverContent = ({ className, isInline, open, setOpen, ...props }: { isInline: boolean; open: boolean; setOpen: (open: boolean) => void; } & TextareaAutosizeProps) => { const editor = useEditorRef(); const readOnly = useReadOnly(); const element = useElement(); React.useEffect(() => { if (isInline && open) { setOpen(true); } }, [isInline, open, setOpen]); if (readOnly) return null; const onClose = () => { setOpen(false); if (isInline) { editor.tf.select(element, { focus: true, next: true }); } else { editor.getApi(BlockSelectionPlugin).blockSelection.set(element.id as string); } }; return ( { e.preventDefault(); }} contentEditable={false} > ); }; ================================================ FILE: app/src/components/ui/equation-toolbar-button.tsx ================================================ "use client"; import * as React from "react"; import { insertInlineEquation } from "@platejs/math"; import { RadicalIcon } from "lucide-react"; import { useEditorRef } from "platejs/react"; import { ToolbarButton } from "./toolbar"; export function InlineEquationToolbarButton(props: React.ComponentProps) { const editor = useEditorRef(); return ( { insertInlineEquation(editor); }} tooltip="Mark as equation" > ); } ================================================ FILE: app/src/components/ui/export-toolbar-button.tsx ================================================ "use client"; import * as React from "react"; import type { DropdownMenuProps } from "@radix-ui/react-dropdown-menu"; import { MarkdownPlugin } from "@platejs/markdown"; import { ArrowDownToLineIcon } from "lucide-react"; import { createSlateEditor, serializeHtml } from "platejs"; import { useEditorRef } from "platejs/react"; import { DropdownMenu, DropdownMenuContent, DropdownMenuGroup, DropdownMenuItem, DropdownMenuTrigger, } from "@/components/ui/dropdown-menu"; import { BaseEditorKit } from "@/components/editor/editor-base-kit"; import { EditorStatic } from "./editor-static"; import { ToolbarButton } from "./toolbar"; const siteUrl = "https://platejs.org"; export function ExportToolbarButton(props: DropdownMenuProps) { const editor = useEditorRef(); const [open, setOpen] = React.useState(false); const getCanvas = async () => { const { default: html2canvas } = await import("html2canvas-pro"); const style = document.createElement("style"); document.head.append(style); const canvas = await html2canvas(editor.api.toDOMNode(editor)!, { onclone: (document: Document) => { const editorElement = document.querySelector('[contenteditable="true"]'); if (editorElement) { Array.from(editorElement.querySelectorAll("*")).forEach((element) => { const existingStyle = element.getAttribute("style") || ""; element.setAttribute( "style", `${existingStyle}; font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif !important`, ); }); } }, }); style.remove(); return canvas; }; const downloadFile = async (url: string, filename: string) => { const response = await fetch(url); const blob = await response.blob(); const blobUrl = window.URL.createObjectURL(blob); const link = document.createElement("a"); link.href = blobUrl; link.download = filename; document.body.append(link); link.click(); link.remove(); // Clean up the blob URL window.URL.revokeObjectURL(blobUrl); }; const exportToPdf = async () => { const canvas = await getCanvas(); const PDFLib = await import("pdf-lib"); const pdfDoc = await PDFLib.PDFDocument.create(); const page = pdfDoc.addPage([canvas.width, canvas.height]); const imageEmbed = await pdfDoc.embedPng(canvas.toDataURL("PNG")); const { height, width } = imageEmbed.scale(1); page.drawImage(imageEmbed, { height, width, x: 0, y: 0, }); const pdfBase64 = await pdfDoc.saveAsBase64({ dataUri: true }); await downloadFile(pdfBase64, "plate.pdf"); }; const exportToImage = async () => { const canvas = await getCanvas(); await downloadFile(canvas.toDataURL("image/png"), "plate.png"); }; const exportToHtml = async () => { const editorStatic = createSlateEditor({ plugins: BaseEditorKit, value: editor.children, }); const editorHtml = await serializeHtml(editorStatic, { editorComponent: EditorStatic, props: { style: { padding: "0 calc(50% - 350px)", paddingBottom: "" } }, }); const tailwindCss = ``; const katexCss = ``; const html = ` ${tailwindCss} ${katexCss} ${editorHtml} `; const url = `data:text/html;charset=utf-8,${encodeURIComponent(html)}`; await downloadFile(url, "plate.html"); }; const exportToMarkdown = async () => { const md = editor.getApi(MarkdownPlugin).markdown.serialize(); const url = `data:text/markdown;charset=utf-8,${encodeURIComponent(md)}`; await downloadFile(url, "plate.md"); }; return ( Export as HTML Export as PDF Export as Image Export as Markdown ); } ================================================ FILE: app/src/components/ui/field.tsx ================================================ import { Button } from "@/components/ui/button"; import { Input } from "@/components/ui/input"; import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from "@/components/ui/select"; import { Slider } from "@/components/ui/slider"; import { Switch } from "@/components/ui/switch"; import { Settings, settingsSchema } from "@/core/service/Settings"; import { settingsIcons } from "@/core/service/SettingsIcons"; import { Telemetry } from "@/core/service/Telemetry"; import { cn } from "@/utils/cn"; import _ from "lodash"; import { ChevronRight, RotateCw } from "lucide-react"; import React, { CSSProperties, Fragment, useEffect, useLayoutEffect, useRef, useState } from "react"; import { useTranslation } from "react-i18next"; export function SettingField({ settingKey, extra = <> }: { settingKey: keyof Settings; extra?: React.ReactNode }) { const [value, setValue] = React.useState(Settings[settingKey]); const { t, i18n } = useTranslation("settings"); const schema = settingsSchema.shape[settingKey]; React.useEffect(() => { if (value !== Settings[settingKey]) { // @ts-expect-error 不知道为什么Settings[settingKey]可能是never Settings[settingKey] = value; postTelemetryEvent(); } if (settingKey === "language") { i18n.changeLanguage(value); } }, [value]); const postTelemetryEvent = _.debounce(() => { if (settingKey === "aiApiKey") return; Telemetry.event("修改设置", { key: settingKey, value, }); }, 1000); // @ts-expect-error fuck ts const Icon = settingsIcons[settingKey] ?? Fragment; return ( } className="border-accent not-hover:rounded-none hover:bg-accent border-b transition" > setValue(schema._def.defaultValue)} /> {extra} {schema._def.innerType._def.typeName === "ZodString" ? ( setValue(e.target.value)} className="w-64" /> ) : schema._def.innerType._def.typeName === "ZodNumber" && schema._def.innerType._def.checks.find((it) => it.kind === "min") && schema._def.innerType._def.checks.find((it) => it.kind === "max") ? ( <> setValue(v)} min={schema._def.innerType._def.checks.find((it) => it.kind === "min")?.value ?? 0} max={schema._def.innerType._def.checks.find((it) => it.kind === "max")?.value ?? 1} step={ schema._def.innerType._def.checks.find((it) => it.kind === "int") ? 1 : (schema._def.innerType._def.checks.find((it) => it.kind === "multipleOf")?.value ?? 0.01) } className="w-48" /> setValue(parseFloat(e.target.value))} type="number" min={schema._def.innerType._def.checks.find((it) => it.kind === "min")?.value ?? 0} max={schema._def.innerType._def.checks.find((it) => it.kind === "max")?.value ?? 1} step={ schema._def.innerType._def.checks.find((it) => it.kind === "int") ? 1 : (schema._def.innerType._def.checks.find((it) => it.kind === "multipleOf")?.value ?? 0.01) } className="w-24" /> ) : schema._def.innerType._def.typeName === "ZodNumber" ? ( setValue(e.target.valueAsNumber)} type="number" className="w-32" /> ) : schema._def.innerType._def.typeName === "ZodBoolean" ? ( ) : schema._def.innerType._def.typeName === "ZodUnion" ? ( ) : ( <>unknown type )} ); } export function ButtonField({ title, description = "", label = "", disabled = false, onClick = () => {}, icon = <>, }: { title: string; description?: string; label?: string; disabled?: boolean; onClick?: () => void; icon?: React.ReactNode; }) { return ( ); } const fieldColors = { default: "hover:bg-field-group-hover-bg", celebrate: "border-2 border-green-500/20 hover:bg-green-500/25", danger: "border-2 border-red-500/20 hover:bg-red-500/25", warning: "border-2 border-yellow-500/20 hover:bg-yellow-500/25", thinking: "border-2 border-blue-500/20 hover:bg-blue-500/25", imaging: "border-2 border-purple-500/20 hover:bg-purple-500/25", }; /** * 每一个设置段 * @param param0 * @returns */ export function Field({ title = "", description = "", children = <>, extra = <>, color = "default", icon = <>, className = "", style = {}, onClick = () => {}, }: { title?: string; description?: string; children?: React.ReactNode; extra?: React.ReactNode; color?: "default" | "celebrate" | "danger" | "warning" | "thinking" | "imaging"; icon?: React.ReactNode; className?: string; style?: CSSProperties; onClick?: () => void; }) { return (
    {icon}
    {title} {description.split("\n").map((dd, ii) => (

    {dd}

    ))}
    {children}
    {extra}
    ); } /** * 用于给各种设置项提供一个分类组 * @param param0 * @returns */ export function FieldGroup({ title = "", icon = null, children = null, className = "", description = "", }: { title?: string; icon?: React.ReactNode; children?: React.ReactNode; className?: string; description?: string; }) { const [isOpen, setIsOpen] = useState(false); const [height, setHeight] = useState(0); const contentRef = useRef(null); const innerRef = useRef(null); const [isAnimating, setAnimating] = useState(false); const [shouldMount, setShouldMount] = useState(isOpen); useEffect(() => { const el = innerRef.current; if (!el) return; const ro = new ResizeObserver(() => { if (isOpen) setHeight(el.offsetHeight); }); ro.observe(el); return () => ro.disconnect(); }, [isOpen]); useLayoutEffect(() => { if (!isOpen) { setHeight(0); return; } requestAnimationFrame(() => { const el = innerRef.current; if (el) setHeight(el.offsetHeight); }); }, [isOpen]); const handleToggle = () => { setAnimating(true); const next = !isOpen; setIsOpen(next); if (next) { setShouldMount(true); // 展开:立即挂载 } else { setTimeout(() => { // 折叠:动画后再卸载 setShouldMount(false); }, 250); } setTimeout(() => setAnimating(false), 500); }; return (
    {icon} {title}
    {description && isOpen &&
    {description}
    }
    {shouldMount && (
    {children}
    )}
    ); } ================================================ FILE: app/src/components/ui/file-chooser.tsx ================================================ import { Button } from "@/components/ui/button"; import { Input } from "@/components/ui/input"; import { isWeb } from "@/utils/platform"; import { open } from "@tauri-apps/plugin-dialog"; import { FolderOpen } from "lucide-react"; export default function FileChooser({ kind, value = "", onChange = () => {}, }: { kind: "file" | "directory"; value?: string; onChange?: (value: string) => void; }) { return isWeb ? (
    网页版暂不支持文件选择
    ) : (
    onChange(e.target.value)} />
    ); } ================================================ FILE: app/src/components/ui/fixed-toolbar-buttons.tsx ================================================ "use client"; import { ArrowUpToLineIcon, BaselineIcon, BoldIcon, Code2Icon, ItalicIcon, PaintBucketIcon, StrikethroughIcon, UnderlineIcon, Hand, } from "lucide-react"; import { KEYS } from "platejs"; import { useEditorReadOnly } from "platejs/react"; import { AlignToolbarButton } from "./align-toolbar-button"; import { ExportToolbarButton } from "./export-toolbar-button"; import { FontColorToolbarButton } from "./font-color-toolbar-button"; // import { RedoToolbarButton, UndoToolbarButton } from "./history-toolbar-button"; import { ImportToolbarButton } from "./import-toolbar-button"; import { InsertToolbarButton } from "./insert-toolbar-button"; import { LinkToolbarButton } from "./link-toolbar-button"; import { BulletedListToolbarButton, NumberedListToolbarButton, TodoListToolbarButton } from "./list-toolbar-button"; import { MarkToolbarButton } from "./mark-toolbar-button"; import { MoreToolbarButton } from "./more-toolbar-button"; import { TableToolbarButton } from "./table-toolbar-button"; import { ToggleToolbarButton } from "./toggle-toolbar-button"; import { ToolbarGroup } from "./toolbar"; import { TurnIntoToolbarButton } from "./turn-into-toolbar-button"; import { FontSizeToolbarButton } from "./font-size-toolbar-button"; export function FixedToolbarButtons() { const readOnly = useEditorReadOnly(); return (
    {!readOnly && ( <> {/* */} {/* */} {/**/} )}
    {/* */}
    ); } ================================================ FILE: app/src/components/ui/fixed-toolbar.tsx ================================================ "use client"; import { cn } from "@/utils/cn"; import { Toolbar } from "./toolbar"; export function FixedToolbar(props: React.ComponentProps) { return ( ); } ================================================ FILE: app/src/components/ui/floating-toolbar-buttons.tsx ================================================ "use client"; import { BoldIcon, Code2Icon, ItalicIcon, StrikethroughIcon, UnderlineIcon } from "lucide-react"; import { KEYS } from "platejs"; import { useEditorReadOnly } from "platejs/react"; import { InlineEquationToolbarButton } from "./equation-toolbar-button"; import { FontSizeToolbarButton } from "./font-size-toolbar-button"; import { LinkToolbarButton } from "./link-toolbar-button"; import { MarkToolbarButton } from "./mark-toolbar-button"; import { ToolbarGroup } from "./toolbar"; import { TurnIntoToolbarButton } from "./turn-into-toolbar-button"; export function FloatingToolbarButtons() { const readOnly = useEditorReadOnly(); return ( <> {!readOnly && ( <> {/* Ask AI */} )} {/* {!readOnly && } */} ); } ================================================ FILE: app/src/components/ui/floating-toolbar.tsx ================================================ // @ts-nocheck "use client"; import * as React from "react"; import { type FloatingToolbarState, flip, offset, useFloatingToolbar, useFloatingToolbarState, } from "@platejs/floating"; import { useComposedRef } from "@udecode/cn"; import { KEYS } from "platejs"; import { useEditorId, useEventEditorValue, usePluginOption } from "platejs/react"; import { cn } from "@/utils/cn"; import { Toolbar } from "./toolbar"; export function FloatingToolbar({ children, className, state, ...props }: React.ComponentProps & { state?: FloatingToolbarState; }) { const editorId = useEditorId(); const focusedEditorId = useEventEditorValue("focus"); const isFloatingLinkOpen = !!usePluginOption({ key: KEYS.link }, "mode"); const isAIChatOpen = usePluginOption({ key: KEYS.aiChat }, "open"); const floatingToolbarState = useFloatingToolbarState({ editorId, focusedEditorId, hideToolbar: isFloatingLinkOpen || isAIChatOpen, ...state, floatingOptions: { middleware: [ offset(12), flip({ fallbackPlacements: ["top-start", "top-end", "bottom-start", "bottom-end"], padding: 12, }), ], placement: "top", ...state?.floatingOptions, }, }); const { clickOutsideRef, hidden, props: rootProps, ref: floatingRef } = useFloatingToolbar(floatingToolbarState); const ref = useComposedRef(props.ref, floatingRef); if (hidden) return null; return (
    {children}
    ); } ================================================ FILE: app/src/components/ui/font-color-toolbar-button.tsx ================================================ "use client"; import React from "react"; import type { DropdownMenuItemProps, DropdownMenuProps } from "@radix-ui/react-dropdown-menu"; import { useComposedRef } from "@udecode/cn"; import debounce from "lodash/debounce.js"; import { EraserIcon, PlusIcon } from "lucide-react"; import { useEditorRef, useEditorSelector } from "platejs/react"; import { buttonVariants } from "@/components/ui/button"; import { DropdownMenu, DropdownMenuContent, DropdownMenuItem, DropdownMenuTrigger, } from "@/components/ui/dropdown-menu"; import { Tooltip, TooltipContent, TooltipProvider, TooltipTrigger } from "@/components/ui/tooltip"; import { cn } from "@/utils/cn"; import { ToolbarButton, ToolbarMenuGroup } from "./toolbar"; export function FontColorToolbarButton({ children, nodeType, tooltip, }: { nodeType: string; tooltip?: string; } & DropdownMenuProps) { const editor = useEditorRef(); const selectionDefined = useEditorSelector((editor) => !!editor.selection, []); const color = useEditorSelector((editor) => editor.api.mark(nodeType) as string, [nodeType]); const [selectedColor, setSelectedColor] = React.useState(); const [open, setOpen] = React.useState(false); const onToggle = React.useCallback( (value = !open) => { setOpen(value); }, [open, setOpen], ); const updateColor = React.useCallback( (value: string) => { if (editor.selection) { setSelectedColor(value); editor.tf.select(editor.selection); editor.tf.focus(); editor.tf.addMarks({ [nodeType]: value }); } }, [editor, nodeType], ); const updateColorAndClose = React.useCallback( (value: string) => { updateColor(value); onToggle(); }, [onToggle, updateColor], ); const clearColor = React.useCallback(() => { if (editor.selection) { editor.tf.select(editor.selection); editor.tf.focus(); if (selectedColor) { editor.tf.removeMarks(nodeType); } onToggle(); } }, [editor, selectedColor, onToggle, nodeType]); React.useEffect(() => { if (selectionDefined) { setSelectedColor(color); } }, [color, selectionDefined]); return ( { setOpen(value); }} modal={false} > {children} ); } function PureColorPicker({ className, clearColor, color, colors, customColors, updateColor, updateCustomColor, ...props }: React.ComponentProps<"div"> & { colors: TColor[]; customColors: TColor[]; clearColor: () => void; updateColor: (color: string) => void; updateCustomColor: (color: string) => void; color?: string; }) { return (
    {color && ( Clear )}
    ); } const ColorPicker = React.memo( PureColorPicker, (prev, next) => prev.color === next.color && prev.colors === next.colors && prev.customColors === next.customColors, ); function ColorCustom({ className, color, colors, customColors, updateColor, updateCustomColor, ...props }: { colors: TColor[]; customColors: TColor[]; updateColor: (color: string) => void; updateCustomColor: (color: string) => void; color?: string; } & React.ComponentPropsWithoutRef<"div">) { const [customColor, setCustomColor] = React.useState(); const [value, setValue] = React.useState(color || "#000000"); React.useEffect(() => { if (!color || customColors.some((c) => c.value === color) || colors.some((c) => c.value === color)) { return; } setCustomColor(color); }, [color, colors, customColors]); const computedColors = React.useMemo( () => customColor ? [ ...customColors, { isBrightColor: false, name: "", value: customColor, }, ] : customColors, [customColor, customColors], ); // eslint-disable-next-line react-hooks/exhaustive-deps const updateCustomColorDebounced = React.useCallback(debounce(updateCustomColor, 100), [updateCustomColor]); return (
    { setValue(e.target.value); updateCustomColorDebounced(e.target.value); }} > { e.preventDefault(); }} > Custom
    ); } function ColorInput({ children, className, value = "#000000", ...props }: React.ComponentProps<"input">) { const inputRef = React.useRef(null); return (
    {React.Children.map(children, (child) => { if (!child) return child; return React.cloneElement( child as React.ReactElement<{ onClick: () => void; }>, { onClick: () => inputRef.current?.click(), }, ); })}
    ); } type TColor = { isBrightColor: boolean; name: string; value: string; }; function ColorDropdownMenuItem({ className, isBrightColor, isSelected, name, updateColor, value, ...props }: { isBrightColor: boolean; isSelected: boolean; value: string; updateColor: (color: string) => void; name?: string; } & DropdownMenuItemProps) { const content = ( { e.preventDefault(); updateColor(value); }} {...props} /> ); return name ? ( {content} {name} ) : ( content ); } export function ColorDropdownMenuItems({ className, color, colors, updateColor, ...props }: { colors: TColor[]; updateColor: (color: string) => void; color?: string; } & React.ComponentProps<"div">) { return (
    {colors.map(({ isBrightColor, name, value }) => ( ))} {props.children}
    ); } export const DEFAULT_COLORS = [ { isBrightColor: false, name: "black", value: "#000000", }, { isBrightColor: false, name: "dark grey 4", value: "#434343", }, { isBrightColor: false, name: "dark grey 3", value: "#666666", }, { isBrightColor: false, name: "dark grey 2", value: "#999999", }, { isBrightColor: false, name: "dark grey 1", value: "#B7B7B7", }, { isBrightColor: false, name: "grey", value: "#CCCCCC", }, { isBrightColor: false, name: "light grey 1", value: "#D9D9D9", }, { isBrightColor: true, name: "light grey 2", value: "#EFEFEF", }, { isBrightColor: true, name: "light grey 3", value: "#F3F3F3", }, { isBrightColor: true, name: "white", value: "#FFFFFF", }, { isBrightColor: false, name: "red berry", value: "#980100", }, { isBrightColor: false, name: "red", value: "#FE0000", }, { isBrightColor: false, name: "orange", value: "#FE9900", }, { isBrightColor: true, name: "yellow", value: "#FEFF00", }, { isBrightColor: false, name: "green", value: "#00FF00", }, { isBrightColor: false, name: "cyan", value: "#00FFFF", }, { isBrightColor: false, name: "cornflower blue", value: "#4B85E8", }, { isBrightColor: false, name: "blue", value: "#1300FF", }, { isBrightColor: false, name: "purple", value: "#9900FF", }, { isBrightColor: false, name: "magenta", value: "#FF00FF", }, { isBrightColor: false, name: "light red berry 3", value: "#E6B8AF", }, { isBrightColor: false, name: "light red 3", value: "#F4CCCC", }, { isBrightColor: true, name: "light orange 3", value: "#FCE4CD", }, { isBrightColor: true, name: "light yellow 3", value: "#FFF2CC", }, { isBrightColor: true, name: "light green 3", value: "#D9EAD3", }, { isBrightColor: false, name: "light cyan 3", value: "#D0DFE3", }, { isBrightColor: false, name: "light cornflower blue 3", value: "#C9DAF8", }, { isBrightColor: true, name: "light blue 3", value: "#CFE1F3", }, { isBrightColor: true, name: "light purple 3", value: "#D9D2E9", }, { isBrightColor: true, name: "light magenta 3", value: "#EAD1DB", }, { isBrightColor: false, name: "light red berry 2", value: "#DC7E6B", }, { isBrightColor: false, name: "light red 2", value: "#EA9999", }, { isBrightColor: false, name: "light orange 2", value: "#F9CB9C", }, { isBrightColor: true, name: "light yellow 2", value: "#FFE598", }, { isBrightColor: false, name: "light green 2", value: "#B7D6A8", }, { isBrightColor: false, name: "light cyan 2", value: "#A1C4C9", }, { isBrightColor: false, name: "light cornflower blue 2", value: "#A4C2F4", }, { isBrightColor: false, name: "light blue 2", value: "#9FC5E8", }, { isBrightColor: false, name: "light purple 2", value: "#B5A7D5", }, { isBrightColor: false, name: "light magenta 2", value: "#D5A6BD", }, { isBrightColor: false, name: "light red berry 1", value: "#CC4125", }, { isBrightColor: false, name: "light red 1", value: "#E06666", }, { isBrightColor: false, name: "light orange 1", value: "#F6B26B", }, { isBrightColor: false, name: "light yellow 1", value: "#FFD966", }, { isBrightColor: false, name: "light green 1", value: "#93C47D", }, { isBrightColor: false, name: "light cyan 1", value: "#76A5AE", }, { isBrightColor: false, name: "light cornflower blue 1", value: "#6C9EEB", }, { isBrightColor: false, name: "light blue 1", value: "#6FA8DC", }, { isBrightColor: false, name: "light purple 1", value: "#8D7CC3", }, { isBrightColor: false, name: "light magenta 1", value: "#C27BA0", }, { isBrightColor: false, name: "dark red berry 1", value: "#A61B00", }, { isBrightColor: false, name: "dark red 1", value: "#CC0000", }, { isBrightColor: false, name: "dark orange 1", value: "#E59138", }, { isBrightColor: false, name: "dark yellow 1", value: "#F1C231", }, { isBrightColor: false, name: "dark green 1", value: "#6AA74F", }, { isBrightColor: false, name: "dark cyan 1", value: "#45818E", }, { isBrightColor: false, name: "dark cornflower blue 1", value: "#3B78D8", }, { isBrightColor: false, name: "dark blue 1", value: "#3E84C6", }, { isBrightColor: false, name: "dark purple 1", value: "#664EA6", }, { isBrightColor: false, name: "dark magenta 1", value: "#A64D78", }, { isBrightColor: false, name: "dark red berry 2", value: "#84200D", }, { isBrightColor: false, name: "dark red 2", value: "#990001", }, { isBrightColor: false, name: "dark orange 2", value: "#B45F05", }, { isBrightColor: false, name: "dark yellow 2", value: "#BF9002", }, { isBrightColor: false, name: "dark green 2", value: "#38761D", }, { isBrightColor: false, name: "dark cyan 2", value: "#124F5C", }, { isBrightColor: false, name: "dark cornflower blue 2", value: "#1155CB", }, { isBrightColor: false, name: "dark blue 2", value: "#0C5394", }, { isBrightColor: false, name: "dark purple 2", value: "#351C75", }, { isBrightColor: false, name: "dark magenta 2", value: "#741B47", }, { isBrightColor: false, name: "dark red berry 3", value: "#5B0F00", }, { isBrightColor: false, name: "dark red 3", value: "#660000", }, { isBrightColor: false, name: "dark orange 3", value: "#783F04", }, { isBrightColor: false, name: "dark yellow 3", value: "#7E6000", }, { isBrightColor: false, name: "dark green 3", value: "#274E12", }, { isBrightColor: false, name: "dark cyan 3", value: "#0D343D", }, { isBrightColor: false, name: "dark cornflower blue 3", value: "#1B4487", }, { isBrightColor: false, name: "dark blue 3", value: "#083763", }, { isBrightColor: false, name: "dark purple 3", value: "#1F124D", }, { isBrightColor: false, name: "dark magenta 3", value: "#4C1130", }, ]; const DEFAULT_CUSTOM_COLORS = [ { isBrightColor: false, name: "dark orange 3", value: "#783F04", }, { isBrightColor: false, name: "dark grey 3", value: "#666666", }, { isBrightColor: false, name: "dark grey 2", value: "#999999", }, { isBrightColor: false, name: "light cornflower blue 1", value: "#6C9EEB", }, { isBrightColor: false, name: "dark magenta 3", value: "#4C1130", }, ]; ================================================ FILE: app/src/components/ui/font-size-toolbar-button.tsx ================================================ // @ts-nocheck "use client"; import * as React from "react"; import type { TElement } from "platejs"; import { toUnitLess } from "@platejs/basic-styles"; import { FontSizePlugin } from "@platejs/basic-styles/react"; import { Minus, Plus } from "lucide-react"; import { KEYS } from "platejs"; import { useEditorPlugin, useEditorSelector } from "platejs/react"; import { Popover, PopoverContent, PopoverTrigger } from "@/components/ui/popover"; import { cn } from "@/utils/cn"; import { ToolbarButton } from "./toolbar"; const DEFAULT_FONT_SIZE = "16"; const FONT_SIZE_MAP = { h1: "36", h2: "24", h3: "20", } as const; const FONT_SIZES = ["8", "9", "10", "12", "14", "16", "18", "24", "30", "36", "48", "60", "72", "96"] as const; export function FontSizeToolbarButton() { const [inputValue, setInputValue] = React.useState(DEFAULT_FONT_SIZE); const [isFocused, setIsFocused] = React.useState(false); const { editor, tf } = useEditorPlugin(FontSizePlugin); const cursorFontSize = useEditorSelector((editor) => { const fontSize = editor.api.marks()?.[KEYS.fontSize]; if (fontSize) { return toUnitLess(fontSize as string); } const [block] = editor.api.block() || []; if (!block?.type) return DEFAULT_FONT_SIZE; return block.type in FONT_SIZE_MAP ? FONT_SIZE_MAP[block.type as keyof typeof FONT_SIZE_MAP] : DEFAULT_FONT_SIZE; }, []); const handleInputChange = () => { const newSize = toUnitLess(inputValue); if (Number.parseInt(newSize) < 1 || Number.parseInt(newSize) > 100) { editor.tf.focus(); return; } if (newSize !== toUnitLess(cursorFontSize)) { tf.fontSize.addMark(`${newSize}px`); } editor.tf.focus(); }; const handleFontSizeChange = (delta: number) => { const newSize = Number(displayValue) + delta; tf.fontSize.addMark(`${newSize}px`); editor.tf.focus(); }; const displayValue = isFocused ? inputValue : cursorFontSize; return (
    handleFontSizeChange(-1)}> { setIsFocused(false); handleInputChange(); }} onChange={(e) => setInputValue(e.target.value)} onFocus={() => { setIsFocused(true); setInputValue(toUnitLess(cursorFontSize)); }} onKeyDown={(e) => { if (e.key === "Enter") { e.preventDefault(); handleInputChange(); } }} data-plate-focus="true" type="text" /> e.preventDefault()}> {FONT_SIZES.map((size) => ( ))} handleFontSizeChange(1)}>
    ); } ================================================ FILE: app/src/components/ui/heading-node-static.tsx ================================================ import * as React from "react"; import type { SlateElementProps } from "platejs"; import { type VariantProps, cva } from "class-variance-authority"; import { SlateElement } from "platejs"; const headingVariants = cva("relative mb-1", { variants: { variant: { h1: "mt-[1.6em] pb-1 font-heading text-4xl font-bold", h2: "mt-[1.4em] pb-px font-heading text-2xl font-semibold tracking-tight", h3: "mt-[1em] pb-px font-heading text-xl font-semibold tracking-tight", h4: "mt-[0.75em] font-heading text-lg font-semibold tracking-tight", h5: "mt-[0.75em] text-lg font-semibold tracking-tight", h6: "mt-[0.75em] text-base font-semibold tracking-tight", }, }, }); export function HeadingElementStatic({ variant = "h1", ...props }: SlateElementProps & VariantProps) { return ( {props.children} ); } export function H1ElementStatic(props: SlateElementProps) { return ; } export function H2ElementStatic(props: React.ComponentProps) { return ; } export function H3ElementStatic(props: React.ComponentProps) { return ; } export function H4ElementStatic(props: React.ComponentProps) { return ; } export function H5ElementStatic(props: React.ComponentProps) { return ; } export function H6ElementStatic(props: React.ComponentProps) { return ; } ================================================ FILE: app/src/components/ui/heading-node.tsx ================================================ // @ts-nocheck "use client"; import * as React from "react"; import type { PlateElementProps } from "platejs/react"; import { type VariantProps, cva } from "class-variance-authority"; import { PlateElement } from "platejs/react"; const headingVariants = cva("relative mb-1", { variants: { variant: { h1: "mt-[1.6em] pb-1 font-heading text-4xl font-bold", h2: "mt-[1.4em] pb-px font-heading text-2xl font-semibold tracking-tight", h3: "mt-[1em] pb-px font-heading text-xl font-semibold tracking-tight", h4: "mt-[0.75em] font-heading text-lg font-semibold tracking-tight", h5: "mt-[0.75em] text-lg font-semibold tracking-tight", h6: "mt-[0.75em] text-base font-semibold tracking-tight", }, }, }); export function HeadingElement({ variant = "h1", ...props }: PlateElementProps & VariantProps) { return ( {props.children} ); } export function H1Element(props: PlateElementProps) { return ; } export function H2Element(props: PlateElementProps) { return ; } export function H3Element(props: PlateElementProps) { return ; } export function H4Element(props: PlateElementProps) { return ; } export function H5Element(props: PlateElementProps) { return ; } export function H6Element(props: PlateElementProps) { return ; } ================================================ FILE: app/src/components/ui/highlight-node-static.tsx ================================================ // @ts-nocheck import * as React from "react"; import type { SlateLeafProps } from "platejs"; import { SlateLeaf } from "platejs"; export function HighlightLeafStatic(props: SlateLeafProps) { return ( {props.children} ); } ================================================ FILE: app/src/components/ui/highlight-node.tsx ================================================ // @ts-nocheck "use client"; import * as React from "react"; import type { PlateLeafProps } from "platejs/react"; import { PlateLeaf } from "platejs/react"; export function HighlightLeaf(props: PlateLeafProps) { return ( {props.children} ); } ================================================ FILE: app/src/components/ui/history-toolbar-button.tsx ================================================ // @ts-nocheck "use client"; import * as React from "react"; import { Redo2Icon, Undo2Icon } from "lucide-react"; import { useEditorRef, useEditorSelector } from "platejs/react"; import { ToolbarButton } from "./toolbar"; export function RedoToolbarButton(props: React.ComponentProps) { const editor = useEditorRef(); const disabled = useEditorSelector((editor) => editor.history.redos.length === 0, []); return ( editor.redo()} onMouseDown={(e) => e.preventDefault()} tooltip="Redo" > ); } export function UndoToolbarButton(props: React.ComponentProps) { const editor = useEditorRef(); const disabled = useEditorSelector((editor) => editor.history.undos.length === 0, []); return ( editor.undo()} onMouseDown={(e) => e.preventDefault()} tooltip="Undo" > ); } ================================================ FILE: app/src/components/ui/hr-node-static.tsx ================================================ // @ts-nocheck import * as React from "react"; import type { SlateElementProps } from "platejs"; import { SlateElement } from "platejs"; import { cn } from "@/utils/cn"; export function HrElementStatic(props: SlateElementProps) { return (

    {props.children}
    ); } ================================================ FILE: app/src/components/ui/hr-node.tsx ================================================ // @ts-nocheck "use client"; import * as React from "react"; import type { PlateElementProps } from "platejs/react"; import { PlateElement, useFocused, useReadOnly, useSelected } from "platejs/react"; import { cn } from "@/utils/cn"; export function HrElement(props: PlateElementProps) { const readOnly = useReadOnly(); const selected = useSelected(); const focused = useFocused(); return (

    {props.children}
    ); } ================================================ FILE: app/src/components/ui/import-toolbar-button.tsx ================================================ "use client"; import * as React from "react"; import type { DropdownMenuProps } from "@radix-ui/react-dropdown-menu"; import { MarkdownPlugin } from "@platejs/markdown"; import { ArrowUpToLineIcon } from "lucide-react"; import { getEditorDOMFromHtmlString } from "platejs"; import { useEditorRef } from "platejs/react"; import { useFilePicker } from "use-file-picker"; import { DropdownMenu, DropdownMenuContent, DropdownMenuGroup, DropdownMenuItem, DropdownMenuTrigger, } from "@/components/ui/dropdown-menu"; import { ToolbarButton } from "./toolbar"; type ImportType = "html" | "markdown"; export function ImportToolbarButton(props: DropdownMenuProps) { const editor = useEditorRef(); const [open, setOpen] = React.useState(false); const getFileNodes = (text: string, type: ImportType) => { if (type === "html") { const editorNode = getEditorDOMFromHtmlString(text); const nodes = editor.api.html.deserialize({ element: editorNode, }); return nodes; } if (type === "markdown") { return editor.getApi(MarkdownPlugin).markdown.deserialize(text); } return []; }; const { openFilePicker: openMdFilePicker } = useFilePicker({ accept: [".md", ".mdx"], multiple: false, onFilesSelected: async ({ plainFiles }) => { const text = await plainFiles[0].text(); const nodes = getFileNodes(text, "markdown"); editor.tf.insertNodes(nodes); }, }); const { openFilePicker: openHtmlFilePicker } = useFilePicker({ accept: ["text/html"], multiple: false, onFilesSelected: async ({ plainFiles }) => { const text = await plainFiles[0].text(); const nodes = getFileNodes(text, "html"); editor.tf.insertNodes(nodes); }, }); return ( { openHtmlFilePicker(); }} > Import from HTML { openMdFilePicker(); }} > Import from Markdown ); } ================================================ FILE: app/src/components/ui/indent-toolbar-button.tsx ================================================ "use client"; import * as React from "react"; import { useIndentButton, useOutdentButton } from "@platejs/indent/react"; import { IndentIcon, OutdentIcon } from "lucide-react"; import { ToolbarButton } from "./toolbar"; export function IndentToolbarButton(props: React.ComponentProps) { const { props: buttonProps } = useIndentButton(); return ( ); } export function OutdentToolbarButton(props: React.ComponentProps) { const { props: buttonProps } = useOutdentButton(); return ( ); } ================================================ FILE: app/src/components/ui/inline-combobox.tsx ================================================ // @ts-nocheck "use client"; import * as React from "react"; import type { Point, TElement } from "platejs"; import { type ComboboxItemProps, Combobox, ComboboxGroup, ComboboxGroupLabel, ComboboxItem, ComboboxPopover, ComboboxProvider, ComboboxRow, Portal, useComboboxContext, useComboboxStore, } from "@ariakit/react"; import { filterWords } from "@platejs/combobox"; import { type UseComboboxInputResult, useComboboxInput, useHTMLInputCursorState } from "@platejs/combobox/react"; import { cva } from "class-variance-authority"; import { useComposedRef, useEditorRef } from "platejs/react"; import { cn } from "@/utils/cn"; type FilterFn = ( item: { value: string; group?: string; keywords?: string[]; label?: string }, search: string, ) => boolean; interface InlineComboboxContextValue { filter: FilterFn | false; inputProps: UseComboboxInputResult["props"]; inputRef: React.RefObject; removeInput: UseComboboxInputResult["removeInput"]; showTrigger: boolean; trigger: string; setHasEmpty: (hasEmpty: boolean) => void; } const InlineComboboxContext = React.createContext( null as unknown as InlineComboboxContextValue, ); const defaultFilter: FilterFn = ({ group, keywords = [], label, value }, search) => { const uniqueTerms = new Set([value, ...keywords, group, label].filter(Boolean)); return Array.from(uniqueTerms).some((keyword) => filterWords(keyword!, search)); }; interface InlineComboboxProps { children: React.ReactNode; element: TElement; trigger: string; filter?: FilterFn | false; hideWhenNoValue?: boolean; showTrigger?: boolean; value?: string; setValue?: (value: string) => void; } const InlineCombobox = ({ children, element, filter = defaultFilter, hideWhenNoValue = false, setValue: setValueProp, showTrigger = true, trigger, value: valueProp, }: InlineComboboxProps) => { const editor = useEditorRef(); const inputRef = React.useRef(null); const cursorState = useHTMLInputCursorState(inputRef); const [valueState, setValueState] = React.useState(""); const hasValueProp = valueProp !== undefined; const value = hasValueProp ? valueProp : valueState; const setValue = React.useCallback( (newValue: string) => { setValueProp?.(newValue); if (!hasValueProp) { setValueState(newValue); } }, [setValueProp, hasValueProp], ); /** * Track the point just before the input element so we know where to * insertText if the combobox closes due to a selection change. */ const insertPoint = React.useRef(null); React.useEffect(() => { const path = editor.api.findPath(element); if (!path) return; const point = editor.api.before(path); if (!point) return; const pointRef = editor.api.pointRef(point); insertPoint.current = pointRef.current; return () => { pointRef.unref(); }; }, [editor, element]); const { props: inputProps, removeInput } = useComboboxInput({ cancelInputOnBlur: true, cursorState, ref: inputRef, onCancelInput: (cause) => { if (cause !== "backspace") { editor.tf.insertText(trigger + value, { at: insertPoint?.current ?? undefined, }); } if (cause === "arrowLeft" || cause === "arrowRight") { editor.tf.move({ distance: 1, reverse: cause === "arrowLeft", }); } }, }); const [hasEmpty, setHasEmpty] = React.useState(false); const contextValue: InlineComboboxContextValue = React.useMemo( () => ({ filter, inputProps, inputRef, removeInput, setHasEmpty, showTrigger, trigger, }), [trigger, showTrigger, filter, inputRef, inputProps, removeInput, setHasEmpty], ); const store = useComboboxStore({ // open: , setValue: (newValue) => React.startTransition(() => setValue(newValue)), }); const items = store.useState("items"); /** * If there is no active ID and the list of items changes, select the first * item. */ React.useEffect(() => { if (!store.getState().activeId) { store.setActiveId(store.first()); } }, [items, store]); return ( 0 || hasEmpty) && (!hideWhenNoValue || value.length > 0)} store={store}> {children} ); }; const InlineComboboxInput = React.forwardRef>( ({ className, ...props }, propRef) => { const { inputProps, inputRef: contextRef, showTrigger, trigger } = React.useContext(InlineComboboxContext); const store = useComboboxContext()!; const value = store.useState("value"); const ref = useComposedRef(propRef, contextRef); /** * To create an auto-resizing input, we render a visually hidden span * containing the input value and position the input element on top of it. * This works well for all cases except when input exceeds the width of the * container. */ return ( <> {showTrigger && trigger} ); }, ); InlineComboboxInput.displayName = "InlineComboboxInput"; const InlineComboboxContent: typeof ComboboxPopover = ({ className, ...props }) => { // Portal prevents CSS from leaking into popover return ( ); }; const comboboxItemVariants = cva( "relative mx-1 flex h-[28px] items-center rounded-sm px-2 text-sm text-foreground outline-none select-none [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0", { defaultVariants: { interactive: true, }, variants: { interactive: { false: "", true: "cursor-pointer transition-colors hover:bg-accent hover:text-accent-foreground data-[active-item=true]:bg-accent data-[active-item=true]:text-accent-foreground", }, }, }, ); const InlineComboboxItem = ({ className, focusEditor = true, group, keywords, label, onClick, ...props }: { focusEditor?: boolean; group?: string; keywords?: string[]; label?: string; } & ComboboxItemProps & Required>) => { const { value } = props; const { filter, removeInput } = React.useContext(InlineComboboxContext); const store = useComboboxContext()!; // Optimization: Do not subscribe to value if filter is false const search = filter && store.useState("value"); const visible = React.useMemo( () => !filter || filter({ group, keywords, label, value }, search as string), [filter, group, keywords, label, value, search], ); if (!visible) return null; return ( { removeInput(focusEditor); onClick?.(event); }} {...props} /> ); }; const InlineComboboxEmpty = ({ children, className }: React.HTMLAttributes) => { const { setHasEmpty } = React.useContext(InlineComboboxContext); const store = useComboboxContext()!; const items = store.useState("items"); React.useEffect(() => { setHasEmpty(true); return () => { setHasEmpty(false); }; }, [setHasEmpty]); if (items.length > 0) return null; return
    {children}
    ; }; const InlineComboboxRow = ComboboxRow; function InlineComboboxGroup({ className, ...props }: React.ComponentProps) { return (