@alpaca-editor/core 1.0.3939 → 1.0.3941
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,307 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
useEditContext,
|
|
3
|
-
useModifiedFieldsContext,
|
|
4
|
-
} from "../client/editContext";
|
|
5
|
-
import { findComponentRect, findFieldElement } from "../utils";
|
|
6
|
-
import { Comment } from "../../types";
|
|
7
|
-
import { useState } from "react";
|
|
8
|
-
import { useEffect } from "react";
|
|
9
|
-
import { classNames } from "primereact/utils";
|
|
10
|
-
import { CommentIcon } from "../ui/Icons";
|
|
11
|
-
import { getComponentById } from "../componentTreeHelper";
|
|
12
|
-
|
|
13
|
-
export function CommentHighlighting({
|
|
14
|
-
comment,
|
|
15
|
-
scale,
|
|
16
|
-
iframe,
|
|
17
|
-
}: {
|
|
18
|
-
comment: Comment;
|
|
19
|
-
scale: number;
|
|
20
|
-
iframe: HTMLIFrameElement;
|
|
21
|
-
}) {
|
|
22
|
-
const editContext = useEditContext();
|
|
23
|
-
const modifiedFields = useModifiedFieldsContext();
|
|
24
|
-
|
|
25
|
-
const [range, setRange] = useState<number[]>([
|
|
26
|
-
comment.rangeStart || 0,
|
|
27
|
-
comment.rangeEnd || 0,
|
|
28
|
-
]);
|
|
29
|
-
|
|
30
|
-
useEffect(() => {
|
|
31
|
-
const findRange = async () => {
|
|
32
|
-
if (!editContext) return;
|
|
33
|
-
if (
|
|
34
|
-
comment.fieldValue &&
|
|
35
|
-
comment.fieldId &&
|
|
36
|
-
comment.rangeStart !== undefined &&
|
|
37
|
-
comment.rangeEnd !== undefined
|
|
38
|
-
) {
|
|
39
|
-
const field = await editContext.itemsRepository.getField({
|
|
40
|
-
item: {
|
|
41
|
-
id: comment.itemId,
|
|
42
|
-
language: comment.language,
|
|
43
|
-
version: comment.version,
|
|
44
|
-
},
|
|
45
|
-
fieldId: comment.fieldId,
|
|
46
|
-
});
|
|
47
|
-
|
|
48
|
-
const modifiedField = modifiedFields?.modifiedFields.find(
|
|
49
|
-
(x) =>
|
|
50
|
-
x.fieldId === field?.id &&
|
|
51
|
-
x.item.id === comment.itemId &&
|
|
52
|
-
x.item.language === comment.language &&
|
|
53
|
-
x.item.version === comment.version,
|
|
54
|
-
);
|
|
55
|
-
|
|
56
|
-
const mapping = computeMapping(
|
|
57
|
-
modifiedField?.value || field?.rawValue || "",
|
|
58
|
-
comment.fieldValue,
|
|
59
|
-
);
|
|
60
|
-
|
|
61
|
-
const mappedRange = [
|
|
62
|
-
mapping[comment.rangeStart],
|
|
63
|
-
mapping[comment.rangeEnd],
|
|
64
|
-
];
|
|
65
|
-
|
|
66
|
-
if (mappedRange[0] !== undefined && mappedRange[1] !== undefined) {
|
|
67
|
-
setRange(mappedRange as number[]);
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
};
|
|
71
|
-
|
|
72
|
-
findRange();
|
|
73
|
-
}, [comment.fieldValue, modifiedFields?.modifiedFields]);
|
|
74
|
-
|
|
75
|
-
if (!editContext) return null;
|
|
76
|
-
|
|
77
|
-
const fieldElement = comment.fieldId
|
|
78
|
-
? findFieldElement(iframe, {
|
|
79
|
-
item: {
|
|
80
|
-
id: comment.itemId,
|
|
81
|
-
language: comment.language,
|
|
82
|
-
version: comment.version,
|
|
83
|
-
},
|
|
84
|
-
fieldId: comment.fieldId,
|
|
85
|
-
})
|
|
86
|
-
: undefined;
|
|
87
|
-
|
|
88
|
-
let rects: DOMRectList | null = null;
|
|
89
|
-
let isTextRange = false;
|
|
90
|
-
|
|
91
|
-
if (fieldElement && range[0] !== undefined && range[1] !== undefined) {
|
|
92
|
-
const startData = getTextNodeAtOffset(fieldElement, range[0]);
|
|
93
|
-
const endData = getTextNodeAtOffset(fieldElement, range[1]);
|
|
94
|
-
|
|
95
|
-
if (startData && endData) {
|
|
96
|
-
const textRange = document.createRange();
|
|
97
|
-
textRange.setStart(startData.node, startData.offset);
|
|
98
|
-
textRange.setEnd(endData.node, endData.offset);
|
|
99
|
-
rects = textRange.getClientRects();
|
|
100
|
-
isTextRange = true;
|
|
101
|
-
}
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
if (!rects || rects.length === 0) {
|
|
105
|
-
let fallbackElement = fieldElement;
|
|
106
|
-
if (
|
|
107
|
-
!fallbackElement &&
|
|
108
|
-
comment.itemId &&
|
|
109
|
-
editContext.page &&
|
|
110
|
-
iframe.contentWindow?.document.body
|
|
111
|
-
) {
|
|
112
|
-
const componentStart = iframe.contentWindow?.document.body.querySelector(
|
|
113
|
-
"[data-component-start='" + comment.itemId + "']",
|
|
114
|
-
);
|
|
115
|
-
|
|
116
|
-
fallbackElement = componentStart?.nextElementSibling;
|
|
117
|
-
while (fallbackElement && fallbackElement.tagName === "SCRIPT") {
|
|
118
|
-
fallbackElement = fallbackElement.nextElementSibling;
|
|
119
|
-
}
|
|
120
|
-
}
|
|
121
|
-
if (!fallbackElement) return null;
|
|
122
|
-
const fallbackRect = fallbackElement.getBoundingClientRect();
|
|
123
|
-
if (!fallbackRect) return null;
|
|
124
|
-
rects = {
|
|
125
|
-
length: 1,
|
|
126
|
-
0: fallbackRect,
|
|
127
|
-
item: (index: number) => (index === 0 ? fallbackRect : null),
|
|
128
|
-
[Symbol.iterator]: function* () {
|
|
129
|
-
yield fallbackRect;
|
|
130
|
-
},
|
|
131
|
-
} as DOMRectList;
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
const iframeRect = iframe.getBoundingClientRect();
|
|
135
|
-
|
|
136
|
-
return (
|
|
137
|
-
<>
|
|
138
|
-
{Array.from(rects).map((rect, index) => (
|
|
139
|
-
<div
|
|
140
|
-
key={index}
|
|
141
|
-
style={{
|
|
142
|
-
position: "absolute",
|
|
143
|
-
top: rect.top * scale,
|
|
144
|
-
left: rect.left * scale,
|
|
145
|
-
width: rect.width * scale,
|
|
146
|
-
height: rect.height * scale,
|
|
147
|
-
pointerEvents: "none",
|
|
148
|
-
}}
|
|
149
|
-
>
|
|
150
|
-
{index === 0 && (
|
|
151
|
-
<div
|
|
152
|
-
className={classNames(
|
|
153
|
-
"pointer-events-auto absolute h-5 w-5 cursor-pointer",
|
|
154
|
-
rect.top * scale < 18 ? "top-0" : "top-[-18px]",
|
|
155
|
-
(rect.left + rect.width) * scale > iframeRect.width - 18
|
|
156
|
-
? "right-0"
|
|
157
|
-
: "right-[-18px]",
|
|
158
|
-
)}
|
|
159
|
-
onClick={() => {
|
|
160
|
-
editContext.switchView("reviews");
|
|
161
|
-
editContext?.select([comment.itemId]);
|
|
162
|
-
editContext?.setSelectedComment(comment);
|
|
163
|
-
}}
|
|
164
|
-
>
|
|
165
|
-
<CommentIcon className="text-blue-500 hover:text-blue-600" />
|
|
166
|
-
</div>
|
|
167
|
-
)}
|
|
168
|
-
{isTextRange && (
|
|
169
|
-
<div
|
|
170
|
-
className="opacity-45"
|
|
171
|
-
style={{
|
|
172
|
-
width: "100%",
|
|
173
|
-
height: "100%",
|
|
174
|
-
backgroundColor: comment.isResolved
|
|
175
|
-
? "rgba(0, 255, 0, 0.45)"
|
|
176
|
-
: "rgba(255, 0, 0, 0.45)",
|
|
177
|
-
}}
|
|
178
|
-
></div>
|
|
179
|
-
)}
|
|
180
|
-
</div>
|
|
181
|
-
))}
|
|
182
|
-
</>
|
|
183
|
-
);
|
|
184
|
-
}
|
|
185
|
-
|
|
186
|
-
function getTextNodeAtOffset(
|
|
187
|
-
root: Node,
|
|
188
|
-
|
|
189
|
-
offset: number,
|
|
190
|
-
): { node: Text; offset: number } | null {
|
|
191
|
-
const walker = document.createTreeWalker(root, NodeFilter.SHOW_TEXT, null);
|
|
192
|
-
let currentNode: Text | null;
|
|
193
|
-
while ((currentNode = walker.nextNode() as Text | null)) {
|
|
194
|
-
const nodeLength = currentNode.textContent?.length || 0;
|
|
195
|
-
if (offset <= nodeLength) {
|
|
196
|
-
return { node: currentNode, offset };
|
|
197
|
-
}
|
|
198
|
-
offset -= nodeLength;
|
|
199
|
-
}
|
|
200
|
-
return null;
|
|
201
|
-
}
|
|
202
|
-
|
|
203
|
-
/**
|
|
204
|
-
* Erzeugt ein Mapping von Positionen im modifizierten String s2 auf die entsprechenden Positionen in s1,
|
|
205
|
-
* basierend auf einer minimalen Edit-Sequenz (Levenshtein-Distance).
|
|
206
|
-
*
|
|
207
|
-
* @param s1 Originalstring
|
|
208
|
-
* @param s2 Modifizierter String
|
|
209
|
-
* @returns Ein Array, in dem mapping[j] die Position in s1 angibt, die erreicht wird, nachdem das j-te Zeichen in s2 erzeugt wurde.
|
|
210
|
-
*/
|
|
211
|
-
function computeMapping(s1: string, s2: string): number[] {
|
|
212
|
-
const n = s1.length;
|
|
213
|
-
const m = s2.length;
|
|
214
|
-
|
|
215
|
-
// 1. Aufbau der DP-Matrix und Backpointer-Matrix
|
|
216
|
-
// dp[i][j] enthält die minimale Anzahl von Operationen, um s1[0..i-1] in s2[0..j-1] zu überführen.
|
|
217
|
-
const dp: number[][] = Array.from({ length: n + 1 }, () =>
|
|
218
|
-
new Array(m + 1).fill(0),
|
|
219
|
-
);
|
|
220
|
-
const back: string[][] = Array.from({ length: n + 1 }, () =>
|
|
221
|
-
new Array(m + 1).fill(""),
|
|
222
|
-
);
|
|
223
|
-
|
|
224
|
-
// Initialisierung: leere Präfixe
|
|
225
|
-
for (let i = 0; i <= n; i++) {
|
|
226
|
-
dp[i]![0] = i;
|
|
227
|
-
if (i > 0) {
|
|
228
|
-
back[i]![0] = "D"; // "Deletion": Zeichen aus s1 wird gelöscht.
|
|
229
|
-
}
|
|
230
|
-
}
|
|
231
|
-
for (let j = 0; j <= m; j++) {
|
|
232
|
-
dp[0]![j] = j;
|
|
233
|
-
if (j > 0) {
|
|
234
|
-
back[0]![j] = "I"; // "Insertion": Zeichen in s2 wurde eingefügt.
|
|
235
|
-
}
|
|
236
|
-
}
|
|
237
|
-
|
|
238
|
-
// Füllen der DP-Matrix (Wagner–Fischer-Algorithmus)
|
|
239
|
-
for (let i = 1; i <= n; i++) {
|
|
240
|
-
for (let j = 1; j <= m; j++) {
|
|
241
|
-
const cost = s1[i - 1] === s2[j - 1] ? 0 : 1;
|
|
242
|
-
|
|
243
|
-
// Drei Möglichkeiten:
|
|
244
|
-
const deletion = dp[i - 1]![j]! + 1;
|
|
245
|
-
const insertion = dp[i]![j - 1]! + 1;
|
|
246
|
-
const substitution = dp[i - 1]![j - 1]! + cost; // "M" (Match) wenn cost==0, sonst "S" (Substitution)
|
|
247
|
-
|
|
248
|
-
// Feste Tie-Breaking Reihenfolge: zuerst Deletion, dann Insertion, dann Substitution.
|
|
249
|
-
let bestVal = deletion;
|
|
250
|
-
let op = "D";
|
|
251
|
-
if (insertion < bestVal) {
|
|
252
|
-
bestVal = insertion;
|
|
253
|
-
op = "I";
|
|
254
|
-
}
|
|
255
|
-
if (substitution < bestVal) {
|
|
256
|
-
bestVal = substitution;
|
|
257
|
-
op = cost === 0 ? "M" : "S";
|
|
258
|
-
}
|
|
259
|
-
|
|
260
|
-
dp[i]![j] = bestVal;
|
|
261
|
-
back[i]![j] = op;
|
|
262
|
-
}
|
|
263
|
-
}
|
|
264
|
-
|
|
265
|
-
// 2. Rekonstruktion des Edit-Skripts per Backtracking
|
|
266
|
-
const ops: string[] = [];
|
|
267
|
-
let i = n;
|
|
268
|
-
let j = m;
|
|
269
|
-
while (i > 0 || j > 0) {
|
|
270
|
-
const op = back[i]![j]!;
|
|
271
|
-
ops.push(op);
|
|
272
|
-
if (op === "M" || op === "S") {
|
|
273
|
-
i--;
|
|
274
|
-
j--;
|
|
275
|
-
} else if (op === "D") {
|
|
276
|
-
i--;
|
|
277
|
-
} else if (op === "I") {
|
|
278
|
-
j--;
|
|
279
|
-
}
|
|
280
|
-
}
|
|
281
|
-
ops.reverse(); // Jetzt liegen die Operationen in der Vorwärtsreihenfolge vor.
|
|
282
|
-
|
|
283
|
-
// 3. Simulation der Transformation von s1 zu s2 und Aufbau des Mappings.
|
|
284
|
-
// mapping[j] soll die Position in s1 angeben, nachdem das j-te Zeichen in s2 erzeugt wurde.
|
|
285
|
-
const mapping: number[] = new Array(m + 1);
|
|
286
|
-
let iPos = 0; // Aktuelle Position in s1
|
|
287
|
-
let jPos = 0; // Aktuelle Position in s2
|
|
288
|
-
mapping[jPos] = iPos; // Vor jeglicher Transformation
|
|
289
|
-
|
|
290
|
-
for (const op of ops) {
|
|
291
|
-
if (op === "M" || op === "S") {
|
|
292
|
-
// Bei Match oder Substitution wird in beiden Strings ein Zeichen verarbeitet.
|
|
293
|
-
iPos++;
|
|
294
|
-
jPos++;
|
|
295
|
-
mapping[jPos] = iPos;
|
|
296
|
-
} else if (op === "I") {
|
|
297
|
-
// Bei Insertion wird in s2 ein Zeichen eingefügt, s1 bleibt unverändert.
|
|
298
|
-
jPos++;
|
|
299
|
-
mapping[jPos] = iPos;
|
|
300
|
-
} else if (op === "D") {
|
|
301
|
-
// Bei Deletion wird in s1 ein Zeichen übersprungen.
|
|
302
|
-
iPos++;
|
|
303
|
-
}
|
|
304
|
-
}
|
|
305
|
-
|
|
306
|
-
return mapping;
|
|
307
|
-
}
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
import { useEffect, useState } from "react";
|
|
2
|
-
import { useEditContext } from "../client/editContext";
|
|
3
|
-
import { CommentHighlighting } from "./CommentHighlighting";
|
|
4
|
-
|
|
5
|
-
import { Comment } from "../../types";
|
|
6
|
-
|
|
7
|
-
export function CommentHighlightings({
|
|
8
|
-
scale,
|
|
9
|
-
iframe,
|
|
10
|
-
}: {
|
|
11
|
-
scale: number;
|
|
12
|
-
iframe: HTMLIFrameElement;
|
|
13
|
-
}) {
|
|
14
|
-
const editContext = useEditContext();
|
|
15
|
-
const [comments, setComments] = useState<Comment[]>([]);
|
|
16
|
-
|
|
17
|
-
useEffect(() => {
|
|
18
|
-
setComments(editContext?.comments || []);
|
|
19
|
-
}, [editContext?.comments, editContext?.suggestedEdits]);
|
|
20
|
-
|
|
21
|
-
return (
|
|
22
|
-
<>
|
|
23
|
-
{comments
|
|
24
|
-
.filter((x) => !x.isResolved)
|
|
25
|
-
.map((comment) => (
|
|
26
|
-
<CommentHighlighting
|
|
27
|
-
iframe={iframe}
|
|
28
|
-
scale={scale}
|
|
29
|
-
key={comment.id}
|
|
30
|
-
comment={comment}
|
|
31
|
-
/>
|
|
32
|
-
))}
|
|
33
|
-
</>
|
|
34
|
-
);
|
|
35
|
-
}
|
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
import { ProgressSpinner } from "primereact/progressspinner";
|
|
2
|
-
import { FieldAction } from "../client/EditorClient";
|
|
3
|
-
import { useEditContext } from "../client/editContext";
|
|
4
|
-
|
|
5
|
-
export function FieldActionIndicator({ action }: { action: FieldAction }) {
|
|
6
|
-
const editContext = useEditContext();
|
|
7
|
-
if (!editContext) return null;
|
|
8
|
-
|
|
9
|
-
const pageViewContext = editContext.pageView;
|
|
10
|
-
const field = action.field;
|
|
11
|
-
const fieldElements =
|
|
12
|
-
pageViewContext.editorIframeRef.current?.contentWindow?.document.querySelectorAll(
|
|
13
|
-
`[data-fieldid="${field.fieldId}"][data-itemid="${field.item.id}"][data-language="${field.item.language}"][data-version="${field.item.version}"]`,
|
|
14
|
-
);
|
|
15
|
-
|
|
16
|
-
if (!fieldElements) return null;
|
|
17
|
-
return (
|
|
18
|
-
<>
|
|
19
|
-
{[...fieldElements].map((element, index) => (
|
|
20
|
-
<SingleIndicator
|
|
21
|
-
element={element}
|
|
22
|
-
key={action.field.fieldId + action.field + index}
|
|
23
|
-
action={action}
|
|
24
|
-
/>
|
|
25
|
-
))}
|
|
26
|
-
</>
|
|
27
|
-
);
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
function SingleIndicator({
|
|
31
|
-
element,
|
|
32
|
-
action,
|
|
33
|
-
}: {
|
|
34
|
-
element: Element;
|
|
35
|
-
action: FieldAction;
|
|
36
|
-
}) {
|
|
37
|
-
const rect = element.getBoundingClientRect();
|
|
38
|
-
const indicatorRect = rect;
|
|
39
|
-
return (
|
|
40
|
-
<div
|
|
41
|
-
className={`focus-shadow executing-action bg-theme-secondary/20 pointer-events-none absolute flex items-center justify-center`}
|
|
42
|
-
style={{
|
|
43
|
-
left: indicatorRect.x,
|
|
44
|
-
top: indicatorRect.y,
|
|
45
|
-
width: indicatorRect.width,
|
|
46
|
-
height: indicatorRect.height,
|
|
47
|
-
zIndex: 800,
|
|
48
|
-
}}
|
|
49
|
-
>
|
|
50
|
-
<div className="text-theme-secondary rounded-mdp-3 bg-theme-secondary-light border-theme-secondary text-3xs flex flex-col items-center justify-center gap-1.5 rounded border p-1 font-bold">
|
|
51
|
-
<div className="flex items-center gap-1">
|
|
52
|
-
<ProgressSpinner style={{ width: "1rem", height: "1rem" }} />
|
|
53
|
-
{action.label}
|
|
54
|
-
</div>
|
|
55
|
-
{action.message && <div className="text-3xs">{action.message}</div>}
|
|
56
|
-
</div>
|
|
57
|
-
</div>
|
|
58
|
-
);
|
|
59
|
-
}
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import { FieldActionIndicator } from "./FieldActionIndicator";
|
|
2
|
-
import { useEditContext } from "../client/editContext";
|
|
3
|
-
|
|
4
|
-
export function FieldActionsIndicators() {
|
|
5
|
-
const editContext = useEditContext();
|
|
6
|
-
|
|
7
|
-
if (!editContext) return null;
|
|
8
|
-
|
|
9
|
-
const actions = editContext.activeFieldActions;
|
|
10
|
-
|
|
11
|
-
return (
|
|
12
|
-
<>
|
|
13
|
-
{actions
|
|
14
|
-
.filter((x) => x.state === "running")
|
|
15
|
-
.map((action) => (
|
|
16
|
-
<FieldActionIndicator
|
|
17
|
-
action={action}
|
|
18
|
-
key={action.field.fieldId + action.field.item.id}
|
|
19
|
-
/>
|
|
20
|
-
))}
|
|
21
|
-
</>
|
|
22
|
-
);
|
|
23
|
-
}
|
|
@@ -1,64 +0,0 @@
|
|
|
1
|
-
import { EditedField, useEditContext } from "../client/editContext";
|
|
2
|
-
import { PageViewContext } from "../page-viewer/pageViewContext";
|
|
3
|
-
|
|
4
|
-
export function FieldEditedIndicator({
|
|
5
|
-
field,
|
|
6
|
-
scale,
|
|
7
|
-
pageViewContext,
|
|
8
|
-
scroll,
|
|
9
|
-
}: {
|
|
10
|
-
field: EditedField;
|
|
11
|
-
scale?: number;
|
|
12
|
-
pageViewContext: PageViewContext;
|
|
13
|
-
scroll?: number;
|
|
14
|
-
}) {
|
|
15
|
-
const editContext = useEditContext();
|
|
16
|
-
if (!editContext) return null;
|
|
17
|
-
|
|
18
|
-
const fieldElements =
|
|
19
|
-
pageViewContext.editorIframeRef.current?.contentWindow?.document.querySelectorAll(
|
|
20
|
-
`[data-fieldid="${field.fieldId}"][data-itemid="${field.item.id}"][data-language="${field.item.language}"][data-version="${field.item.version}"]`
|
|
21
|
-
);
|
|
22
|
-
|
|
23
|
-
if (!fieldElements) return null;
|
|
24
|
-
return (
|
|
25
|
-
<>
|
|
26
|
-
{[...fieldElements]
|
|
27
|
-
.filter((x) => x != editContext.inlineEditingFieldElement)
|
|
28
|
-
.map((element) => (
|
|
29
|
-
<SingleFieldEditedIndicator
|
|
30
|
-
element={element}
|
|
31
|
-
key={field.fieldId + field.item.id}
|
|
32
|
-
scale={scale}
|
|
33
|
-
scroll={scroll}
|
|
34
|
-
/>
|
|
35
|
-
))}
|
|
36
|
-
</>
|
|
37
|
-
);
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
function SingleFieldEditedIndicator({
|
|
41
|
-
element,
|
|
42
|
-
scale,
|
|
43
|
-
scroll,
|
|
44
|
-
}: {
|
|
45
|
-
element: Element;
|
|
46
|
-
scale?: number;
|
|
47
|
-
scroll?: number;
|
|
48
|
-
}) {
|
|
49
|
-
const rect = element.getBoundingClientRect();
|
|
50
|
-
|
|
51
|
-
const indicatorRect = rect;
|
|
52
|
-
return (
|
|
53
|
-
<div
|
|
54
|
-
className={`pointer-events-none absolute focus-shadow edited-field`}
|
|
55
|
-
style={{
|
|
56
|
-
left: indicatorRect.x * (scale || 1),
|
|
57
|
-
top: (indicatorRect.y + (scroll || 0)) * (scale || 1),
|
|
58
|
-
width: indicatorRect.width * (scale || 1),
|
|
59
|
-
height: indicatorRect.height * (scale || 1),
|
|
60
|
-
zIndex: 800,
|
|
61
|
-
}}
|
|
62
|
-
/>
|
|
63
|
-
);
|
|
64
|
-
}
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
import { useEditContext } from "../client/editContext";
|
|
2
|
-
import { PageViewContext } from "../page-viewer/pageViewContext";
|
|
3
|
-
import { FieldEditedIndicator } from "./FieldEditedIndicator";
|
|
4
|
-
|
|
5
|
-
export function FieldEditedIndicators({
|
|
6
|
-
scale,
|
|
7
|
-
pageViewContext,
|
|
8
|
-
scroll,
|
|
9
|
-
}: {
|
|
10
|
-
scale?: number;
|
|
11
|
-
pageViewContext: PageViewContext;
|
|
12
|
-
scroll?: number;
|
|
13
|
-
}) {
|
|
14
|
-
const editContext = useEditContext();
|
|
15
|
-
|
|
16
|
-
if (!editContext) return null;
|
|
17
|
-
|
|
18
|
-
const fields = editContext.lastEditedFields;
|
|
19
|
-
|
|
20
|
-
return (
|
|
21
|
-
<>
|
|
22
|
-
{fields
|
|
23
|
-
.filter((x) => x.timestamp > Date.now() - 10000 && x.user.ai)
|
|
24
|
-
.map((field) => (
|
|
25
|
-
<FieldEditedIndicator
|
|
26
|
-
field={field}
|
|
27
|
-
key={field.fieldId + field.item.id + field.timestamp}
|
|
28
|
-
scale={scale}
|
|
29
|
-
pageViewContext={pageViewContext}
|
|
30
|
-
scroll={scroll}
|
|
31
|
-
/>
|
|
32
|
-
))}
|
|
33
|
-
</>
|
|
34
|
-
);
|
|
35
|
-
}
|