@open-press/cli 0.8.0 → 1.1.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/README.md +33 -23
- package/dist/cli.js +320 -252
- package/package.json +9 -8
- package/template/core/AGENTS.md +0 -126
- package/template/core/CHANGELOG.md +0 -215
- package/template/core/README.md +0 -40
- package/template/core/engine/cli.mjs +0 -96
- package/template/core/engine/commands/_shared.mjs +0 -177
- package/template/core/engine/commands/deploy.mjs +0 -31
- package/template/core/engine/commands/dev.mjs +0 -49
- package/template/core/engine/commands/doctor.mjs +0 -229
- package/template/core/engine/commands/export.mjs +0 -8
- package/template/core/engine/commands/init.mjs +0 -24
- package/template/core/engine/commands/inspect.mjs +0 -35
- package/template/core/engine/commands/pdf.mjs +0 -26
- package/template/core/engine/commands/preview.mjs +0 -26
- package/template/core/engine/commands/render.mjs +0 -17
- package/template/core/engine/commands/replace.mjs +0 -41
- package/template/core/engine/commands/search.mjs +0 -33
- package/template/core/engine/commands/typecheck.mjs +0 -5
- package/template/core/engine/commands/upgrade.mjs +0 -159
- package/template/core/engine/commands/validate.mjs +0 -17
- package/template/core/engine/document-export.mjs +0 -15
- package/template/core/engine/init.mjs +0 -90
- package/template/core/engine/output/chrome-pdf.d.mts +0 -34
- package/template/core/engine/output/chrome-pdf.mjs +0 -358
- package/template/core/engine/output/deploy-sync.mjs +0 -15
- package/template/core/engine/output/fonts.mjs +0 -62
- package/template/core/engine/output/katex-assets.mjs +0 -45
- package/template/core/engine/output/page-block.mjs +0 -30
- package/template/core/engine/output/pdf-media.mjs +0 -45
- package/template/core/engine/output/public-assets.mjs +0 -19
- package/template/core/engine/output/static-server.mjs +0 -532
- package/template/core/engine/react/caption-numbering.mjs +0 -73
- package/template/core/engine/react/comment-endpoint.d.mts +0 -11
- package/template/core/engine/react/comment-endpoint.mjs +0 -102
- package/template/core/engine/react/comment-marker.mjs +0 -374
- package/template/core/engine/react/document-entry.mjs +0 -324
- package/template/core/engine/react/document-export.mjs +0 -373
- package/template/core/engine/react/http-json.mjs +0 -24
- package/template/core/engine/react/mdx-compile.mjs +0 -599
- package/template/core/engine/react/measurement-css.mjs +0 -136
- package/template/core/engine/react/object-entities.mjs +0 -119
- package/template/core/engine/react/pagination/allocator.mjs +0 -122
- package/template/core/engine/react/pagination/regions.mjs +0 -81
- package/template/core/engine/react/pagination-constants.mjs +0 -3
- package/template/core/engine/react/pagination.mjs +0 -9
- package/template/core/engine/react/pipeline/allocate.mjs +0 -251
- package/template/core/engine/react/pipeline/final-render.mjs +0 -94
- package/template/core/engine/react/pipeline/frame-measurement.mjs +0 -302
- package/template/core/engine/react/pipeline/press-tree.mjs +0 -135
- package/template/core/engine/react/project-asset-endpoint.d.mts +0 -10
- package/template/core/engine/react/project-asset-endpoint.mjs +0 -361
- package/template/core/engine/react/section-css.mjs +0 -56
- package/template/core/engine/react/source-edit-endpoint.d.mts +0 -10
- package/template/core/engine/react/source-edit-endpoint.mjs +0 -75
- package/template/core/engine/react/sources/heading-numbering.mjs +0 -132
- package/template/core/engine/react/sources/mdx-resolver.mjs +0 -439
- package/template/core/engine/react/style-discovery.mjs +0 -142
- package/template/core/engine/runtime/config.d.mts +0 -40
- package/template/core/engine/runtime/config.mjs +0 -175
- package/template/core/engine/runtime/file-utils.mjs +0 -106
- package/template/core/engine/runtime/file-walk.mjs +0 -22
- package/template/core/engine/runtime/inspection.mjs +0 -328
- package/template/core/engine/runtime/issue-report.mjs +0 -44
- package/template/core/engine/runtime/path-utils.mjs +0 -20
- package/template/core/engine/runtime/source-text-tools.d.mts +0 -102
- package/template/core/engine/runtime/source-text-tools.mjs +0 -832
- package/template/core/engine/runtime/source-workspace.mjs +0 -159
- package/template/core/engine/runtime/validation.mjs +0 -174
- package/template/core/index.html +0 -13
- package/template/core/openpress.config.mjs +0 -12
- package/template/core/package.json +0 -91
- package/template/core/src/main.tsx +0 -16
- package/template/core/src/openpress/app/OpenPressApp.tsx +0 -140
- package/template/core/src/openpress/app/OpenPressRuntime.tsx +0 -94
- package/template/core/src/openpress/app/index.ts +0 -2
- package/template/core/src/openpress/core/Frame.tsx +0 -78
- package/template/core/src/openpress/core/FrameContext.tsx +0 -24
- package/template/core/src/openpress/core/MdxArea.tsx +0 -34
- package/template/core/src/openpress/core/Press.tsx +0 -34
- package/template/core/src/openpress/core/cn.ts +0 -4
- package/template/core/src/openpress/core/index.tsx +0 -40
- package/template/core/src/openpress/core/primitives.tsx +0 -44
- package/template/core/src/openpress/core/types.ts +0 -191
- package/template/core/src/openpress/core/useSource.ts +0 -28
- package/template/core/src/openpress/document-model/anchorMapModel.ts +0 -27
- package/template/core/src/openpress/document-model/documentIndexes.ts +0 -329
- package/template/core/src/openpress/document-model/documentTypes.ts +0 -138
- package/template/core/src/openpress/document-model/index.ts +0 -6
- package/template/core/src/openpress/document-model/objectEntityModel.ts +0 -51
- package/template/core/src/openpress/document-model/projectIdentityModel.ts +0 -15
- package/template/core/src/openpress/document-model/reactDocumentMetadataModel.ts +0 -27
- package/template/core/src/openpress/manuscript/index.tsx +0 -238
- package/template/core/src/openpress/mdx/index.ts +0 -88
- package/template/core/src/openpress/numbering/index.ts +0 -294
- package/template/core/src/openpress/reader/PublicReaderPage.tsx +0 -267
- package/template/core/src/openpress/reader/ReaderNavigationPanel.tsx +0 -123
- package/template/core/src/openpress/reader/index.ts +0 -10
- package/template/core/src/openpress/reader/pageViewportScaleModel.ts +0 -73
- package/template/core/src/openpress/reader/readerPageRegistry.ts +0 -41
- package/template/core/src/openpress/reader/readerPageRoute.ts +0 -21
- package/template/core/src/openpress/reader/readerScroll.ts +0 -92
- package/template/core/src/openpress/reader/readerStateModel.ts +0 -15
- package/template/core/src/openpress/reader/readerTypes.ts +0 -4
- package/template/core/src/openpress/reader/usePageViewportScale.ts +0 -119
- package/template/core/src/openpress/reader/usePanelState.ts +0 -56
- package/template/core/src/openpress/reader/useReaderHashSync.ts +0 -61
- package/template/core/src/openpress/reader/useReaderKeyboardNav.ts +0 -48
- package/template/core/src/openpress/reader/useReaderRuntime.ts +0 -146
- package/template/core/src/openpress/reader/useReaderScrollAnchor.ts +0 -64
- package/template/core/src/openpress/shared/Panel.tsx +0 -77
- package/template/core/src/openpress/shared/frameScheduler.ts +0 -32
- package/template/core/src/openpress/shared/index.ts +0 -4
- package/template/core/src/openpress/shared/numberUtils.ts +0 -3
- package/template/core/src/openpress/shared/runtimeMode.ts +0 -11
- package/template/core/src/openpress/workbench/Workbench.tsx +0 -407
- package/template/core/src/openpress/workbench/actions/DeploymentControl.tsx +0 -157
- package/template/core/src/openpress/workbench/actions/PageZoomControl.tsx +0 -182
- package/template/core/src/openpress/workbench/actions/SearchControl.tsx +0 -345
- package/template/core/src/openpress/workbench/actions/deploymentStatusModel.ts +0 -112
- package/template/core/src/openpress/workbench/actions/index.ts +0 -5
- package/template/core/src/openpress/workbench/actions/useDeploymentWorkbench.ts +0 -136
- package/template/core/src/openpress/workbench/dialog/WorkbenchDialog.tsx +0 -72
- package/template/core/src/openpress/workbench/dialog/index.ts +0 -1
- package/template/core/src/openpress/workbench/document/components/DocumentPanel.tsx +0 -127
- package/template/core/src/openpress/workbench/document/components/InlineSourceEditorLayer.tsx +0 -207
- package/template/core/src/openpress/workbench/document/components/ReaderStage.tsx +0 -9
- package/template/core/src/openpress/workbench/document/hooks/useDocumentWorkbenchModel.ts +0 -34
- package/template/core/src/openpress/workbench/document/hooks/useInlineDocumentEditor.ts +0 -525
- package/template/core/src/openpress/workbench/document/index.ts +0 -10
- package/template/core/src/openpress/workbench/index.ts +0 -2
- package/template/core/src/openpress/workbench/inspector/InlineInspectorLayer.tsx +0 -459
- package/template/core/src/openpress/workbench/inspector/index.ts +0 -5
- package/template/core/src/openpress/workbench/inspector/inlineCommentModel.ts +0 -125
- package/template/core/src/openpress/workbench/inspector/inspectorGeometryModel.ts +0 -160
- package/template/core/src/openpress/workbench/inspector/inspectorModel.ts +0 -408
- package/template/core/src/openpress/workbench/inspector/useInspectorComments.ts +0 -248
- package/template/core/src/openpress/workbench/mentions/MentionSuggestionList.tsx +0 -41
- package/template/core/src/openpress/workbench/mentions/index.ts +0 -2
- package/template/core/src/openpress/workbench/mentions/useComposerMentions.ts +0 -185
- package/template/core/src/openpress/workbench/panels/Panel.tsx +0 -1
- package/template/core/src/openpress/workbench/panels/PendingCommentsPanel.tsx +0 -76
- package/template/core/src/openpress/workbench/panels/WorkbenchControlPanel.tsx +0 -29
- package/template/core/src/openpress/workbench/panels/index.ts +0 -3
- package/template/core/src/openpress/workbench/project/ProjectEntryPanel.tsx +0 -523
- package/template/core/src/openpress/workbench/project/ProjectPreviewDialog.tsx +0 -35
- package/template/core/src/openpress/workbench/project/index.ts +0 -2
- package/template/core/src/openpress/workbench/project/projectPreviewTypes.ts +0 -11
- package/template/core/src/openpress/workbench/project/projectSourceModel.ts +0 -24
- package/template/core/src/openpress/workbench/shell/WorkbenchShell.tsx +0 -167
- package/template/core/src/openpress/workbench/shell/index.ts +0 -1
- package/template/core/src/openpress/workbench/workbenchFormatters.ts +0 -120
- package/template/core/src/openpress/workbench/workbenchTypes.ts +0 -35
- package/template/core/src/styles/openpress/app-shell.css +0 -251
- package/template/core/src/styles/openpress/media-workspace.css +0 -230
- package/template/core/src/styles/openpress/print-route.css +0 -184
- package/template/core/src/styles/openpress/project-preview-panel.css +0 -924
- package/template/core/src/styles/openpress/public-viewer.css +0 -688
- package/template/core/src/styles/openpress/reader-runtime.css +0 -980
- package/template/core/src/styles/openpress/responsive.css +0 -245
- package/template/core/src/styles/openpress/workbench-panels.css +0 -594
- package/template/core/src/styles/openpress/workbench.css +0 -1255
- package/template/core/src/styles/openpress.css +0 -14
- package/template/core/src/vite-env.d.ts +0 -9
- package/template/core/tsconfig.json +0 -40
- package/template/core/vite.config.ts +0 -584
- package/template/packs/academic-paper/document/chapters/01-introduction/content/01-introduction.mdx +0 -35
- package/template/packs/academic-paper/document/chapters/02-methods/content/01-methods.mdx +0 -50
- package/template/packs/academic-paper/document/chapters/03-results-and-discussion/content/01-results.mdx +0 -47
- package/template/packs/academic-paper/document/chapters/04-acknowledgment/content/01-acknowledgment.mdx +0 -26
- package/template/packs/academic-paper/document/chapters/05-references/content/01-references.mdx +0 -32
- package/template/packs/academic-paper/document/components/ChapterOpenerVisual/index.tsx +0 -76
- package/template/packs/academic-paper/document/components/Page.tsx +0 -60
- package/template/packs/academic-paper/document/components/TokenSwatchGrid/index.tsx +0 -46
- package/template/packs/academic-paper/document/components/TokenSwatchGrid/style.css +0 -63
- package/template/packs/academic-paper/document/components/TypeSpecimen/index.tsx +0 -38
- package/template/packs/academic-paper/document/components/TypeSpecimen/style.css +0 -111
- package/template/packs/academic-paper/document/design.md +0 -279
- package/template/packs/academic-paper/document/index.tsx +0 -123
- package/template/packs/academic-paper/document/media/README.md +0 -13
- package/template/packs/academic-paper/document/media/figure-placeholder.svg +0 -9
- package/template/packs/academic-paper/document/openpress.config.mjs +0 -26
- package/template/packs/academic-paper/document/theme/README.md +0 -11
- package/template/packs/academic-paper/document/theme/base/page-contract.css +0 -522
- package/template/packs/academic-paper/document/theme/base/print.css +0 -93
- package/template/packs/academic-paper/document/theme/base/typography.css +0 -333
- package/template/packs/academic-paper/document/theme/fonts.css +0 -3
- package/template/packs/academic-paper/document/theme/page-surfaces/back-cover.css +0 -43
- package/template/packs/academic-paper/document/theme/page-surfaces/chapter-opener.css +0 -205
- package/template/packs/academic-paper/document/theme/page-surfaces/cover.css +0 -294
- package/template/packs/academic-paper/document/theme/page-surfaces/toc.css +0 -149
- package/template/packs/academic-paper/document/theme/patterns/_chart-frame.css +0 -49
- package/template/packs/academic-paper/document/theme/patterns/figure-grid.css +0 -68
- package/template/packs/academic-paper/document/theme/patterns/table-utilities.css +0 -66
- package/template/packs/academic-paper/document/theme/shell/reader-controls.css +0 -761
- package/template/packs/academic-paper/document/theme/tokens.css +0 -80
- package/template/packs/academic-paper/openpress.config.mjs +0 -5
- package/template/packs/claude-document/document/chapters/01-document-shape/content/01-document-shape.mdx +0 -51
- package/template/packs/claude-document/document/chapters/02-review-loop/content/01-review-loop.mdx +0 -31
- package/template/packs/claude-document/document/components/ChapterOpenerVisual.tsx +0 -96
- package/template/packs/claude-document/document/components/Page.tsx +0 -37
- package/template/packs/claude-document/document/design.md +0 -142
- package/template/packs/claude-document/document/index.tsx +0 -94
- package/template/packs/claude-document/document/media/README.md +0 -13
- package/template/packs/claude-document/document/openpress.config.mjs +0 -26
- package/template/packs/claude-document/document/theme/README.md +0 -15
- package/template/packs/claude-document/document/theme/base/page-contract.css +0 -525
- package/template/packs/claude-document/document/theme/base/print.css +0 -93
- package/template/packs/claude-document/document/theme/base/typography.css +0 -612
- package/template/packs/claude-document/document/theme/fonts.css +0 -4
- package/template/packs/claude-document/document/theme/page-surfaces/back-cover.css +0 -72
- package/template/packs/claude-document/document/theme/page-surfaces/chapter-opener.css +0 -236
- package/template/packs/claude-document/document/theme/page-surfaces/cover.css +0 -309
- package/template/packs/claude-document/document/theme/page-surfaces/toc.css +0 -225
- package/template/packs/claude-document/document/theme/patterns/_chart-frame.css +0 -53
- package/template/packs/claude-document/document/theme/patterns/figure-grid.css +0 -68
- package/template/packs/claude-document/document/theme/patterns/table-utilities.css +0 -66
- package/template/packs/claude-document/document/theme/shell/reader-controls.css +0 -789
- package/template/packs/claude-document/document/theme/tokens.css +0 -89
- package/template/packs/claude-document/openpress.config.mjs +0 -5
- package/template/packs/editorial-monograph/document/chapters/01-product-and-use-cases/content/01-product-and-use-cases.mdx +0 -31
- package/template/packs/editorial-monograph/document/chapters/02-workflow/content/01-workflow.mdx +0 -89
- package/template/packs/editorial-monograph/document/chapters/03-agent-skills-contributors/content/01-agent-skills-contributors.mdx +0 -51
- package/template/packs/editorial-monograph/document/chapters/04-validation-deploy/content/01-validation-deploy.mdx +0 -39
- package/template/packs/editorial-monograph/document/components/ChapterOpenerVisual/index.tsx +0 -76
- package/template/packs/editorial-monograph/document/components/Page.tsx +0 -37
- package/template/packs/editorial-monograph/document/components/TokenSwatchGrid/index.tsx +0 -46
- package/template/packs/editorial-monograph/document/components/TokenSwatchGrid/style.css +0 -63
- package/template/packs/editorial-monograph/document/components/TypeSpecimen/index.tsx +0 -38
- package/template/packs/editorial-monograph/document/components/TypeSpecimen/style.css +0 -111
- package/template/packs/editorial-monograph/document/design.md +0 -279
- package/template/packs/editorial-monograph/document/index.tsx +0 -97
- package/template/packs/editorial-monograph/document/media/README.md +0 -13
- package/template/packs/editorial-monograph/document/openpress.config.mjs +0 -26
- package/template/packs/editorial-monograph/document/theme/README.md +0 -11
- package/template/packs/editorial-monograph/document/theme/base/page-contract.css +0 -505
- package/template/packs/editorial-monograph/document/theme/base/print.css +0 -93
- package/template/packs/editorial-monograph/document/theme/base/typography.css +0 -336
- package/template/packs/editorial-monograph/document/theme/fonts.css +0 -3
- package/template/packs/editorial-monograph/document/theme/page-surfaces/back-cover.css +0 -43
- package/template/packs/editorial-monograph/document/theme/page-surfaces/chapter-opener.css +0 -205
- package/template/packs/editorial-monograph/document/theme/page-surfaces/cover.css +0 -147
- package/template/packs/editorial-monograph/document/theme/page-surfaces/toc.css +0 -149
- package/template/packs/editorial-monograph/document/theme/patterns/_chart-frame.css +0 -49
- package/template/packs/editorial-monograph/document/theme/patterns/figure-grid.css +0 -68
- package/template/packs/editorial-monograph/document/theme/patterns/table-utilities.css +0 -66
- package/template/packs/editorial-monograph/document/theme/shell/reader-controls.css +0 -761
- package/template/packs/editorial-monograph/document/theme/tokens.css +0 -80
- package/template/packs/editorial-monograph/openpress.config.mjs +0 -5
|
@@ -1,523 +0,0 @@
|
|
|
1
|
-
import { useState, type CSSProperties } from "react";
|
|
2
|
-
import { Component as ComponentIcon, Images, Palette, type LucideIcon } from "lucide-react";
|
|
3
|
-
import type { BookmarkItem, BookmarkSubItem, MediaAssetItem } from "../../document-model";
|
|
4
|
-
import { projectSourceDirectoryPath, PROJECT_SOURCES } from "./projectSourceModel";
|
|
5
|
-
import type { BlockSource } from "../../document-model";
|
|
6
|
-
import type { DisplayPage } from "../../reader";
|
|
7
|
-
import { Panel } from "../panels/Panel";
|
|
8
|
-
import { ProjectPreviewDialog } from "./ProjectPreviewDialog";
|
|
9
|
-
import {
|
|
10
|
-
createProjectObjectEntityId,
|
|
11
|
-
type ProjectMentionItem,
|
|
12
|
-
type ProjectPanelPreview,
|
|
13
|
-
} from "./projectPreviewTypes";
|
|
14
|
-
|
|
15
|
-
export { createProjectObjectEntityId } from "./projectPreviewTypes";
|
|
16
|
-
export type { ProjectMentionItem, ProjectPanelPreview } from "./projectPreviewTypes";
|
|
17
|
-
|
|
18
|
-
export const PROJECT_VISUAL_SYSTEM_KEY = "visual-system";
|
|
19
|
-
export const PROJECT_IMAGE_GALLERY_KEY = "image-gallery";
|
|
20
|
-
export const PROJECT_COMPONENT_LIBRARY_KEY = "component-library";
|
|
21
|
-
|
|
22
|
-
export type ProjectComponentUsage = {
|
|
23
|
-
count: number;
|
|
24
|
-
pageIndexes: number[];
|
|
25
|
-
html: string;
|
|
26
|
-
previews: ProjectComponentPreview[];
|
|
27
|
-
};
|
|
28
|
-
|
|
29
|
-
export type ProjectComponentPreview = {
|
|
30
|
-
name: string;
|
|
31
|
-
html: string;
|
|
32
|
-
pageIndex: number;
|
|
33
|
-
};
|
|
34
|
-
|
|
35
|
-
export function createProjectComponentUsages(pages: DisplayPage[]): Map<string, ProjectComponentUsage> {
|
|
36
|
-
const usages = new Map<string, ProjectComponentUsage>();
|
|
37
|
-
pages.forEach((page) => {
|
|
38
|
-
const html = String(page.html ?? "");
|
|
39
|
-
const pageIndex = page.pageNumber - 1;
|
|
40
|
-
for (const block of extractRenderedComponentBlocks(html)) {
|
|
41
|
-
const current = usages.get(block.name) ?? { count: 0, pageIndexes: [], html: block.html, previews: [] };
|
|
42
|
-
current.count += 1;
|
|
43
|
-
if (!current.html) current.html = block.html;
|
|
44
|
-
if (!current.pageIndexes.includes(pageIndex)) current.pageIndexes.push(pageIndex);
|
|
45
|
-
current.previews.push({ name: block.name, html: block.html, pageIndex });
|
|
46
|
-
usages.set(block.name, current);
|
|
47
|
-
}
|
|
48
|
-
});
|
|
49
|
-
return usages;
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
export function createProjectMentionItems(
|
|
53
|
-
mediaAssets: MediaAssetItem[],
|
|
54
|
-
componentUsages: Map<string, ProjectComponentUsage>,
|
|
55
|
-
bookmarks: BookmarkItem[] = [],
|
|
56
|
-
): ProjectMentionItem[] {
|
|
57
|
-
const referenceItems = createBookmarkMentionItems(bookmarks);
|
|
58
|
-
|
|
59
|
-
const mediaItems: ProjectMentionItem[] = mediaAssets.map((item) => ({
|
|
60
|
-
trigger: "@",
|
|
61
|
-
value: mediaMention(item.fileName),
|
|
62
|
-
label: item.fileName,
|
|
63
|
-
meta: item.usageCount > 0 ? `media · P${String(item.pageIndex + 1).padStart(2, "0")}` : "media · unused",
|
|
64
|
-
kind: "media",
|
|
65
|
-
}));
|
|
66
|
-
|
|
67
|
-
const componentItems: ProjectMentionItem[] = Array.from(componentUsages.entries())
|
|
68
|
-
.sort(([a], [b]) => a.localeCompare(b, "zh-Hant"))
|
|
69
|
-
.map(([name, usage]) => ({
|
|
70
|
-
trigger: "@",
|
|
71
|
-
value: componentMention(name),
|
|
72
|
-
label: name,
|
|
73
|
-
meta: `component · ${usage.count}`,
|
|
74
|
-
kind: "component",
|
|
75
|
-
}));
|
|
76
|
-
|
|
77
|
-
return [...PROJECT_SKILL_MENTIONS, ...referenceItems, ...mediaItems, ...componentItems];
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
export function ProjectEntryPanel({
|
|
81
|
-
mediaAssets,
|
|
82
|
-
componentUsages,
|
|
83
|
-
mentionItems,
|
|
84
|
-
currentSource,
|
|
85
|
-
onCommentSubmitted,
|
|
86
|
-
}: {
|
|
87
|
-
mediaAssets: MediaAssetItem[];
|
|
88
|
-
componentUsages: Map<string, ProjectComponentUsage>;
|
|
89
|
-
mentionItems: ProjectMentionItem[];
|
|
90
|
-
currentSource: BlockSource | undefined;
|
|
91
|
-
onCommentSubmitted?: () => void | Promise<void>;
|
|
92
|
-
}) {
|
|
93
|
-
const [preview, setPreview] = useState<ProjectPanelPreview | null>(null);
|
|
94
|
-
const componentItems = Array.from(componentUsages.entries())
|
|
95
|
-
.sort(([a], [b]) => a.localeCompare(b, "zh-Hant"))
|
|
96
|
-
.slice(0, 8);
|
|
97
|
-
const mediaItems = mediaAssets
|
|
98
|
-
.slice(0, 10)
|
|
99
|
-
.map((item) => ({
|
|
100
|
-
fileName: item.fileName,
|
|
101
|
-
src: item.src,
|
|
102
|
-
mention: mediaMention(item.fileName),
|
|
103
|
-
meta: item.usageCount > 0 ? `P${String(item.pageIndex + 1).padStart(2, "0")}` : "unused",
|
|
104
|
-
}));
|
|
105
|
-
|
|
106
|
-
return (
|
|
107
|
-
<Panel className="openpress-project-panel openpress-panel--compact" aria-label="Project tools">
|
|
108
|
-
<Panel.Section className="openpress-project-tool-block" aria-label="媒體素材">
|
|
109
|
-
<Panel.SectionTitle>Media</Panel.SectionTitle>
|
|
110
|
-
{mediaItems.length > 0 ? (
|
|
111
|
-
<div className="openpress-project-asset-list">
|
|
112
|
-
{mediaItems.map((item) => (
|
|
113
|
-
<button
|
|
114
|
-
type="button"
|
|
115
|
-
className="openpress-project-asset"
|
|
116
|
-
data-openpress-object-id={createProjectObjectEntityId("media", item.fileName)}
|
|
117
|
-
key={`${item.src}-${item.fileName}`}
|
|
118
|
-
onClick={() => setPreview({ kind: "media", title: item.fileName, src: item.src })}
|
|
119
|
-
>
|
|
120
|
-
<span className="openpress-project-asset-thumb">
|
|
121
|
-
<img src={item.src} alt="" loading="lazy" />
|
|
122
|
-
</span>
|
|
123
|
-
<span className="openpress-project-asset-body">
|
|
124
|
-
<strong>{item.fileName}</strong>
|
|
125
|
-
</span>
|
|
126
|
-
</button>
|
|
127
|
-
))}
|
|
128
|
-
</div>
|
|
129
|
-
) : (
|
|
130
|
-
<Panel.Empty>尚無圖片</Panel.Empty>
|
|
131
|
-
)}
|
|
132
|
-
</Panel.Section>
|
|
133
|
-
|
|
134
|
-
<Panel.Section className="openpress-project-tool-block" aria-label="Components">
|
|
135
|
-
<Panel.SectionTitle>Components</Panel.SectionTitle>
|
|
136
|
-
{componentItems.length > 0 ? (
|
|
137
|
-
<div className="openpress-project-component-mention-list">
|
|
138
|
-
{componentItems.map(([name, usage]) => (
|
|
139
|
-
<button
|
|
140
|
-
type="button"
|
|
141
|
-
data-openpress-object-id={createProjectObjectEntityId("component", name)}
|
|
142
|
-
key={name}
|
|
143
|
-
onClick={() => setPreview({ kind: "component", title: name, html: usage.html })}
|
|
144
|
-
>
|
|
145
|
-
<ComponentIcon aria-hidden="true" />
|
|
146
|
-
<span>
|
|
147
|
-
<strong>{name}</strong>
|
|
148
|
-
</span>
|
|
149
|
-
</button>
|
|
150
|
-
))}
|
|
151
|
-
</div>
|
|
152
|
-
) : (
|
|
153
|
-
<Panel.Empty>尚無 component</Panel.Empty>
|
|
154
|
-
)}
|
|
155
|
-
</Panel.Section>
|
|
156
|
-
{preview ? (
|
|
157
|
-
<ProjectPreviewDialog
|
|
158
|
-
key={`${preview.kind}-${preview.title}`}
|
|
159
|
-
preview={preview}
|
|
160
|
-
onClose={() => setPreview(null)}
|
|
161
|
-
/>
|
|
162
|
-
) : null}
|
|
163
|
-
</Panel>
|
|
164
|
-
);
|
|
165
|
-
}
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
export function ProjectPreviewPanel({
|
|
169
|
-
mediaAssets,
|
|
170
|
-
componentUsages,
|
|
171
|
-
selectedKey,
|
|
172
|
-
}: {
|
|
173
|
-
mediaAssets: MediaAssetItem[];
|
|
174
|
-
componentUsages: Map<string, ProjectComponentUsage>;
|
|
175
|
-
selectedKey: string | null;
|
|
176
|
-
}) {
|
|
177
|
-
if (!selectedKey || selectedKey === PROJECT_VISUAL_SYSTEM_KEY) {
|
|
178
|
-
return <ProjectVisualSystem />;
|
|
179
|
-
}
|
|
180
|
-
|
|
181
|
-
if (selectedKey === PROJECT_IMAGE_GALLERY_KEY) {
|
|
182
|
-
return <ProjectImageGallery mediaAssets={mediaAssets} />;
|
|
183
|
-
}
|
|
184
|
-
|
|
185
|
-
if (selectedKey === PROJECT_COMPONENT_LIBRARY_KEY) {
|
|
186
|
-
return <ProjectComponentLibrary usages={componentUsages} />;
|
|
187
|
-
}
|
|
188
|
-
|
|
189
|
-
return <ProjectVisualSystem />;
|
|
190
|
-
}
|
|
191
|
-
|
|
192
|
-
function ProjectPanelButton({
|
|
193
|
-
icon: Icon,
|
|
194
|
-
label,
|
|
195
|
-
meta,
|
|
196
|
-
active,
|
|
197
|
-
onClick,
|
|
198
|
-
}: {
|
|
199
|
-
icon: LucideIcon;
|
|
200
|
-
label: string;
|
|
201
|
-
meta: string;
|
|
202
|
-
active: boolean;
|
|
203
|
-
onClick: () => void;
|
|
204
|
-
}) {
|
|
205
|
-
return (
|
|
206
|
-
<button
|
|
207
|
-
type="button"
|
|
208
|
-
className={`bookmark-item bookmark-h2 openpress-project-entry${active ? " is-active" : ""}`}
|
|
209
|
-
aria-pressed={active}
|
|
210
|
-
onClick={onClick}
|
|
211
|
-
>
|
|
212
|
-
<span className="bookmark-index openpress-project-entry-icon"><Icon aria-hidden="true" /></span>
|
|
213
|
-
<span className="bookmark-title">
|
|
214
|
-
<span>{label}</span>
|
|
215
|
-
<small>{meta}</small>
|
|
216
|
-
</span>
|
|
217
|
-
</button>
|
|
218
|
-
);
|
|
219
|
-
}
|
|
220
|
-
|
|
221
|
-
function ProjectVisualSystem() {
|
|
222
|
-
return (
|
|
223
|
-
<section className="openpress-project-preview-panel" aria-label="專案">
|
|
224
|
-
<article className="openpress-project-visual-system" aria-label="Visual System">
|
|
225
|
-
<ProjectSectionHeader title="Visual System" minimal />
|
|
226
|
-
|
|
227
|
-
<div className="openpress-project-visual-grid">
|
|
228
|
-
<section className="openpress-project-visual-card openpress-project-visual-card--typography" aria-label="Typography">
|
|
229
|
-
<header>
|
|
230
|
-
<span>Typography</span>
|
|
231
|
-
<strong>閱讀層級</strong>
|
|
232
|
-
</header>
|
|
233
|
-
<div className="openpress-project-type-specimen">
|
|
234
|
-
<p className="openpress-project-type-kicker">Course Notes</p>
|
|
235
|
-
<h2>Data Structures</h2>
|
|
236
|
-
<h3>Linked List 與 Tree Traversal</h3>
|
|
237
|
-
<h4>Pointer / Node / Recursive Thinking</h4>
|
|
238
|
-
<p>以 C/C++ 實作資料結構,整理概念、表示法與操作流程。</p>
|
|
239
|
-
<code>struct Node *next = head;</code>
|
|
240
|
-
</div>
|
|
241
|
-
</section>
|
|
242
|
-
|
|
243
|
-
<section className="openpress-project-visual-card" aria-label="Color Palette">
|
|
244
|
-
<header>
|
|
245
|
-
<span>Palette</span>
|
|
246
|
-
<strong>色票配置</strong>
|
|
247
|
-
</header>
|
|
248
|
-
<div className="openpress-project-swatch-grid">
|
|
249
|
-
{PROJECT_COLOR_SWATCHES.map((item) => (
|
|
250
|
-
<div className="openpress-project-swatch" key={item.token}>
|
|
251
|
-
<span
|
|
252
|
-
className="openpress-project-swatch-chip"
|
|
253
|
-
style={{ "--openpress-project-swatch": `var(${item.token})` } as CSSProperties}
|
|
254
|
-
aria-hidden="true"
|
|
255
|
-
/>
|
|
256
|
-
<strong>{item.label}</strong>
|
|
257
|
-
<code>{item.token.replace("--openpress-", "")}</code>
|
|
258
|
-
</div>
|
|
259
|
-
))}
|
|
260
|
-
</div>
|
|
261
|
-
</section>
|
|
262
|
-
|
|
263
|
-
<section className="openpress-project-visual-card openpress-project-visual-card--surfaces" aria-label="Surfaces">
|
|
264
|
-
<header>
|
|
265
|
-
<span>Surfaces</span>
|
|
266
|
-
<strong>區塊背景</strong>
|
|
267
|
-
</header>
|
|
268
|
-
<div className="openpress-project-surface-preview">
|
|
269
|
-
<div className="openpress-project-surface-paper">
|
|
270
|
-
<span>Page paper</span>
|
|
271
|
-
</div>
|
|
272
|
-
<div className="openpress-project-surface-block">
|
|
273
|
-
<span>Figure / Code block</span>
|
|
274
|
-
</div>
|
|
275
|
-
</div>
|
|
276
|
-
</section>
|
|
277
|
-
</div>
|
|
278
|
-
</article>
|
|
279
|
-
</section>
|
|
280
|
-
);
|
|
281
|
-
}
|
|
282
|
-
|
|
283
|
-
function ProjectComponentLibrary({
|
|
284
|
-
usages,
|
|
285
|
-
}: {
|
|
286
|
-
usages: Map<string, ProjectComponentUsage>;
|
|
287
|
-
}) {
|
|
288
|
-
const previewItems = createComponentPreviewItems(usages);
|
|
289
|
-
return (
|
|
290
|
-
<section className="openpress-project-preview-panel" aria-label="專案">
|
|
291
|
-
<article className="openpress-project-component-viewer" aria-label={PROJECT_SOURCES.components.label}>
|
|
292
|
-
<ProjectSectionHeader
|
|
293
|
-
title="Rendered Components"
|
|
294
|
-
description="文件目前實際渲染出的 component、圖表與示意圖狀態。"
|
|
295
|
-
stats={[
|
|
296
|
-
["Kinds", String(usages.size)],
|
|
297
|
-
["Renders", String(previewItems.length)],
|
|
298
|
-
]}
|
|
299
|
-
/>
|
|
300
|
-
{previewItems.length > 0 ? (
|
|
301
|
-
<div className="openpress-project-component-list" aria-label="rendered content block list">
|
|
302
|
-
{previewItems.map((item) => (
|
|
303
|
-
<figure className="openpress-project-component-preview-row" key={`${item.name}-${item.index}`}>
|
|
304
|
-
<figcaption>
|
|
305
|
-
<span>{item.name}</span>
|
|
306
|
-
<small>P{String(item.preview.pageIndex + 1).padStart(2, "0")}</small>
|
|
307
|
-
</figcaption>
|
|
308
|
-
<div
|
|
309
|
-
className="openpress-project-component-preview"
|
|
310
|
-
dangerouslySetInnerHTML={{ __html: item.preview.html }}
|
|
311
|
-
/>
|
|
312
|
-
</figure>
|
|
313
|
-
))}
|
|
314
|
-
</div>
|
|
315
|
-
) : (
|
|
316
|
-
<p className="openpress-project-empty">目前文件尚未渲染任何內容區塊。</p>
|
|
317
|
-
)}
|
|
318
|
-
</article>
|
|
319
|
-
</section>
|
|
320
|
-
);
|
|
321
|
-
}
|
|
322
|
-
|
|
323
|
-
function ProjectImageGallery({
|
|
324
|
-
mediaAssets,
|
|
325
|
-
}: {
|
|
326
|
-
mediaAssets: MediaAssetItem[];
|
|
327
|
-
}) {
|
|
328
|
-
const usedCount = mediaAssets.filter((item) => item.usageCount > 0).length;
|
|
329
|
-
const unreferencedAssets = mediaAssets.filter((item) => item.usageCount === 0);
|
|
330
|
-
const referencedAssets = mediaAssets.filter((item) => item.usageCount > 0);
|
|
331
|
-
return (
|
|
332
|
-
<section className="openpress-project-preview-panel" aria-label="專案">
|
|
333
|
-
<article className="openpress-project-gallery-viewer" aria-label="Image Gallery">
|
|
334
|
-
<ProjectSectionHeader
|
|
335
|
-
title="Media Library"
|
|
336
|
-
description={projectSourceDirectoryPath("media")}
|
|
337
|
-
stats={[
|
|
338
|
-
["Files", String(mediaAssets.length)],
|
|
339
|
-
["Used", String(usedCount)],
|
|
340
|
-
]}
|
|
341
|
-
/>
|
|
342
|
-
{mediaAssets.length > 0 ? (
|
|
343
|
-
<div className="openpress-project-media-sections" aria-label="media gallery">
|
|
344
|
-
<ProjectMediaSection title="未引用" assets={unreferencedAssets} />
|
|
345
|
-
<ProjectMediaSection title="已引用" assets={referencedAssets} />
|
|
346
|
-
</div>
|
|
347
|
-
) : (
|
|
348
|
-
<p className="openpress-project-empty">{projectSourceDirectoryPath("media")} 尚未有可預覽素材。</p>
|
|
349
|
-
)}
|
|
350
|
-
</article>
|
|
351
|
-
</section>
|
|
352
|
-
);
|
|
353
|
-
}
|
|
354
|
-
|
|
355
|
-
function ProjectSectionHeader({
|
|
356
|
-
title,
|
|
357
|
-
description,
|
|
358
|
-
stats,
|
|
359
|
-
minimal = false,
|
|
360
|
-
}: {
|
|
361
|
-
title: string;
|
|
362
|
-
description?: string;
|
|
363
|
-
stats?: Array<[string, string]>;
|
|
364
|
-
minimal?: boolean;
|
|
365
|
-
}) {
|
|
366
|
-
return (
|
|
367
|
-
<header className={`openpress-project-section-header${minimal ? " openpress-project-section-header--minimal" : ""}`}>
|
|
368
|
-
<div>
|
|
369
|
-
<h2>{title}</h2>
|
|
370
|
-
{description ? <span>{description}</span> : null}
|
|
371
|
-
</div>
|
|
372
|
-
{!minimal && stats?.length ? (
|
|
373
|
-
<dl>
|
|
374
|
-
{stats.map(([label, value]) => (
|
|
375
|
-
<div key={label}>
|
|
376
|
-
<dt>{label}</dt>
|
|
377
|
-
<dd>{value}</dd>
|
|
378
|
-
</div>
|
|
379
|
-
))}
|
|
380
|
-
</dl>
|
|
381
|
-
) : null}
|
|
382
|
-
</header>
|
|
383
|
-
);
|
|
384
|
-
}
|
|
385
|
-
|
|
386
|
-
function ProjectMediaSection({
|
|
387
|
-
title,
|
|
388
|
-
assets,
|
|
389
|
-
}: {
|
|
390
|
-
title: string;
|
|
391
|
-
assets: MediaAssetItem[];
|
|
392
|
-
}) {
|
|
393
|
-
return (
|
|
394
|
-
<section className="openpress-project-media-section" aria-label={title}>
|
|
395
|
-
<header className="openpress-project-media-section-header">
|
|
396
|
-
<h3>{title}</h3>
|
|
397
|
-
</header>
|
|
398
|
-
{assets.length > 0 ? (
|
|
399
|
-
<div className="openpress-project-media-gallery">
|
|
400
|
-
{assets.map((item) => (
|
|
401
|
-
<figure className="openpress-project-media-card" data-unused={item.usageCount === 0 ? "true" : "false"} key={item.id}>
|
|
402
|
-
<img src={item.src} alt="" loading="lazy" />
|
|
403
|
-
<figcaption>
|
|
404
|
-
<strong>{item.fileName}</strong>
|
|
405
|
-
</figcaption>
|
|
406
|
-
</figure>
|
|
407
|
-
))}
|
|
408
|
-
</div>
|
|
409
|
-
) : (
|
|
410
|
-
<p className="openpress-project-media-section-empty">沒有{title}圖片。</p>
|
|
411
|
-
)}
|
|
412
|
-
</section>
|
|
413
|
-
);
|
|
414
|
-
}
|
|
415
|
-
|
|
416
|
-
function createComponentPreviewItems(usages: Map<string, ProjectComponentUsage>) {
|
|
417
|
-
return Array.from(usages.entries())
|
|
418
|
-
.flatMap(([name, usage]) => usage.previews.map((preview, index) => ({ name, preview, index })))
|
|
419
|
-
.filter((item) => Boolean(item.preview.html))
|
|
420
|
-
.sort((a, b) => {
|
|
421
|
-
const pageDelta = a.preview.pageIndex - b.preview.pageIndex;
|
|
422
|
-
return pageDelta || a.name.localeCompare(b.name, "zh-Hant") || a.index - b.index;
|
|
423
|
-
});
|
|
424
|
-
}
|
|
425
|
-
|
|
426
|
-
function extractRenderedComponentBlocks(html: string) {
|
|
427
|
-
const blocks: Array<{ name: string; html: string }> = [];
|
|
428
|
-
const openTagPattern = /<(figure|section|article|div)\b[^>]*data-openpress-component="([^"]+)"[^>]*>/g;
|
|
429
|
-
for (const match of html.matchAll(openTagPattern)) {
|
|
430
|
-
const tagName = match[1];
|
|
431
|
-
const componentName = match[2];
|
|
432
|
-
const start = match.index ?? 0;
|
|
433
|
-
const end = findClosingTagEnd(html, tagName, start + match[0].length);
|
|
434
|
-
blocks.push({
|
|
435
|
-
name: componentName,
|
|
436
|
-
html: end > start ? html.slice(start, end) : match[0],
|
|
437
|
-
});
|
|
438
|
-
}
|
|
439
|
-
return blocks;
|
|
440
|
-
}
|
|
441
|
-
|
|
442
|
-
function findClosingTagEnd(html: string, tagName: string, fromIndex: number) {
|
|
443
|
-
const tagPattern = new RegExp(`</?${tagName}\\b[^>]*>`, "gi");
|
|
444
|
-
tagPattern.lastIndex = fromIndex;
|
|
445
|
-
let depth = 1;
|
|
446
|
-
let match: RegExpExecArray | null;
|
|
447
|
-
while ((match = tagPattern.exec(html))) {
|
|
448
|
-
if (match[0].startsWith("</")) {
|
|
449
|
-
depth -= 1;
|
|
450
|
-
} else if (!match[0].endsWith("/>")) {
|
|
451
|
-
depth += 1;
|
|
452
|
-
}
|
|
453
|
-
if (depth === 0) return tagPattern.lastIndex;
|
|
454
|
-
}
|
|
455
|
-
return -1;
|
|
456
|
-
}
|
|
457
|
-
|
|
458
|
-
function mediaMention(fileName: string) {
|
|
459
|
-
return `@media/${fileName}`;
|
|
460
|
-
}
|
|
461
|
-
|
|
462
|
-
function componentMention(name: string) {
|
|
463
|
-
return `@component/${name}`;
|
|
464
|
-
}
|
|
465
|
-
|
|
466
|
-
function createBookmarkMentionItems(bookmarks: BookmarkItem[]): ProjectMentionItem[] {
|
|
467
|
-
return bookmarks
|
|
468
|
-
.filter((item) => item.label !== "00")
|
|
469
|
-
.flatMap((chapter) => [
|
|
470
|
-
bookmarkMentionItem("chapter", chapter),
|
|
471
|
-
...chapter.subs.map((section) => bookmarkMentionItem("section", section)),
|
|
472
|
-
]);
|
|
473
|
-
}
|
|
474
|
-
|
|
475
|
-
function bookmarkMentionItem(kind: "chapter" | "section", item: BookmarkItem | BookmarkSubItem): ProjectMentionItem {
|
|
476
|
-
const label = item.label ? `${item.label} ` : "";
|
|
477
|
-
return {
|
|
478
|
-
trigger: "@",
|
|
479
|
-
value: `@${kind}/${bookmarkMentionSlug(item)}`,
|
|
480
|
-
label: `${label}${item.title}`,
|
|
481
|
-
meta: `${kind === "chapter" ? "chapter" : "section"} · P${String(item.pageIndex + 1).padStart(2, "0")}`,
|
|
482
|
-
kind,
|
|
483
|
-
};
|
|
484
|
-
}
|
|
485
|
-
|
|
486
|
-
function bookmarkMentionSlug(item: BookmarkItem | BookmarkSubItem) {
|
|
487
|
-
const parts = [item.label, item.title]
|
|
488
|
-
.filter(Boolean)
|
|
489
|
-
.map((part) => mentionSlugPart(String(part)));
|
|
490
|
-
return parts.filter(Boolean).join("-") || item.id;
|
|
491
|
-
}
|
|
492
|
-
|
|
493
|
-
function mentionSlugPart(value: string) {
|
|
494
|
-
return value
|
|
495
|
-
.trim()
|
|
496
|
-
.replace(/\s+/g, "-")
|
|
497
|
-
.replace(/[^\p{L}\p{N}._-]+/gu, "-")
|
|
498
|
-
.replace(/-+/g, "-")
|
|
499
|
-
.replace(/^-|-$/g, "");
|
|
500
|
-
}
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
const PROJECT_SKILL_MENTIONS: ProjectMentionItem[] = [
|
|
504
|
-
{ trigger: "/", value: "/insert-image", label: "insert-image", meta: "skill", kind: "skill" },
|
|
505
|
-
{ trigger: "/", value: "/redraw-figure", label: "redraw-figure", meta: "skill", kind: "skill" },
|
|
506
|
-
{ trigger: "/", value: "/rewrite-section", label: "rewrite-section", meta: "skill", kind: "skill" },
|
|
507
|
-
{ trigger: "/", value: "/apply-comments", label: "apply-comments", meta: "skill", kind: "skill" },
|
|
508
|
-
{ trigger: "/", value: "/apply-style", label: "apply-style", meta: "skill", kind: "skill" },
|
|
509
|
-
{ trigger: "/", value: "/fix-code", label: "fix-code", meta: "skill", kind: "skill" },
|
|
510
|
-
];
|
|
511
|
-
|
|
512
|
-
const PROJECT_COLOR_SWATCHES = [
|
|
513
|
-
{ label: "Document", token: "--openpress-color-document" },
|
|
514
|
-
{ label: "Paper", token: "--openpress-color-paper" },
|
|
515
|
-
{ label: "Ink", token: "--openpress-color-ink" },
|
|
516
|
-
{ label: "Body", token: "--openpress-color-body" },
|
|
517
|
-
{ label: "Muted", token: "--openpress-color-muted" },
|
|
518
|
-
{ label: "Subtle", token: "--openpress-color-subtle" },
|
|
519
|
-
{ label: "Line", token: "--openpress-color-line" },
|
|
520
|
-
{ label: "Block", token: "--openpress-color-block" },
|
|
521
|
-
{ label: "Info", token: "--openpress-color-info" },
|
|
522
|
-
{ label: "Green", token: "--openpress-color-green" },
|
|
523
|
-
];
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
import { useId } from "react";
|
|
2
|
-
import { WorkbenchDialog } from "../dialog";
|
|
3
|
-
import type { ProjectPanelPreview } from "./projectPreviewTypes";
|
|
4
|
-
import { createProjectObjectEntityId } from "./projectPreviewTypes";
|
|
5
|
-
|
|
6
|
-
export interface ProjectPreviewDialogProps {
|
|
7
|
-
preview: ProjectPanelPreview;
|
|
8
|
-
onClose: () => void;
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
export function ProjectPreviewDialog({ preview, onClose }: ProjectPreviewDialogProps) {
|
|
12
|
-
const titleId = useId();
|
|
13
|
-
|
|
14
|
-
return (
|
|
15
|
-
<WorkbenchDialog
|
|
16
|
-
titleId={titleId}
|
|
17
|
-
title={preview.title}
|
|
18
|
-
className="openpress-project-preview-dialog"
|
|
19
|
-
closeLabel="關閉預覽"
|
|
20
|
-
onClose={onClose}
|
|
21
|
-
>
|
|
22
|
-
<div
|
|
23
|
-
className="openpress-project-preview-dialog__body"
|
|
24
|
-
data-preview-kind={preview.kind}
|
|
25
|
-
data-openpress-object-id={createProjectObjectEntityId(preview.kind, preview.title)}
|
|
26
|
-
>
|
|
27
|
-
{preview.kind === "media" ? (
|
|
28
|
-
<img src={preview.src} alt="" />
|
|
29
|
-
) : (
|
|
30
|
-
<div dangerouslySetInnerHTML={{ __html: preview.html }} />
|
|
31
|
-
)}
|
|
32
|
-
</div>
|
|
33
|
-
</WorkbenchDialog>
|
|
34
|
-
);
|
|
35
|
-
}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import type { ComposerMentionItem } from "../mentions";
|
|
2
|
-
|
|
3
|
-
export type ProjectMentionItem = ComposerMentionItem;
|
|
4
|
-
|
|
5
|
-
export type ProjectPanelPreview =
|
|
6
|
-
| { kind: "media"; title: string; src: string }
|
|
7
|
-
| { kind: "component"; title: string; html: string };
|
|
8
|
-
|
|
9
|
-
export function createProjectObjectEntityId(kind: "media" | "component", name: string) {
|
|
10
|
-
return [kind, encodeURIComponent(name)].join(":");
|
|
11
|
-
}
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
// Source directory paths come from vite.config.ts build-time defines, which
|
|
2
|
-
// in turn read openpress.config.mjs. The React app does not hardcode `document/`.
|
|
3
|
-
|
|
4
|
-
export const PROJECT_SOURCES = {
|
|
5
|
-
content: {
|
|
6
|
-
key: "content",
|
|
7
|
-
directory: __OPENPRESS_CONTENT_PATH__,
|
|
8
|
-
label: "Content",
|
|
9
|
-
},
|
|
10
|
-
media: {
|
|
11
|
-
key: "media",
|
|
12
|
-
directory: __OPENPRESS_MEDIA_PATH__,
|
|
13
|
-
label: "Image Gallery",
|
|
14
|
-
},
|
|
15
|
-
components: {
|
|
16
|
-
key: "components",
|
|
17
|
-
directory: __OPENPRESS_COMPONENTS_PATH__,
|
|
18
|
-
label: "內容區塊",
|
|
19
|
-
},
|
|
20
|
-
} as const;
|
|
21
|
-
|
|
22
|
-
export function projectSourceDirectoryPath(source: keyof typeof PROJECT_SOURCES) {
|
|
23
|
-
return `${PROJECT_SOURCES[source].directory}/`;
|
|
24
|
-
}
|