@alpaca-editor/core 1.0.3939 → 1.0.3942
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/dist/components/ActionButton.d.ts +1 -0
- package/dist/components/ActionButton.js +2 -2
- package/dist/components/ActionButton.js.map +1 -1
- package/dist/editor/FieldActionsOverlay.d.ts +1 -0
- package/dist/editor/FieldActionsOverlay.js +2 -11
- package/dist/editor/FieldActionsOverlay.js.map +1 -1
- package/dist/editor/PictureCropper.js +65 -23
- package/dist/editor/PictureCropper.js.map +1 -1
- package/dist/editor/PictureEditor.js +16 -2
- package/dist/editor/PictureEditor.js.map +1 -1
- package/dist/editor/Titlebar.js +1 -1
- package/dist/editor/Titlebar.js.map +1 -1
- package/dist/editor/ai/GhostWriter.js +21 -2
- package/dist/editor/ai/GhostWriter.js.map +1 -1
- package/dist/editor/commands/componentCommands.js +7 -3
- package/dist/editor/commands/componentCommands.js.map +1 -1
- package/dist/editor/media-selector/MediaFolderBrowser.d.ts +5 -0
- package/dist/editor/media-selector/MediaFolderBrowser.js +77 -0
- package/dist/editor/media-selector/MediaFolderBrowser.js.map +1 -0
- package/dist/editor/media-selector/MediaSelector.js +1 -1
- package/dist/editor/media-selector/MediaSelector.js.map +1 -1
- package/dist/editor/media-selector/Thumbnails.js +2 -2
- package/dist/editor/media-selector/index.d.ts +8 -0
- package/dist/editor/media-selector/index.js +9 -0
- package/dist/editor/media-selector/index.js.map +1 -0
- package/dist/editor/menubar/BrowseHistory.js +1 -1
- package/dist/editor/menubar/PageSelector.js +39 -15
- package/dist/editor/menubar/PageSelector.js.map +1 -1
- package/dist/editor/page-editor-chrome/useInlineAICompletion.js +37 -11
- package/dist/editor/page-editor-chrome/useInlineAICompletion.js.map +1 -1
- package/dist/editor/reviews/Comment.js +1 -1
- package/dist/editor/reviews/Comment.js.map +1 -1
- package/dist/editor/services/aiService.js +0 -1
- package/dist/editor/services/aiService.js.map +1 -1
- package/dist/editor/sidebar/ComponentTree.js +3 -4
- package/dist/editor/sidebar/ComponentTree.js.map +1 -1
- package/dist/editor/ui/SimpleTabs.d.ts +1 -0
- package/dist/editor/ui/SimpleTabs.js +3 -3
- package/dist/editor/ui/SimpleTabs.js.map +1 -1
- package/dist/editor/ui/Splitter.js +61 -6
- package/dist/editor/ui/Splitter.js.map +1 -1
- package/dist/editor/views/MediaFolderEditView.d.ts +4 -0
- package/dist/editor/views/MediaFolderEditView.js +40 -0
- package/dist/editor/views/MediaFolderEditView.js.map +1 -0
- package/dist/editor/views/SingleEditView.js +9 -1
- package/dist/editor/views/SingleEditView.js.map +1 -1
- package/dist/revision.d.ts +2 -2
- package/dist/revision.js +2 -2
- package/dist/styles.css +61 -5
- package/package.json +8 -2
- package/.prettierrc +0 -3
- package/build.css +0 -3
- package/components.json +0 -21
- package/eslint.config.mjs +0 -4
- package/images/bg-shape-black.webp +0 -0
- package/images/wizard-bg.png +0 -0
- package/images/wizard-tour.png +0 -0
- package/images/wizard.png +0 -0
- package/src/client-components/api.ts +0 -6
- package/src/client-components/index.ts +0 -19
- package/src/components/ActionButton.tsx +0 -41
- package/src/components/Error.tsx +0 -57
- package/src/components/ui/CardConnector.tsx +0 -56
- package/src/components/ui/button.tsx +0 -62
- package/src/components/ui/card.tsx +0 -372
- package/src/components/ui/context-menu.tsx +0 -250
- package/src/config/config.tsx +0 -917
- package/src/config/types.ts +0 -286
- package/src/editor/ComponentInfo.tsx +0 -90
- package/src/editor/ConfirmationDialog.tsx +0 -103
- package/src/editor/ContentTree.tsx +0 -730
- package/src/editor/ContextMenu.tsx +0 -230
- package/src/editor/Editor.tsx +0 -90
- package/src/editor/EditorWarning.tsx +0 -34
- package/src/editor/EditorWarnings.tsx +0 -33
- package/src/editor/FieldActionsOverlay.tsx +0 -307
- package/src/editor/FieldEditorPopup.tsx +0 -65
- package/src/editor/FieldHistory.tsx +0 -75
- package/src/editor/FieldList.tsx +0 -190
- package/src/editor/FieldListField.tsx +0 -391
- package/src/editor/FieldListFieldWithFallbacks.tsx +0 -217
- package/src/editor/FloatingToolbar.tsx +0 -163
- package/src/editor/ImageEditor.tsx +0 -128
- package/src/editor/ItemInfo.tsx +0 -90
- package/src/editor/LinkEditorDialog.tsx +0 -196
- package/src/editor/MainLayout.tsx +0 -95
- package/src/editor/MobileLayout.tsx +0 -68
- package/src/editor/NewEditorClient.tsx +0 -11
- package/src/editor/PictureCropper.tsx +0 -503
- package/src/editor/PictureEditor.tsx +0 -277
- package/src/editor/PictureEditorDialog.tsx +0 -381
- package/src/editor/PublishDialog.ignore +0 -74
- package/src/editor/ScrollingContentTree.tsx +0 -67
- package/src/editor/Terminal.tsx +0 -227
- package/src/editor/Titlebar.tsx +0 -104
- package/src/editor/ai/AiPopup.tsx +0 -59
- package/src/editor/ai/AiResponseMessage.tsx +0 -106
- package/src/editor/ai/AiTerminal.tsx +0 -503
- package/src/editor/ai/AiToolCall.tsx +0 -61
- package/src/editor/ai/EditorAiTerminal.tsx +0 -20
- package/src/editor/ai/GhostWriter.tsx +0 -432
- package/src/editor/ai/aiPageModel.ts +0 -108
- package/src/editor/ai/editorAiContext.ts +0 -18
- package/src/editor/client/AboutDialog.tsx +0 -44
- package/src/editor/client/EditorClient.tsx +0 -2241
- package/src/editor/client/GenericDialog.tsx +0 -50
- package/src/editor/client/editContext.ts +0 -416
- package/src/editor/client/helpers.ts +0 -44
- package/src/editor/client/itemsRepository.ts +0 -574
- package/src/editor/client/operations.ts +0 -768
- package/src/editor/client/pageModelBuilder.ts +0 -219
- package/src/editor/commands/commands.ts +0 -22
- package/src/editor/commands/componentCommands.tsx +0 -424
- package/src/editor/commands/createVersionCommand.ts +0 -33
- package/src/editor/commands/deleteVersionCommand.ts +0 -71
- package/src/editor/commands/itemCommands.tsx +0 -351
- package/src/editor/commands/localizeItem/LocalizeItemDialog.tsx +0 -201
- package/src/editor/commands/localizeItem/LocalizeItemUtils.ts +0 -27
- package/src/editor/commands/undo.ts +0 -39
- package/src/editor/component-designer/ComponentDesigner.tsx +0 -70
- package/src/editor/component-designer/ComponentDesignerAiTerminal.tsx +0 -11
- package/src/editor/component-designer/ComponentDesignerMenu.tsx +0 -91
- package/src/editor/component-designer/ComponentEditor.tsx +0 -97
- package/src/editor/component-designer/ComponentRenderingCodeEditor.tsx +0 -31
- package/src/editor/component-designer/ComponentRenderingEditor.tsx +0 -104
- package/src/editor/component-designer/ComponentsDropdown.tsx +0 -39
- package/src/editor/component-designer/PlaceholdersEditor.tsx +0 -179
- package/src/editor/component-designer/RenderingsDropdown.tsx +0 -36
- package/src/editor/component-designer/TemplateEditor.tsx +0 -236
- package/src/editor/component-designer/aiContext.ts +0 -23
- package/src/editor/componentTreeHelper.tsx +0 -116
- package/src/editor/context-menu/CopyMoveMenu.tsx +0 -103
- package/src/editor/context-menu/InsertMenu.tsx +0 -347
- package/src/editor/control-center/About.tsx +0 -342
- package/src/editor/control-center/ControlCenterMenu.tsx +0 -76
- package/src/editor/control-center/IndexOverview.tsx +0 -50
- package/src/editor/control-center/IndexSettings.tsx +0 -266
- package/src/editor/control-center/Info.tsx +0 -104
- package/src/editor/control-center/QuotaInfo.tsx +0 -301
- package/src/editor/control-center/Status.tsx +0 -113
- package/src/editor/control-center/WebSocketMessages.tsx +0 -155
- package/src/editor/editor-warnings/ItemLocked.tsx +0 -63
- package/src/editor/editor-warnings/NoLanguageWriteAccess.tsx +0 -22
- package/src/editor/editor-warnings/NoWorkflowWriteAccess.tsx +0 -23
- package/src/editor/editor-warnings/NoWriteAccess.tsx +0 -16
- package/src/editor/editor-warnings/ValidationErrors.tsx +0 -54
- package/src/editor/field-types/AttachmentEditor.tsx +0 -9
- package/src/editor/field-types/CheckboxEditor.tsx +0 -47
- package/src/editor/field-types/DropLinkEditor.tsx +0 -80
- package/src/editor/field-types/DropListEditor.tsx +0 -84
- package/src/editor/field-types/ImageFieldEditor.tsx +0 -65
- package/src/editor/field-types/InternalLinkFieldEditor.tsx +0 -117
- package/src/editor/field-types/LinkFieldEditor.tsx +0 -85
- package/src/editor/field-types/MultiLineText.tsx +0 -82
- package/src/editor/field-types/PictureFieldEditor.tsx +0 -121
- package/src/editor/field-types/RawEditor.tsx +0 -53
- package/src/editor/field-types/ReactQuill.tsx +0 -580
- package/src/editor/field-types/RichTextEditor.tsx +0 -22
- package/src/editor/field-types/RichTextEditorComponent.tsx +0 -127
- package/src/editor/field-types/SingleLineText.tsx +0 -174
- package/src/editor/field-types/TreeListEditor.tsx +0 -261
- package/src/editor/fieldTypes.ts +0 -140
- package/src/editor/media-selector/AiImageSearch.tsx +0 -185
- package/src/editor/media-selector/AiImageSearchPrompt.tsx +0 -94
- package/src/editor/media-selector/MediaSelector.tsx +0 -42
- package/src/editor/media-selector/Preview.tsx +0 -14
- package/src/editor/media-selector/Thumbnails.tsx +0 -48
- package/src/editor/media-selector/TreeSelector.tsx +0 -292
- package/src/editor/media-selector/UploadZone.tsx +0 -137
- package/src/editor/menubar/ActionsMenu.tsx +0 -94
- package/src/editor/menubar/ActiveUsers.tsx +0 -17
- package/src/editor/menubar/ApproveAndPublish.tsx +0 -18
- package/src/editor/menubar/BrowseHistory.tsx +0 -28
- package/src/editor/menubar/ItemLanguageVersion.tsx +0 -76
- package/src/editor/menubar/LanguageSelector.tsx +0 -226
- package/src/editor/menubar/Menu.tsx +0 -83
- package/src/editor/menubar/NavButtons.tsx +0 -74
- package/src/editor/menubar/PageSelector.tsx +0 -166
- package/src/editor/menubar/PageViewerControls.tsx +0 -120
- package/src/editor/menubar/PreviewSecondaryControls.tsx +0 -18
- package/src/editor/menubar/SecondaryControls.tsx +0 -45
- package/src/editor/menubar/Separator.tsx +0 -12
- package/src/editor/menubar/SiteInfo.tsx +0 -53
- package/src/editor/menubar/User.tsx +0 -27
- package/src/editor/menubar/VersionSelector.tsx +0 -142
- package/src/editor/page-editor-chrome/CommentHighlighting.tsx +0 -307
- package/src/editor/page-editor-chrome/CommentHighlightings.tsx +0 -35
- package/src/editor/page-editor-chrome/FieldActionIndicator.tsx +0 -59
- package/src/editor/page-editor-chrome/FieldActionIndicators.tsx +0 -23
- package/src/editor/page-editor-chrome/FieldEditedIndicator.tsx +0 -64
- package/src/editor/page-editor-chrome/FieldEditedIndicators.tsx +0 -35
- package/src/editor/page-editor-chrome/FrameMenu.tsx +0 -338
- package/src/editor/page-editor-chrome/FrameMenus.tsx +0 -48
- package/src/editor/page-editor-chrome/InlineEditor.tsx +0 -765
- package/src/editor/page-editor-chrome/LockedFieldIndicator.tsx +0 -61
- package/src/editor/page-editor-chrome/NoLayout.tsx +0 -36
- package/src/editor/page-editor-chrome/PageEditorChrome.tsx +0 -122
- package/src/editor/page-editor-chrome/PictureEditorOverlay.tsx +0 -161
- package/src/editor/page-editor-chrome/PlaceholderDropZone.tsx +0 -169
- package/src/editor/page-editor-chrome/PlaceholderDropZones.tsx +0 -315
- package/src/editor/page-editor-chrome/SuggestionHighlighting.tsx +0 -300
- package/src/editor/page-editor-chrome/SuggestionHighlightings.tsx +0 -40
- package/src/editor/page-editor-chrome/useInlineAICompletion.tsx +0 -791
- package/src/editor/page-viewer/DeviceToolbar.tsx +0 -70
- package/src/editor/page-viewer/EditorForm.tsx +0 -258
- package/src/editor/page-viewer/MiniMap.tsx +0 -362
- package/src/editor/page-viewer/PageViewer.tsx +0 -169
- package/src/editor/page-viewer/PageViewerFrame.tsx +0 -1022
- package/src/editor/page-viewer/pageModelSkeletonBuilder.ts +0 -412
- package/src/editor/page-viewer/pageViewContext.ts +0 -186
- package/src/editor/pageModel.ts +0 -220
- package/src/editor/picture-shared.tsx +0 -53
- package/src/editor/reviews/Comment.tsx +0 -307
- package/src/editor/reviews/Comments.tsx +0 -125
- package/src/editor/reviews/DiffView.tsx +0 -109
- package/src/editor/reviews/PreviewInfo.tsx +0 -35
- package/src/editor/reviews/Reviews.tsx +0 -280
- package/src/editor/reviews/SuggestedEdit.tsx +0 -316
- package/src/editor/reviews/reviewCommands.tsx +0 -47
- package/src/editor/reviews/useReviews.tsx +0 -70
- package/src/editor/services/aiService.ts +0 -174
- package/src/editor/services/componentDesignerService.ts +0 -151
- package/src/editor/services/contentService.ts +0 -180
- package/src/editor/services/editService.ts +0 -488
- package/src/editor/services/indexService.ts +0 -24
- package/src/editor/services/reviewsService.ts +0 -53
- package/src/editor/services/serviceHelper.ts +0 -95
- package/src/editor/services/suggestedEditsService.ts +0 -39
- package/src/editor/services/systemService.ts +0 -5
- package/src/editor/services/translationService.ts +0 -21
- package/src/editor/services-server/api.ts +0 -150
- package/src/editor/services-server/graphQL.ts +0 -106
- package/src/editor/sidebar/ComponentPalette.tsx +0 -161
- package/src/editor/sidebar/ComponentTree.tsx +0 -548
- package/src/editor/sidebar/ComponentTree2.tsxx +0 -490
- package/src/editor/sidebar/Debug.tsx +0 -111
- package/src/editor/sidebar/DictionaryEditor.tsx +0 -261
- package/src/editor/sidebar/EditHistory.tsx +0 -134
- package/src/editor/sidebar/GraphQL.tsx +0 -164
- package/src/editor/sidebar/Insert.tsx +0 -35
- package/src/editor/sidebar/MainContentTree.tsx +0 -102
- package/src/editor/sidebar/Performance.tsx +0 -53
- package/src/editor/sidebar/Sessions.tsx +0 -35
- package/src/editor/sidebar/Sidebar.tsx +0 -20
- package/src/editor/sidebar/SidebarView.tsx +0 -152
- package/src/editor/sidebar/Translations.tsx +0 -295
- package/src/editor/sidebar/Validation.tsx +0 -102
- package/src/editor/sidebar/ViewSelector.tsx +0 -60
- package/src/editor/sidebar/Workbox.tsx +0 -209
- package/src/editor/ui/CenteredMessage.tsx +0 -7
- package/src/editor/ui/CopyMoveTargetSelectorDialog.tsx +0 -81
- package/src/editor/ui/CopyToClipboardButton.tsx +0 -24
- package/src/editor/ui/DialogButtons.tsx +0 -11
- package/src/editor/ui/Icons.tsx +0 -709
- package/src/editor/ui/ItemList.tsx +0 -76
- package/src/editor/ui/ItemNameDialogNew.tsx +0 -118
- package/src/editor/ui/ItemSearch.tsx +0 -153
- package/src/editor/ui/PerfectTree.tsx +0 -571
- package/src/editor/ui/Section.tsx +0 -35
- package/src/editor/ui/SimpleIconButton.tsx +0 -54
- package/src/editor/ui/SimpleMenu.tsx +0 -40
- package/src/editor/ui/SimpleTable.tsx +0 -60
- package/src/editor/ui/SimpleTabs.tsx +0 -55
- package/src/editor/ui/SimpleToolbar.tsx +0 -7
- package/src/editor/ui/Spinner.tsx +0 -9
- package/src/editor/ui/Splitter.tsx +0 -314
- package/src/editor/ui/StackedPanels.tsx +0 -134
- package/src/editor/ui/Toolbar.tsx +0 -7
- package/src/editor/utils/id-helper.ts +0 -3
- package/src/editor/utils/insertOptions.ts +0 -69
- package/src/editor/utils/itemutils.ts +0 -29
- package/src/editor/utils/useMemoDebug.ts +0 -28
- package/src/editor/utils.ts +0 -486
- package/src/editor/views/CompareView.tsx +0 -245
- package/src/editor/views/EditView.tsx +0 -27
- package/src/editor/views/ItemEditor.tsx +0 -58
- package/src/editor/views/SingleEditView.tsx +0 -46
- package/src/fonts/Geist-Black.woff2 +0 -0
- package/src/fonts/Geist-Bold.woff2 +0 -0
- package/src/fonts/Geist-ExtraBold.woff2 +0 -0
- package/src/fonts/Geist-ExtraLight.woff2 +0 -0
- package/src/fonts/Geist-Light.woff2 +0 -0
- package/src/fonts/Geist-Medium.woff2 +0 -0
- package/src/fonts/Geist-Regular.woff2 +0 -0
- package/src/fonts/Geist-SemiBold.woff2 +0 -0
- package/src/fonts/Geist-Thin.woff2 +0 -0
- package/src/fonts/Geist[wght].woff2 +0 -0
- package/src/fonts/index.ts +0 -10
- package/src/index.ts +0 -23
- package/src/lib/safelist.tsx +0 -16
- package/src/lib/utils.ts +0 -6
- package/src/page-wizard/PageWizard.tsx +0 -139
- package/src/page-wizard/WizardBox.tsx +0 -4
- package/src/page-wizard/WizardBoxConnector.tsx +0 -56
- package/src/page-wizard/WizardSteps.tsx +0 -458
- package/src/page-wizard/service.ts +0 -35
- package/src/page-wizard/startPageWizardCommand.ts +0 -26
- package/src/page-wizard/steps/BuildPageStep.tsx +0 -259
- package/src/page-wizard/steps/CollectStep.tsx +0 -296
- package/src/page-wizard/steps/ComponentTypesSelector.tsx +0 -454
- package/src/page-wizard/steps/Components.tsx +0 -193
- package/src/page-wizard/steps/ContentStep.tsx +0 -890
- package/src/page-wizard/steps/EditButton.tsx +0 -34
- package/src/page-wizard/steps/FieldEditor.tsx +0 -102
- package/src/page-wizard/steps/Generate.tsx +0 -60
- package/src/page-wizard/steps/ImagesStep.tsx +0 -382
- package/src/page-wizard/steps/LayoutStep.tsx +0 -227
- package/src/page-wizard/steps/MetaDataStep.tsx +0 -173
- package/src/page-wizard/steps/SelectStep.tsx +0 -281
- package/src/page-wizard/steps/schema.ts +0 -180
- package/src/page-wizard/steps/usePageCreator.ts +0 -325
- package/src/page-wizard/usePageWizard.ts +0 -79
- package/src/revision.ts +0 -2
- package/src/splash-screen/NewPage.tsx +0 -294
- package/src/splash-screen/OpenPage.tsx +0 -113
- package/src/splash-screen/RecentPages.tsx +0 -123
- package/src/splash-screen/SectionHeadline.tsx +0 -21
- package/src/splash-screen/SplashScreen.tsx +0 -195
- package/src/tour/Tour.tsx +0 -566
- package/src/tour/default-tour.tsx +0 -301
- package/src/tour/preview-tour.tsx +0 -128
- package/src/types.ts +0 -335
- package/styles.css +0 -765
- package/tsconfig.build.json +0 -31
- package/tsconfig.json +0 -14
|
@@ -1,109 +0,0 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
import { diffWords, diffChars } from "diff";
|
|
3
|
-
|
|
4
|
-
interface DiffViewProps {
|
|
5
|
-
oldText: string;
|
|
6
|
-
newText: string;
|
|
7
|
-
/** If true, use a word-based diff; otherwise, use a character-based diff */
|
|
8
|
-
useWordDiff?: boolean;
|
|
9
|
-
/** If true, strip HTML and ignore formatting differences */
|
|
10
|
-
ignoreFormatting?: boolean;
|
|
11
|
-
/** If true, clip long unchanged segments */
|
|
12
|
-
clipUnchanged?: boolean;
|
|
13
|
-
/** Threshold length for unchanged segments before clipping */
|
|
14
|
-
clipThreshold?: number;
|
|
15
|
-
/** How many characters to show at the start and end of a clipped segment */
|
|
16
|
-
clipContext?: number;
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
function stripHtml(html: string): string {
|
|
20
|
-
const temp = document.createElement("div");
|
|
21
|
-
temp.innerHTML = html;
|
|
22
|
-
return temp.textContent || temp.innerText || "";
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
/**
|
|
26
|
-
* Clips a long string by preserving the first and last `contextChars` characters,
|
|
27
|
-
* inserting an ellipsis in between.
|
|
28
|
-
*/
|
|
29
|
-
function clipPartValue(value: string, contextChars: number): string {
|
|
30
|
-
const prefix = value.substring(0, contextChars);
|
|
31
|
-
const suffix = value.substring(value.length - contextChars);
|
|
32
|
-
return `${prefix}…${suffix}`;
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
export const DiffView: React.FC<DiffViewProps> = ({
|
|
36
|
-
oldText,
|
|
37
|
-
newText,
|
|
38
|
-
useWordDiff = true,
|
|
39
|
-
ignoreFormatting = false,
|
|
40
|
-
clipUnchanged = false,
|
|
41
|
-
clipThreshold = 50,
|
|
42
|
-
clipContext = 10,
|
|
43
|
-
}) => {
|
|
44
|
-
// Normalize text if styling should be ignored.
|
|
45
|
-
const normalizedOldText = ignoreFormatting ? stripHtml(oldText) : oldText;
|
|
46
|
-
const normalizedNewText = ignoreFormatting ? stripHtml(newText) : newText;
|
|
47
|
-
|
|
48
|
-
// Choose diffing algorithm.
|
|
49
|
-
const diff = useWordDiff
|
|
50
|
-
? diffWords(normalizedOldText, normalizedNewText)
|
|
51
|
-
: diffChars(normalizedOldText, normalizedNewText);
|
|
52
|
-
|
|
53
|
-
// Heuristic: if the diff results in just one removed and one added segment,
|
|
54
|
-
// assume a full replacement and show both values in full.
|
|
55
|
-
if (
|
|
56
|
-
diff.length === 2 &&
|
|
57
|
-
diff[0]?.removed &&
|
|
58
|
-
diff[1]?.added &&
|
|
59
|
-
diff[0]?.value.trim().length > 0 &&
|
|
60
|
-
diff[1]?.value.trim().length > 0
|
|
61
|
-
) {
|
|
62
|
-
return (
|
|
63
|
-
<div style={{ fontFamily: "monospace", fontSize: "14px" }}>
|
|
64
|
-
<div style={{ marginBottom: "0.5rem" }}>
|
|
65
|
-
<strong>Old:</strong>{" "}
|
|
66
|
-
<span style={{ color: "red", textDecoration: "line-through" }}>
|
|
67
|
-
{normalizedOldText}
|
|
68
|
-
</span>
|
|
69
|
-
</div>
|
|
70
|
-
<div>
|
|
71
|
-
<strong>New:</strong>{" "}
|
|
72
|
-
<span style={{ color: "green" }}>{normalizedNewText}</span>
|
|
73
|
-
</div>
|
|
74
|
-
</div>
|
|
75
|
-
);
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
return (
|
|
79
|
-
<div style={{ fontFamily: "monospace", fontSize: "14px" }}>
|
|
80
|
-
{diff.map((part, index) => {
|
|
81
|
-
let style: React.CSSProperties = {};
|
|
82
|
-
if (part.added) {
|
|
83
|
-
style = { color: "green" };
|
|
84
|
-
} else if (part.removed) {
|
|
85
|
-
style = { color: "red", textDecoration: "line-through" };
|
|
86
|
-
} else {
|
|
87
|
-
style = { color: "gray" };
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
// For unchanged segments, if clipping is enabled and the segment is too long,
|
|
91
|
-
// show part of it before and after an ellipsis.
|
|
92
|
-
let displayValue = part.value;
|
|
93
|
-
if (
|
|
94
|
-
!part.added &&
|
|
95
|
-
!part.removed &&
|
|
96
|
-
clipUnchanged &&
|
|
97
|
-
part.value.length > clipThreshold
|
|
98
|
-
) {
|
|
99
|
-
displayValue = clipPartValue(part.value, clipContext);
|
|
100
|
-
}
|
|
101
|
-
return (
|
|
102
|
-
<span key={index} style={style}>
|
|
103
|
-
{displayValue}
|
|
104
|
-
</span>
|
|
105
|
-
);
|
|
106
|
-
})}
|
|
107
|
-
</div>
|
|
108
|
-
);
|
|
109
|
-
};
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
import { useEditContext } from "../../client-components";
|
|
2
|
-
import { formatDate } from "../utils";
|
|
3
|
-
|
|
4
|
-
export function PreviewInfo() {
|
|
5
|
-
const editContext = useEditContext();
|
|
6
|
-
if (!editContext) return null;
|
|
7
|
-
const review = editContext.reviews.reviews.find(
|
|
8
|
-
(x) => x.reviewerEmail === editContext.user?.email
|
|
9
|
-
);
|
|
10
|
-
|
|
11
|
-
return (
|
|
12
|
-
<div className="flex gap-3 items-center">
|
|
13
|
-
<div className="text-white">
|
|
14
|
-
Welcome to your page <b>preview</b>, {editContext.user?.displayName}!
|
|
15
|
-
<div className="text-gray-300 text-xs">
|
|
16
|
-
{editContext.contentEditorItem?.path}{" "}
|
|
17
|
-
{editContext.contentEditorItem?.language}{" "}
|
|
18
|
-
{editContext.contentEditorItem?.version}
|
|
19
|
-
</div>
|
|
20
|
-
</div>
|
|
21
|
-
{review?.approvalDate && (
|
|
22
|
-
<i
|
|
23
|
-
className="pi pi-check text-green-400 text-2xl font-bold"
|
|
24
|
-
title={"Approved " + formatDate(new Date(review.approvalDate))}
|
|
25
|
-
></i>
|
|
26
|
-
)}
|
|
27
|
-
{review?.rejectedDate && (
|
|
28
|
-
<i
|
|
29
|
-
className="pi pi-times text-red-400 text-2xl font-bold"
|
|
30
|
-
title={"Rejected " + formatDate(new Date(review.rejectedDate))}
|
|
31
|
-
></i>
|
|
32
|
-
)}
|
|
33
|
-
</div>
|
|
34
|
-
);
|
|
35
|
-
}
|
|
@@ -1,280 +0,0 @@
|
|
|
1
|
-
import { SimpleToolbar } from "../ui/SimpleToolbar";
|
|
2
|
-
import { useEffect, useRef, useState } from "react";
|
|
3
|
-
import { SimpleTable } from "../ui/SimpleTable";
|
|
4
|
-
import { Reviewer } from "../../types";
|
|
5
|
-
import { Review } from "../../types";
|
|
6
|
-
import { inviteReviewer, addReview } from "../services/reviewsService";
|
|
7
|
-
import { useEditContext } from "../client/editContext";
|
|
8
|
-
import { Checkbox } from "primereact/checkbox";
|
|
9
|
-
import { formatDate } from "../utils";
|
|
10
|
-
import { InputText } from "primereact/inputtext";
|
|
11
|
-
import { OverlayPanel } from "primereact/overlaypanel";
|
|
12
|
-
import { SimpleIconButton } from "../ui/SimpleIconButton";
|
|
13
|
-
import { Button } from "primereact/button";
|
|
14
|
-
import uuid from "react-uuid";
|
|
15
|
-
|
|
16
|
-
type ReviewData = {
|
|
17
|
-
review: Review;
|
|
18
|
-
checked: boolean;
|
|
19
|
-
updating?: boolean;
|
|
20
|
-
error?: string;
|
|
21
|
-
};
|
|
22
|
-
|
|
23
|
-
export function Reviews() {
|
|
24
|
-
const [reviewData, setReviewData] = useState<ReviewData[]>([]);
|
|
25
|
-
const [newReviewer, setNewReviewer] = useState<Reviewer>({
|
|
26
|
-
email: "",
|
|
27
|
-
name: "",
|
|
28
|
-
});
|
|
29
|
-
const overlayPanelRef = useRef<OverlayPanel>(null);
|
|
30
|
-
|
|
31
|
-
const editContext = useEditContext();
|
|
32
|
-
|
|
33
|
-
const [showErrors, setShowErrors] = useState(false);
|
|
34
|
-
const [waiting, setWaiting] = useState(false);
|
|
35
|
-
|
|
36
|
-
useEffect(() => {
|
|
37
|
-
if (editContext?.reviews) {
|
|
38
|
-
setReviewData(
|
|
39
|
-
editContext.reviews.reviews.map((x) => ({
|
|
40
|
-
review: x,
|
|
41
|
-
checked: false,
|
|
42
|
-
}))
|
|
43
|
-
);
|
|
44
|
-
}
|
|
45
|
-
}, [editContext?.reviews]);
|
|
46
|
-
|
|
47
|
-
// Simple email validation function
|
|
48
|
-
const isValidEmail = (email: string): boolean => {
|
|
49
|
-
// This regular expression is not perfect but works for basic validation
|
|
50
|
-
const emailRegex = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
|
|
51
|
-
return emailRegex.test(email);
|
|
52
|
-
};
|
|
53
|
-
|
|
54
|
-
const emailAlreadyExists = (email: string): boolean => {
|
|
55
|
-
return reviewData.some((x) => x.review?.reviewerEmail === email);
|
|
56
|
-
};
|
|
57
|
-
|
|
58
|
-
const getStatus = (reviewData?: ReviewData) => {
|
|
59
|
-
if (reviewData?.updating) {
|
|
60
|
-
return <i className="pi pi-spinner pi-spin" />;
|
|
61
|
-
}
|
|
62
|
-
if (reviewData?.error) {
|
|
63
|
-
return (
|
|
64
|
-
<div className="flex items-center gap-1">
|
|
65
|
-
<i className="pi pi-times text-red-500 " /> {reviewData.error}
|
|
66
|
-
</div>
|
|
67
|
-
);
|
|
68
|
-
}
|
|
69
|
-
const review = reviewData?.review;
|
|
70
|
-
|
|
71
|
-
if (review) {
|
|
72
|
-
if (review.approvalDate) {
|
|
73
|
-
return (
|
|
74
|
-
<div className="flex flex-row gap-1">
|
|
75
|
-
<i className="pi pi-check text-green-500 " />
|
|
76
|
-
Approved {formatDate(new Date(review.approvalDate))}
|
|
77
|
-
</div>
|
|
78
|
-
);
|
|
79
|
-
}
|
|
80
|
-
if (review.rejectedDate) {
|
|
81
|
-
return (
|
|
82
|
-
<div className="flex flex-row gap-1">
|
|
83
|
-
<i className="pi pi-times text-red-500 " />
|
|
84
|
-
Rejected {formatDate(new Date(review.rejectedDate))}
|
|
85
|
-
</div>
|
|
86
|
-
);
|
|
87
|
-
}
|
|
88
|
-
if (review.invitationSentDate) {
|
|
89
|
-
return (
|
|
90
|
-
"Invitation Sent " + formatDate(new Date(review.invitationSentDate))
|
|
91
|
-
);
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
|
-
return "Not yet invited";
|
|
95
|
-
};
|
|
96
|
-
|
|
97
|
-
const sendInvitations = () => {
|
|
98
|
-
setShowErrors(true);
|
|
99
|
-
const invalidReviewers = reviewData.filter(
|
|
100
|
-
(x) =>
|
|
101
|
-
x.checked &&
|
|
102
|
-
(!x.review?.reviewerEmail || !isValidEmail(x.review?.reviewerEmail))
|
|
103
|
-
);
|
|
104
|
-
if (invalidReviewers.length > 0) {
|
|
105
|
-
return;
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
reviewData.forEach(async (x) => {
|
|
109
|
-
if (!editContext?.currentItemDescriptor) return;
|
|
110
|
-
if (x.checked) {
|
|
111
|
-
x.updating = true;
|
|
112
|
-
setReviewData([...reviewData]);
|
|
113
|
-
const result = await inviteReviewer(x.review);
|
|
114
|
-
if (result.response.status !== 200) {
|
|
115
|
-
x.error = "Error inviting reviewer";
|
|
116
|
-
}
|
|
117
|
-
x.updating = false;
|
|
118
|
-
x.updating = false;
|
|
119
|
-
setReviewData([...reviewData]);
|
|
120
|
-
}
|
|
121
|
-
});
|
|
122
|
-
};
|
|
123
|
-
|
|
124
|
-
return (
|
|
125
|
-
<div className="flex flex-col h-full">
|
|
126
|
-
<SimpleToolbar>
|
|
127
|
-
<SimpleIconButton
|
|
128
|
-
label="Add Reviewer"
|
|
129
|
-
icon="pi pi-plus"
|
|
130
|
-
onClick={(x) => {
|
|
131
|
-
overlayPanelRef.current?.toggle(x);
|
|
132
|
-
setTimeout(() => {
|
|
133
|
-
document.getElementById("name")?.focus();
|
|
134
|
-
}, 100);
|
|
135
|
-
}}
|
|
136
|
-
/>
|
|
137
|
-
<SimpleIconButton
|
|
138
|
-
label="Send Invitations"
|
|
139
|
-
icon="pi pi-send"
|
|
140
|
-
disabled={!reviewData.some((x) => x.checked)}
|
|
141
|
-
onClick={sendInvitations}
|
|
142
|
-
/>
|
|
143
|
-
</SimpleToolbar>
|
|
144
|
-
<OverlayPanel ref={overlayPanelRef}>
|
|
145
|
-
<div className="p-2 text-xs flex flex-col gap-2">
|
|
146
|
-
<div className="flex flex-col gap-2">
|
|
147
|
-
<label htmlFor="name">Name</label>
|
|
148
|
-
|
|
149
|
-
<InputText
|
|
150
|
-
id="name"
|
|
151
|
-
className="w-full"
|
|
152
|
-
value={newReviewer?.name}
|
|
153
|
-
onChange={(e) => {
|
|
154
|
-
setNewReviewer((x) => ({
|
|
155
|
-
...x!,
|
|
156
|
-
name: e.target.value,
|
|
157
|
-
}));
|
|
158
|
-
}}
|
|
159
|
-
autoFocus
|
|
160
|
-
/>
|
|
161
|
-
{showErrors && !newReviewer?.name && (
|
|
162
|
-
<small style={{ color: "red" }}>Name is required</small>
|
|
163
|
-
)}
|
|
164
|
-
<div className="flex flex-col gap-2">
|
|
165
|
-
<label htmlFor="email">Email</label>
|
|
166
|
-
<InputText
|
|
167
|
-
id="email"
|
|
168
|
-
className="w-full"
|
|
169
|
-
value={newReviewer?.email}
|
|
170
|
-
onChange={(e) => {
|
|
171
|
-
setNewReviewer((x) => ({
|
|
172
|
-
...x!,
|
|
173
|
-
email: e.target.value,
|
|
174
|
-
}));
|
|
175
|
-
}}
|
|
176
|
-
/>
|
|
177
|
-
{showErrors && !isValidEmail(newReviewer.email) && (
|
|
178
|
-
<small style={{ color: "red" }}>
|
|
179
|
-
Not a valid email address
|
|
180
|
-
</small>
|
|
181
|
-
)}
|
|
182
|
-
{showErrors && emailAlreadyExists(newReviewer.email) && (
|
|
183
|
-
<small style={{ color: "red" }}>Email already exists</small>
|
|
184
|
-
)}
|
|
185
|
-
</div>
|
|
186
|
-
|
|
187
|
-
<Button
|
|
188
|
-
label="Add Reviewer"
|
|
189
|
-
disabled={waiting}
|
|
190
|
-
icon="pi pi-plus"
|
|
191
|
-
onClick={async () => {
|
|
192
|
-
if (!editContext?.contentEditorItem) return;
|
|
193
|
-
setShowErrors(true);
|
|
194
|
-
if (emailAlreadyExists(newReviewer.email)) {
|
|
195
|
-
return;
|
|
196
|
-
}
|
|
197
|
-
if (!isValidEmail(newReviewer.email) || !newReviewer.name) {
|
|
198
|
-
return;
|
|
199
|
-
}
|
|
200
|
-
setWaiting(true);
|
|
201
|
-
await addReview({
|
|
202
|
-
id: uuid(),
|
|
203
|
-
reviewerName: newReviewer!.name,
|
|
204
|
-
reviewerEmail: newReviewer!.email,
|
|
205
|
-
itemId: editContext.contentEditorItem.id,
|
|
206
|
-
language: editContext.contentEditorItem.language,
|
|
207
|
-
version: editContext.contentEditorItem.version,
|
|
208
|
-
});
|
|
209
|
-
|
|
210
|
-
editContext.reviews.loadReviews();
|
|
211
|
-
overlayPanelRef.current?.hide();
|
|
212
|
-
setNewReviewer({
|
|
213
|
-
email: "",
|
|
214
|
-
name: "",
|
|
215
|
-
});
|
|
216
|
-
|
|
217
|
-
setWaiting(false);
|
|
218
|
-
}}
|
|
219
|
-
/>
|
|
220
|
-
</div>
|
|
221
|
-
</div>
|
|
222
|
-
</OverlayPanel>
|
|
223
|
-
<div className="flex-1 relative">
|
|
224
|
-
<div className="absolute inset-0 overflow-auto">
|
|
225
|
-
<SimpleTable
|
|
226
|
-
columns={[
|
|
227
|
-
{
|
|
228
|
-
header: (
|
|
229
|
-
<Checkbox
|
|
230
|
-
checked={reviewData.every((x) => x.checked)}
|
|
231
|
-
onChange={(e) => {
|
|
232
|
-
setReviewData((reviews) =>
|
|
233
|
-
reviews.map((x) => ({
|
|
234
|
-
...x,
|
|
235
|
-
checked: e.checked ?? false,
|
|
236
|
-
}))
|
|
237
|
-
);
|
|
238
|
-
}}
|
|
239
|
-
/>
|
|
240
|
-
),
|
|
241
|
-
body: (x) => (
|
|
242
|
-
<Checkbox
|
|
243
|
-
checked={x.checked}
|
|
244
|
-
onChange={(e) => {
|
|
245
|
-
setReviewData((reviews) => {
|
|
246
|
-
// It’s safer to update by index or assign an id to each reviewer.
|
|
247
|
-
// For brevity, we’re using the email to locate the reviewer.
|
|
248
|
-
const index = reviews.findIndex(
|
|
249
|
-
(y) =>
|
|
250
|
-
y.review?.reviewerEmail === x.review?.reviewerEmail
|
|
251
|
-
);
|
|
252
|
-
if (index !== -1) {
|
|
253
|
-
reviews[index]!.checked = e.checked ?? false;
|
|
254
|
-
}
|
|
255
|
-
return [...reviews];
|
|
256
|
-
});
|
|
257
|
-
}}
|
|
258
|
-
/>
|
|
259
|
-
),
|
|
260
|
-
},
|
|
261
|
-
{
|
|
262
|
-
header: "Name",
|
|
263
|
-
body: (x) => x.review?.reviewerName,
|
|
264
|
-
},
|
|
265
|
-
{
|
|
266
|
-
header: "Email",
|
|
267
|
-
body: (x) => x.review?.reviewerEmail,
|
|
268
|
-
},
|
|
269
|
-
{
|
|
270
|
-
header: "Status",
|
|
271
|
-
body: (z) => getStatus(z),
|
|
272
|
-
},
|
|
273
|
-
]}
|
|
274
|
-
items={reviewData}
|
|
275
|
-
/>
|
|
276
|
-
</div>
|
|
277
|
-
</div>
|
|
278
|
-
</div>
|
|
279
|
-
);
|
|
280
|
-
}
|