@anthusai/papyrus 2.0.2 → 3.0.0
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.
- package/amplify/plugins/editorial-checks/function/handler.py +11 -0
- package/amplify/plugins/editorial-checks/function/requirements.txt +1 -0
- package/amplify/plugins/editorial-checks/function/resource.js +43 -0
- package/amplify/plugins/editorial-checks/function/resource.ts +60 -0
- package/amplify/plugins/editorial-checks/papyrus.plugin.js +50 -0
- package/amplify/plugins/editorial-checks/papyrus.plugin.ts +63 -0
- package/amplify/plugins/editorial-checks/schema.js +94 -0
- package/amplify/plugins/editorial-checks/schema.ts +96 -0
- package/amplify/plugins/registry.js +2 -0
- package/amplify/plugins/registry.ts +2 -0
- package/components/editorial-checks-admin-panel.tsx +337 -0
- package/components/editorial-finding-card.tsx +162 -0
- package/components/editorial-findings-panel.tsx +91 -0
- package/components/editorial-preview-popover.tsx +103 -0
- package/components/markus-body-editor.tsx +213 -0
- package/components/markus-ir-preview.tsx +147 -6
- package/components/newsroom-article-editor.tsx +138 -11
- package/components/newsroom-board-view.tsx +2 -6
- package/components/newsroom-ops-shell.tsx +7 -3
- package/components/newsroom-organizer.css +57 -61
- package/components/newsroom-theme-fonts/broadsheet-green.css +10 -0
- package/components/newsroom-theme-fonts/broadsheet-green.tsx +6 -0
- package/components/newsroom-theme-fonts/newspaper-gothic.css +9 -0
- package/components/newsroom-theme-fonts/newspaper-gothic.tsx +6 -0
- package/components/newsroom-theme-fonts/night-desk.css +10 -0
- package/components/newsroom-theme-fonts/night-desk.tsx +6 -0
- package/components/newsroom-theme-fonts/refined-newsprint.css +11 -0
- package/components/newsroom-theme-fonts/refined-newsprint.tsx +6 -0
- package/components/newsroom-theme.css +39 -0
- package/components/newsroom-theme.tsx +33 -0
- package/components/topic-steering-workspace.tsx +19 -1
- package/components/use-editorial-checks.ts +131 -0
- package/lib/editorial-checks-backend.ts +16 -0
- package/lib/editorial-checks-client.ts +194 -0
- package/lib/editorial-checks-demo.ts +147 -0
- package/lib/editorial-checks-settings.ts +24 -0
- package/lib/editorial-checks.ts +178 -0
- package/lib/editorial-preview.ts +228 -0
- package/lib/site-brand.ts +17 -0
- package/package.json +34 -2
- package/routes.manifest.json +1 -1
- package/components/newsroom-fonts/playfair-display-700.ttf +0 -0
- package/components/newsroom-fonts/playfair-display-900.ttf +0 -0
- package/components/newsroom-fonts/playfair-display-OFL.txt +0 -93
- package/components/newsroom-fonts/plus-jakarta-sans-400.ttf +0 -0
- package/components/newsroom-fonts/plus-jakarta-sans-600.ttf +0 -0
- package/components/newsroom-fonts/plus-jakarta-sans-OFL.txt +0 -93
- package/components/newsroom-newsprint-board.css +0 -7
|
@@ -0,0 +1,178 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Editorial checks: the Limatus result shapes the newsroom uses, and pure helpers
|
|
3
|
+
* over them. Limatus counts offsets in UTF-16 code units, which is exactly how
|
|
4
|
+
* JavaScript indexes strings, so spans apply to the body text as they are.
|
|
5
|
+
*/
|
|
6
|
+
import { pluginSettings, type PluginOutputs } from "./plugin-settings";
|
|
7
|
+
|
|
8
|
+
export const EDITORIAL_CHECKS_PLUGIN = "editorial-checks";
|
|
9
|
+
|
|
10
|
+
export type Span = { start: number; end: number };
|
|
11
|
+
export type Severity = "info" | "warn" | "error";
|
|
12
|
+
|
|
13
|
+
export type EditorialFinding = {
|
|
14
|
+
id: string;
|
|
15
|
+
policyId: string;
|
|
16
|
+
policyVersion: number;
|
|
17
|
+
detectorId: string;
|
|
18
|
+
lane: "rules" | "classifier";
|
|
19
|
+
severity: Severity;
|
|
20
|
+
status: "violation" | "review";
|
|
21
|
+
segmentId: string;
|
|
22
|
+
span: Span;
|
|
23
|
+
excerpt: string;
|
|
24
|
+
/** The excerpt as a reader sees it (inline markup removed). */
|
|
25
|
+
excerptText?: string;
|
|
26
|
+
message: string;
|
|
27
|
+
probability?: number;
|
|
28
|
+
rawProbability?: number;
|
|
29
|
+
replacement?: string;
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
export type EditorialSegment = {
|
|
33
|
+
id: string;
|
|
34
|
+
kind: "document" | "paragraph" | "sentence";
|
|
35
|
+
block?: "paragraph" | "heading" | "listItem";
|
|
36
|
+
parentId?: string;
|
|
37
|
+
start: number;
|
|
38
|
+
end: number;
|
|
39
|
+
textHash: string;
|
|
40
|
+
/** Plain prose of a paragraph or sentence segment. */
|
|
41
|
+
text?: string;
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
export type LaneStatus = { status: "ran" | "disabled" | "unavailable" | "failed" | "partial"; reason?: string; detectors?: number };
|
|
45
|
+
|
|
46
|
+
export type EditorialCheckResult = {
|
|
47
|
+
schemaVersion: 1;
|
|
48
|
+
offsetUnit: "utf16";
|
|
49
|
+
document: { hash: string; length: number };
|
|
50
|
+
pack: { packId: string; version: string };
|
|
51
|
+
segments: EditorialSegment[];
|
|
52
|
+
protected: { kind: string; start: number; end: number }[];
|
|
53
|
+
findings: EditorialFinding[];
|
|
54
|
+
coverage: unknown[];
|
|
55
|
+
lanes: { rules: LaneStatus; classifier: LaneStatus };
|
|
56
|
+
usage?: Record<string, number>;
|
|
57
|
+
};
|
|
58
|
+
|
|
59
|
+
export type RewriteOption = {
|
|
60
|
+
id: string;
|
|
61
|
+
span: Span;
|
|
62
|
+
replacement: string;
|
|
63
|
+
rationale: string;
|
|
64
|
+
factVerificationRequired: boolean;
|
|
65
|
+
unresolvedQuestions: string[];
|
|
66
|
+
};
|
|
67
|
+
|
|
68
|
+
export type RewriteResult = {
|
|
69
|
+
target: { findingId?: string; span: Span; excerpt: string };
|
|
70
|
+
model: string;
|
|
71
|
+
options: RewriteOption[];
|
|
72
|
+
dropped?: { replacement: string; reason: string }[];
|
|
73
|
+
};
|
|
74
|
+
|
|
75
|
+
export type FeedbackDecision = "accepted" | "fixed" | "dismissed";
|
|
76
|
+
|
|
77
|
+
export type EditorialFeedbackInput = {
|
|
78
|
+
itemId: string;
|
|
79
|
+
findingId: string;
|
|
80
|
+
policyId: string;
|
|
81
|
+
detectorId: string;
|
|
82
|
+
lane: EditorialFinding["lane"];
|
|
83
|
+
probability: number | null;
|
|
84
|
+
decision: FeedbackDecision;
|
|
85
|
+
reason: string | null;
|
|
86
|
+
text: string | null;
|
|
87
|
+
};
|
|
88
|
+
|
|
89
|
+
/** Decisions on an article that has never been saved are kept under this id. */
|
|
90
|
+
export const UNSAVED_ITEM_ID = "unsaved";
|
|
91
|
+
|
|
92
|
+
const SEVERITY_ORDER: Record<Severity, number> = { error: 0, warn: 1, info: 2 };
|
|
93
|
+
|
|
94
|
+
export function editorialChecksEnabled(outputs: PluginOutputs | null | undefined): boolean {
|
|
95
|
+
return pluginSettings(outputs, EDITORIAL_CHECKS_PLUGIN) !== null;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
/** Findings worth showing: not dismissed, not covering the whole document, most severe first, then in reading order. */
|
|
99
|
+
export function visibleFindings(findings: EditorialFinding[], dismissed: ReadonlySet<string>): EditorialFinding[] {
|
|
100
|
+
return findings
|
|
101
|
+
.filter((finding) => !dismissed.has(finding.id))
|
|
102
|
+
.sort(
|
|
103
|
+
(a, b) =>
|
|
104
|
+
SEVERITY_ORDER[a.severity] - SEVERITY_ORDER[b.severity] ||
|
|
105
|
+
a.span.start - b.span.start ||
|
|
106
|
+
a.policyId.localeCompare(b.policyId),
|
|
107
|
+
);
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
/** Findings that can be marked in the text (document-level ones have no excerpt). */
|
|
111
|
+
export function inlineFindings(findings: EditorialFinding[]): EditorialFinding[] {
|
|
112
|
+
return findings.filter((finding) => finding.excerpt.length > 0 && finding.span.end > finding.span.start);
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
export type FindingGroup = { policyId: string; severity: Severity; findings: EditorialFinding[] };
|
|
116
|
+
|
|
117
|
+
export function groupByPolicy(findings: EditorialFinding[]): FindingGroup[] {
|
|
118
|
+
const groups = new Map<string, FindingGroup>();
|
|
119
|
+
for (const finding of findings) {
|
|
120
|
+
const group = groups.get(finding.policyId) ?? { policyId: finding.policyId, severity: finding.severity, findings: [] };
|
|
121
|
+
group.findings.push(finding);
|
|
122
|
+
if (SEVERITY_ORDER[finding.severity] < SEVERITY_ORDER[group.severity]) group.severity = finding.severity;
|
|
123
|
+
groups.set(finding.policyId, group);
|
|
124
|
+
}
|
|
125
|
+
return [...groups.values()].sort((a, b) => SEVERITY_ORDER[a.severity] - SEVERITY_ORDER[b.severity] || a.policyId.localeCompare(b.policyId));
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
/** Open findings that should make an editor pause before publishing (never a block). */
|
|
129
|
+
export function publishWarnings(findings: EditorialFinding[], dismissed: ReadonlySet<string>): EditorialFinding[] {
|
|
130
|
+
return visibleFindings(findings, dismissed).filter((finding) => finding.severity !== "info" && finding.status === "violation");
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
/** The text of the segment a finding sits in, which becomes a few-shot example for the classifier. */
|
|
134
|
+
export function findingSegmentText(result: EditorialCheckResult, body: string, finding: EditorialFinding): string | null {
|
|
135
|
+
const segment = result.segments.find((candidate) => candidate.id === finding.segmentId);
|
|
136
|
+
if (!segment || segment.kind === "document") return null;
|
|
137
|
+
return body.slice(segment.start, segment.end);
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
export function feedbackFor(
|
|
141
|
+
result: EditorialCheckResult,
|
|
142
|
+
body: string,
|
|
143
|
+
finding: EditorialFinding,
|
|
144
|
+
decision: FeedbackDecision,
|
|
145
|
+
itemId: string | null,
|
|
146
|
+
reason: string | null = null,
|
|
147
|
+
): EditorialFeedbackInput {
|
|
148
|
+
return {
|
|
149
|
+
itemId: itemId ?? UNSAVED_ITEM_ID,
|
|
150
|
+
findingId: finding.id,
|
|
151
|
+
policyId: finding.policyId,
|
|
152
|
+
detectorId: finding.detectorId,
|
|
153
|
+
lane: finding.lane,
|
|
154
|
+
probability: finding.rawProbability ?? finding.probability ?? null,
|
|
155
|
+
decision,
|
|
156
|
+
reason: reason?.trim() ? reason.trim() : null,
|
|
157
|
+
text: finding.lane === "classifier" ? findingSegmentText(result, body, finding) : null,
|
|
158
|
+
};
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
/** Replace one span of the body; the span must still hold the text it was computed for. */
|
|
162
|
+
export function applyReplacement(body: string, span: Span, expected: string, replacement: string): string | null {
|
|
163
|
+
if (body.slice(span.start, span.end) !== expected) return null;
|
|
164
|
+
return body.slice(0, span.start) + replacement + body.slice(span.end);
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
export function describeProbability(finding: EditorialFinding): string | null {
|
|
168
|
+
if (finding.probability === undefined) return null;
|
|
169
|
+
return `${Math.round(finding.probability * 100)}% sure`;
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
export function laneNotice(result: EditorialCheckResult): string | null {
|
|
173
|
+
const classifier = result.lanes.classifier;
|
|
174
|
+
if (classifier.status === "partial") return `Some sentences were not judged: ${classifier.reason ?? "the check ran out of time"}.`;
|
|
175
|
+
if (classifier.status === "failed") return `The judgment checks failed: ${classifier.reason ?? "unknown error"}. Rule checks still ran.`;
|
|
176
|
+
if (classifier.status === "unavailable" && (classifier.detectors ?? 0) === 0 && classifier.reason) return `Judgment checks are not configured: ${classifier.reason}.`;
|
|
177
|
+
return null;
|
|
178
|
+
}
|
|
@@ -0,0 +1,228 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Places Limatus findings on the rendered Markus preview.
|
|
3
|
+
*
|
|
4
|
+
* Limatus reports spans in the markup; the preview renders an IR tree with no
|
|
5
|
+
* character offsets. Both sides agree on the words a reader sees, so findings
|
|
6
|
+
* are placed by text: each Limatus paragraph is matched, in document order, to
|
|
7
|
+
* the rendered prose block with the same words, and each finding's plain
|
|
8
|
+
* excerpt is located inside that block. Whitespace is ignored while matching,
|
|
9
|
+
* because rendering and Limatus collapse it differently (citations, breaks).
|
|
10
|
+
*
|
|
11
|
+
* "Rendered text" is defined by `inlineLeaves`, which the preview renderer also
|
|
12
|
+
* uses, so offsets computed here are offsets the renderer can split on.
|
|
13
|
+
*/
|
|
14
|
+
import type { EditorialCheckResult, EditorialFinding, Severity, Span } from "./editorial-checks";
|
|
15
|
+
import type { MarkusBlock, MarkusDocument, MarkusInline, MarkusNode } from "./markus-ir";
|
|
16
|
+
|
|
17
|
+
export const CITATION_TOKEN = /PAPYRUSMARKUP\d{5}END/g;
|
|
18
|
+
|
|
19
|
+
export type InlineLeaf =
|
|
20
|
+
| { kind: "text"; node: MarkusInline & { type: "text" }; start: number; pieces: { raw: string; start: number; isToken: boolean }[] }
|
|
21
|
+
| { kind: "code"; node: MarkusInline & { type: "code_span" }; start: number; text: string }
|
|
22
|
+
| { kind: "break"; start: number; text: string }
|
|
23
|
+
| { kind: "opaque"; start: number };
|
|
24
|
+
|
|
25
|
+
/** The reader-visible text of a run of inlines; citation tokens and images take no width. */
|
|
26
|
+
export function inlineLeaves(inlines: MarkusInline[], offset = 0): { leaves: InlineLeaf[]; text: string } {
|
|
27
|
+
const leaves: InlineLeaf[] = [];
|
|
28
|
+
let text = "";
|
|
29
|
+
const walk = (nodes: MarkusInline[]) => {
|
|
30
|
+
for (const node of nodes) {
|
|
31
|
+
const start = offset + text.length;
|
|
32
|
+
switch (node.type) {
|
|
33
|
+
case "text": {
|
|
34
|
+
const pieces: { raw: string; start: number; isToken: boolean }[] = [];
|
|
35
|
+
let cursor = 0;
|
|
36
|
+
let plainLength = 0;
|
|
37
|
+
for (const match of node.text.matchAll(CITATION_TOKEN)) {
|
|
38
|
+
const index = match.index ?? 0;
|
|
39
|
+
if (index > cursor) {
|
|
40
|
+
pieces.push({ raw: node.text.slice(cursor, index), start: start + plainLength, isToken: false });
|
|
41
|
+
plainLength += index - cursor;
|
|
42
|
+
}
|
|
43
|
+
pieces.push({ raw: match[0], start: start + plainLength, isToken: true });
|
|
44
|
+
cursor = index + match[0].length;
|
|
45
|
+
}
|
|
46
|
+
if (cursor < node.text.length) {
|
|
47
|
+
pieces.push({ raw: node.text.slice(cursor), start: start + plainLength, isToken: false });
|
|
48
|
+
plainLength += node.text.length - cursor;
|
|
49
|
+
}
|
|
50
|
+
leaves.push({ kind: "text", node, start, pieces });
|
|
51
|
+
text += pieces.filter((piece) => !piece.isToken).map((piece) => piece.raw).join("");
|
|
52
|
+
break;
|
|
53
|
+
}
|
|
54
|
+
case "code_span":
|
|
55
|
+
leaves.push({ kind: "code", node, start, text: node.code });
|
|
56
|
+
text += node.code;
|
|
57
|
+
break;
|
|
58
|
+
case "soft_break":
|
|
59
|
+
case "hard_break":
|
|
60
|
+
leaves.push({ kind: "break", start, text: " " });
|
|
61
|
+
text += " ";
|
|
62
|
+
break;
|
|
63
|
+
case "emphasis":
|
|
64
|
+
case "strong":
|
|
65
|
+
case "strikethrough":
|
|
66
|
+
case "link":
|
|
67
|
+
walk(node.children);
|
|
68
|
+
break;
|
|
69
|
+
default:
|
|
70
|
+
leaves.push({ kind: "opaque", start });
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
};
|
|
74
|
+
walk(inlines);
|
|
75
|
+
return { leaves, text };
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
/** Prose blocks (paragraphs and headings, including those inside lists, quotes and directives) in reading order. */
|
|
79
|
+
export function proseBlocks(document: MarkusDocument): (MarkusBlock & { inline: MarkusInline[] })[] {
|
|
80
|
+
const blocks: (MarkusBlock & { inline: MarkusInline[] })[] = [];
|
|
81
|
+
const visit = (nodes: MarkusNode[]) => {
|
|
82
|
+
for (const node of nodes) {
|
|
83
|
+
if (node.type === "directive") visit(node.children);
|
|
84
|
+
else if (node.type === "paragraph" || node.type === "heading") blocks.push(node);
|
|
85
|
+
else if (node.type === "list") for (const item of node.items) visit(item.children);
|
|
86
|
+
else if (node.type === "blockquote") visit(node.children);
|
|
87
|
+
}
|
|
88
|
+
};
|
|
89
|
+
visit(document.children);
|
|
90
|
+
return blocks;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
export type PreviewMark = Span & { findingIds: string[]; severity: Severity; status: EditorialFinding["status"] };
|
|
94
|
+
export type PreviewSentence = Span & { segmentId: string; source: Span };
|
|
95
|
+
|
|
96
|
+
/** What the preview needs for one rendered block, in that block's rendered-text offsets. */
|
|
97
|
+
export type BlockAnnotation = { marks: PreviewMark[]; sentences: PreviewSentence[] };
|
|
98
|
+
|
|
99
|
+
export type PreviewPlan = WeakMap<object, BlockAnnotation>;
|
|
100
|
+
|
|
101
|
+
const SEVERITY_RANK: Record<Severity, number> = { error: 0, warn: 1, info: 2 };
|
|
102
|
+
|
|
103
|
+
/** Text without whitespace, with a map from each kept character back to its index in the original. */
|
|
104
|
+
function compact(text: string): { value: string; index: number[] } {
|
|
105
|
+
let value = "";
|
|
106
|
+
const index: number[] = [];
|
|
107
|
+
for (let i = 0; i < text.length; i += 1) {
|
|
108
|
+
if (!/\s/.test(text[i])) {
|
|
109
|
+
value += text[i];
|
|
110
|
+
index.push(i);
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
return { value, index };
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
/** Locate `needle` in `haystack` ignoring whitespace; the occurrence nearest `near` (a 0..1 position) wins. */
|
|
117
|
+
export function locate(haystack: string, needle: string, near = 0): Span | null {
|
|
118
|
+
const hay = compact(haystack);
|
|
119
|
+
const want = compact(needle).value;
|
|
120
|
+
if (!want) return null;
|
|
121
|
+
let best: number | null = null;
|
|
122
|
+
for (let at = hay.value.indexOf(want); at !== -1; at = hay.value.indexOf(want, at + 1)) {
|
|
123
|
+
if (best === null || Math.abs(at / Math.max(hay.value.length, 1) - near) < Math.abs(best / Math.max(hay.value.length, 1) - near)) best = at;
|
|
124
|
+
}
|
|
125
|
+
if (best === null) return null;
|
|
126
|
+
return { start: hay.index[best], end: hay.index[best + want.length - 1] + 1 };
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
/** The identity of a block's words: no whitespace, no stray emphasis or code markers. */
|
|
130
|
+
function blockKey(text: string): string {
|
|
131
|
+
return compact(text).value.replace(/[*_`~]/g, "");
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
/** Match every Limatus paragraph to a rendered block and place its findings and sentences there. */
|
|
135
|
+
export function planPreview(
|
|
136
|
+
document: MarkusDocument,
|
|
137
|
+
result: EditorialCheckResult,
|
|
138
|
+
findings: EditorialFinding[],
|
|
139
|
+
): PreviewPlan {
|
|
140
|
+
const plan: PreviewPlan = new WeakMap();
|
|
141
|
+
const blocks = proseBlocks(document).map((block) => ({ block, text: inlineLeaves(block.inline).text }));
|
|
142
|
+
const paragraphs = result.segments.filter((segment) => segment.kind === "paragraph" && segment.text);
|
|
143
|
+
let cursor = 0;
|
|
144
|
+
for (const paragraph of paragraphs) {
|
|
145
|
+
const wanted = blockKey(paragraph.text ?? "");
|
|
146
|
+
let matched = -1;
|
|
147
|
+
for (let candidate = cursor; candidate < blocks.length; candidate += 1) {
|
|
148
|
+
if (blockKey(blocks[candidate].text) === wanted) {
|
|
149
|
+
matched = candidate;
|
|
150
|
+
break;
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
if (matched === -1) continue;
|
|
154
|
+
cursor = matched + 1;
|
|
155
|
+
const { block, text } = blocks[matched];
|
|
156
|
+
const sentences: PreviewSentence[] = [];
|
|
157
|
+
for (const sentence of result.segments.filter((s) => s.kind === "sentence" && s.parentId === paragraph.id)) {
|
|
158
|
+
const near = (sentence.start - paragraph.start) / Math.max(paragraph.end - paragraph.start, 1);
|
|
159
|
+
const span = locate(text, sentence.text ?? "", near);
|
|
160
|
+
if (span) sentences.push({ ...span, segmentId: sentence.id, source: { start: sentence.start, end: sentence.end } });
|
|
161
|
+
}
|
|
162
|
+
const ranges: (Span & { finding: EditorialFinding })[] = [];
|
|
163
|
+
for (const finding of findings) {
|
|
164
|
+
const inParagraph =
|
|
165
|
+
finding.segmentId === paragraph.id ||
|
|
166
|
+
result.segments.some((s) => s.id === finding.segmentId && s.parentId === paragraph.id);
|
|
167
|
+
if (!inParagraph || !finding.excerptText) continue;
|
|
168
|
+
const near = (finding.span.start - paragraph.start) / Math.max(paragraph.end - paragraph.start, 1);
|
|
169
|
+
const span = locate(text, finding.excerptText, near);
|
|
170
|
+
if (span) ranges.push({ ...span, finding });
|
|
171
|
+
}
|
|
172
|
+
plan.set(block, { marks: flatten(ranges), sentences });
|
|
173
|
+
}
|
|
174
|
+
return plan;
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
/** Overlapping finding ranges become non-overlapping marks, each listing every finding it belongs to. */
|
|
178
|
+
function flatten(ranges: (Span & { finding: EditorialFinding })[]): PreviewMark[] {
|
|
179
|
+
const cuts = [...new Set(ranges.flatMap((range) => [range.start, range.end]))].sort((a, b) => a - b);
|
|
180
|
+
const marks: PreviewMark[] = [];
|
|
181
|
+
for (let i = 0; i < cuts.length - 1; i += 1) {
|
|
182
|
+
const start = cuts[i];
|
|
183
|
+
const end = cuts[i + 1];
|
|
184
|
+
const covering = ranges.filter((range) => range.start <= start && end <= range.end).map((range) => range.finding);
|
|
185
|
+
if (covering.length === 0) continue;
|
|
186
|
+
const strongest = [...covering].sort((a, b) => SEVERITY_RANK[a.severity] - SEVERITY_RANK[b.severity])[0];
|
|
187
|
+
const previous = marks[marks.length - 1];
|
|
188
|
+
const ids = covering.map((finding) => finding.id).sort();
|
|
189
|
+
if (previous && previous.end === start && previous.findingIds.join() === ids.join()) {
|
|
190
|
+
previous.end = end;
|
|
191
|
+
continue;
|
|
192
|
+
}
|
|
193
|
+
marks.push({
|
|
194
|
+
start,
|
|
195
|
+
end,
|
|
196
|
+
findingIds: ids,
|
|
197
|
+
severity: strongest.severity,
|
|
198
|
+
status: covering.every((finding) => finding.status === "review") ? "review" : "violation",
|
|
199
|
+
});
|
|
200
|
+
}
|
|
201
|
+
return marks;
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
/** A selection on the preview, as the source span of the whole sentences it touches. */
|
|
205
|
+
export function selectionToSource(annotation: BlockAnnotation | undefined, selection: Span): Span | null {
|
|
206
|
+
if (!annotation) return null;
|
|
207
|
+
const touched = annotation.sentences.filter((sentence) => sentence.start < selection.end && selection.start < sentence.end);
|
|
208
|
+
if (touched.length === 0) return null;
|
|
209
|
+
return {
|
|
210
|
+
start: Math.min(...touched.map((sentence) => sentence.source.start)),
|
|
211
|
+
end: Math.max(...touched.map((sentence) => sentence.source.end)),
|
|
212
|
+
};
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
/** Split [start, end) of rendered text at mark boundaries; each piece says which mark (if any) covers it. */
|
|
216
|
+
export function splitByMarks(start: number, end: number, marks: PreviewMark[]): { start: number; end: number; mark: PreviewMark | null }[] {
|
|
217
|
+
const pieces: { start: number; end: number; mark: PreviewMark | null }[] = [];
|
|
218
|
+
let cursor = start;
|
|
219
|
+
for (const mark of marks) {
|
|
220
|
+
if (mark.end <= cursor || mark.start >= end) continue;
|
|
221
|
+
if (mark.start > cursor) pieces.push({ start: cursor, end: mark.start, mark: null });
|
|
222
|
+
const pieceEnd = Math.min(mark.end, end);
|
|
223
|
+
pieces.push({ start: Math.max(mark.start, cursor), end: pieceEnd, mark });
|
|
224
|
+
cursor = pieceEnd;
|
|
225
|
+
}
|
|
226
|
+
if (cursor < end) pieces.push({ start: cursor, end, mark: null });
|
|
227
|
+
return pieces;
|
|
228
|
+
}
|
package/lib/site-brand.ts
CHANGED
|
@@ -3,6 +3,7 @@ import type { ComponentType } from "react";
|
|
|
3
3
|
import type { EditionPresentationFormat } from "./content-types";
|
|
4
4
|
import type { Article, ArticleVideoAsset } from "./articles";
|
|
5
5
|
import type { BlogPageBackgroundProps } from "../components/blog-page-background";
|
|
6
|
+
import type { KanbusThemeId } from "@kanbus/ui";
|
|
6
7
|
import type { SiteBrandFont } from "./brand-fonts";
|
|
7
8
|
import type { PictogramFigureProps } from "../components/pictogram-figure";
|
|
8
9
|
import papyrusSite from "papyrus-site";
|
|
@@ -118,6 +119,13 @@ export type SiteBrand = {
|
|
|
118
119
|
defaultVideoCredit?: string;
|
|
119
120
|
themePack: ThemePackId;
|
|
120
121
|
themeTokens: ThemePackTokens;
|
|
122
|
+
/**
|
|
123
|
+
* The Kanbus editorial theme the whole newsroom (sidebar, toolbar, boards,
|
|
124
|
+
* detail panel) renders in. Hard-coded per publication: editors cannot
|
|
125
|
+
* change it. Per-publication tweaks are `--kb-theme-*` overrides in the
|
|
126
|
+
* publication's `theme.css`, scoped to `[data-kanbus-theme]`.
|
|
127
|
+
*/
|
|
128
|
+
kanbusTheme: KanbusThemeId;
|
|
121
129
|
renderer: RendererConfig;
|
|
122
130
|
hosting: HostingConfig;
|
|
123
131
|
/** Static reader app when it is not co-hosted with this Papyrus checkout. */
|
|
@@ -182,6 +190,7 @@ const REFERENCE_SITE_BRANDS: Record<SiteBrandId, SiteBrand> = {
|
|
|
182
190
|
sectionLinkStrategy: "route",
|
|
183
191
|
themePack: "papyrus",
|
|
184
192
|
themeTokens: DEFAULT_THEME_PACK_TOKENS,
|
|
193
|
+
kanbusTheme: "broadsheet-green",
|
|
185
194
|
renderer: { kind: "pretext" },
|
|
186
195
|
hosting: { kind: "amplify-ssr" },
|
|
187
196
|
opsChrome: "app",
|
|
@@ -237,6 +246,14 @@ export function getSiteBrand(id: SiteBrandId = resolveSiteBrandId()): SiteBrand
|
|
|
237
246
|
|
|
238
247
|
export const SITE_BRAND = getSiteBrand();
|
|
239
248
|
|
|
249
|
+
/** Mirrors `DEFAULT_KANBUS_THEME` from `@kanbus/ui` (a test keeps the two equal) without a runtime import. */
|
|
250
|
+
export const FALLBACK_KANBUS_THEME: KanbusThemeId = "newspaper-gothic";
|
|
251
|
+
|
|
252
|
+
/** The newsroom theme for a brand; a brand that predates the field falls back to the default theme. */
|
|
253
|
+
export function getKanbusTheme(brand: Pick<SiteBrand, "kanbusTheme"> = SITE_BRAND): KanbusThemeId {
|
|
254
|
+
return brand.kanbusTheme ?? FALLBACK_KANBUS_THEME;
|
|
255
|
+
}
|
|
256
|
+
|
|
240
257
|
export function getContentItemName(brand: SiteBrand = SITE_BRAND): ContentItemName {
|
|
241
258
|
return brand.contentItemName ?? DEFAULT_CONTENT_ITEM_NAME;
|
|
242
259
|
}
|
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",
|
|
@@ -95,6 +100,11 @@
|
|
|
95
100
|
"./components/newsroom-ops-overview": "./components/newsroom-ops-overview.tsx",
|
|
96
101
|
"./components/newsroom-ops-shell": "./components/newsroom-ops-shell.tsx",
|
|
97
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",
|
|
98
108
|
"./components/newsroom-topics-view": "./components/newsroom-topics-view.tsx",
|
|
99
109
|
"./components/papyrus-console-shell": "./components/papyrus-console-shell.tsx",
|
|
100
110
|
"./components/pictogram-figure": "./components/pictogram-figure.tsx",
|
|
@@ -143,6 +153,7 @@
|
|
|
143
153
|
"./components/ui/tooltip": "./components/ui/tooltip.tsx",
|
|
144
154
|
"./components/use-blog-header-obstacles": "./components/use-blog-header-obstacles.ts",
|
|
145
155
|
"./components/use-brand-fonts-ready": "./components/use-brand-fonts-ready.ts",
|
|
156
|
+
"./components/use-editorial-checks": "./components/use-editorial-checks.ts",
|
|
146
157
|
"./components/use-near-viewport": "./components/use-near-viewport.ts",
|
|
147
158
|
"./components/use-paged-content-item-versions": "./components/use-paged-content-item-versions.ts",
|
|
148
159
|
"./components/use-resolved-papyrus-theme": "./components/use-resolved-papyrus-theme.ts",
|
|
@@ -184,6 +195,12 @@
|
|
|
184
195
|
"./lib/doctrine": "./lib/doctrine.ts",
|
|
185
196
|
"./lib/edition-routes": "./lib/edition-routes.ts",
|
|
186
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",
|
|
187
204
|
"./lib/empty-edition-layout-plan": "./lib/empty-edition-layout-plan.ts",
|
|
188
205
|
"./lib/excerpts": "./lib/excerpts.ts",
|
|
189
206
|
"./lib/front-matter-fields": "./lib/front-matter-fields.ts",
|
|
@@ -378,7 +395,7 @@
|
|
|
378
395
|
"optional": true
|
|
379
396
|
}
|
|
380
397
|
},
|
|
381
|
-
"version": "
|
|
398
|
+
"version": "3.0.0",
|
|
382
399
|
"dependencies": {
|
|
383
400
|
"@aws-amplify/adapter-nextjs": "^1.7.3",
|
|
384
401
|
"@aws-crypto/sha256-js": "5.2.0",
|
|
@@ -391,7 +408,22 @@
|
|
|
391
408
|
"@aws-sdk/s3-request-presigner": "^3.1045.0",
|
|
392
409
|
"@base-ui/react": "^1.5.0",
|
|
393
410
|
"@chenglou/pretext": "^0.0.7",
|
|
394
|
-
"@
|
|
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.0/kanbus-ui-0.4.0.tgz",
|
|
426
|
+
"@lezer/highlight": "^1.2.5",
|
|
395
427
|
"@radix-ui/colors": "3.0.0",
|
|
396
428
|
"@smithy/protocol-http": "5.4.1",
|
|
397
429
|
"@smithy/signature-v4": "5.7.4",
|
package/routes.manifest.json
CHANGED
|
Binary file
|
|
Binary file
|
|
@@ -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.
|
|
Binary file
|
|
Binary file
|