{"id":20683175,"url":"https://github.com/chimehq/containeddocument","last_synced_at":"2025-04-22T12:21:34.794Z","repository":{"id":48011311,"uuid":"339445555","full_name":"ChimeHQ/ContainedDocument","owner":"ChimeHQ","description":"Nested NSDocuments","archived":false,"fork":false,"pushed_at":"2024-07-09T13:58:11.000Z","size":50,"stargazers_count":26,"open_issues_count":0,"forks_count":2,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-04-20T15:17:36.857Z","etag":null,"topics":["appkit","macos","nsdocument","swift"],"latest_commit_sha":null,"homepage":null,"language":"Swift","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ChimeHQ.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null},"funding":{"github":["mattmassicotte"]}},"created_at":"2021-02-16T15:38:57.000Z","updated_at":"2024-08-24T04:45:20.000Z","dependencies_parsed_at":"2023-11-29T19:30:52.759Z","dependency_job_id":"4b24b361-aa75-4455-ab33-fde584a1e4b8","html_url":"https://github.com/ChimeHQ/ContainedDocument","commit_stats":{"total_commits":12,"total_committers":2,"mean_commits":6.0,"dds":"0.33333333333333337","last_synced_commit":"c9577f1031d27dbb4d16f2645b1ee8b861490f42"},"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ChimeHQ%2FContainedDocument","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ChimeHQ%2FContainedDocument/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ChimeHQ%2FContainedDocument/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ChimeHQ%2FContainedDocument/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ChimeHQ","download_url":"https://codeload.github.com/ChimeHQ/ContainedDocument/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250237851,"owners_count":21397403,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["appkit","macos","nsdocument","swift"],"created_at":"2024-11-16T22:15:39.512Z","updated_at":"2025-04-22T12:21:34.776Z","avatar_url":"https://github.com/ChimeHQ.png","language":"Swift","funding_links":["https://github.com/sponsors/mattmassicotte"],"categories":[],"sub_categories":[],"readme":"\u003cdiv align=\"center\"\u003e\n\n[![Platforms][platforms badge]][platforms]\n[![Documentation][documentation badge]][documentation]\n[![Matrix][matrix badge]][matrix]\n\n\u003c/div\u003e\n\n# ContainedDocument\n\nContainedDocument allows you to nest `NSDocument` instances inside of abstract containers. These can be anything you need, including other `NSDocument` instances. This turns out to be a very tricky thing to do, and requires careful management of an `NSDocumentController` to make it possible.\n\nSupporting the full range of `NSDocument` operations and interactions is challenging. I was able to pull off many of them, but the coordination still requires subclassing both `NSDocument` and `NSDocumentController`. \n\n## Integration\n\n```swift\ndependencies: [\n    .package(url: \"https://github.com/ChimeHQ/ContainedDocument\", from: \"1.0.0\")\n]\n```\n\n## Classes\n\n**ContainedDocumentController**\n\nAn `NSDocumentController` subclass that manages the `NSDocument` life-cycle and relationship to your containers. To use it, you must override the three container-document association methods. Restorable state is supported, but is optional.\n\n```swift\nopen func associateDocument(_ document: NSDocument, to container: Container)\nopen func disassociateDocument(_ document: NSDocument)\nopen func documentContainer(for document: NSDocument) -\u003e Container?\n\nopen func encodeRestorableState(with coder: NSCoder, for document: NSDocument)\nopen func restoreState(with coder: NSCoder, for document: NSDocument)\n// ...\n```\n\nAlso, don't forget that an `NSDocumentController` is global to your AppKit process. You must instantiate your subclass as soon as possible to ensure it is being used.\n\n**ContainedDocument**\n\nThis is an `NSDocument` subclass that makes it possible to support document duplication and window restoration.\n\n## Contributing and Collaboration\n\nI would love to hear from you! Issues or pull requests work great. A [Matrix space][matrix] is also available for live help, but I have a strong bias towards answering in the form of documenation.\n\nI prefer collaboration, and would love to find ways to work together if you have a similar project.\n\nI prefer indentation with tabs for improved accessibility. But, I'd rather you use the system you want and make a PR than hesitate because of whitespace.\n\nBy participating in this project you agree to abide by the [Contributor Code of Conduct](CODE_OF_CONDUCT.md).\n\n[platforms]: https://swiftpackageindex.com/ChimeHQ/ContainedDocument\n[platforms badge]: https://img.shields.io/endpoint?url=https%3A%2F%2Fswiftpackageindex.com%2Fapi%2Fpackages%2FChimeHQ%2FContainedDocument%2Fbadge%3Ftype%3Dplatforms\n[documentation]: https://swiftpackageindex.com/ChimeHQ/ContainedDocument/main/documentation\n[documentation badge]: https://img.shields.io/badge/Documentation-DocC-blue\n[matrix]: https://matrix.to/#/%23chimehq%3Amatrix.org\n[matrix badge]: https://img.shields.io/matrix/chimehq%3Amatrix.org?label=Matrix\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fchimehq%2Fcontaineddocument","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fchimehq%2Fcontaineddocument","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fchimehq%2Fcontaineddocument/lists"}