TidGi-Desktop/docs/features/SubWiki.md
lin onetwo 5cd8437e10
Feat/subwiki external attachment (#671)
* lint

* fix: Use macos-15 (Intel) for x64 builds to get correct dugite git binaries

* Refactor routing utilities and improve files/ external in sub-wiki

Moves routing utility functions to be exported via $tw.utils and updates type usage for better plugin integration. Adds support for excluding external attachments folders (configurable via $:/config/ExternalAttachments/WikiFolderToMove) from file watching. Updates build script to include new entry points and adjusts loader to use the correct module path. Adds and renames relevant .meta and type definition files.

* Add sub-wiki support for external file access

Introduces sub-wiki path management and updates file retrieval logic to search both main and sub-wiki external attachment folders, as configured by `$:/config/ExternalAttachments/WikiFolderToMove`. Adds documentation for sub-wiki features and ensures consistent file access and exclusion across main and sub-wikis.

* Update FileSystemAdaptor.routing.test.ts

* Update fix-location-info.ts

* Apply suggestions from code review

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

* fix: test

---------

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
2025-12-16 17:01:09 +08:00

1.9 KiB

Sub-wiki Support

TidGi supports sub-wiki (child workspace) routing and management at several levels.

Tiddler Routing

FileSystemAdaptor routes tiddlers to the correct sub-wiki based on tags or custom filters. Routing rules, in order of priority:

  1. Direct tag match: tiddler tags match sub-wiki tagNames
  2. Tag tree match: recursive tag hierarchy if includeTagTree is enabled
  3. Custom filter: use fileSystemPathFilter expressions

These configs are editable by user using EditWorkspace's SubWiki section.

Tiddlers not matched to any sub-wiki are saved to the main workspace.

File Watching

WatchFileSystemAdaptor reads the external attachment folder name from $:/config/ExternalAttachments/WikiFolderToMove (default files) and excludes this folder from watching. This prevents external attachments from being repeatedly created as tiddlers.

External Attachments

tidgi-external-attachments plugin provides two key features:

Import-time routing:

  • When importing files, tags in the import dialog are used to match sub-wikis
  • Files are moved to the matched sub-wiki's files folder
  • Tiddlers are saved to the corresponding sub-wiki

Tag change sync:

  • When changing tags on an existing attachment tiddler, the file is automatically moved to the new sub-wiki
  • _canonical_uri remains unchanged (relative path stays the same)
  • Tiddler and file always stay in sync

File Access

ipcServerRoutes.getFile() searches for files in order:

  1. Main workspace's external attachment folder
  2. Each sub-wiki's external attachment folder (in configured order)

This ensures that even if a tiddler's _canonical_uri points to the main workspace, but the file is actually in a sub-wiki, it will still be found.

Configuration

All features use the same $:/config/ExternalAttachments/WikiFolderToMove config to determine the external attachment folder name, ensuring consistent behavior.