@anthusai/papyrus 1.19.1 → 2.0.0-next.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (80) hide show
  1. package/amplify/data/resource.js +7 -0
  2. package/amplify/data/resource.ts +8 -0
  3. package/amplify/data/schema.js +8 -0
  4. package/amplify/data/schema.ts +9 -0
  5. package/amplify/functions/assignment-action/data-access.js +88 -0
  6. package/amplify/functions/assignment-action/data-access.ts +87 -0
  7. package/amplify/functions/content-actions/handler.py +7 -0
  8. package/amplify/functions/model-attachment-upload/handler.ts +1 -0
  9. package/amplify/plugins/editorial-checks/function/handler.py +14 -0
  10. package/amplify/plugins/editorial-checks/function/requirements.txt +1 -0
  11. package/amplify/plugins/editorial-checks/function/resource.js +43 -0
  12. package/amplify/plugins/editorial-checks/function/resource.ts +60 -0
  13. package/amplify/plugins/editorial-checks/papyrus.plugin.js +71 -0
  14. package/amplify/plugins/editorial-checks/papyrus.plugin.ts +87 -0
  15. package/amplify/plugins/editorial-checks/schema.js +94 -0
  16. package/amplify/plugins/editorial-checks/schema.ts +96 -0
  17. package/amplify/plugins/registry.js +2 -0
  18. package/amplify/plugins/registry.ts +2 -0
  19. package/amplify/site-backend.js +5 -0
  20. package/amplify/site-backend.ts +11 -0
  21. package/app/globals.css +0 -175
  22. package/app/newsroom/[section]/[...selection]/page.tsx +0 -6
  23. package/app/newsroom/[section]/page.tsx +2 -4
  24. package/app/newsroom/articles/page.tsx +1 -2
  25. package/app/newsroom/sections/[sectionId]/page.tsx +2 -6
  26. package/bin/papyrus-infra.mjs +11 -2
  27. package/components/editorial-checks-admin-panel.tsx +337 -0
  28. package/components/editorial-finding-card.tsx +162 -0
  29. package/components/editorial-findings-panel.tsx +91 -0
  30. package/components/editorial-preview-popover.tsx +103 -0
  31. package/components/markus-body-editor.tsx +213 -0
  32. package/components/markus-ir-preview.tsx +147 -6
  33. package/components/news-desk-page.tsx +3 -4
  34. package/components/newsroom-article-editor.tsx +138 -11
  35. package/components/newsroom-board-view.tsx +6 -7
  36. package/components/newsroom-ops-shell.tsx +146 -234
  37. package/components/newsroom-organizer.css +57 -61
  38. package/components/newsroom-theme-fonts/broadsheet-green.css +10 -0
  39. package/components/newsroom-theme-fonts/broadsheet-green.tsx +6 -0
  40. package/components/newsroom-theme-fonts/newspaper-gothic.css +9 -0
  41. package/components/newsroom-theme-fonts/newspaper-gothic.tsx +6 -0
  42. package/components/newsroom-theme-fonts/night-desk.css +10 -0
  43. package/components/newsroom-theme-fonts/night-desk.tsx +6 -0
  44. package/components/newsroom-theme-fonts/refined-newsprint.css +11 -0
  45. package/components/newsroom-theme-fonts/refined-newsprint.tsx +6 -0
  46. package/components/newsroom-theme.css +39 -0
  47. package/components/newsroom-theme.tsx +33 -0
  48. package/components/reference-cyclotron-priming.tsx +12 -13
  49. package/components/reference-cyclotron-status.tsx +4 -4
  50. package/components/reference-cyclotron-suggestion.tsx +6 -6
  51. package/components/reference-live-agreement.tsx +10 -10
  52. package/components/reference-priming.tsx +1 -1
  53. package/components/reference-relevance-review.tsx +1 -1
  54. package/components/reference-section-suggestion.tsx +1 -1
  55. package/components/topic-steering-workspace.tsx +36 -511
  56. package/components/use-editorial-checks.ts +131 -0
  57. package/lib/cyclotron-suggestions.ts +9 -9
  58. package/lib/editorial-checks-backend.ts +16 -0
  59. package/lib/editorial-checks-client.ts +194 -0
  60. package/lib/editorial-checks-demo.ts +147 -0
  61. package/lib/editorial-checks-settings.ts +24 -0
  62. package/lib/editorial-checks.ts +178 -0
  63. package/lib/editorial-preview.ts +228 -0
  64. package/lib/newsroom-board.ts +27 -2
  65. package/lib/newsroom-list-selection.ts +0 -3
  66. package/lib/newsroom-nav.ts +5 -8
  67. package/lib/newsroom-section-routing.ts +2 -4
  68. package/lib/relevance-status.ts +4 -4
  69. package/lib/site-brand.ts +18 -8
  70. package/package.json +34 -3
  71. package/routes.manifest.json +1 -1
  72. package/src/cdk-environment.mjs +44 -0
  73. package/components/newsroom-fonts/playfair-display-700.ttf +0 -0
  74. package/components/newsroom-fonts/playfair-display-900.ttf +0 -0
  75. package/components/newsroom-fonts/playfair-display-OFL.txt +0 -93
  76. package/components/newsroom-fonts/plus-jakarta-sans-400.ttf +0 -0
  77. package/components/newsroom-fonts/plus-jakarta-sans-600.ttf +0 -0
  78. package/components/newsroom-fonts/plus-jakarta-sans-OFL.txt +0 -93
  79. package/components/newsroom-newsprint-board.css +0 -7
  80. package/components/newsroom-organizer-shell.tsx +0 -153
package/package.json CHANGED
@@ -78,7 +78,12 @@
78
78
  "./components/blog-page-background": "./components/blog-page-background.tsx",
79
79
  "./components/curation-delegation-client": "./components/curation-delegation-client.ts",
80
80
  "./components/dev-sandbox-editor-sign-in": "./components/dev-sandbox-editor-sign-in.tsx",
81
+ "./components/editorial-checks-admin-panel": "./components/editorial-checks-admin-panel.tsx",
82
+ "./components/editorial-finding-card": "./components/editorial-finding-card.tsx",
83
+ "./components/editorial-findings-panel": "./components/editorial-findings-panel.tsx",
84
+ "./components/editorial-preview-popover": "./components/editorial-preview-popover.tsx",
81
85
  "./components/item-stream-view": "./components/item-stream-view.tsx",
86
+ "./components/markus-body-editor": "./components/markus-body-editor.tsx",
82
87
  "./components/markus-ir-preview": "./components/markus-ir-preview.tsx",
83
88
  "./components/news-desk-client-provider": "./components/news-desk-client-provider.tsx",
84
89
  "./components/news-desk-page": "./components/news-desk-page.tsx",
@@ -94,8 +99,12 @@
94
99
  "./components/newsroom-curation-provider": "./components/newsroom-curation-provider.tsx",
95
100
  "./components/newsroom-ops-overview": "./components/newsroom-ops-overview.tsx",
96
101
  "./components/newsroom-ops-shell": "./components/newsroom-ops-shell.tsx",
97
- "./components/newsroom-organizer-shell": "./components/newsroom-organizer-shell.tsx",
98
102
  "./components/newsroom-references-view": "./components/newsroom-references-view.tsx",
103
+ "./components/newsroom-theme-fonts/broadsheet-green": "./components/newsroom-theme-fonts/broadsheet-green.tsx",
104
+ "./components/newsroom-theme-fonts/newspaper-gothic": "./components/newsroom-theme-fonts/newspaper-gothic.tsx",
105
+ "./components/newsroom-theme-fonts/night-desk": "./components/newsroom-theme-fonts/night-desk.tsx",
106
+ "./components/newsroom-theme-fonts/refined-newsprint": "./components/newsroom-theme-fonts/refined-newsprint.tsx",
107
+ "./components/newsroom-theme": "./components/newsroom-theme.tsx",
99
108
  "./components/newsroom-topics-view": "./components/newsroom-topics-view.tsx",
100
109
  "./components/papyrus-console-shell": "./components/papyrus-console-shell.tsx",
101
110
  "./components/pictogram-figure": "./components/pictogram-figure.tsx",
@@ -144,6 +153,7 @@
144
153
  "./components/ui/tooltip": "./components/ui/tooltip.tsx",
145
154
  "./components/use-blog-header-obstacles": "./components/use-blog-header-obstacles.ts",
146
155
  "./components/use-brand-fonts-ready": "./components/use-brand-fonts-ready.ts",
156
+ "./components/use-editorial-checks": "./components/use-editorial-checks.ts",
147
157
  "./components/use-near-viewport": "./components/use-near-viewport.ts",
148
158
  "./components/use-paged-content-item-versions": "./components/use-paged-content-item-versions.ts",
149
159
  "./components/use-resolved-papyrus-theme": "./components/use-resolved-papyrus-theme.ts",
@@ -185,6 +195,12 @@
185
195
  "./lib/doctrine": "./lib/doctrine.ts",
186
196
  "./lib/edition-routes": "./lib/edition-routes.ts",
187
197
  "./lib/edition-sections": "./lib/edition-sections.ts",
198
+ "./lib/editorial-checks-backend": "./lib/editorial-checks-backend.ts",
199
+ "./lib/editorial-checks-client": "./lib/editorial-checks-client.ts",
200
+ "./lib/editorial-checks-demo": "./lib/editorial-checks-demo.ts",
201
+ "./lib/editorial-checks-settings": "./lib/editorial-checks-settings.ts",
202
+ "./lib/editorial-checks": "./lib/editorial-checks.ts",
203
+ "./lib/editorial-preview": "./lib/editorial-preview.ts",
188
204
  "./lib/empty-edition-layout-plan": "./lib/empty-edition-layout-plan.ts",
189
205
  "./lib/excerpts": "./lib/excerpts.ts",
190
206
  "./lib/front-matter-fields": "./lib/front-matter-fields.ts",
@@ -379,7 +395,7 @@
379
395
  "optional": true
380
396
  }
381
397
  },
382
- "version": "1.19.1",
398
+ "version": "2.0.0-next.10",
383
399
  "dependencies": {
384
400
  "@aws-amplify/adapter-nextjs": "^1.7.3",
385
401
  "@aws-crypto/sha256-js": "5.2.0",
@@ -392,7 +408,22 @@
392
408
  "@aws-sdk/s3-request-presigner": "^3.1045.0",
393
409
  "@base-ui/react": "^1.5.0",
394
410
  "@chenglou/pretext": "^0.0.7",
395
- "@kanbus/ui": "https://github.com/AnthusAI/Kanbus/releases/download/ui-v0.3.0/kanbus-ui-0.3.0.tgz",
411
+ "@codemirror/commands": "^6.11.1",
412
+ "@codemirror/lang-markdown": "^6.5.2",
413
+ "@codemirror/language": "^6.13.1",
414
+ "@codemirror/state": "^6.7.6",
415
+ "@codemirror/view": "^6.43.15",
416
+ "@fontsource-variable/hanken-grotesk": "5.3.0",
417
+ "@fontsource-variable/jetbrains-mono": "5.3.0",
418
+ "@fontsource-variable/libre-franklin": "5.3.0",
419
+ "@fontsource-variable/literata": "5.3.0",
420
+ "@fontsource-variable/newsreader": "5.3.0",
421
+ "@fontsource-variable/public-sans": "5.3.0",
422
+ "@fontsource-variable/source-serif-4": "5.3.1",
423
+ "@fontsource/ibm-plex-mono": "5.3.0",
424
+ "@fontsource/ibm-plex-sans": "5.3.0",
425
+ "@kanbus/ui": "https://github.com/AnthusAI/Kanbus/releases/download/ui-v0.4.1/kanbus-ui-0.4.1.tgz",
426
+ "@lezer/highlight": "^1.2.5",
396
427
  "@radix-ui/colors": "3.0.0",
397
428
  "@smithy/protocol-http": "5.4.1",
398
429
  "@smithy/signature-v4": "5.7.4",
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "1.19.1",
2
+ "version": "2.0.0-next.10",
3
3
  "routes": [
4
4
  {
5
5
  "file": "app/%5F_preview/[[...path]]/route.ts",
@@ -0,0 +1,44 @@
1
+ import { spawnSync } from "node:child_process";
2
+
3
+ const DEFAULT_REGION = "us-east-1";
4
+
5
+ export function resolveCdkRegion({ explicitRegion, environment = process.env }) {
6
+ return (
7
+ explicitRegion ||
8
+ environment.AWS_REGION ||
9
+ environment.AWS_DEFAULT_REGION ||
10
+ environment.CDK_DEFAULT_REGION ||
11
+ DEFAULT_REGION
12
+ );
13
+ }
14
+
15
+ function callerAccountFromAwsCli() {
16
+ const completed = spawnSync("aws", ["sts", "get-caller-identity", "--output", "json"], { encoding: "utf8" });
17
+ if (completed.error) throw new Error(`could not run the aws CLI: ${completed.error.message}`);
18
+ if (completed.status !== 0) throw new Error(String(completed.stderr || completed.stdout).trim() || `aws exited with status ${completed.status}`);
19
+ return JSON.parse(completed.stdout).Account;
20
+ }
21
+
22
+ export function resolveCdkAccount({ explicitAccount, environment = process.env, lookupCallerAccount = callerAccountFromAwsCli }) {
23
+ if (explicitAccount) return explicitAccount;
24
+ if (environment.CDK_DEFAULT_ACCOUNT) return environment.CDK_DEFAULT_ACCOUNT;
25
+ let account;
26
+ try {
27
+ account = lookupCallerAccount();
28
+ } catch (error) {
29
+ throw new Error(
30
+ `cannot determine the AWS account: pass --account, set CDK_DEFAULT_ACCOUNT, or provide credentials for "aws sts get-caller-identity" (${error instanceof Error ? error.message : error})`,
31
+ );
32
+ }
33
+ if (!/^\d{12}$/.test(String(account))) {
34
+ throw new Error(`cannot determine the AWS account: "aws sts get-caller-identity" returned ${JSON.stringify(account)}; pass --account or set CDK_DEFAULT_ACCOUNT`);
35
+ }
36
+ return String(account);
37
+ }
38
+
39
+ export function resolveCdkEnvironment({ explicitAccount, explicitRegion, environment = process.env, lookupCallerAccount }) {
40
+ return {
41
+ account: resolveCdkAccount({ explicitAccount, environment, lookupCallerAccount }),
42
+ region: resolveCdkRegion({ explicitRegion, environment }),
43
+ };
44
+ }
@@ -1,93 +0,0 @@
1
- Copyright 2017 The Playfair Display Project Authors (https://github.com/clauseggers/Playfair-Display), with Reserved Font Name "Playfair Display"
2
-
3
- This Font Software is licensed under the SIL Open Font License, Version 1.1.
4
- This license is copied below, and is also available with a FAQ at:
5
- http://scripts.sil.org/OFL
6
-
7
-
8
- -----------------------------------------------------------
9
- SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007
10
- -----------------------------------------------------------
11
-
12
- PREAMBLE
13
- The goals of the Open Font License (OFL) are to stimulate worldwide
14
- development of collaborative font projects, to support the font creation
15
- efforts of academic and linguistic communities, and to provide a free and
16
- open framework in which fonts may be shared and improved in partnership
17
- with others.
18
-
19
- The OFL allows the licensed fonts to be used, studied, modified and
20
- redistributed freely as long as they are not sold by themselves. The
21
- fonts, including any derivative works, can be bundled, embedded,
22
- redistributed and/or sold with any software provided that any reserved
23
- names are not used by derivative works. The fonts and derivatives,
24
- however, cannot be released under any other type of license. The
25
- requirement for fonts to remain under this license does not apply
26
- to any document created using the fonts or their derivatives.
27
-
28
- DEFINITIONS
29
- "Font Software" refers to the set of files released by the Copyright
30
- Holder(s) under this license and clearly marked as such. This may
31
- include source files, build scripts and documentation.
32
-
33
- "Reserved Font Name" refers to any names specified as such after the
34
- copyright statement(s).
35
-
36
- "Original Version" refers to the collection of Font Software components as
37
- distributed by the Copyright Holder(s).
38
-
39
- "Modified Version" refers to any derivative made by adding to, deleting,
40
- or substituting -- in part or in whole -- any of the components of the
41
- Original Version, by changing formats or by porting the Font Software to a
42
- new environment.
43
-
44
- "Author" refers to any designer, engineer, programmer, technical
45
- writer or other person who contributed to the Font Software.
46
-
47
- PERMISSION & CONDITIONS
48
- Permission is hereby granted, free of charge, to any person obtaining
49
- a copy of the Font Software, to use, study, copy, merge, embed, modify,
50
- redistribute, and sell modified and unmodified copies of the Font
51
- Software, subject to the following conditions:
52
-
53
- 1) Neither the Font Software nor any of its individual components,
54
- in Original or Modified Versions, may be sold by itself.
55
-
56
- 2) Original or Modified Versions of the Font Software may be bundled,
57
- redistributed and/or sold with any software, provided that each copy
58
- contains the above copyright notice and this license. These can be
59
- included either as stand-alone text files, human-readable headers or
60
- in the appropriate machine-readable metadata fields within text or
61
- binary files as long as those fields can be easily viewed by the user.
62
-
63
- 3) No Modified Version of the Font Software may use the Reserved Font
64
- Name(s) unless explicit written permission is granted by the corresponding
65
- Copyright Holder. This restriction only applies to the primary font name as
66
- presented to the users.
67
-
68
- 4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font
69
- Software shall not be used to promote, endorse or advertise any
70
- Modified Version, except to acknowledge the contribution(s) of the
71
- Copyright Holder(s) and the Author(s) or with their explicit written
72
- permission.
73
-
74
- 5) The Font Software, modified or unmodified, in part or in whole,
75
- must be distributed entirely under this license, and must not be
76
- distributed under any other license. The requirement for fonts to
77
- remain under this license does not apply to any document created
78
- using the Font Software.
79
-
80
- TERMINATION
81
- This license becomes null and void if any of the above conditions are
82
- not met.
83
-
84
- DISCLAIMER
85
- THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
86
- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF
87
- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
88
- OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE
89
- COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
90
- INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL
91
- DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
92
- FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM
93
- OTHER DEALINGS IN THE FONT SOFTWARE.
@@ -1,93 +0,0 @@
1
- Copyright 2020 The Plus Jakarta Sans Project Authors (https://github.com/tokotype/PlusJakartaSans)
2
-
3
- This Font Software is licensed under the SIL Open Font License, Version 1.1.
4
- This license is copied below, and is also available with a FAQ at:
5
- http://scripts.sil.org/OFL
6
-
7
-
8
- -----------------------------------------------------------
9
- SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007
10
- -----------------------------------------------------------
11
-
12
- PREAMBLE
13
- The goals of the Open Font License (OFL) are to stimulate worldwide
14
- development of collaborative font projects, to support the font creation
15
- efforts of academic and linguistic communities, and to provide a free and
16
- open framework in which fonts may be shared and improved in partnership
17
- with others.
18
-
19
- The OFL allows the licensed fonts to be used, studied, modified and
20
- redistributed freely as long as they are not sold by themselves. The
21
- fonts, including any derivative works, can be bundled, embedded,
22
- redistributed and/or sold with any software provided that any reserved
23
- names are not used by derivative works. The fonts and derivatives,
24
- however, cannot be released under any other type of license. The
25
- requirement for fonts to remain under this license does not apply
26
- to any document created using the fonts or their derivatives.
27
-
28
- DEFINITIONS
29
- "Font Software" refers to the set of files released by the Copyright
30
- Holder(s) under this license and clearly marked as such. This may
31
- include source files, build scripts and documentation.
32
-
33
- "Reserved Font Name" refers to any names specified as such after the
34
- copyright statement(s).
35
-
36
- "Original Version" refers to the collection of Font Software components as
37
- distributed by the Copyright Holder(s).
38
-
39
- "Modified Version" refers to any derivative made by adding to, deleting,
40
- or substituting -- in part or in whole -- any of the components of the
41
- Original Version, by changing formats or by porting the Font Software to a
42
- new environment.
43
-
44
- "Author" refers to any designer, engineer, programmer, technical
45
- writer or other person who contributed to the Font Software.
46
-
47
- PERMISSION & CONDITIONS
48
- Permission is hereby granted, free of charge, to any person obtaining
49
- a copy of the Font Software, to use, study, copy, merge, embed, modify,
50
- redistribute, and sell modified and unmodified copies of the Font
51
- Software, subject to the following conditions:
52
-
53
- 1) Neither the Font Software nor any of its individual components,
54
- in Original or Modified Versions, may be sold by itself.
55
-
56
- 2) Original or Modified Versions of the Font Software may be bundled,
57
- redistributed and/or sold with any software, provided that each copy
58
- contains the above copyright notice and this license. These can be
59
- included either as stand-alone text files, human-readable headers or
60
- in the appropriate machine-readable metadata fields within text or
61
- binary files as long as those fields can be easily viewed by the user.
62
-
63
- 3) No Modified Version of the Font Software may use the Reserved Font
64
- Name(s) unless explicit written permission is granted by the corresponding
65
- Copyright Holder. This restriction only applies to the primary font name as
66
- presented to the users.
67
-
68
- 4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font
69
- Software shall not be used to promote, endorse or advertise any
70
- Modified Version, except to acknowledge the contribution(s) of the
71
- Copyright Holder(s) and the Author(s) or with their explicit written
72
- permission.
73
-
74
- 5) The Font Software, modified or unmodified, in part or in whole,
75
- must be distributed entirely under this license, and must not be
76
- distributed under any other license. The requirement for fonts to
77
- remain under this license does not apply to any document created
78
- using the Font Software.
79
-
80
- TERMINATION
81
- This license becomes null and void if any of the above conditions are
82
- not met.
83
-
84
- DISCLAIMER
85
- THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
86
- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF
87
- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
88
- OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE
89
- COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
90
- INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL
91
- DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
92
- FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM
93
- OTHER DEALINGS IN THE FONT SOFTWARE.
@@ -1,7 +0,0 @@
1
- .papyrus-newsprint-board {
2
- --kb-newsprint-paper: var(--org-paper);
3
- --kb-newsprint-ink: var(--org-ink);
4
- --kb-newsprint-line: var(--org-line);
5
- --kb-newsprint-display-font: Newsroom Display, Georgia, serif;
6
- --kb-newsprint-body-font: Newsroom UI, system-ui, sans-serif;
7
- }
@@ -1,153 +0,0 @@
1
- "use client";
2
-
3
- import { useEffect, useId, useState } from "react";
4
- import Link from "next/link";
5
- import { usePathname, useRouter, useSearchParams } from "next/navigation";
6
- import { BookOpen, ClipboardList, Menu, Search, MessagesSquare, PanelLeftClose, PanelLeftOpen, Settings, UserRound, LogIn, LogOut } from "lucide-react";
7
- import { ORGANIZER_NAV_GROUPS, ORGANIZER_PRIMARY_NAV, ORGANIZER_SETTINGS_DESTINATION } from "../lib/newsroom-organizer-nav";
8
- import { browserPathToInternalNewsroomPath } from "../lib/newsroom-base-path";
9
- import { getNewsroomNavHref } from "../lib/newsroom-nav";
10
- import { SITE_BRAND } from "../lib/site-brand";
11
- import { useOptionalNewsDeskClient } from "./news-desk-client-provider";
12
- import { ReaderAuthControl } from "./reader-auth-control";
13
- import { ProspectusAccountChooser, useProspectusAccountSummary } from "./prospectus-account-chooser";
14
- import { Sheet, SheetContent, SheetHeader, SheetTitle, SheetDescription, SheetTrigger } from "./ui/sheet";
15
- import { DropdownMenu, DropdownMenuTrigger, DropdownMenuContent, DropdownMenuGroup, DropdownMenuLabel, DropdownMenuItem, DropdownMenuSeparator } from "./ui/dropdown-menu";
16
- import type { NewsroomOpsShellProps } from "./newsroom-ops-shell";
17
- import "./newsroom-organizer.css";
18
-
19
- /** The standard place to search the knowledge base; the Search page is the results page. */
20
- function OrganizerSearch({ demo }: { demo: boolean }) {
21
- const router = useRouter();
22
- const searchParams = useSearchParams();
23
- const [text, setText] = useState(searchParams.get("q") ?? "");
24
- return <form className="organizer-search" role="search" onSubmit={event => {
25
- event.preventDefault();
26
- const query = text.trim();
27
- if (query) router.push(getNewsroomNavHref(`/newsroom/search?q=${encodeURIComponent(query)}`, demo));
28
- }}>
29
- <Search size={14} aria-hidden="true" />
30
- <input aria-label="Search the knowledge base" data-newsroom-search type="search" onChange={event => setText(event.target.value)} placeholder="Search" value={text} />
31
- </form>;
32
- }
33
-
34
- const ICONS = { articles: ClipboardList, references: BookOpen, messages: MessagesSquare };
35
-
36
- /** Navigation is a presentation layer; existing route and server authorization still own access. */
37
- function Navigation({ activePath, demo, admin, surface, onNavigate }: { activePath: string; demo: boolean; admin: boolean; surface: string; onNavigate?: () => void }) {
38
- const id = useId();
39
- const all = ORGANIZER_NAV_GROUPS.flatMap(group => group.items);
40
- const active = all.filter(item => [item.path, ...(item.alsoActiveOnPaths ?? [])].some(candidate => activePath === candidate || (candidate !== "/newsroom" && activePath.startsWith(candidate + "/")))).sort((a, b) => b.path.length - a.path.length)[0]?.key;
41
- return <nav className="organizer-destinations" aria-label={surface === "sidebar" ? "Newsroom" : "All workspaces"}>
42
- {ORGANIZER_NAV_GROUPS.map((group, index) => <section key={group.title} aria-labelledby={`${id}-${index}`}>
43
- <h3 id={`${id}-${index}`}>{group.title}</h3>
44
- {group.items.filter(item => item.access !== "admin" || admin).map(item => <Link key={item.key}
45
- href={getNewsroomNavHref(item.path, demo)} onClick={onNavigate} aria-label={item.label}
46
- aria-current={active === item.key ? "page" : undefined} aria-describedby={`${id}-${item.key}`}
47
- data-news-desk-tab={item.key}>
48
- <strong>{item.label}</strong><small id={`${id}-${item.key}`}>{item.description}</small>
49
- </Link>)}
50
- </section>)}
51
- </nav>;
52
- }
53
-
54
- function Account({ placement }: { placement: "sidebar" | "header" }) {
55
- const session = useOptionalNewsDeskClient();
56
- const auth = session?.shell.auth ?? { status: "loading" as const, label: "Checking sign-in" };
57
- const [open, setOpen] = useState(false);
58
- const accountSummary = useProspectusAccountSummary();
59
- useEffect(() => {
60
- const media = matchMedia("(max-width: 900px)");
61
- const close = () => setOpen(false);
62
- media.addEventListener("change", close);
63
- return () => media.removeEventListener("change", close);
64
- }, []);
65
- return <DropdownMenu open={open} onOpenChange={setOpen}>
66
- <DropdownMenuTrigger id={`organizer-account-trigger-${placement}`} className={`organizer-account organizer-account-${placement}`} aria-label="Account menu" title="Account menu">
67
- <UserRound size={18} aria-hidden="true" /><span><strong>{auth.label}</strong><small>{accountSummary ?? (auth.status === "signedIn" ? "Account & preferences" : auth.status === "signedOut" ? "Not signed in" : "Checking session")}</small></span>
68
- </DropdownMenuTrigger>
69
- <DropdownMenuContent className="organizer-account-popup" side={placement === "sidebar" ? "top" : "bottom"} align="end">
70
- <DropdownMenuGroup>
71
- <DropdownMenuLabel>{auth.label}</DropdownMenuLabel><DropdownMenuSeparator />
72
- <ProspectusAccountChooser />
73
- <DropdownMenuItem render={<Link href={getNewsroomNavHref(ORGANIZER_SETTINGS_DESTINATION.path)} />}><Settings aria-hidden="true" />{ORGANIZER_SETTINGS_DESTINATION.label}</DropdownMenuItem>
74
- <ReaderAuthControl authState={auth} renderAction={({ disabled, onClick, signedIn }) => <DropdownMenuItem disabled={disabled} closeOnClick={false} onClick={onClick}>
75
- {signedIn ? <LogOut aria-hidden="true" /> : <LogIn aria-hidden="true" />}{signedIn ? "Sign out" : "Sign in"}
76
- </DropdownMenuItem>} />
77
- </DropdownMenuGroup>
78
- </DropdownMenuContent>
79
- </DropdownMenu>;
80
- }
81
-
82
- export function NewsroomOrganizerShell({ activeTab, appTitle, backHref = "/", backLabel, children, demo = false, headerActions, pageTitle, showNavigation = true }: NewsroomOpsShellProps) {
83
- const pathname = usePathname();
84
- const session = useOptionalNewsDeskClient();
85
- const admin = demo || session?.shell.dashboard?.canManageUsers === true;
86
- const [menuOpen, setMenuOpen] = useState(false);
87
- const [collapsed, setCollapsed] = useState(false);
88
- const [loadedPreference, setLoadedPreference] = useState(false);
89
- const preferenceKey = `papyrus.cms.sidebar.v1.${SITE_BRAND.id}`;
90
- useEffect(() => {
91
- try { setCollapsed(localStorage.getItem(preferenceKey) === "true"); } catch { /* Optional browser preference. */ }
92
- setLoadedPreference(true);
93
- }, [preferenceKey]);
94
- useEffect(() => { if (loadedPreference) try { localStorage.setItem(preferenceKey, String(collapsed)); } catch { /* Controls still work without storage. */ } }, [collapsed, loadedPreference, preferenceKey]);
95
- useEffect(() => { setMenuOpen(false); }, [pathname]);
96
- useEffect(() => {
97
- const media = matchMedia("(max-width: 900px)");
98
- let previousFocus: Element | null = null;
99
- let frame = 0;
100
- const remember = () => { if (document.activeElement !== document.body) previousFocus = document.activeElement; };
101
- const change = () => {
102
- const active = document.activeElement === document.body ? previousFocus : document.activeElement;
103
- if (!(active instanceof HTMLElement)) return;
104
- if (!media.matches) setMenuOpen(false);
105
- const selector = active.closest(".organizer-account, .organizer-account-popup") ? ".organizer-account"
106
- : media.matches && active.closest(".organizer-sidebar, .organizer-toggle") ? ".organizer-more"
107
- : !media.matches && active.closest(".organizer-bottom-nav, .organizer-menu") ? ".organizer-toggle" : null;
108
- if (!selector) return;
109
- cancelAnimationFrame(frame);
110
- frame = requestAnimationFrame(() => {
111
- if (document.activeElement === active || document.activeElement === document.body || !(document.activeElement as HTMLElement)?.getClientRects().length)
112
- Array.from(document.querySelectorAll<HTMLElement>(selector)).find(element => element.getClientRects().length)?.focus();
113
- });
114
- };
115
- document.addEventListener("focusin", remember);
116
- media.addEventListener("change", change);
117
- return () => { document.removeEventListener("focusin", remember); media.removeEventListener("change", change); cancelAnimationFrame(frame); };
118
- }, []);
119
- const activePath = browserPathToInternalNewsroomPath(pathname ?? "/newsroom");
120
- const sidebarToggleLabel = collapsed ? "Expand sidebar" : "Collapse sidebar";
121
- const sidebarToggle = <button type="button" className="organizer-toggle" title={sidebarToggleLabel}
122
- aria-label={sidebarToggleLabel} aria-expanded={!collapsed} aria-controls="organizer-sidebar" onClick={() => setCollapsed(value => !value)}>
123
- {collapsed ? <PanelLeftOpen size={16} aria-hidden="true" /> : <PanelLeftClose size={16} aria-hidden="true" />}
124
- </button>;
125
- return <div className="newsroom-organizer" data-news-desk data-newsroom-ops-shell="true" data-newsroom-chrome="organizer" data-sidebar-collapsed={collapsed || !showNavigation ? "true" : "false"}>
126
- {showNavigation && <aside className="organizer-sidebar" hidden={collapsed} id="organizer-sidebar">
127
- <div className="organizer-sidebar-head">
128
- <Link className="organizer-brand" href={getNewsroomNavHref("/newsroom", demo)}>{SITE_BRAND.components?.NewsroomLogo ? <SITE_BRAND.components.NewsroomLogo className="organizer-brand-logo" /> : appTitle}<small>The newsroom</small></Link>
129
- {sidebarToggle}
130
- </div>
131
- <Navigation activePath={activePath} demo={demo} admin={admin} surface="sidebar" />
132
- <Account placement="sidebar" />
133
- </aside>}
134
- <div className="organizer-workspace">
135
- <header className="organizer-topbar" data-newsroom-ops-topbar>
136
- {showNavigation && collapsed && sidebarToggle}
137
- <Link className="organizer-masthead" href={backHref} title={backLabel}>{appTitle}</Link>
138
- <h1 data-newsroom-ops-title>{pageTitle}</h1><OrganizerSearch demo={demo} /><div className="organizer-header-actions">{headerActions}</div><Account placement="header" />
139
- </header>
140
- <main className="organizer-main">{demo && <p className="organizer-demo-notice">Demo workspace · synthetic examples</p>}{children}</main>
141
- </div>
142
- {showNavigation && <nav className="organizer-bottom-nav" aria-label="Primary newsroom navigation"><ul>
143
- {ORGANIZER_PRIMARY_NAV.map(item => { const Icon = ICONS[item.key as keyof typeof ICONS]; return <li key={item.key}><Link
144
- href={getNewsroomNavHref(item.path, demo)} title={item.description} aria-label={item.label} aria-current={activeTab === item.key ? "page" : undefined}>
145
- <Icon size={18} aria-hidden="true" /><span>{item.label}</span></Link></li>; })}
146
- <li><Sheet open={menuOpen} onOpenChange={setMenuOpen}><SheetTrigger className="organizer-more" aria-label="More"><Menu size={18} aria-hidden="true" /><span>More</span></SheetTrigger>
147
- <SheetContent side="bottom" className="organizer-menu"><SheetHeader><SheetTitle>Newsroom</SheetTitle><SheetDescription>Workspaces and administration</SheetDescription></SheetHeader>
148
- <Navigation activePath={activePath} demo={demo} admin={admin} surface="menu" onNavigate={() => setMenuOpen(false)} />
149
- </SheetContent>
150
- </Sheet></li>
151
- </ul></nav>}
152
- </div>;
153
- }