@crimson-education/helios-editor-renderer 1.1.2 → 1.1.3

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/.babelrc ADDED
@@ -0,0 +1,12 @@
1
+ {
2
+ "presets": [
3
+ [
4
+ "@nx/react/babel",
5
+ {
6
+ "runtime": "automatic",
7
+ "useBuiltIns": "usage"
8
+ }
9
+ ]
10
+ ],
11
+ "plugins": []
12
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@crimson-education/helios-editor-renderer",
3
- "version": "1.1.2",
3
+ "version": "1.1.3",
4
4
  "main": "./index.js",
5
5
  "types": "./index.d.ts",
6
6
  "exports": {
@@ -40,4 +40,4 @@
40
40
  "react": "^18.3.1",
41
41
  "react-dom": "^18.3.1"
42
42
  }
43
- }
43
+ }
package/project.json ADDED
@@ -0,0 +1,37 @@
1
+ {
2
+ "name": "helios-editor-renderer",
3
+ "$schema": "../../node_modules/nx/schemas/project-schema.json",
4
+ "sourceRoot": "packages/helios-editor-renderer/src",
5
+ "projectType": "library",
6
+ "tags": [],
7
+ "targets": {
8
+ "build": {
9
+ "executor": "@nx/vite:build",
10
+ "outputs": [
11
+ "{options.outputPath}"
12
+ ],
13
+ "options": {
14
+ "outputPath": "dist/packages/helios-editor-renderer",
15
+ "main": "packages/helios-editor-renderer/src/index.ts",
16
+ "tsConfig": "packages/helios-editor-renderer/tsconfig.lib.json",
17
+ "assets": [
18
+ "packages/helios-editor-renderer/*.md"
19
+ ]
20
+ }
21
+ },
22
+ "nx-release-publish": {
23
+ "options": {
24
+ "packageRoot": "dist/{projectRoot}"
25
+ }
26
+ }
27
+ },
28
+ "release": {
29
+ "version": {
30
+ "generatorOptions": {
31
+ "packageRoot": "dist/{projectRoot}",
32
+ "currentVersionResolver": "git-tag",
33
+ "fallbackCurrentVersionResolver": "disk"
34
+ }
35
+ }
36
+ }
37
+ }
@@ -0,0 +1,458 @@
1
+ 'use client';
2
+
3
+ import { useMemo } from 'react';
4
+ import { Plate, PlateContent, createPlateEditor } from '@udecode/plate/react';
5
+
6
+ import {
7
+ type Value,
8
+ BaseParagraphPlugin,
9
+ Descendant,
10
+ SlateLeaf,
11
+ TText,
12
+ } from '@udecode/plate';
13
+ import { BaseAlignPlugin } from '@udecode/plate-alignment';
14
+ import {
15
+ BaseBoldPlugin,
16
+ BaseCodePlugin,
17
+ BaseItalicPlugin,
18
+ BaseStrikethroughPlugin,
19
+ BaseSubscriptPlugin,
20
+ BaseSuperscriptPlugin,
21
+ BaseUnderlinePlugin,
22
+ } from '@udecode/plate-basic-marks';
23
+ import { BaseBlockquotePlugin } from '@udecode/plate-block-quote';
24
+ import {
25
+ BaseCodeBlockPlugin,
26
+ BaseCodeLinePlugin,
27
+ BaseCodeSyntaxPlugin,
28
+ } from '@udecode/plate-code-block';
29
+ import { BaseCommentsPlugin } from '@udecode/plate-comments';
30
+ import { BaseDatePlugin } from '@udecode/plate-date';
31
+ import {
32
+ BaseFontBackgroundColorPlugin,
33
+ BaseFontColorPlugin,
34
+ // BaseFontSizePlugin,
35
+ } from '@udecode/plate-font';
36
+ import {
37
+ BaseHeadingPlugin,
38
+ BaseTocPlugin,
39
+ HEADING_KEYS,
40
+ HEADING_LEVELS,
41
+ } from '@udecode/plate-heading';
42
+ import { BaseHighlightPlugin } from '@udecode/plate-highlight';
43
+ import { BaseHorizontalRulePlugin } from '@udecode/plate-horizontal-rule';
44
+ import { BaseIndentPlugin } from '@udecode/plate-indent';
45
+ import { BaseIndentListPlugin } from '@udecode/plate-indent-list';
46
+ import { BaseKbdPlugin } from '@udecode/plate-kbd';
47
+ import { BaseColumnItemPlugin, BaseColumnPlugin } from '@udecode/plate-layout';
48
+ import { BaseLineHeightPlugin } from '@udecode/plate-line-height';
49
+ import { BaseLinkPlugin } from '@udecode/plate-link';
50
+ import {
51
+ BaseEquationPlugin,
52
+ BaseInlineEquationPlugin,
53
+ } from '@udecode/plate-math';
54
+ import {
55
+ BaseAudioPlugin,
56
+ BaseFilePlugin,
57
+ BaseImagePlugin,
58
+ BaseMediaEmbedPlugin,
59
+ BaseVideoPlugin,
60
+ } from '@udecode/plate-media';
61
+ import { BaseMentionPlugin } from '@udecode/plate-mention';
62
+ import {
63
+ BaseTableCellHeaderPlugin,
64
+ BaseTableCellPlugin,
65
+ BaseTablePlugin,
66
+ BaseTableRowPlugin,
67
+ } from '@udecode/plate-table';
68
+ import { BaseTogglePlugin } from '@udecode/plate-toggle';
69
+ import { all, createLowlight } from 'lowlight';
70
+
71
+ import { BlockquoteElementStatic } from '@crimson-education/helios-plate/lib/plate-ui/blockquote-element-static';
72
+ import { CodeBlockElementStatic } from '@crimson-education/helios-plate/lib/plate-ui/code-block-element-static';
73
+ import { CodeLeafStatic } from '@crimson-education/helios-plate/lib/plate-ui/code-leaf-static';
74
+ import { CodeLineElementStatic } from '@crimson-education/helios-plate/lib/plate-ui/code-line-element-static';
75
+ import { CodeSyntaxLeafStatic } from '@crimson-education/helios-plate/lib/plate-ui/code-syntax-leaf-static';
76
+ import { ColumnElementStatic } from '@crimson-education/helios-plate/lib/plate-ui/column-element-static';
77
+ import { ColumnGroupElementStatic } from '@crimson-education/helios-plate/lib/plate-ui/column-group-element-static';
78
+ import { CommentLeafStatic } from '@crimson-education/helios-plate/lib/plate-ui/comment-leaf-static';
79
+ import { DateElementStatic } from '@crimson-education/helios-plate/lib/plate-ui/date-element-static';
80
+ // import { EditorStatic } from '@crimson-education/helios-plate/lib/plate-ui/editor-static';
81
+ import { HeadingElementStatic } from '@crimson-education/helios-plate/lib/plate-ui/heading-element-static';
82
+ import { HighlightLeafStatic } from '@crimson-education/helios-plate/lib/plate-ui/highlight-leaf-static';
83
+ import { HrElementStatic } from '@crimson-education/helios-plate/lib/plate-ui/hr-element-static';
84
+ import { ImageElementStatic } from '@crimson-education/helios-plate/lib/plate-ui/image-element-static';
85
+ import {
86
+ FireLiComponent,
87
+ FireMarker,
88
+ } from '@crimson-education/helios-plate/lib/plate-ui/indent-fire-marker';
89
+ import {
90
+ TodoLiStatic,
91
+ TodoMarkerStatic,
92
+ } from '@crimson-education/helios-plate/lib/plate-ui/indent-todo-marker-static';
93
+ import { KbdLeafStatic } from '@crimson-education/helios-plate/lib/plate-ui/kbd-leaf-static';
94
+ import { LinkElementStatic } from '@crimson-education/helios-plate/lib/plate-ui/link-element-static';
95
+ import { MediaAudioElementStatic } from '@crimson-education/helios-plate/lib/plate-ui/media-audio-element-static';
96
+ import { MediaFileElementStatic } from '@crimson-education/helios-plate/lib/plate-ui/media-file-element-static';
97
+ import { MediaVideoElementStatic } from '@crimson-education/helios-plate/lib/plate-ui/media-video-element-static';
98
+ import { MentionElementStatic } from '@crimson-education/helios-plate/lib/plate-ui/mention-element-static';
99
+ import { ParagraphElementStatic } from '@crimson-education/helios-plate/lib/plate-ui/paragraph-element-static';
100
+ import {
101
+ TableCellElementStatic,
102
+ TableCellHeaderStaticElement,
103
+ } from '@crimson-education/helios-plate/lib/plate-ui/table-cell-element-static';
104
+ import { TableElementStatic } from '@crimson-education/helios-plate/lib/plate-ui/table-element-static';
105
+ import { TableRowElementStatic } from '@crimson-education/helios-plate/lib/plate-ui/table-row-element-static';
106
+ import { TocElementStatic } from '@crimson-education/helios-plate/lib/plate-ui/toc-element-static';
107
+ import { ToggleElementStatic } from '@crimson-education/helios-plate/lib/plate-ui/toggle-element-static';
108
+
109
+ // q&a
110
+ import { QASectionTitleElement } from '@crimson-education/helios-plate/lib/plate-ui/qa-section-title-element';
111
+ import { QASectionSubtitleElement } from '@crimson-education/helios-plate/lib/plate-ui/qa-section-subtitle-element';
112
+ import { QAHeaderElement } from '@crimson-education/helios-plate/lib/plate-ui/qa-header-element';
113
+ import { QABodyElement } from '@crimson-education/helios-plate/lib/plate-ui/qa-body-element';
114
+ import { QAItemElement } from '@crimson-education/helios-plate/lib/plate-ui/qa-item-element';
115
+ import { QASectionElement } from '@crimson-education/helios-plate/lib/plate-ui/qa-section-element-static';
116
+ import {
117
+ ELEMENT_QA_SECTION,
118
+ QASectionPlugin,
119
+ } from '@crimson-education/helios-plate/lib/editor/plugins/qa-section-plugin';
120
+ import {
121
+ ELEMENT_QA_ITEM,
122
+ QAItemPlugin,
123
+ } from '@crimson-education/helios-plate/lib/editor/plugins/qa-item-plugin';
124
+ import {
125
+ ELEMENT_QA_SECTION_TITLE,
126
+ QASectionTitlePlugin,
127
+ } from '@crimson-education/helios-plate/lib/editor/plugins/qa-section-title-plugin';
128
+ import {
129
+ ELEMENT_QA_SECTION_SUBTITLE,
130
+ QASectionSubtitlePlugin,
131
+ } from '@crimson-education/helios-plate/lib/editor/plugins/qa-section-subtitle-plugin';
132
+ import {
133
+ ELEMENT_QA_HEADER,
134
+ QAHeaderPlugin,
135
+ } from '@crimson-education/helios-plate/lib/editor/plugins/qa-header-plugin';
136
+ import {
137
+ ELEMENT_QA_BODY,
138
+ QABodyPlugin,
139
+ } from '@crimson-education/helios-plate/lib/editor/plugins/qa-body-plugin';
140
+
141
+ // essay
142
+ import { EssayExcerptTitleElement } from '@crimson-education/helios-plate/lib/plate-ui/essay-excerpt-title-element';
143
+ import { EssayExcerptSubtitleElement } from '@crimson-education/helios-plate/lib/plate-ui/essay-excerpt-subtitle-element';
144
+ import { EssayExcerptElement } from '@crimson-education/helios-plate/lib/plate-ui/essay-excerpt-static';
145
+ import { EssayExcerptBodyElement } from '@crimson-education/helios-plate/lib/plate-ui/essay-excerpt-body-static';
146
+ import {
147
+ ELEMENT_ESSAY_EXCERPT,
148
+ EssayExcerptPlugin,
149
+ } from '@crimson-education/helios-plate/lib/editor/plugins/essay-excerpt-plugin';
150
+ import {
151
+ ELEMENT_ESSAY_EXCERPT_TITLE,
152
+ EssayExcerptTitlePlugin,
153
+ } from '@crimson-education/helios-plate/lib/editor/plugins/essay-excerpt-title-plugin';
154
+ import {
155
+ ELEMENT_ESSAY_EXCERPT_SUBTITLE,
156
+ EssayExcerptSubtitlePlugin,
157
+ } from '@crimson-education/helios-plate/lib/editor/plugins/essay-excerpt-subtitle-plugin';
158
+ import {
159
+ ELEMENT_ESSAY_EXCERPT_BODY,
160
+ EssayExcerptBodyPlugin,
161
+ } from '@crimson-education/helios-plate/lib/editor/plugins/essay-excerpt-body-plugin';
162
+
163
+ // import { CleanPastePlugin } from '@crimson-education/helios-plate/lib/editor/plugins/clean-paste-plugin';
164
+
165
+ // quote
166
+ import {
167
+ ELEMENT_QUOTE_BLOCK,
168
+ QuoteBlockPlugin,
169
+ } from '@crimson-education/helios-plate/lib/editor/plugins/quote-block-plugin';
170
+ import {
171
+ ELEMENT_QUOTE_AUTHOR,
172
+ QuoteAuthorPlugin,
173
+ } from '@crimson-education/helios-plate/lib/editor/plugins/quote-author-plugin';
174
+ import { QuoteBlockElementStatic } from '@crimson-education/helios-plate/lib/plate-ui/quote-block-element-static';
175
+ import { QuoteAuthorElement } from '@crimson-education/helios-plate/lib/plate-ui/quote-author-element';
176
+ import { MediaEmbedElementStatic } from '@crimson-education/helios-plate/lib/plate-ui/media-embed-element-static';
177
+
178
+ import {
179
+ TABLE_HEADING_SPECIAL,
180
+ tableHeaderSpecailPlugin,
181
+ } from '@crimson-education/helios-plate/lib/editor/plugins/table-header-specail-plugin';
182
+ import { TableHeadingSpecialStatic } from '@crimson-education/helios-plate/lib/plate-ui/table-header-special-static';
183
+
184
+ import {
185
+ CALLOUT_BOX,
186
+ CalloutBoxPlugin,
187
+ } from '@crimson-education/helios-plate/lib/editor/plugins/callout-box-plugin';
188
+ import { CalloutBoxElementStatic } from '@crimson-education/helios-plate/lib/plate-ui/callout-box-element-static';
189
+ import {
190
+ CALLOUT_CONTENT,
191
+ CalloutContentPlugin,
192
+ } from '@crimson-education/helios-plate/lib/editor/plugins/callout-content-plugin';
193
+ import { CalloutContentElement } from '@crimson-education/helios-plate/lib/plate-ui/callout-content-element';
194
+ import {
195
+ CALLOUT_TITLE,
196
+ CalloutTitlePlugin,
197
+ } from '@crimson-education/helios-plate/lib/editor/plugins/callout-title-plugin';
198
+ import { CalloutTitleElement } from '@crimson-education/helios-plate/lib/plate-ui/callout-title-element';
199
+ import { LinkElementWithLocaleStatic } from '@crimson-education/helios-plate/lib/plate-ui/link-element-with-local-static';
200
+
201
+ import { withProps } from '@udecode/cn';
202
+
203
+ const lowlight = createLowlight(all);
204
+
205
+ // Utility function to convert straight quotes to curly quotes
206
+ function convertToCurlyQuotes(text: string): string {
207
+ if (!text?.includes('"') && !text?.includes('“') && !text?.includes('”')) {
208
+ return text;
209
+ }
210
+ // Pattern to match any non-English (non-ASCII) characters
211
+ // Matches any character with code point > 127 (outside ASCII range)
212
+ const nonEnglishPattern = '[^\x00-\x7F]';
213
+ // Use a unique placeholder string that's extremely unlikely to appear in content
214
+ const placeholder = '\uE000\uE001\uE002QUOTEPLACEHOLDER\uE003\uE004\uE005';
215
+
216
+ // Replace quotes adjacent to non-English characters with placeholder
217
+ text = text.replace(
218
+ new RegExp(`(${nonEnglishPattern})"|"(${nonEnglishPattern})`, 'g'),
219
+ (match, before, after) => {
220
+ if (before) return before + placeholder;
221
+ return placeholder + after;
222
+ }
223
+ );
224
+
225
+ // Replace opening double quotes
226
+ text = text.replace(/(^|[-\u2014/\s(\u2018[])"/g, '$1\u201c');
227
+ // Replace closing double quotes
228
+ text = text.replace(/"/g, '\u201d');
229
+
230
+ // Restore original quotes (replace placeholder back to straight quote)
231
+ text = text.replace(
232
+ new RegExp(placeholder.replace(/[.*+?^${}()|[\]\\]/g, '\\$&'), 'g'),
233
+ '"'
234
+ );
235
+
236
+ return text;
237
+ }
238
+
239
+ // Recursively transform all text nodes in the editor value
240
+ function isTextNode(node: Descendant): node is TText {
241
+ return 'text' in node && typeof node.text === 'string';
242
+ }
243
+
244
+ function transformQuotesInValue(value: Value): Value {
245
+ return value.map((node: Descendant) => {
246
+ if (isTextNode(node)) {
247
+ // This is a text node
248
+ return {
249
+ ...node,
250
+ text: convertToCurlyQuotes(node.text),
251
+ };
252
+ } else if ('children' in node && Array.isArray(node.children)) {
253
+ // This is a parent node with children
254
+ return {
255
+ ...node,
256
+ children: transformQuotesInValue(node.children as Value),
257
+ };
258
+ }
259
+ return node;
260
+ }) as Value;
261
+ }
262
+
263
+ interface RichEditorProps {
264
+ value: Value;
265
+ readOnly?: boolean;
266
+ locale?: string;
267
+ }
268
+
269
+ export function RichEditor({
270
+ value,
271
+ readOnly = false,
272
+ locale = 'en',
273
+ }: RichEditorProps) {
274
+ // Transform straight quotes to curly quotes (only for English locales)
275
+ const transformedValue = useMemo(() => {
276
+ const isEnglish = locale.toLowerCase().startsWith('en');
277
+ return isEnglish ? transformQuotesInValue(value) : value;
278
+ }, [value, locale]);
279
+
280
+ const components = useMemo(
281
+ () => ({
282
+ [CALLOUT_TITLE]: CalloutTitleElement,
283
+ [CALLOUT_CONTENT]: CalloutContentElement,
284
+ [CALLOUT_BOX]: CalloutBoxElementStatic,
285
+ [TABLE_HEADING_SPECIAL]: TableHeadingSpecialStatic,
286
+ [ELEMENT_QA_SECTION]: QASectionElement,
287
+ [ELEMENT_QA_ITEM]: QAItemElement,
288
+ [ELEMENT_QA_HEADER]: QAHeaderElement,
289
+ [ELEMENT_QA_BODY]: QABodyElement,
290
+ [ELEMENT_QA_SECTION_TITLE]: QASectionTitleElement,
291
+ [ELEMENT_QA_SECTION_SUBTITLE]: QASectionSubtitleElement,
292
+ [ELEMENT_ESSAY_EXCERPT]: EssayExcerptElement,
293
+ [ELEMENT_ESSAY_EXCERPT_BODY]: EssayExcerptBodyElement,
294
+ [ELEMENT_ESSAY_EXCERPT_TITLE]: EssayExcerptTitleElement,
295
+ [ELEMENT_ESSAY_EXCERPT_SUBTITLE]: EssayExcerptSubtitleElement,
296
+ [ELEMENT_QUOTE_BLOCK]: QuoteBlockElementStatic,
297
+ [ELEMENT_QUOTE_AUTHOR]: QuoteAuthorElement,
298
+ [BaseAudioPlugin.key]: MediaAudioElementStatic,
299
+ [BaseBlockquotePlugin.key]: BlockquoteElementStatic,
300
+ [BaseBoldPlugin.key]: withProps(SlateLeaf, { as: 'strong' }),
301
+ [BaseCodeBlockPlugin.key]: CodeBlockElementStatic,
302
+ [BaseCodeLinePlugin.key]: CodeLineElementStatic,
303
+ [BaseCodePlugin.key]: CodeLeafStatic,
304
+ [BaseCodeSyntaxPlugin.key]: CodeSyntaxLeafStatic,
305
+ [BaseColumnItemPlugin.key]: ColumnElementStatic,
306
+ [BaseColumnPlugin.key]: ColumnGroupElementStatic,
307
+ [BaseCommentsPlugin.key]: CommentLeafStatic,
308
+ [BaseDatePlugin.key]: DateElementStatic,
309
+ [BaseFilePlugin.key]: MediaFileElementStatic,
310
+ [BaseHighlightPlugin.key]: HighlightLeafStatic,
311
+ [BaseHorizontalRulePlugin.key]: HrElementStatic,
312
+ [BaseImagePlugin.key]: ImageElementStatic,
313
+ [BaseItalicPlugin.key]: withProps(SlateLeaf, { as: 'em' }),
314
+ [BaseKbdPlugin.key]: KbdLeafStatic,
315
+ [BaseLinkPlugin.key]: (props: any) => (
316
+ <LinkElementWithLocaleStatic {...props} locale={locale} />
317
+ ),
318
+ // [BaseLinkPlugin.key]: LinkElementStatic,
319
+ [BaseMediaEmbedPlugin.key]: MediaEmbedElementStatic,
320
+ [BaseMentionPlugin.key]: MentionElementStatic,
321
+ [BaseParagraphPlugin.key]: ParagraphElementStatic,
322
+ [BaseStrikethroughPlugin.key]: withProps(SlateLeaf, { as: 'del' }),
323
+ [BaseSubscriptPlugin.key]: withProps(SlateLeaf, { as: 'sub' }),
324
+ [BaseSuperscriptPlugin.key]: withProps(SlateLeaf, { as: 'sup' }),
325
+ [BaseTableCellHeaderPlugin.key]: TableCellHeaderStaticElement,
326
+ [BaseTableCellPlugin.key]: TableCellElementStatic,
327
+ [BaseTablePlugin.key]: TableElementStatic,
328
+ [BaseTableRowPlugin.key]: TableRowElementStatic,
329
+ [BaseTocPlugin.key]: TocElementStatic,
330
+ [BaseTogglePlugin.key]: ToggleElementStatic,
331
+ [BaseUnderlinePlugin.key]: withProps(SlateLeaf, { as: 'u' }),
332
+ [BaseVideoPlugin.key]: MediaVideoElementStatic,
333
+ [HEADING_KEYS.h1]: withProps(HeadingElementStatic, { variant: 'h1' }),
334
+ [HEADING_KEYS.h2]: withProps(HeadingElementStatic, { variant: 'h2' }),
335
+ [HEADING_KEYS.h3]: withProps(HeadingElementStatic, { variant: 'h3' }),
336
+ [HEADING_KEYS.h4]: withProps(HeadingElementStatic, { variant: 'h4' }),
337
+ [HEADING_KEYS.h5]: withProps(HeadingElementStatic, { variant: 'h5' }),
338
+ [HEADING_KEYS.h6]: withProps(HeadingElementStatic, { variant: 'h6' }),
339
+ }),
340
+ []
341
+ );
342
+
343
+ const editor = useMemo(
344
+ () =>
345
+ createPlateEditor({
346
+ plugins: [
347
+ CalloutContentPlugin,
348
+ CalloutTitlePlugin,
349
+ CalloutBoxPlugin,
350
+ tableHeaderSpecailPlugin,
351
+ BaseMediaEmbedPlugin,
352
+ QuoteBlockPlugin,
353
+ QuoteAuthorPlugin,
354
+ EssayExcerptBodyPlugin,
355
+ EssayExcerptPlugin,
356
+ EssayExcerptTitlePlugin,
357
+ EssayExcerptSubtitlePlugin,
358
+ QASectionSubtitlePlugin,
359
+ QASectionTitlePlugin,
360
+ QASectionPlugin,
361
+ QAItemPlugin,
362
+ QABodyPlugin,
363
+ QAHeaderPlugin,
364
+ BaseEquationPlugin,
365
+ BaseInlineEquationPlugin,
366
+ BaseColumnPlugin,
367
+ BaseColumnItemPlugin,
368
+ BaseTocPlugin,
369
+ BaseVideoPlugin,
370
+ BaseAudioPlugin,
371
+ BaseParagraphPlugin,
372
+ BaseHeadingPlugin,
373
+ BaseBoldPlugin,
374
+ BaseCodePlugin,
375
+ BaseItalicPlugin,
376
+ BaseStrikethroughPlugin,
377
+ BaseSubscriptPlugin,
378
+ BaseSuperscriptPlugin,
379
+ BaseUnderlinePlugin,
380
+ BaseBlockquotePlugin,
381
+ BaseDatePlugin,
382
+ BaseCodeBlockPlugin.configure({
383
+ options: { lowlight },
384
+ }),
385
+ BaseIndentPlugin.extend({
386
+ inject: {
387
+ targetPlugins: [
388
+ BaseParagraphPlugin.key,
389
+ BaseBlockquotePlugin.key,
390
+ BaseCodeBlockPlugin.key,
391
+ ],
392
+ },
393
+ }),
394
+ BaseIndentListPlugin.extend({
395
+ inject: {
396
+ targetPlugins: [
397
+ BaseParagraphPlugin.key,
398
+ ...HEADING_LEVELS,
399
+ BaseBlockquotePlugin.key,
400
+ BaseCodeBlockPlugin.key,
401
+ BaseTogglePlugin.key,
402
+ ],
403
+ },
404
+ options: {
405
+ listStyleTypes: {
406
+ fire: {
407
+ liComponent: FireLiComponent,
408
+ markerComponent: FireMarker,
409
+ type: 'fire',
410
+ },
411
+ todo: {
412
+ liComponent: TodoLiStatic,
413
+ markerComponent: TodoMarkerStatic,
414
+ type: 'todo',
415
+ },
416
+ },
417
+ },
418
+ }),
419
+ BaseLinkPlugin,
420
+ BaseTableRowPlugin,
421
+ BaseTablePlugin,
422
+ BaseTableCellPlugin,
423
+ BaseHorizontalRulePlugin,
424
+ BaseFontColorPlugin,
425
+ BaseFontBackgroundColorPlugin,
426
+ BaseKbdPlugin,
427
+ BaseAlignPlugin.extend({
428
+ inject: {
429
+ targetPlugins: [
430
+ BaseParagraphPlugin.key,
431
+ BaseMediaEmbedPlugin.key,
432
+ ...HEADING_LEVELS,
433
+ BaseImagePlugin.key,
434
+ ],
435
+ },
436
+ }),
437
+ BaseLineHeightPlugin,
438
+ BaseHighlightPlugin,
439
+ BaseFilePlugin,
440
+ BaseImagePlugin,
441
+ BaseMentionPlugin,
442
+ BaseCommentsPlugin,
443
+ BaseTogglePlugin,
444
+ ],
445
+ value: transformedValue,
446
+ override: {
447
+ components,
448
+ },
449
+ }),
450
+ [transformedValue, components]
451
+ );
452
+
453
+ return (
454
+ <Plate editor={editor} onChange={() => {}}>
455
+ <PlateContent readOnly={true} />
456
+ </Plate>
457
+ );
458
+ }
package/tsconfig.json ADDED
@@ -0,0 +1,18 @@
1
+ {
2
+ "compilerOptions": {
3
+ "jsx": "react-jsx",
4
+ "allowJs": false,
5
+ "esModuleInterop": false,
6
+ "allowSyntheticDefaultImports": true,
7
+ "strict": true,
8
+ "types": ["vite/client"]
9
+ },
10
+ "files": [],
11
+ "include": [],
12
+ "references": [
13
+ {
14
+ "path": "./tsconfig.lib.json"
15
+ }
16
+ ],
17
+ "extends": "../../tsconfig.base.json"
18
+ }
@@ -0,0 +1,29 @@
1
+ {
2
+ "extends": "./tsconfig.json",
3
+ "compilerOptions": {
4
+ "outDir": "../../dist/out-tsc",
5
+ "moduleResolution": "bundler",
6
+ "module": "esnext",
7
+ "target": "esnext",
8
+ "allowSyntheticDefaultImports": true,
9
+ "esModuleInterop": true,
10
+ "types": [
11
+ "node",
12
+ "@nx/react/typings/cssmodule.d.ts",
13
+ "@nx/react/typings/image.d.ts",
14
+ "vite/client"
15
+ ],
16
+ "skipLibCheck": true
17
+ },
18
+ "exclude": [
19
+ "**/*.spec.ts",
20
+ "**/*.test.ts",
21
+ "**/*.spec.tsx",
22
+ "**/*.test.tsx",
23
+ "**/*.spec.js",
24
+ "**/*.test.js",
25
+ "**/*.spec.jsx",
26
+ "**/*.test.jsx"
27
+ ],
28
+ "include": ["src/**/*.js", "src/**/*.jsx", "src/**/*.ts", "src/**/*.tsx"]
29
+ }
package/vite.config.ts ADDED
@@ -0,0 +1,42 @@
1
+ /// <reference types='vitest' />
2
+ import { defineConfig } from 'vite';
3
+ import react from '@vitejs/plugin-react';
4
+ import dts from 'vite-plugin-dts';
5
+ import * as path from 'path';
6
+ import { nxViteTsPaths } from '@nx/vite/plugins/nx-tsconfig-paths.plugin';
7
+ import { nxCopyAssetsPlugin } from '@nx/vite/plugins/nx-copy-assets.plugin';
8
+
9
+ export default defineConfig(() => ({
10
+ root: __dirname,
11
+ cacheDir: '../../node_modules/.vite/packages/helios-editor-renderer',
12
+ plugins: [
13
+ react(),
14
+ nxViteTsPaths(),
15
+ nxCopyAssetsPlugin(['*.md']),
16
+ dts({
17
+ entryRoot: 'src',
18
+ tsconfigPath: path.join(__dirname, 'tsconfig.lib.json'),
19
+ }),
20
+ ],
21
+ build: {
22
+ outDir: '../../dist/packages/helios-editor-renderer',
23
+ emptyOutDir: true,
24
+ reportCompressedSize: true,
25
+ commonjsOptions: {
26
+ transformMixedEsModules: true,
27
+ },
28
+ lib: {
29
+ // Could also be a dictionary or array of multiple entry points.
30
+ entry: 'src/index.ts',
31
+ name: 'helios-editor-renderer',
32
+ fileName: 'index',
33
+ // Change this to the formats you want to support.
34
+ // Don't forget to update your package.json as well.
35
+ formats: ['es' as const],
36
+ },
37
+ rollupOptions: {
38
+ // External packages that should not be bundled into your library.
39
+ external: ['react', 'react-dom', 'react/jsx-runtime'],
40
+ },
41
+ },
42
+ }));