@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.
Files changed (325) hide show
  1. package/dist/components/ActionButton.d.ts +1 -0
  2. package/dist/components/ActionButton.js +2 -2
  3. package/dist/components/ActionButton.js.map +1 -1
  4. package/dist/editor/FieldActionsOverlay.d.ts +1 -0
  5. package/dist/editor/FieldActionsOverlay.js +2 -11
  6. package/dist/editor/FieldActionsOverlay.js.map +1 -1
  7. package/dist/editor/PictureCropper.js +65 -23
  8. package/dist/editor/PictureCropper.js.map +1 -1
  9. package/dist/editor/PictureEditor.js +16 -2
  10. package/dist/editor/PictureEditor.js.map +1 -1
  11. package/dist/editor/Titlebar.js +1 -1
  12. package/dist/editor/Titlebar.js.map +1 -1
  13. package/dist/editor/ai/GhostWriter.js +21 -2
  14. package/dist/editor/ai/GhostWriter.js.map +1 -1
  15. package/dist/editor/commands/componentCommands.js +7 -3
  16. package/dist/editor/commands/componentCommands.js.map +1 -1
  17. package/dist/editor/media-selector/MediaFolderBrowser.d.ts +5 -0
  18. package/dist/editor/media-selector/MediaFolderBrowser.js +77 -0
  19. package/dist/editor/media-selector/MediaFolderBrowser.js.map +1 -0
  20. package/dist/editor/media-selector/MediaSelector.js +1 -1
  21. package/dist/editor/media-selector/MediaSelector.js.map +1 -1
  22. package/dist/editor/media-selector/Thumbnails.js +2 -2
  23. package/dist/editor/media-selector/index.d.ts +8 -0
  24. package/dist/editor/media-selector/index.js +9 -0
  25. package/dist/editor/media-selector/index.js.map +1 -0
  26. package/dist/editor/menubar/BrowseHistory.js +1 -1
  27. package/dist/editor/menubar/PageSelector.js +39 -15
  28. package/dist/editor/menubar/PageSelector.js.map +1 -1
  29. package/dist/editor/page-editor-chrome/useInlineAICompletion.js +37 -11
  30. package/dist/editor/page-editor-chrome/useInlineAICompletion.js.map +1 -1
  31. package/dist/editor/reviews/Comment.js +1 -1
  32. package/dist/editor/reviews/Comment.js.map +1 -1
  33. package/dist/editor/services/aiService.js +0 -1
  34. package/dist/editor/services/aiService.js.map +1 -1
  35. package/dist/editor/sidebar/ComponentTree.js +3 -4
  36. package/dist/editor/sidebar/ComponentTree.js.map +1 -1
  37. package/dist/editor/ui/SimpleTabs.d.ts +1 -0
  38. package/dist/editor/ui/SimpleTabs.js +3 -3
  39. package/dist/editor/ui/SimpleTabs.js.map +1 -1
  40. package/dist/editor/ui/Splitter.js +61 -6
  41. package/dist/editor/ui/Splitter.js.map +1 -1
  42. package/dist/editor/views/MediaFolderEditView.d.ts +4 -0
  43. package/dist/editor/views/MediaFolderEditView.js +40 -0
  44. package/dist/editor/views/MediaFolderEditView.js.map +1 -0
  45. package/dist/editor/views/SingleEditView.js +9 -1
  46. package/dist/editor/views/SingleEditView.js.map +1 -1
  47. package/dist/revision.d.ts +2 -2
  48. package/dist/revision.js +2 -2
  49. package/dist/styles.css +61 -5
  50. package/package.json +8 -2
  51. package/.prettierrc +0 -3
  52. package/build.css +0 -3
  53. package/components.json +0 -21
  54. package/eslint.config.mjs +0 -4
  55. package/images/bg-shape-black.webp +0 -0
  56. package/images/wizard-bg.png +0 -0
  57. package/images/wizard-tour.png +0 -0
  58. package/images/wizard.png +0 -0
  59. package/src/client-components/api.ts +0 -6
  60. package/src/client-components/index.ts +0 -19
  61. package/src/components/ActionButton.tsx +0 -41
  62. package/src/components/Error.tsx +0 -57
  63. package/src/components/ui/CardConnector.tsx +0 -56
  64. package/src/components/ui/button.tsx +0 -62
  65. package/src/components/ui/card.tsx +0 -372
  66. package/src/components/ui/context-menu.tsx +0 -250
  67. package/src/config/config.tsx +0 -917
  68. package/src/config/types.ts +0 -286
  69. package/src/editor/ComponentInfo.tsx +0 -90
  70. package/src/editor/ConfirmationDialog.tsx +0 -103
  71. package/src/editor/ContentTree.tsx +0 -730
  72. package/src/editor/ContextMenu.tsx +0 -230
  73. package/src/editor/Editor.tsx +0 -90
  74. package/src/editor/EditorWarning.tsx +0 -34
  75. package/src/editor/EditorWarnings.tsx +0 -33
  76. package/src/editor/FieldActionsOverlay.tsx +0 -307
  77. package/src/editor/FieldEditorPopup.tsx +0 -65
  78. package/src/editor/FieldHistory.tsx +0 -75
  79. package/src/editor/FieldList.tsx +0 -190
  80. package/src/editor/FieldListField.tsx +0 -391
  81. package/src/editor/FieldListFieldWithFallbacks.tsx +0 -217
  82. package/src/editor/FloatingToolbar.tsx +0 -163
  83. package/src/editor/ImageEditor.tsx +0 -128
  84. package/src/editor/ItemInfo.tsx +0 -90
  85. package/src/editor/LinkEditorDialog.tsx +0 -196
  86. package/src/editor/MainLayout.tsx +0 -95
  87. package/src/editor/MobileLayout.tsx +0 -68
  88. package/src/editor/NewEditorClient.tsx +0 -11
  89. package/src/editor/PictureCropper.tsx +0 -503
  90. package/src/editor/PictureEditor.tsx +0 -277
  91. package/src/editor/PictureEditorDialog.tsx +0 -381
  92. package/src/editor/PublishDialog.ignore +0 -74
  93. package/src/editor/ScrollingContentTree.tsx +0 -67
  94. package/src/editor/Terminal.tsx +0 -227
  95. package/src/editor/Titlebar.tsx +0 -104
  96. package/src/editor/ai/AiPopup.tsx +0 -59
  97. package/src/editor/ai/AiResponseMessage.tsx +0 -106
  98. package/src/editor/ai/AiTerminal.tsx +0 -503
  99. package/src/editor/ai/AiToolCall.tsx +0 -61
  100. package/src/editor/ai/EditorAiTerminal.tsx +0 -20
  101. package/src/editor/ai/GhostWriter.tsx +0 -432
  102. package/src/editor/ai/aiPageModel.ts +0 -108
  103. package/src/editor/ai/editorAiContext.ts +0 -18
  104. package/src/editor/client/AboutDialog.tsx +0 -44
  105. package/src/editor/client/EditorClient.tsx +0 -2241
  106. package/src/editor/client/GenericDialog.tsx +0 -50
  107. package/src/editor/client/editContext.ts +0 -416
  108. package/src/editor/client/helpers.ts +0 -44
  109. package/src/editor/client/itemsRepository.ts +0 -574
  110. package/src/editor/client/operations.ts +0 -768
  111. package/src/editor/client/pageModelBuilder.ts +0 -219
  112. package/src/editor/commands/commands.ts +0 -22
  113. package/src/editor/commands/componentCommands.tsx +0 -424
  114. package/src/editor/commands/createVersionCommand.ts +0 -33
  115. package/src/editor/commands/deleteVersionCommand.ts +0 -71
  116. package/src/editor/commands/itemCommands.tsx +0 -351
  117. package/src/editor/commands/localizeItem/LocalizeItemDialog.tsx +0 -201
  118. package/src/editor/commands/localizeItem/LocalizeItemUtils.ts +0 -27
  119. package/src/editor/commands/undo.ts +0 -39
  120. package/src/editor/component-designer/ComponentDesigner.tsx +0 -70
  121. package/src/editor/component-designer/ComponentDesignerAiTerminal.tsx +0 -11
  122. package/src/editor/component-designer/ComponentDesignerMenu.tsx +0 -91
  123. package/src/editor/component-designer/ComponentEditor.tsx +0 -97
  124. package/src/editor/component-designer/ComponentRenderingCodeEditor.tsx +0 -31
  125. package/src/editor/component-designer/ComponentRenderingEditor.tsx +0 -104
  126. package/src/editor/component-designer/ComponentsDropdown.tsx +0 -39
  127. package/src/editor/component-designer/PlaceholdersEditor.tsx +0 -179
  128. package/src/editor/component-designer/RenderingsDropdown.tsx +0 -36
  129. package/src/editor/component-designer/TemplateEditor.tsx +0 -236
  130. package/src/editor/component-designer/aiContext.ts +0 -23
  131. package/src/editor/componentTreeHelper.tsx +0 -116
  132. package/src/editor/context-menu/CopyMoveMenu.tsx +0 -103
  133. package/src/editor/context-menu/InsertMenu.tsx +0 -347
  134. package/src/editor/control-center/About.tsx +0 -342
  135. package/src/editor/control-center/ControlCenterMenu.tsx +0 -76
  136. package/src/editor/control-center/IndexOverview.tsx +0 -50
  137. package/src/editor/control-center/IndexSettings.tsx +0 -266
  138. package/src/editor/control-center/Info.tsx +0 -104
  139. package/src/editor/control-center/QuotaInfo.tsx +0 -301
  140. package/src/editor/control-center/Status.tsx +0 -113
  141. package/src/editor/control-center/WebSocketMessages.tsx +0 -155
  142. package/src/editor/editor-warnings/ItemLocked.tsx +0 -63
  143. package/src/editor/editor-warnings/NoLanguageWriteAccess.tsx +0 -22
  144. package/src/editor/editor-warnings/NoWorkflowWriteAccess.tsx +0 -23
  145. package/src/editor/editor-warnings/NoWriteAccess.tsx +0 -16
  146. package/src/editor/editor-warnings/ValidationErrors.tsx +0 -54
  147. package/src/editor/field-types/AttachmentEditor.tsx +0 -9
  148. package/src/editor/field-types/CheckboxEditor.tsx +0 -47
  149. package/src/editor/field-types/DropLinkEditor.tsx +0 -80
  150. package/src/editor/field-types/DropListEditor.tsx +0 -84
  151. package/src/editor/field-types/ImageFieldEditor.tsx +0 -65
  152. package/src/editor/field-types/InternalLinkFieldEditor.tsx +0 -117
  153. package/src/editor/field-types/LinkFieldEditor.tsx +0 -85
  154. package/src/editor/field-types/MultiLineText.tsx +0 -82
  155. package/src/editor/field-types/PictureFieldEditor.tsx +0 -121
  156. package/src/editor/field-types/RawEditor.tsx +0 -53
  157. package/src/editor/field-types/ReactQuill.tsx +0 -580
  158. package/src/editor/field-types/RichTextEditor.tsx +0 -22
  159. package/src/editor/field-types/RichTextEditorComponent.tsx +0 -127
  160. package/src/editor/field-types/SingleLineText.tsx +0 -174
  161. package/src/editor/field-types/TreeListEditor.tsx +0 -261
  162. package/src/editor/fieldTypes.ts +0 -140
  163. package/src/editor/media-selector/AiImageSearch.tsx +0 -185
  164. package/src/editor/media-selector/AiImageSearchPrompt.tsx +0 -94
  165. package/src/editor/media-selector/MediaSelector.tsx +0 -42
  166. package/src/editor/media-selector/Preview.tsx +0 -14
  167. package/src/editor/media-selector/Thumbnails.tsx +0 -48
  168. package/src/editor/media-selector/TreeSelector.tsx +0 -292
  169. package/src/editor/media-selector/UploadZone.tsx +0 -137
  170. package/src/editor/menubar/ActionsMenu.tsx +0 -94
  171. package/src/editor/menubar/ActiveUsers.tsx +0 -17
  172. package/src/editor/menubar/ApproveAndPublish.tsx +0 -18
  173. package/src/editor/menubar/BrowseHistory.tsx +0 -28
  174. package/src/editor/menubar/ItemLanguageVersion.tsx +0 -76
  175. package/src/editor/menubar/LanguageSelector.tsx +0 -226
  176. package/src/editor/menubar/Menu.tsx +0 -83
  177. package/src/editor/menubar/NavButtons.tsx +0 -74
  178. package/src/editor/menubar/PageSelector.tsx +0 -166
  179. package/src/editor/menubar/PageViewerControls.tsx +0 -120
  180. package/src/editor/menubar/PreviewSecondaryControls.tsx +0 -18
  181. package/src/editor/menubar/SecondaryControls.tsx +0 -45
  182. package/src/editor/menubar/Separator.tsx +0 -12
  183. package/src/editor/menubar/SiteInfo.tsx +0 -53
  184. package/src/editor/menubar/User.tsx +0 -27
  185. package/src/editor/menubar/VersionSelector.tsx +0 -142
  186. package/src/editor/page-editor-chrome/CommentHighlighting.tsx +0 -307
  187. package/src/editor/page-editor-chrome/CommentHighlightings.tsx +0 -35
  188. package/src/editor/page-editor-chrome/FieldActionIndicator.tsx +0 -59
  189. package/src/editor/page-editor-chrome/FieldActionIndicators.tsx +0 -23
  190. package/src/editor/page-editor-chrome/FieldEditedIndicator.tsx +0 -64
  191. package/src/editor/page-editor-chrome/FieldEditedIndicators.tsx +0 -35
  192. package/src/editor/page-editor-chrome/FrameMenu.tsx +0 -338
  193. package/src/editor/page-editor-chrome/FrameMenus.tsx +0 -48
  194. package/src/editor/page-editor-chrome/InlineEditor.tsx +0 -765
  195. package/src/editor/page-editor-chrome/LockedFieldIndicator.tsx +0 -61
  196. package/src/editor/page-editor-chrome/NoLayout.tsx +0 -36
  197. package/src/editor/page-editor-chrome/PageEditorChrome.tsx +0 -122
  198. package/src/editor/page-editor-chrome/PictureEditorOverlay.tsx +0 -161
  199. package/src/editor/page-editor-chrome/PlaceholderDropZone.tsx +0 -169
  200. package/src/editor/page-editor-chrome/PlaceholderDropZones.tsx +0 -315
  201. package/src/editor/page-editor-chrome/SuggestionHighlighting.tsx +0 -300
  202. package/src/editor/page-editor-chrome/SuggestionHighlightings.tsx +0 -40
  203. package/src/editor/page-editor-chrome/useInlineAICompletion.tsx +0 -791
  204. package/src/editor/page-viewer/DeviceToolbar.tsx +0 -70
  205. package/src/editor/page-viewer/EditorForm.tsx +0 -258
  206. package/src/editor/page-viewer/MiniMap.tsx +0 -362
  207. package/src/editor/page-viewer/PageViewer.tsx +0 -169
  208. package/src/editor/page-viewer/PageViewerFrame.tsx +0 -1022
  209. package/src/editor/page-viewer/pageModelSkeletonBuilder.ts +0 -412
  210. package/src/editor/page-viewer/pageViewContext.ts +0 -186
  211. package/src/editor/pageModel.ts +0 -220
  212. package/src/editor/picture-shared.tsx +0 -53
  213. package/src/editor/reviews/Comment.tsx +0 -307
  214. package/src/editor/reviews/Comments.tsx +0 -125
  215. package/src/editor/reviews/DiffView.tsx +0 -109
  216. package/src/editor/reviews/PreviewInfo.tsx +0 -35
  217. package/src/editor/reviews/Reviews.tsx +0 -280
  218. package/src/editor/reviews/SuggestedEdit.tsx +0 -316
  219. package/src/editor/reviews/reviewCommands.tsx +0 -47
  220. package/src/editor/reviews/useReviews.tsx +0 -70
  221. package/src/editor/services/aiService.ts +0 -174
  222. package/src/editor/services/componentDesignerService.ts +0 -151
  223. package/src/editor/services/contentService.ts +0 -180
  224. package/src/editor/services/editService.ts +0 -488
  225. package/src/editor/services/indexService.ts +0 -24
  226. package/src/editor/services/reviewsService.ts +0 -53
  227. package/src/editor/services/serviceHelper.ts +0 -95
  228. package/src/editor/services/suggestedEditsService.ts +0 -39
  229. package/src/editor/services/systemService.ts +0 -5
  230. package/src/editor/services/translationService.ts +0 -21
  231. package/src/editor/services-server/api.ts +0 -150
  232. package/src/editor/services-server/graphQL.ts +0 -106
  233. package/src/editor/sidebar/ComponentPalette.tsx +0 -161
  234. package/src/editor/sidebar/ComponentTree.tsx +0 -548
  235. package/src/editor/sidebar/ComponentTree2.tsxx +0 -490
  236. package/src/editor/sidebar/Debug.tsx +0 -111
  237. package/src/editor/sidebar/DictionaryEditor.tsx +0 -261
  238. package/src/editor/sidebar/EditHistory.tsx +0 -134
  239. package/src/editor/sidebar/GraphQL.tsx +0 -164
  240. package/src/editor/sidebar/Insert.tsx +0 -35
  241. package/src/editor/sidebar/MainContentTree.tsx +0 -102
  242. package/src/editor/sidebar/Performance.tsx +0 -53
  243. package/src/editor/sidebar/Sessions.tsx +0 -35
  244. package/src/editor/sidebar/Sidebar.tsx +0 -20
  245. package/src/editor/sidebar/SidebarView.tsx +0 -152
  246. package/src/editor/sidebar/Translations.tsx +0 -295
  247. package/src/editor/sidebar/Validation.tsx +0 -102
  248. package/src/editor/sidebar/ViewSelector.tsx +0 -60
  249. package/src/editor/sidebar/Workbox.tsx +0 -209
  250. package/src/editor/ui/CenteredMessage.tsx +0 -7
  251. package/src/editor/ui/CopyMoveTargetSelectorDialog.tsx +0 -81
  252. package/src/editor/ui/CopyToClipboardButton.tsx +0 -24
  253. package/src/editor/ui/DialogButtons.tsx +0 -11
  254. package/src/editor/ui/Icons.tsx +0 -709
  255. package/src/editor/ui/ItemList.tsx +0 -76
  256. package/src/editor/ui/ItemNameDialogNew.tsx +0 -118
  257. package/src/editor/ui/ItemSearch.tsx +0 -153
  258. package/src/editor/ui/PerfectTree.tsx +0 -571
  259. package/src/editor/ui/Section.tsx +0 -35
  260. package/src/editor/ui/SimpleIconButton.tsx +0 -54
  261. package/src/editor/ui/SimpleMenu.tsx +0 -40
  262. package/src/editor/ui/SimpleTable.tsx +0 -60
  263. package/src/editor/ui/SimpleTabs.tsx +0 -55
  264. package/src/editor/ui/SimpleToolbar.tsx +0 -7
  265. package/src/editor/ui/Spinner.tsx +0 -9
  266. package/src/editor/ui/Splitter.tsx +0 -314
  267. package/src/editor/ui/StackedPanels.tsx +0 -134
  268. package/src/editor/ui/Toolbar.tsx +0 -7
  269. package/src/editor/utils/id-helper.ts +0 -3
  270. package/src/editor/utils/insertOptions.ts +0 -69
  271. package/src/editor/utils/itemutils.ts +0 -29
  272. package/src/editor/utils/useMemoDebug.ts +0 -28
  273. package/src/editor/utils.ts +0 -486
  274. package/src/editor/views/CompareView.tsx +0 -245
  275. package/src/editor/views/EditView.tsx +0 -27
  276. package/src/editor/views/ItemEditor.tsx +0 -58
  277. package/src/editor/views/SingleEditView.tsx +0 -46
  278. package/src/fonts/Geist-Black.woff2 +0 -0
  279. package/src/fonts/Geist-Bold.woff2 +0 -0
  280. package/src/fonts/Geist-ExtraBold.woff2 +0 -0
  281. package/src/fonts/Geist-ExtraLight.woff2 +0 -0
  282. package/src/fonts/Geist-Light.woff2 +0 -0
  283. package/src/fonts/Geist-Medium.woff2 +0 -0
  284. package/src/fonts/Geist-Regular.woff2 +0 -0
  285. package/src/fonts/Geist-SemiBold.woff2 +0 -0
  286. package/src/fonts/Geist-Thin.woff2 +0 -0
  287. package/src/fonts/Geist[wght].woff2 +0 -0
  288. package/src/fonts/index.ts +0 -10
  289. package/src/index.ts +0 -23
  290. package/src/lib/safelist.tsx +0 -16
  291. package/src/lib/utils.ts +0 -6
  292. package/src/page-wizard/PageWizard.tsx +0 -139
  293. package/src/page-wizard/WizardBox.tsx +0 -4
  294. package/src/page-wizard/WizardBoxConnector.tsx +0 -56
  295. package/src/page-wizard/WizardSteps.tsx +0 -458
  296. package/src/page-wizard/service.ts +0 -35
  297. package/src/page-wizard/startPageWizardCommand.ts +0 -26
  298. package/src/page-wizard/steps/BuildPageStep.tsx +0 -259
  299. package/src/page-wizard/steps/CollectStep.tsx +0 -296
  300. package/src/page-wizard/steps/ComponentTypesSelector.tsx +0 -454
  301. package/src/page-wizard/steps/Components.tsx +0 -193
  302. package/src/page-wizard/steps/ContentStep.tsx +0 -890
  303. package/src/page-wizard/steps/EditButton.tsx +0 -34
  304. package/src/page-wizard/steps/FieldEditor.tsx +0 -102
  305. package/src/page-wizard/steps/Generate.tsx +0 -60
  306. package/src/page-wizard/steps/ImagesStep.tsx +0 -382
  307. package/src/page-wizard/steps/LayoutStep.tsx +0 -227
  308. package/src/page-wizard/steps/MetaDataStep.tsx +0 -173
  309. package/src/page-wizard/steps/SelectStep.tsx +0 -281
  310. package/src/page-wizard/steps/schema.ts +0 -180
  311. package/src/page-wizard/steps/usePageCreator.ts +0 -325
  312. package/src/page-wizard/usePageWizard.ts +0 -79
  313. package/src/revision.ts +0 -2
  314. package/src/splash-screen/NewPage.tsx +0 -294
  315. package/src/splash-screen/OpenPage.tsx +0 -113
  316. package/src/splash-screen/RecentPages.tsx +0 -123
  317. package/src/splash-screen/SectionHeadline.tsx +0 -21
  318. package/src/splash-screen/SplashScreen.tsx +0 -195
  319. package/src/tour/Tour.tsx +0 -566
  320. package/src/tour/default-tour.tsx +0 -301
  321. package/src/tour/preview-tour.tsx +0 -128
  322. package/src/types.ts +0 -335
  323. package/styles.css +0 -765
  324. package/tsconfig.build.json +0 -31
  325. package/tsconfig.json +0 -14
@@ -1,580 +0,0 @@
1
- /*
2
- React-Quill
3
- https://github.com/zenoamaro/react-quill
4
- */
5
-
6
- import React from "react";
7
- import isEqual from "lodash/isEqual";
8
-
9
- import Quill, {
10
- type EmitterSource,
11
- type Range as RangeStatic,
12
- QuillOptions as QuillOptionsStatic,
13
- } from "quill";
14
- import type DeltaStatic from "quill-delta";
15
-
16
- // Merged namespace hack to export types along with default object
17
- // See: https://github.com/Microsoft/TypeScript/issues/2719
18
- namespace ReactQuill {
19
- export type Value = string | DeltaStatic;
20
- export type Range = RangeStatic | null;
21
-
22
- export interface QuillOptions extends QuillOptionsStatic {
23
- scrollingContainer?: HTMLElement | string | undefined;
24
- strict?: boolean | undefined;
25
- tabIndex?: number;
26
- }
27
-
28
- export interface ReactQuillProps {
29
- bounds?: string | HTMLElement;
30
- children?: React.ReactElement<any>;
31
- className?: string;
32
- defaultValue?: Value;
33
- formats?: string[];
34
- id?: string;
35
- modules?: QuillOptions["modules"];
36
- onChange?(
37
- value: string,
38
- delta: DeltaStatic,
39
- source: EmitterSource,
40
- editor: UnprivilegedEditor
41
- ): void;
42
- onChangeSelection?(
43
- selection: Range,
44
- source: EmitterSource,
45
- editor: UnprivilegedEditor
46
- ): void;
47
- onFocus?(
48
- selection: Range,
49
- source: EmitterSource,
50
- editor: UnprivilegedEditor
51
- ): void;
52
- onBlur?(
53
- previousSelection: Range,
54
- source: EmitterSource,
55
- editor: UnprivilegedEditor
56
- ): void;
57
- onKeyDown?: React.EventHandler<any>;
58
- onKeyPress?: React.EventHandler<any>;
59
- onKeyUp?: React.EventHandler<any>;
60
- placeholder?: string;
61
- preserveWhitespace?: boolean;
62
- readOnly?: boolean;
63
- scrollingContainer?: string | HTMLElement;
64
- style?: React.CSSProperties;
65
- tabIndex?: number;
66
- theme?: string;
67
- value?: Value;
68
- }
69
-
70
- export interface UnprivilegedEditor {
71
- getLength: Quill["getLength"];
72
- getText: Quill["getText"];
73
- getHTML: Quill["getSemanticHTML"];
74
- getBounds: Quill["getBounds"];
75
- getSelection: Quill["getSelection"];
76
- getContents: Quill["getContents"];
77
- }
78
- }
79
-
80
- // Re-import everything from namespace into scope for comfort
81
- import Value = ReactQuill.Value;
82
- import Range = ReactQuill.Range;
83
- import QuillOptions = ReactQuill.QuillOptions;
84
- import ReactQuillProps = ReactQuill.ReactQuillProps;
85
- import UnprivilegedEditor = ReactQuill.UnprivilegedEditor;
86
-
87
- interface ReactQuillState {
88
- generation: number;
89
- }
90
-
91
- export class ReactQuill extends React.Component<
92
- ReactQuillProps,
93
- ReactQuillState
94
- > {
95
- static displayName = "React Quill";
96
-
97
- /*
98
- Export Quill to be able to call `register`
99
- */
100
- static Quill = Quill;
101
-
102
- /*
103
- Changing one of these props should cause a full re-render and a
104
- re-instantiation of the Quill editor.
105
- */
106
- dirtyProps: (keyof ReactQuillProps)[] = [
107
- "modules",
108
- "formats",
109
- "bounds",
110
- "theme",
111
- "children",
112
- ];
113
-
114
- /*
115
- Changing one of these props should cause a regular update. These are mostly
116
- props that act on the container, rather than the quillized editing area.
117
- */
118
- cleanProps: (keyof ReactQuillProps)[] = [
119
- "id",
120
- "className",
121
- "style",
122
- "placeholder",
123
- "tabIndex",
124
- "onChange",
125
- "onChangeSelection",
126
- "onFocus",
127
- "onBlur",
128
- "onKeyPress",
129
- "onKeyDown",
130
- "onKeyUp",
131
- ];
132
-
133
- static defaultProps = {
134
- theme: "snow",
135
- modules: {},
136
- readOnly: false,
137
- };
138
-
139
- state: ReactQuillState = {
140
- generation: 0,
141
- };
142
-
143
- /*
144
- The Quill Editor instance.
145
- */
146
- editor?: Quill;
147
-
148
- /*
149
- Reference to the element holding the Quill editing area.
150
- */
151
- editingArea?: React.ReactInstance | null;
152
-
153
- /*
154
- Tracks the internal value of the Quill editor
155
- */
156
- value: Value;
157
-
158
- /*
159
- Tracks the internal selection of the Quill editor
160
- */
161
- selection: Range = null;
162
-
163
- /*
164
- Used to compare whether deltas from `onChange` are being used as `value`.
165
- */
166
- lastDeltaChangeSet?: DeltaStatic;
167
-
168
- /*
169
- Stores the contents of the editor to be restored after regeneration.
170
- */
171
- regenerationSnapshot?: {
172
- delta: DeltaStatic;
173
- selection: Range;
174
- };
175
-
176
- /*
177
- A weaker, unprivileged proxy for the editor that does not allow accidentally
178
- modifying editor state.
179
- */
180
- unprivilegedEditor?: UnprivilegedEditor;
181
-
182
- private editingAreaRef = React.createRef<HTMLDivElement | HTMLPreElement>();
183
-
184
- constructor(props: ReactQuillProps) {
185
- super(props);
186
- const value = this.isControlled() ? props.value : props.defaultValue;
187
- this.value = value ?? "";
188
- }
189
-
190
- validateProps(props: ReactQuillProps): void {
191
- if (React.Children.count(props.children) > 1)
192
- throw new Error(
193
- "The Quill editing area can only be composed of a single React element."
194
- );
195
-
196
- if (React.Children.count(props.children)) {
197
- const child = React.Children.only(props.children);
198
- if (child?.type === "textarea")
199
- throw new Error(
200
- "Quill does not support editing on a <textarea>. Use a <div> instead."
201
- );
202
- }
203
-
204
- if (this.lastDeltaChangeSet && props.value === this.lastDeltaChangeSet)
205
- throw new Error(
206
- "You are passing the `delta` object from the `onChange` event back " +
207
- "as `value`. You most probably want `editor.getContents()` instead. " +
208
- "See: https://github.com/zenoamaro/react-quill#using-deltas"
209
- );
210
- }
211
-
212
- shouldComponentUpdate(
213
- nextProps: ReactQuillProps,
214
- nextState: ReactQuillState
215
- ) {
216
- this.validateProps(nextProps);
217
-
218
- // If the editor hasn't been instantiated yet, or the component has been
219
- // regenerated, we already know we should update.
220
- if (!this.editor || this.state.generation !== nextState.generation) {
221
- return true;
222
- }
223
-
224
- // Handle value changes in-place
225
- if ("value" in nextProps) {
226
- const prevContents = this.getEditorContents();
227
- const nextContents = nextProps.value ?? "";
228
-
229
- // NOTE: Seeing that Quill is missing a way to prevent edits, we have to
230
- // settle for a hybrid between controlled and uncontrolled mode. We
231
- // can't prevent the change, but we'll still override content
232
- // whenever `value` differs from current state.
233
- // NOTE: Comparing an HTML string and a Quill Delta will always trigger a
234
- // change, regardless of whether they represent the same document.
235
- if (!this.isEqualValue(nextContents, prevContents)) {
236
- this.setEditorContents(this.editor, nextContents);
237
- }
238
- }
239
-
240
- // Handle read-only changes in-place
241
- if (nextProps.readOnly !== this.props.readOnly) {
242
- this.setEditorReadOnly(this.editor, nextProps.readOnly!);
243
- }
244
-
245
- // Clean and Dirty props require a render
246
- return [...this.cleanProps, ...this.dirtyProps].some((prop) => {
247
- return !isEqual(nextProps[prop], this.props[prop]);
248
- });
249
- }
250
-
251
- shouldComponentRegenerate(nextProps: ReactQuillProps): boolean {
252
- // Whenever a `dirtyProp` changes, the editor needs reinstantiation.
253
- return this.dirtyProps.some((prop) => {
254
- return !isEqual(nextProps[prop], this.props[prop]);
255
- });
256
- }
257
-
258
- componentDidMount() {
259
- this.instantiateEditor();
260
- this.setEditorContents(this.editor!, this.getEditorContents());
261
- }
262
-
263
- componentWillUnmount() {
264
- this.destroyEditor();
265
- }
266
-
267
- componentDidUpdate(prevProps: ReactQuillProps, prevState: ReactQuillState) {
268
- // If we're changing one of the `dirtyProps`, the entire Quill Editor needs
269
- // to be re-instantiated. Regenerating the editor will cause the whole tree,
270
- // including the container, to be cleaned up and re-rendered from scratch.
271
- // Store the contents so they can be restored later.
272
- if (this.editor && this.shouldComponentRegenerate(prevProps)) {
273
- const delta = this.editor.getContents();
274
- const selection = this.editor.getSelection();
275
- this.regenerationSnapshot = { delta, selection };
276
- this.setState({ generation: this.state.generation + 1 });
277
- this.destroyEditor();
278
- }
279
-
280
- // The component has been regenerated, so it must be re-instantiated, and
281
- // its content must be restored to the previous values from the snapshot.
282
- if (this.state.generation !== prevState.generation) {
283
- const { delta, selection } = this.regenerationSnapshot!;
284
- delete this.regenerationSnapshot;
285
- this.instantiateEditor();
286
- const editor = this.editor!;
287
- editor.setContents(delta);
288
- postpone(() => this.setEditorSelection(editor, selection));
289
- }
290
- }
291
-
292
- instantiateEditor(): void {
293
- if (this.editor) {
294
- this.hookEditor(this.editor);
295
- } else {
296
- this.editor = this.createEditor(
297
- this.getEditingArea(),
298
- this.getEditorConfig()
299
- );
300
- }
301
- }
302
-
303
- destroyEditor(): void {
304
- if (!this.editor) return;
305
- this.unhookEditor(this.editor);
306
- }
307
-
308
- /*
309
- We consider the component to be controlled if `value` is being sent in props.
310
- */
311
- isControlled(): boolean {
312
- return "value" in this.props;
313
- }
314
-
315
- getEditorConfig(): QuillOptions {
316
- return {
317
- bounds: this.props.bounds,
318
- formats: this.props.formats,
319
- modules: this.props.modules,
320
- placeholder: this.props.placeholder,
321
- readOnly: this.props.readOnly,
322
- scrollingContainer: this.props.scrollingContainer,
323
- tabIndex: this.props.tabIndex,
324
- theme: this.props.theme,
325
- };
326
- }
327
-
328
- getEditor(): Quill {
329
- if (!this.editor) throw new Error("Accessing non-instantiated editor");
330
- return this.editor;
331
- }
332
-
333
- /**
334
- Creates an editor on the given element. The editor will be passed the
335
- configuration, have its events bound,
336
- */
337
- createEditor(element: HTMLElement, config: QuillOptions) {
338
- const editor = new Quill(element, config);
339
- if (config.tabIndex != null) {
340
- this.setEditorTabIndex(editor, config.tabIndex);
341
- }
342
- this.hookEditor(editor);
343
- return editor;
344
- }
345
-
346
- hookEditor(editor: Quill) {
347
- // Expose the editor on change events via a weaker, unprivileged proxy
348
- // object that does not allow accidentally modifying editor state.
349
- this.unprivilegedEditor = this.makeUnprivilegedEditor(editor);
350
- // Using `editor-change` allows picking up silent updates, like selection
351
- // changes on typing.
352
- editor.on("editor-change", this.onEditorChange);
353
- }
354
-
355
- unhookEditor(editor: Quill) {
356
- editor.off("editor-change", this.onEditorChange);
357
- }
358
-
359
- getEditorContents(): Value {
360
- return this.value;
361
- }
362
-
363
- getEditorSelection(): Range {
364
- return this.selection;
365
- }
366
-
367
- /*
368
- True if the value is a Delta instance or a Delta look-alike.
369
- */
370
- isDelta(value: any): boolean {
371
- return value && value.ops;
372
- }
373
-
374
- /*
375
- Special comparison function that knows how to compare Deltas.
376
- */
377
- isEqualValue(value: any, nextValue: any): boolean {
378
- if (this.isDelta(value) && this.isDelta(nextValue)) {
379
- return isEqual(value.ops, nextValue.ops);
380
- } else {
381
- return isEqual(value, nextValue);
382
- }
383
- }
384
-
385
- /*
386
- Replace the contents of the editor, but keep the previous selection hanging
387
- around so that the cursor won't move.
388
- */
389
- setEditorContents(editor: Quill, value: Value) {
390
- this.value = value;
391
-
392
- //const sel = this.getEditorSelection();
393
- if (typeof value === "string") {
394
- editor.setContents(editor.clipboard.convert({ html: value }));
395
- } else {
396
- editor.setContents(value);
397
- }
398
- // THIS STEALS FOCUS!
399
- // postpone(() => this.setEditorSelection(editor, sel));
400
- }
401
-
402
- setEditorSelection(editor: Quill, range: Range) {
403
- this.selection = range;
404
- if (range) {
405
- // Validate bounds before applying.
406
- const length = editor.getLength();
407
- range.index = Math.max(0, Math.min(range.index, length - 1));
408
- range.length = Math.max(
409
- 0,
410
- Math.min(range.length, length - 1 - range.index)
411
- );
412
- editor.setSelection(range);
413
- }
414
- }
415
-
416
- setEditorTabIndex(editor: Quill, tabIndex: number) {
417
- if (editor?.scroll?.domNode) {
418
- (editor.scroll.domNode as HTMLElement).tabIndex = tabIndex;
419
- }
420
- }
421
-
422
- setEditorReadOnly(editor: Quill, value: boolean) {
423
- if (value) {
424
- editor.disable();
425
- } else {
426
- editor.enable();
427
- }
428
- }
429
-
430
- /*
431
- Returns a weaker, unprivileged proxy object that only exposes read-only
432
- accessors found on the editor instance, without any state-modifying methods.
433
- */
434
- makeUnprivilegedEditor(editor: Quill) {
435
- const e = editor;
436
- return {
437
- getHTML: () => e.root.innerHTML,
438
- getLength: e.getLength.bind(e),
439
- getText: e.getText.bind(e),
440
- getContents: e.getContents.bind(e),
441
- getSelection: e.getSelection.bind(e),
442
- getBounds: e.getBounds.bind(e),
443
- };
444
- }
445
-
446
- getEditingArea(): HTMLElement {
447
- if (!this.editingAreaRef.current) {
448
- throw new Error("Editing area is not available");
449
- }
450
- return this.editingAreaRef.current;
451
- }
452
-
453
- /*
454
- Renders an editor area, unless it has been provided one to clone.
455
- */
456
- renderEditingArea(): React.ReactNode {
457
- const { children, preserveWhitespace } = this.props;
458
- const { generation } = this.state;
459
-
460
- if (React.Children.count(children)) {
461
- return React.cloneElement(React.Children.only(children)!, {
462
- ref: this.editingAreaRef,
463
- });
464
- }
465
-
466
- return preserveWhitespace ? (
467
- <pre
468
- ref={this.editingAreaRef as React.LegacyRef<HTMLPreElement>}
469
- key={generation}
470
- />
471
- ) : (
472
- <div
473
- ref={this.editingAreaRef as React.LegacyRef<HTMLDivElement>}
474
- key={generation}
475
- />
476
- );
477
- }
478
-
479
- render() {
480
- return (
481
- <div
482
- id={this.props.id}
483
- style={this.props.style}
484
- key={this.state.generation}
485
- className={`quill ${this.props.className ?? ""}`}
486
- onKeyPress={this.props.onKeyPress}
487
- onKeyDownCapture={this.props.onKeyDown}
488
- onKeyUp={this.props.onKeyUp}
489
- >
490
- {this.renderEditingArea()}
491
- </div>
492
- );
493
- }
494
-
495
- onEditorChange = (
496
- eventName: "text-change" | "selection-change",
497
- rangeOrDelta: Range | DeltaStatic,
498
- //oldRangeOrDelta: Range | DeltaStatic,
499
- source: EmitterSource
500
- ) => {
501
- if (eventName === "text-change") {
502
- this.onEditorChangeText?.(
503
- this.editor!.root.innerHTML,
504
- rangeOrDelta as DeltaStatic,
505
- source,
506
- this.unprivilegedEditor!
507
- );
508
- } else if (eventName === "selection-change") {
509
- this.onEditorChangeSelection?.(
510
- rangeOrDelta as RangeStatic,
511
- source,
512
- this.unprivilegedEditor!
513
- );
514
- }
515
- };
516
-
517
- onEditorChangeText(
518
- value: string,
519
- delta: DeltaStatic,
520
- source: EmitterSource,
521
- editor: UnprivilegedEditor
522
- ): void {
523
- if (!this.editor) return;
524
-
525
- // We keep storing the same type of value as what the user gives us,
526
- // so that value comparisons will be more stable and predictable.
527
- const nextContents = this.isDelta(this.value)
528
- ? editor.getContents()
529
- : editor.getHTML();
530
-
531
- if (nextContents !== this.getEditorContents()) {
532
- // Taint this `delta` object, so we can recognize whether the user
533
- // is trying to send it back as `value`, preventing a likely loop.
534
- this.lastDeltaChangeSet = delta;
535
-
536
- this.value = nextContents;
537
- this.props.onChange?.(value, delta, source, editor);
538
- }
539
- }
540
-
541
- onEditorChangeSelection(
542
- nextSelection: RangeStatic,
543
- source: EmitterSource,
544
- editor: UnprivilegedEditor
545
- ): void {
546
- if (!this.editor) return;
547
- const currentSelection = this.getEditorSelection();
548
- const hasGainedFocus = !currentSelection && nextSelection;
549
- const hasLostFocus = currentSelection && !nextSelection;
550
-
551
- if (isEqual(nextSelection, currentSelection)) return;
552
-
553
- this.selection = nextSelection;
554
- this.props.onChangeSelection?.(nextSelection, source, editor);
555
-
556
- if (hasGainedFocus) {
557
- this.props.onFocus?.(nextSelection, source, editor);
558
- } else if (hasLostFocus) {
559
- this.props.onBlur?.(currentSelection, source, editor);
560
- }
561
- }
562
-
563
- focus(): void {
564
- if (!this.editor) return;
565
- this.editor.focus();
566
- }
567
-
568
- blur(): void {
569
- if (!this.editor) return;
570
- this.selection = null;
571
- this.editor.blur();
572
- }
573
- }
574
-
575
- /*
576
- Small helper to execute a function in the next micro-tick.
577
- */
578
- function postpone(fn: (value: void) => void) {
579
- Promise.resolve().then(fn);
580
- }
@@ -1,22 +0,0 @@
1
- "use client";
2
-
3
- import dynamic from "next/dynamic";
4
- import { Field } from "../pageModel";
5
-
6
- const RichTextEditorComponent = dynamic(
7
- () =>
8
- import("./RichTextEditorComponent").then(
9
- (dnd) => dnd.RichTextEditorComponent
10
- ),
11
- { ssr: false }
12
- );
13
-
14
- export function RichTextEditor({
15
- field,
16
- readOnly,
17
- }: {
18
- field: Field;
19
- readOnly?: boolean;
20
- }) {
21
- return <RichTextEditorComponent field={field} readOnly={readOnly} />;
22
- }