@procore/text-editor 0.0.1

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 (161) hide show
  1. package/.jest/ckeditorMock.js +67 -0
  2. package/.jest/esToolkitMock.js +23 -0
  3. package/.jest/setupTests.js +33 -0
  4. package/.jest/styleMock.js +1 -0
  5. package/.jest/svgTransform.js +10 -0
  6. package/.jest/translationFileMock.js +4 -0
  7. package/.jest/translationMock.js +12 -0
  8. package/LICENSE +84 -0
  9. package/README.md +107 -0
  10. package/codemod/__fixtures__/hammer.config.mjs +15 -0
  11. package/codemod/__fixtures__/jest.config.js +6 -0
  12. package/codemod/__fixtures__/procore.config.js +12 -0
  13. package/codemod/__fixtures__/src/components/ComplexEditor.tsx +21 -0
  14. package/codemod/__fixtures__/src/components/FormWithRichText.tsx +10 -0
  15. package/codemod/__fixtures__/src/components/MultilineFormRichText.tsx +14 -0
  16. package/codemod/__fixtures__/src/components/NoTextEditor.tsx +11 -0
  17. package/codemod/__fixtures__/src/components/ReadOnlyRichText.tsx +10 -0
  18. package/codemod/__fixtures__/src/components/SimpleEditor.tsx +11 -0
  19. package/codemod/__fixtures__/src/components/TypeImportEditor.tsx +17 -0
  20. package/codemod/text-editor-migrate.js +509 -0
  21. package/codemod/text-editor-migrate.test.js +225 -0
  22. package/dist/TextEditor/EditorError.js +9 -0
  23. package/dist/TextEditor/EditorError.js.map +1 -0
  24. package/dist/TextEditor/StickyToolbar/index.js +2 -0
  25. package/dist/TextEditor/StickyToolbar/index.js.map +1 -0
  26. package/dist/TextEditor/StickyToolbar/useStickyToolbar.js +59 -0
  27. package/dist/TextEditor/StickyToolbar/useStickyToolbar.js.map +1 -0
  28. package/dist/TextEditor/StickyToolbar/useStickyToolbar.types.js +2 -0
  29. package/dist/TextEditor/StickyToolbar/useStickyToolbar.types.js.map +1 -0
  30. package/dist/TextEditor/TextEditor.js +226 -0
  31. package/dist/TextEditor/TextEditor.js.map +1 -0
  32. package/dist/TextEditor/TextEditor.styles.js +26 -0
  33. package/dist/TextEditor/TextEditor.styles.js.map +1 -0
  34. package/dist/TextEditor/TextEditor.types.js +2 -0
  35. package/dist/TextEditor/TextEditor.types.js.map +1 -0
  36. package/dist/TextEditor/TextEditorProvider.js +17 -0
  37. package/dist/TextEditor/TextEditorProvider.js.map +1 -0
  38. package/dist/TextEditor/TextEditorProvider.types.js +2 -0
  39. package/dist/TextEditor/TextEditorProvider.types.js.map +1 -0
  40. package/dist/TextEditor/index.js +4 -0
  41. package/dist/TextEditor/index.js.map +1 -0
  42. package/dist/TextEditor/license_key.js +3 -0
  43. package/dist/TextEditor/license_key.js.map +1 -0
  44. package/dist/TextEditor/plugins/CutPlugin/CutCommand.js +99 -0
  45. package/dist/TextEditor/plugins/CutPlugin/CutCommand.js.map +1 -0
  46. package/dist/TextEditor/plugins/CutPlugin/CutPlugin.js +56 -0
  47. package/dist/TextEditor/plugins/CutPlugin/CutPlugin.js.map +1 -0
  48. package/dist/TextEditor/plugins/CutPlugin/index.js +2 -0
  49. package/dist/TextEditor/plugins/CutPlugin/index.js.map +1 -0
  50. package/dist/TextEditor/plugins/IndentPaddingToMarginPlugin/IndentPaddingToMarginPlugin.js +40 -0
  51. package/dist/TextEditor/plugins/IndentPaddingToMarginPlugin/IndentPaddingToMarginPlugin.js.map +1 -0
  52. package/dist/TextEditor/plugins/IndentPaddingToMarginPlugin/index.js +2 -0
  53. package/dist/TextEditor/plugins/IndentPaddingToMarginPlugin/index.js.map +1 -0
  54. package/dist/TextEditor/plugins/PasteAsTextPlugin/PasteAsTextCommand.js +86 -0
  55. package/dist/TextEditor/plugins/PasteAsTextPlugin/PasteAsTextCommand.js.map +1 -0
  56. package/dist/TextEditor/plugins/PasteAsTextPlugin/PasteAsTextPlugin.js +56 -0
  57. package/dist/TextEditor/plugins/PasteAsTextPlugin/PasteAsTextPlugin.js.map +1 -0
  58. package/dist/TextEditor/plugins/PasteAsTextPlugin/index.js +2 -0
  59. package/dist/TextEditor/plugins/PasteAsTextPlugin/index.js.map +1 -0
  60. package/dist/TextEditor/plugins/PastePlugin/PasteCommand.js +149 -0
  61. package/dist/TextEditor/plugins/PastePlugin/PasteCommand.js.map +1 -0
  62. package/dist/TextEditor/plugins/PastePlugin/PastePlugin.js +56 -0
  63. package/dist/TextEditor/plugins/PastePlugin/PastePlugin.js.map +1 -0
  64. package/dist/TextEditor/plugins/PastePlugin/index.js +2 -0
  65. package/dist/TextEditor/plugins/PastePlugin/index.js.map +1 -0
  66. package/dist/TextEditor/plugins/TabSpacesPlugin/TabSpacesPlugin.js +87 -0
  67. package/dist/TextEditor/plugins/TabSpacesPlugin/TabSpacesPlugin.js.map +1 -0
  68. package/dist/TextEditor/plugins/TabSpacesPlugin/index.js +2 -0
  69. package/dist/TextEditor/plugins/TabSpacesPlugin/index.js.map +1 -0
  70. package/dist/TextEditor/textEditorTheming/icons.js +24 -0
  71. package/dist/TextEditor/textEditorTheming/icons.js.map +1 -0
  72. package/dist/TextEditor/textEditorTheming/index.js +2 -0
  73. package/dist/TextEditor/textEditorTheming/index.js.map +1 -0
  74. package/dist/TextEditor/textEditorTheming/textEditorTheming.styles.js +10 -0
  75. package/dist/TextEditor/textEditorTheming/textEditorTheming.styles.js.map +1 -0
  76. package/dist/TextEditor/useCKEditorCss.js +36 -0
  77. package/dist/TextEditor/useCKEditorCss.js.map +1 -0
  78. package/dist/TextEditor/useTabAsNavigation.js +29 -0
  79. package/dist/TextEditor/useTabAsNavigation.js.map +1 -0
  80. package/dist/TextEditor/utils/config.js +179 -0
  81. package/dist/TextEditor/utils/config.js.map +1 -0
  82. package/dist/TextEditor/utils/index.js +3 -0
  83. package/dist/TextEditor/utils/index.js.map +1 -0
  84. package/dist/TextEditor/utils/locale.js +102 -0
  85. package/dist/TextEditor/utils/locale.js.map +1 -0
  86. package/dist/TextEditor/utils/plugins.js +184 -0
  87. package/dist/TextEditor/utils/plugins.js.map +1 -0
  88. package/dist/TextEditorOutput/TextEditorOutput.js +29 -0
  89. package/dist/TextEditorOutput/TextEditorOutput.js.map +1 -0
  90. package/dist/TextEditorOutput/TextEditorOutput.styles.js +6 -0
  91. package/dist/TextEditorOutput/TextEditorOutput.styles.js.map +1 -0
  92. package/dist/TextEditorOutput/TextEditorOutput.types.js +2 -0
  93. package/dist/TextEditorOutput/TextEditorOutput.types.js.map +1 -0
  94. package/dist/TextEditorOutput/TextEditorOutput.utils.js +59 -0
  95. package/dist/TextEditorOutput/TextEditorOutput.utils.js.map +1 -0
  96. package/dist/TextEditorOutput/index.js +2 -0
  97. package/dist/TextEditorOutput/index.js.map +1 -0
  98. package/dist/_storyHelpers/constants.js +48 -0
  99. package/dist/_storyHelpers/constants.js.map +1 -0
  100. package/dist/_typedoc/TextEditor/TextEditor.types.json +227 -0
  101. package/dist/_typedoc/TextEditor/TextEditorProvider.types.json +28 -0
  102. package/dist/_typedoc/TextEditorOutput/TextEditorOutput.types.json +38 -0
  103. package/dist/_typedoc/deprecations.json +1 -0
  104. package/dist/_utils/propsTypedoc.js +4 -0
  105. package/dist/_utils/propsTypedoc.js.map +1 -0
  106. package/dist/codemod/__fixtures__/src/components/ComplexEditor.d.ts +2 -0
  107. package/dist/codemod/__fixtures__/src/components/FormWithRichText.d.ts +2 -0
  108. package/dist/codemod/__fixtures__/src/components/MultilineFormRichText.d.ts +2 -0
  109. package/dist/codemod/__fixtures__/src/components/NoTextEditor.d.ts +2 -0
  110. package/dist/codemod/__fixtures__/src/components/ReadOnlyRichText.d.ts +2 -0
  111. package/dist/codemod/__fixtures__/src/components/SimpleEditor.d.ts +2 -0
  112. package/dist/codemod/__fixtures__/src/components/TypeImportEditor.d.ts +2 -0
  113. package/dist/index.js +3 -0
  114. package/dist/index.js.map +1 -0
  115. package/dist/src/TextEditor/EditorError.d.ts +2 -0
  116. package/dist/src/TextEditor/StickyToolbar/index.d.ts +2 -0
  117. package/dist/src/TextEditor/StickyToolbar/useStickyToolbar.d.ts +2 -0
  118. package/dist/src/TextEditor/StickyToolbar/useStickyToolbar.types.d.ts +8 -0
  119. package/dist/src/TextEditor/TextEditor.d.ts +44 -0
  120. package/dist/src/TextEditor/TextEditor.styles.d.ts +7 -0
  121. package/dist/src/TextEditor/TextEditor.types.d.ts +155 -0
  122. package/dist/src/TextEditor/TextEditorProvider.d.ts +4 -0
  123. package/dist/src/TextEditor/TextEditorProvider.types.d.ts +14 -0
  124. package/dist/src/TextEditor/index.d.ts +4 -0
  125. package/dist/src/TextEditor/license_key.d.ts +2 -0
  126. package/dist/src/TextEditor/plugins/CutPlugin/CutCommand.d.ts +5 -0
  127. package/dist/src/TextEditor/plugins/CutPlugin/CutPlugin.d.ts +5 -0
  128. package/dist/src/TextEditor/plugins/CutPlugin/index.d.ts +1 -0
  129. package/dist/src/TextEditor/plugins/IndentPaddingToMarginPlugin/IndentPaddingToMarginPlugin.d.ts +5 -0
  130. package/dist/src/TextEditor/plugins/IndentPaddingToMarginPlugin/index.d.ts +1 -0
  131. package/dist/src/TextEditor/plugins/PasteAsTextPlugin/PasteAsTextCommand.d.ts +5 -0
  132. package/dist/src/TextEditor/plugins/PasteAsTextPlugin/PasteAsTextPlugin.d.ts +5 -0
  133. package/dist/src/TextEditor/plugins/PasteAsTextPlugin/index.d.ts +1 -0
  134. package/dist/src/TextEditor/plugins/PastePlugin/PasteCommand.d.ts +5 -0
  135. package/dist/src/TextEditor/plugins/PastePlugin/PastePlugin.d.ts +5 -0
  136. package/dist/src/TextEditor/plugins/PastePlugin/index.d.ts +1 -0
  137. package/dist/src/TextEditor/plugins/TabSpacesPlugin/TabSpacesPlugin.d.ts +6 -0
  138. package/dist/src/TextEditor/plugins/TabSpacesPlugin/index.d.ts +1 -0
  139. package/dist/src/TextEditor/textEditorTheming/icons.d.ts +23 -0
  140. package/dist/src/TextEditor/textEditorTheming/index.d.ts +1 -0
  141. package/dist/src/TextEditor/textEditorTheming/textEditorTheming.styles.d.ts +2 -0
  142. package/dist/src/TextEditor/useCKEditorCss.d.ts +3 -0
  143. package/dist/src/TextEditor/useTabAsNavigation.d.ts +11 -0
  144. package/dist/src/TextEditor/utils/config.d.ts +3 -0
  145. package/dist/src/TextEditor/utils/index.d.ts +2 -0
  146. package/dist/src/TextEditor/utils/locale.d.ts +3 -0
  147. package/dist/src/TextEditor/utils/plugins.d.ts +7 -0
  148. package/dist/src/TextEditorOutput/TextEditorOutput.d.ts +8 -0
  149. package/dist/src/TextEditorOutput/TextEditorOutput.styles.d.ts +2 -0
  150. package/dist/src/TextEditorOutput/TextEditorOutput.types.d.ts +21 -0
  151. package/dist/src/TextEditorOutput/TextEditorOutput.utils.d.ts +2 -0
  152. package/dist/src/TextEditorOutput/index.d.ts +2 -0
  153. package/dist/src/_storyHelpers/constants.d.ts +14 -0
  154. package/dist/src/_utils/propsTypedoc.d.ts +3 -0
  155. package/dist/src/index.d.ts +2 -0
  156. package/dist/src/stories/util.d.ts +21 -0
  157. package/dist/stories/util.js +86 -0
  158. package/dist/stories/util.js.map +1 -0
  159. package/jestConfig.d.ts +1 -0
  160. package/jestConfig.js +66 -0
  161. package/package.json +146 -0
@@ -0,0 +1,225 @@
1
+ const fs = require('fs')
2
+ const path = require('path')
3
+ const { execFileSync } = require('child_process')
4
+
5
+ describe('text-editor-migrate codemod', () => {
6
+ const fixturesDir = path.join(__dirname, '__fixtures__')
7
+ const testDir = path.join(__dirname, '__test_output__')
8
+ const codemodPath = path.join(__dirname, 'text-editor-migrate.js')
9
+
10
+ beforeEach(() => {
11
+ // Clean up test directory if it exists
12
+ if (fs.existsSync(testDir)) {
13
+ fs.rmSync(testDir, { recursive: true })
14
+ }
15
+ // Copy fixtures to test directory
16
+ copyDirectory(fixturesDir, testDir)
17
+ })
18
+
19
+ afterEach(() => {
20
+ // Clean up test directory
21
+ if (fs.existsSync(testDir)) {
22
+ fs.rmSync(testDir, { recursive: true })
23
+ }
24
+ })
25
+
26
+ function copyDirectory(src, dest) {
27
+ if (!fs.existsSync(dest)) {
28
+ fs.mkdirSync(dest, { recursive: true })
29
+ }
30
+
31
+ const entries = fs.readdirSync(src, { withFileTypes: true })
32
+
33
+ for (const entry of entries) {
34
+ const srcPath = path.join(src, entry.name)
35
+ const destPath = path.join(dest, entry.name)
36
+
37
+ if (entry.isDirectory()) {
38
+ copyDirectory(srcPath, destPath)
39
+ } else {
40
+ fs.copyFileSync(srcPath, destPath)
41
+ }
42
+ }
43
+ }
44
+
45
+ function readFile(filePath) {
46
+ return fs.readFileSync(path.join(testDir, filePath), 'utf8')
47
+ }
48
+
49
+ describe('import transformations', () => {
50
+ it('should migrate TextEditor imports from core-react to text-editor', () => {
51
+ execFileSync('node', [codemodPath, testDir], { stdio: 'ignore' })
52
+
53
+ const content = readFile('src/components/SimpleEditor.tsx')
54
+
55
+ expect(content).toContain(
56
+ "import { TextEditor } from '@procore/text-editor'"
57
+ )
58
+ expect(content).toContain("import { Button } from '@procore/core-react'")
59
+ expect(content).not.toContain(
60
+ "import { TextEditor, Button } from '@procore/core-react'"
61
+ )
62
+ })
63
+
64
+ it('should migrate multiple TextEditor-related imports', () => {
65
+ execFileSync('node', [codemodPath, testDir], { stdio: 'ignore' })
66
+
67
+ const content = readFile('src/components/ComplexEditor.tsx')
68
+
69
+ // The output should preserve multiline imports
70
+ expect(content).toContain("from '@procore/text-editor'")
71
+ expect(content).toContain('TextEditor,')
72
+ expect(content).toContain('TextEditorOutput,')
73
+ expect(content).toContain('TextEditorProvider,')
74
+ expect(content).toContain("from '@procore/core-react'")
75
+ expect(content).toContain('Form,')
76
+ expect(content).toContain('Modal,')
77
+ })
78
+
79
+ it('should handle TypeScript type imports', () => {
80
+ execFileSync('node', [codemodPath, testDir], { stdio: 'ignore' })
81
+
82
+ const content = readFile('src/components/TypeImportEditor.tsx')
83
+
84
+ // Check that the type imports were migrated to text-editor package
85
+ expect(content).toContain('@procore/text-editor')
86
+ expect(content).toContain('TextEditorProps')
87
+ expect(content).toContain('TextEditorOutputProps')
88
+ expect(content).not.toContain('@procore/core-react')
89
+ })
90
+ })
91
+
92
+ describe('Form.RichText transformations', () => {
93
+ it('should add textEditorComponent prop to Form.RichText', () => {
94
+ execFileSync('node', [codemodPath, testDir], { stdio: 'ignore' })
95
+
96
+ const content = readFile('src/components/FormWithRichText.tsx')
97
+
98
+ expect(content).toContain('textEditorComponent={TextEditor}')
99
+ expect(content).toContain(
100
+ "import { TextEditor } from '@procore/text-editor'"
101
+ )
102
+ })
103
+
104
+ it('should handle multiline Form.RichText props correctly', () => {
105
+ execFileSync('node', [codemodPath, testDir], { stdio: 'ignore' })
106
+
107
+ const content = readFile('src/components/MultilineFormRichText.tsx')
108
+ const lines = content.split('\n')
109
+
110
+ // Find the line with textEditorComponent
111
+ const textEditorLine = lines.find((line) =>
112
+ line.includes('textEditorComponent={TextEditor}')
113
+ )
114
+ const labelLine = lines.find((line) => line.includes('label='))
115
+
116
+ // Check that indentation matches
117
+ const textEditorIndent = textEditorLine?.match(/^(\s*)/)?.[1] || ''
118
+ const labelIndent = labelLine?.match(/^(\s*)/)?.[1] || ''
119
+
120
+ expect(textEditorIndent).toBe(labelIndent)
121
+ })
122
+
123
+ it('should not modify Form.RichText.Read components', () => {
124
+ execFileSync('node', [codemodPath, testDir], { stdio: 'ignore' })
125
+
126
+ const content = readFile('src/components/ReadOnlyRichText.tsx')
127
+
128
+ // Should not add TextEditor import or prop to read-only components
129
+ expect(content).not.toContain('textEditorComponent={TextEditor}')
130
+ expect(content).not.toContain('@procore/text-editor')
131
+ })
132
+ })
133
+
134
+ describe('Jest configuration transformations', () => {
135
+ it('should migrate coreReactJestConfig to textEditorJestConfig', () => {
136
+ execFileSync('node', [codemodPath, testDir], { stdio: 'ignore' })
137
+
138
+ const content = readFile('procore.config.js')
139
+
140
+ expect(content).toContain(
141
+ "const { textEditorJestConfig } = require('@procore/text-editor/jestConfig')"
142
+ )
143
+ expect(content).toContain('textEditorJestConfig(defaultConfig)')
144
+ expect(content).not.toContain('coreReactJestConfig')
145
+ })
146
+
147
+ it('should handle jest.config.js files', () => {
148
+ execFileSync('node', [codemodPath, testDir], { stdio: 'ignore' })
149
+
150
+ const content = readFile('jest.config.js')
151
+
152
+ expect(content).toContain(
153
+ "const { textEditorJestConfig } = require('@procore/text-editor/jestConfig')"
154
+ )
155
+ expect(content).toContain('module.exports = textEditorJestConfig({')
156
+ })
157
+
158
+ it('should handle hammer.config.mjs ES module files', () => {
159
+ execFileSync('node', [codemodPath, testDir], { stdio: 'ignore' })
160
+
161
+ const content = readFile('hammer.config.mjs')
162
+
163
+ expect(content).toContain(
164
+ "import { textEditorJestConfig } from '@procore/text-editor/jestConfig'"
165
+ )
166
+ expect(content).toContain('textEditorJestConfig({')
167
+ expect(content).not.toContain('coreReactJestConfig')
168
+ expect(content).not.toContain('@procore/core-react/jestConfig')
169
+ })
170
+ })
171
+
172
+ describe('edge cases', () => {
173
+ it('should not modify files without TextEditor usage', () => {
174
+ execFileSync('node', [codemodPath, testDir], { stdio: 'ignore' })
175
+
176
+ const content = readFile('src/components/NoTextEditor.tsx')
177
+ const originalContent = fs.readFileSync(
178
+ path.join(fixturesDir, 'src/components/NoTextEditor.tsx'),
179
+ 'utf8'
180
+ )
181
+
182
+ expect(content).toBe(originalContent)
183
+ })
184
+
185
+ it('should skip already migrated files', () => {
186
+ // Run codemod twice
187
+ execFileSync('node', [codemodPath, testDir], { stdio: 'ignore' })
188
+ const firstRun = readFile('src/components/SimpleEditor.tsx')
189
+
190
+ execFileSync('node', [codemodPath, testDir], { stdio: 'ignore' })
191
+ const secondRun = readFile('src/components/SimpleEditor.tsx')
192
+
193
+ expect(firstRun).toBe(secondRun)
194
+ })
195
+ })
196
+
197
+ describe('console output', () => {
198
+ it('should show "No changes" when running on already migrated code', () => {
199
+ // First migration
200
+ execFileSync('node', [codemodPath, testDir], { stdio: 'ignore' })
201
+
202
+ // Second migration should show "No changes"
203
+ const output = execFileSync('node', [codemodPath, testDir], {
204
+ encoding: 'utf8',
205
+ })
206
+
207
+ expect(output).toContain('No changes')
208
+ })
209
+
210
+ it('should report statistics for successful migration', () => {
211
+ // Need to create a fresh copy for this test since other tests may have already run
212
+ if (fs.existsSync(testDir)) {
213
+ fs.rmSync(testDir, { recursive: true })
214
+ }
215
+ copyDirectory(fixturesDir, testDir)
216
+
217
+ const output = execFileSync('node', [codemodPath, testDir], {
218
+ encoding: 'utf8',
219
+ })
220
+
221
+ expect(output).toContain('Files processed:')
222
+ expect(output).toContain('Migration complete!')
223
+ })
224
+ })
225
+ })
@@ -0,0 +1,9 @@
1
+ import { Banner } from '@procore/core-react';
2
+ import React from 'react';
3
+ export var EditorError = function EditorError(_ref) {
4
+ var children = _ref.children;
5
+ return /*#__PURE__*/React.createElement(Banner, {
6
+ variant: "error"
7
+ }, /*#__PURE__*/React.createElement(Banner.Content, null, /*#__PURE__*/React.createElement(Banner.Body, null, children)));
8
+ };
9
+ //# sourceMappingURL=EditorError.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"EditorError.js","names":["Banner","React","EditorError","_ref","children","createElement","variant","Content","Body"],"sources":["../../src/TextEditor/EditorError.tsx"],"sourcesContent":["import { Banner } from '@procore/core-react'\nimport React, { type PropsWithChildren } from 'react'\n\nexport const EditorError = ({ children }: PropsWithChildren<{}>) => {\n return (\n <Banner variant=\"error\">\n <Banner.Content>\n <Banner.Body>{children}</Banner.Body>\n </Banner.Content>\n </Banner>\n )\n}\n"],"mappings":"AAAA,SAASA,MAAM,QAAQ,qBAAqB;AAC5C,OAAOC,KAAK,MAAkC,OAAO;AAErD,OAAO,IAAMC,WAAW,GAAG,SAAdA,WAAWA,CAAAC,IAAA,EAA4C;EAAA,IAAtCC,QAAQ,GAAAD,IAAA,CAARC,QAAQ;EACpC,oBACEH,KAAA,CAAAI,aAAA,CAACL,MAAM;IAACM,OAAO,EAAC;EAAO,gBACrBL,KAAA,CAAAI,aAAA,CAACL,MAAM,CAACO,OAAO,qBACbN,KAAA,CAAAI,aAAA,CAACL,MAAM,CAACQ,IAAI,QAAEJ,QAAsB,CACtB,CACV,CAAC;AAEb,CAAC"}
@@ -0,0 +1,2 @@
1
+ export { useStickyToolbar } from './useStickyToolbar';
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","names":["useStickyToolbar"],"sources":["../../../src/TextEditor/StickyToolbar/index.ts"],"sourcesContent":["export { useStickyToolbar } from './useStickyToolbar'\nexport type { UseStickyToolbarProps } from './useStickyToolbar.types'\n"],"mappings":"AAAA,SAASA,gBAAgB,QAAQ,oBAAoB"}
@@ -0,0 +1,59 @@
1
+ function _createForOfIteratorHelper(r, e) { var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (!t) { if (Array.isArray(r) || (t = _unsupportedIterableToArray(r)) || e && r && "number" == typeof r.length) { t && (r = t); var _n = 0, F = function F() {}; return { s: F, n: function n() { return _n >= r.length ? { done: !0 } : { done: !1, value: r[_n++] }; }, e: function e(r) { throw r; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var o, a = !0, u = !1; return { s: function s() { t = t.call(r); }, n: function n() { var r = t.next(); return a = r.done, r; }, e: function e(r) { u = !0, o = r; }, f: function f() { try { a || null == t["return"] || t["return"](); } finally { if (u) throw o; } } }; }
2
+ function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
3
+ function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
4
+ import { useEffect, useRef } from 'react';
5
+ export function useStickyToolbar(_ref) {
6
+ var enabled = _ref.enabled,
7
+ editor = _ref.editor,
8
+ editorRef = _ref.editorRef,
9
+ cssLoading = _ref.cssLoading;
10
+ var originalLimiterElementRef = useRef(null);
11
+ useEffect(function () {
12
+ if (!editorRef.current || !editor) {
13
+ return;
14
+ }
15
+ var modal = editorRef.current.closest('[data-id="modal"]');
16
+ if (!modal) {
17
+ return;
18
+ }
19
+ var modalHeader = modal.querySelector('[data-id="modal-header"]');
20
+ if (!modalHeader) {
21
+ return;
22
+ }
23
+ var resizeObserver = new ResizeObserver(function (entries) {
24
+ var _iterator = _createForOfIteratorHelper(entries),
25
+ _step;
26
+ try {
27
+ for (_iterator.s(); !(_step = _iterator.n()).done;) {
28
+ var entry = _step.value;
29
+ var _getComputedStyle = getComputedStyle(entry.target),
30
+ height = _getComputedStyle.height;
31
+ var heightValue = parseInt(height, 10) - 1;
32
+ modal.setAttribute('style', "--modal-header-height: ".concat(heightValue, "px"));
33
+ }
34
+ } catch (err) {
35
+ _iterator.e(err);
36
+ } finally {
37
+ _iterator.f();
38
+ }
39
+ });
40
+ resizeObserver.observe(modalHeader);
41
+ return function () {
42
+ return resizeObserver.disconnect();
43
+ };
44
+ }, [editorRef, editor]);
45
+ useEffect(function () {
46
+ if (!editorRef.current || cssLoading || !(editor !== null && editor !== void 0 && editor.ui.view.stickyPanel)) {
47
+ return;
48
+ }
49
+ var stickyPanel = editor.ui.view.stickyPanel;
50
+ if (!enabled) {
51
+ originalLimiterElementRef.current = stickyPanel.limiterElement;
52
+ stickyPanel.limiterElement = null;
53
+ } else if (originalLimiterElementRef.current) {
54
+ stickyPanel.limiterElement = originalLimiterElementRef.current;
55
+ originalLimiterElementRef.current = null;
56
+ }
57
+ }, [enabled, editorRef, editor, cssLoading]);
58
+ }
59
+ //# sourceMappingURL=useStickyToolbar.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useStickyToolbar.js","names":["useEffect","useRef","useStickyToolbar","_ref","enabled","editor","editorRef","cssLoading","originalLimiterElementRef","current","modal","closest","modalHeader","querySelector","resizeObserver","ResizeObserver","entries","_iterator","_createForOfIteratorHelper","_step","s","n","done","entry","value","_getComputedStyle","getComputedStyle","target","height","heightValue","parseInt","setAttribute","concat","err","e","f","observe","disconnect","ui","view","stickyPanel","limiterElement"],"sources":["../../../src/TextEditor/StickyToolbar/useStickyToolbar.ts"],"sourcesContent":["import { useEffect, useRef } from 'react'\n\nimport type { UseStickyToolbarProps } from './useStickyToolbar.types'\n\nexport function useStickyToolbar({\n enabled,\n editor,\n editorRef,\n cssLoading,\n}: UseStickyToolbarProps) {\n const originalLimiterElementRef = useRef<HTMLElement | null>(null)\n\n useEffect(() => {\n if (!editorRef.current || !editor) {\n return\n }\n\n const modal = editorRef.current.closest('[data-id=\"modal\"]')\n if (!modal) {\n return\n }\n\n const modalHeader = modal.querySelector('[data-id=\"modal-header\"]')\n if (!modalHeader) {\n return\n }\n\n const resizeObserver = new ResizeObserver((entries) => {\n for (const entry of entries) {\n const { height } = getComputedStyle(entry.target)\n const heightValue = parseInt(height, 10) - 1\n modal.setAttribute('style', `--modal-header-height: ${heightValue}px`)\n }\n })\n\n resizeObserver.observe(modalHeader)\n return () => resizeObserver.disconnect()\n }, [editorRef, editor])\n\n useEffect(() => {\n if (!editorRef.current || cssLoading || !editor?.ui.view.stickyPanel) {\n return\n }\n\n const stickyPanel = editor.ui.view.stickyPanel\n\n if (!enabled) {\n originalLimiterElementRef.current = stickyPanel.limiterElement\n stickyPanel.limiterElement = null\n } else if (originalLimiterElementRef.current) {\n stickyPanel.limiterElement = originalLimiterElementRef.current\n originalLimiterElementRef.current = null\n }\n }, [enabled, editorRef, editor, cssLoading])\n}\n"],"mappings":";;;AAAA,SAASA,SAAS,EAAEC,MAAM,QAAQ,OAAO;AAIzC,OAAO,SAASC,gBAAgBA,CAAAC,IAAA,EAKN;EAAA,IAJxBC,OAAO,GAAAD,IAAA,CAAPC,OAAO;IACPC,MAAM,GAAAF,IAAA,CAANE,MAAM;IACNC,SAAS,GAAAH,IAAA,CAATG,SAAS;IACTC,UAAU,GAAAJ,IAAA,CAAVI,UAAU;EAEV,IAAMC,y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CAACG,OAAO,IAAIF,UAAU,IAAI,EAACF,MAAM,aAANA,MAAM,eAANA,MAAM,CAAEiC,EAAE,CAACC,IAAI,CAACC,WAAW,GAAE;MACpE;IACF;IAEA,IAAMA,WAAW,GAAGnC,MAAM,CAACiC,EAAE,CAACC,IAAI,CAACC,WAAW;IAE9C,IAAI,CAACpC,OAAO,EAAE;MACZI,yBAAyB,CAACC,OAAO,GAAG+B,WAAW,CAACC,cAAc;MAC9DD,WAAW,CAACC,cAAc,GAAG,IAAI;IACnC,CAAC,MAAM,IAAIjC,yBAAyB,CAACC,OAAO,EAAE;MAC5C+B,WAAW,CAACC,cAAc,GAAGjC,yBAAyB,CAACC,OAAO;MAC9DD,yBAAyB,CAACC,OAAO,GAAG,IAAI;IAC1C;EACF,CAAC,EAAE,CAACL,OAAO,EAAEE,SAAS,EAAED,MAAM,EAAEE,UAAU,CAAC,CAAC;AAC9C"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=useStickyToolbar.types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useStickyToolbar.types.js","names":[],"sources":["../../../src/TextEditor/StickyToolbar/useStickyToolbar.types.ts"],"sourcesContent":["import type { ClassicEditor } from 'ckeditor5'\nimport type { RefObject } from 'react'\n\nexport interface UseStickyToolbarProps {\n enabled: boolean\n editorRef: RefObject<HTMLDivElement>\n editor?: ClassicEditor | null\n cssLoading?: boolean\n}\n"],"mappings":""}
@@ -0,0 +1,226 @@
1
+ function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
2
+ var _excluded = ["disabled", "error", "value", "initialValue", "onChange", "onInit", "onBlur", "onKeyDown", "config", "plugins", "locale", "onDirty", "tinyMCE", "init", "onEditorChange", "onFocusOut"];
3
+ function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
4
+ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
5
+ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
6
+ function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
7
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
8
+ function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
9
+ function _slicedToArray(r, e) { return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _nonIterableRest(); }
10
+ function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
11
+ function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
12
+ function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
13
+ function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t["return"] && (u = t["return"](), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
14
+ function _arrayWithHoles(r) { if (Array.isArray(r)) return r; }
15
+ function _objectWithoutProperties(e, t) { if (null == e) return {}; var o, r, i = _objectWithoutPropertiesLoose(e, t); if (Object.getOwnPropertySymbols) { var n = Object.getOwnPropertySymbols(e); for (r = 0; r < n.length; r++) o = n[r], -1 === t.indexOf(o) && {}.propertyIsEnumerable.call(e, o) && (i[o] = e[o]); } return i; }
16
+ function _objectWithoutPropertiesLoose(r, e) { if (null == r) return {}; var t = {}; for (var n in r) if ({}.hasOwnProperty.call(r, n)) { if (-1 !== e.indexOf(n)) continue; t[n] = r[n]; } return t; }
17
+ import { CKEditor } from '@ckeditor/ckeditor5-react';
18
+ import { ClassicEditor } from 'ckeditor5';
19
+ import React from 'react';
20
+ import { UNSAFE_useOverridableFocusScope, useI18nContext, useZIndexContext } from '@procore/core-react';
21
+ import { useStickyToolbar } from './StickyToolbar';
22
+ import { GlobalEditorStyles, StyledTextEditor } from './TextEditor.styles';
23
+ import { TextEditorContext } from './TextEditorProvider';
24
+ import { TextEditorTheme } from './textEditorTheming';
25
+ import { useCKEditorCss } from './useCKEditorCss';
26
+ import { useTabAsNavigation } from './useTabAsNavigation';
27
+ import { addButtonDataAttributes, addPluginsFromStringArray, getDefaultConfig } from './utils';
28
+
29
+ /**
30
+ * To ensure your Jest tests work with the CKEditor implementation, wrap your Jest configuration with `textEditorJestConfig`:
31
+ *
32
+ * @example
33
+ *
34
+ * // Using Jest config file
35
+ *
36
+ * const { textEditorJestConfig } = require('@procore/text-editor/jestConfig')
37
+ *
38
+ * module.exports = textEditorJestConfig({
39
+ * // Your existing Jest config
40
+ * })
41
+ *
42
+ * @example
43
+ *
44
+ * // Using Hammer
45
+ *
46
+ * import { textEditorJestConfig } from '@procore/text-editor/jestConfig'
47
+ *
48
+ * export default {
49
+ * testJest: (defaultConfig) =>
50
+ * textEditorJestConfig({
51
+ * ...defaultConfig,
52
+ * // Your existing Jest config
53
+ * }),
54
+ * }
55
+ *
56
+ * @example
57
+ *
58
+ * // Using Core Scripts
59
+ *
60
+ * const { textEditorJestConfig } = require('@procore/text-editor/jestConfig')
61
+ *
62
+ * module.exports = () => ({
63
+ * jestOverride: (defaultConfig) =>
64
+ * textEditorJestConfig({
65
+ * ...defaultConfig,
66
+ * // Your existing Jest config
67
+ * }),
68
+ * })
69
+ */
70
+ export function TextEditor(_ref) {
71
+ var disabled = _ref.disabled,
72
+ error = _ref.error,
73
+ value = _ref.value,
74
+ initialValue = _ref.initialValue,
75
+ onChange = _ref.onChange,
76
+ onInit = _ref.onInit,
77
+ onBlur = _ref.onBlur,
78
+ onKeyDown = _ref.onKeyDown,
79
+ externalConfig = _ref.config,
80
+ stringPlugins = _ref.plugins,
81
+ propLocale = _ref.locale,
82
+ onDirty = _ref.onDirty,
83
+ _tinyMCE = _ref.tinyMCE,
84
+ _init = _ref.init,
85
+ _onEditorChange = _ref.onEditorChange,
86
+ _onFocusOut = _ref.onFocusOut,
87
+ restProps = _objectWithoutProperties(_ref, _excluded);
88
+ var _useCKEditorCss = useCKEditorCss(),
89
+ cssLoading = _useCKEditorCss.isLoading;
90
+ var editorRef = React.useRef(null);
91
+ var editorInstanceRef = React.useRef(null);
92
+ var initialValueRef = React.useRef(value || initialValue || '');
93
+ var keyDownListenerRef = React.useRef(null);
94
+ var _React$useState = React.useState(false),
95
+ _React$useState2 = _slicedToArray(_React$useState, 2),
96
+ isDirtyState = _React$useState2[0],
97
+ setIsDirtyState = _React$useState2[1];
98
+ var _React$useState3 = React.useState(false),
99
+ _React$useState4 = _slicedToArray(_React$useState3, 2),
100
+ isEditorReady = _React$useState4[0],
101
+ setIsEditorReady = _React$useState4[1];
102
+ var _useI18nContext = useI18nContext(),
103
+ contextLocale = _useI18nContext.locale;
104
+ var locale = propLocale || contextLocale;
105
+ React.useEffect(function () {
106
+ if (value !== undefined) {
107
+ initialValueRef.current = value;
108
+ }
109
+ }, [value]);
110
+
111
+ // Cleanup keydown listener on unmount
112
+ React.useEffect(function () {
113
+ return function () {
114
+ if (keyDownListenerRef.current && editorInstanceRef.current) {
115
+ editorInstanceRef.current.editing.view.document.off('keydown', keyDownListenerRef.current);
116
+ keyDownListenerRef.current = null;
117
+ }
118
+ };
119
+ }, []);
120
+ var _useZIndexContext = useZIndexContext(),
121
+ zIndex = _useZIndexContext.value;
122
+ var _React$useContext = React.useContext(TextEditorContext),
123
+ features = _React$useContext.features;
124
+ var enableStickyToolbar = !!(features !== null && features !== void 0 && features.stickyToolbar);
125
+ var enableTabAsNavigation = !!(features !== null && features !== void 0 && features.tabAsNavigation);
126
+ var mergedConfig = React.useMemo(function () {
127
+ var defaultConfig = getDefaultConfig(locale);
128
+
129
+ // Handle string plugins for backward compatibility
130
+ var configWithPlugins = stringPlugins !== null && stringPlugins !== void 0 && stringPlugins.length ? addPluginsFromStringArray(defaultConfig, stringPlugins) : defaultConfig;
131
+
132
+ // Apply any external CKEditor config overrides provided by the consumer
133
+ var externalResult = typeof externalConfig === 'function' ? externalConfig(configWithPlugins) : undefined;
134
+ // Merge default config (with plugins) and consumer overrides
135
+ var finalConfig = _objectSpread(_objectSpread({}, configWithPlugins), externalResult !== null && externalResult !== void 0 ? externalResult : {});
136
+ return finalConfig;
137
+ }, [externalConfig, locale, stringPlugins]);
138
+ var focusScope = UNSAFE_useOverridableFocusScope();
139
+ React.useEffect(function () {
140
+ focusScope.setProps({
141
+ contain: false
142
+ });
143
+ }, [focusScope]);
144
+ var bindKeyDownHandler = React.useCallback(function (editor) {
145
+ if (!onKeyDown) {
146
+ return;
147
+ }
148
+ var editorElement = editor.editing.view.document.getRoot();
149
+ if (!editorElement) {
150
+ return;
151
+ }
152
+
153
+ // Remove existing keydown listener
154
+ if (keyDownListenerRef.current) {
155
+ editor.editing.view.document.off('keydown', keyDownListenerRef.current);
156
+ }
157
+
158
+ // Create and store the new listener
159
+ var keyDownListener = function keyDownListener(_event, data) {
160
+ var domEvent = data.domEvent;
161
+ onKeyDown(domEvent, editor);
162
+ };
163
+ keyDownListenerRef.current = keyDownListener;
164
+
165
+ // Add the keydown listener
166
+ editor.editing.view.document.on('keydown', keyDownListener);
167
+ }, [onKeyDown]);
168
+ var handleChange = function handleChange(_event, editor) {
169
+ var data = editor.getData();
170
+ var isDirty = data !== initialValueRef.current;
171
+
172
+ // Call onDirty only on first content modification
173
+ if (isDirty && !isDirtyState) {
174
+ setIsDirtyState(true);
175
+ onDirty === null || onDirty === void 0 ? void 0 : onDirty();
176
+ }
177
+ onChange === null || onChange === void 0 ? void 0 : onChange(data, isDirty);
178
+ };
179
+ var handleReady = function handleReady(editor) {
180
+ addButtonDataAttributes(editor);
181
+ editorInstanceRef.current = editor;
182
+ setIsEditorReady(true);
183
+ if (initialValue) {
184
+ editor.setData(initialValue);
185
+ }
186
+
187
+ // Bind keydown handler when editor is ready
188
+ bindKeyDownHandler(editor);
189
+ onInit === null || onInit === void 0 ? void 0 : onInit(editor);
190
+ };
191
+ var handleBlur = function handleBlur(event, editor) {
192
+ onBlur === null || onBlur === void 0 ? void 0 : onBlur(event, editor);
193
+ };
194
+ useStickyToolbar({
195
+ enabled: enableStickyToolbar,
196
+ editor: isEditorReady ? editorInstanceRef.current : null,
197
+ editorRef: editorRef,
198
+ cssLoading: cssLoading
199
+ });
200
+ var _useTabAsNavigation = useTabAsNavigation({
201
+ config: mergedConfig,
202
+ enabled: enableTabAsNavigation,
203
+ editor: isEditorReady ? editorInstanceRef.current : null
204
+ }),
205
+ config = _useTabAsNavigation.config;
206
+ var editorKey = "".concat(locale, "-").concat(enableTabAsNavigation);
207
+ if (cssLoading) {
208
+ return null;
209
+ }
210
+ return /*#__PURE__*/React.createElement(StyledTextEditor, {
211
+ ref: editorRef,
212
+ key: editorKey,
213
+ error: error
214
+ }, /*#__PURE__*/React.createElement(GlobalEditorStyles, {
215
+ zIndex: zIndex + 1
216
+ }), /*#__PURE__*/React.createElement(TextEditorTheme, null), /*#__PURE__*/React.createElement(CKEditor, _extends({}, restProps, {
217
+ editor: ClassicEditor,
218
+ config: config,
219
+ disabled: disabled,
220
+ data: value,
221
+ onChange: handleChange,
222
+ onReady: handleReady,
223
+ onBlur: handleBlur
224
+ })));
225
+ }
226
+ //# sourceMappingURL=TextEditor.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"TextEditor.js","names":["CKEditor","ClassicEditor","React","UNSAFE_useOverridableFocusScope","useI18nContext","useZIndexContext","useStickyToolbar","GlobalEditorStyles","StyledTextEditor","TextEditorContext","TextEditorTheme","useCKEditorCss","useTabAsNavigation","addButtonDataAttributes","addPluginsFromStringArray","getDefaultConfig","TextEditor","_ref","disabled","error","value","initialValue","onChange","onInit","onBlur","onKeyDown","externalConfig","config","stringPlugins","plugins","propLocale","locale","onDirty","_tinyMCE","tinyMCE","_init","init","_onEditorChange","onEditorChange","_onFocusOut","onFocusOut","restProps","_objectWithoutProperties","_excluded","_useCKEditorCss","cssLoading","isLoading","editorRef","useRef","editorInstanceRef","initialValueRef","keyDownListenerRef","_React$useState","useState","_React$useState2","_slicedToArray","isDirtyState","setIsDirtyState","_React$useState3","_React$useState4","isEditorReady","setIsEditorReady","_useI18nContext","contextLocale","useEffect","undefined","current","editing","view","document","off","_useZIndexContext","zIndex","_React$useContext","useContext","features","enableStickyToolbar","stickyToolbar","enableTabAsNavigation","tabAsNavigation","mergedConfig","useMemo","defaultConfig","configWithPlugins","length","externalResult","finalConfig","_objectSpread","focusScope","setProps","contain","bindKeyDownHandler","useCallback","editor","editorElement","getRoot","keyDownListener","_event","data","domEvent","on","handleChange","getData","isDirty","handleReady","setData","handleBlur","event","enabled","_useTabAsNavigation","editorKey","concat","createElement","ref","key","_extends","onReady"],"sources":["../../src/TextEditor/TextEditor.tsx"],"sourcesContent":["import { CKEditor } from '@ckeditor/ckeditor5-react'\nimport type { EditorConfig } from 'ckeditor5'\nimport { ClassicEditor, type EventInfo } from 'ckeditor5'\nimport React from 'react'\n\nimport {\n UNSAFE_useOverridableFocusScope,\n useI18nContext,\n useZIndexContext,\n} from '@procore/core-react'\nimport { useStickyToolbar } from './StickyToolbar'\nimport { GlobalEditorStyles, StyledTextEditor } from './TextEditor.styles'\nimport type { KeyDownListener, TextEditorProps } from './TextEditor.types'\nimport { TextEditorContext } from './TextEditorProvider'\nimport { TextEditorTheme } from './textEditorTheming'\nimport { useCKEditorCss } from './useCKEditorCss'\nimport { useTabAsNavigation } from './useTabAsNavigation'\nimport {\n addButtonDataAttributes,\n addPluginsFromStringArray,\n getDefaultConfig,\n} from './utils'\n\n/**\n * To ensure your Jest tests work with the CKEditor implementation, wrap your Jest configuration with `textEditorJestConfig`:\n *\n * @example\n *\n * // Using Jest config file\n *\n * const { textEditorJestConfig } = require('@procore/text-editor/jestConfig')\n *\n * module.exports = textEditorJestConfig({\n * // Your existing Jest config\n * })\n *\n * @example\n *\n * // Using Hammer\n *\n * import { textEditorJestConfig } from '@procore/text-editor/jestConfig'\n *\n * export default {\n * testJest: (defaultConfig) =>\n * textEditorJestConfig({\n * ...defaultConfig,\n * // Your existing Jest config\n * }),\n * }\n *\n * @example\n *\n * // Using Core Scripts\n *\n * const { textEditorJestConfig } = require('@procore/text-editor/jestConfig')\n *\n * module.exports = () => ({\n * jestOverride: (defaultConfig) =>\n * textEditorJestConfig({\n * ...defaultConfig,\n * // Your existing Jest config\n * }),\n * })\n */\nexport function TextEditor({\n disabled,\n error,\n value,\n initialValue,\n onChange,\n onInit,\n onBlur,\n onKeyDown,\n config: externalConfig,\n plugins: stringPlugins,\n locale: propLocale,\n onDirty,\n // Deprecated TinyMCE props - no-op for backward compatibility\n tinyMCE: _tinyMCE,\n init: _init,\n onEditorChange: _onEditorChange,\n onFocusOut: _onFocusOut,\n ...restProps\n}: TextEditorProps) {\n const { isLoading: cssLoading } = useCKEditorCss()\n\n const editorRef = React.useRef<HTMLDivElement>(null)\n const editorInstanceRef = React.useRef<ClassicEditor | null>(null)\n const initialValueRef = React.useRef<string>(value || initialValue || '')\n const keyDownListenerRef = React.useRef<KeyDownListener | null>(null)\n const [isDirtyState, setIsDirtyState] = React.useState(false)\n const [isEditorReady, setIsEditorReady] = React.useState(false)\n const { locale: contextLocale } = useI18nContext()\n const locale = propLocale || contextLocale\n\n React.useEffect(() => {\n if (value !== undefined) {\n initialValueRef.current = value\n }\n }, [value])\n\n // Cleanup keydown listener on unmount\n React.useEffect(() => {\n return () => {\n if (keyDownListenerRef.current && editorInstanceRef.current) {\n editorInstanceRef.current.editing.view.document.off(\n 'keydown',\n keyDownListenerRef.current\n )\n keyDownListenerRef.current = null\n }\n }\n }, [])\n\n const { value: zIndex } = useZIndexContext()\n\n const { features } = React.useContext(TextEditorContext)\n const enableStickyToolbar = !!features?.stickyToolbar\n const enableTabAsNavigation = !!features?.tabAsNavigation\n\n const mergedConfig = React.useMemo(() => {\n const defaultConfig = getDefaultConfig(locale)\n\n // Handle string plugins for backward compatibility\n const configWithPlugins = stringPlugins?.length\n ? addPluginsFromStringArray(defaultConfig, stringPlugins)\n : defaultConfig\n\n // Apply any external CKEditor config overrides provided by the consumer\n const externalResult =\n typeof externalConfig === 'function'\n ? externalConfig(configWithPlugins)\n : undefined\n // Merge default config (with plugins) and consumer overrides\n let finalConfig: EditorConfig = {\n ...configWithPlugins,\n ...(externalResult ?? {}),\n }\n\n return finalConfig\n }, [externalConfig, locale, stringPlugins])\n\n const focusScope = UNSAFE_useOverridableFocusScope()\n React.useEffect(() => {\n focusScope.setProps({ contain: false })\n }, [focusScope])\n\n const bindKeyDownHandler = React.useCallback(\n (editor: ClassicEditor) => {\n if (!onKeyDown) {\n return\n }\n\n const editorElement = editor.editing.view.document.getRoot()\n if (!editorElement) {\n return\n }\n\n // Remove existing keydown listener\n if (keyDownListenerRef.current) {\n editor.editing.view.document.off('keydown', keyDownListenerRef.current)\n }\n\n // Create and store the new listener\n const keyDownListener = (\n _event: EventInfo,\n data: { domEvent: Event }\n ) => {\n const domEvent = data.domEvent as KeyboardEvent\n onKeyDown(domEvent, editor)\n }\n\n keyDownListenerRef.current = keyDownListener\n\n // Add the keydown listener\n editor.editing.view.document.on('keydown', keyDownListener)\n },\n [onKeyDown]\n )\n\n const handleChange = (\n _event: EventInfo<string, unknown>,\n editor: ClassicEditor\n ) => {\n const data = editor.getData()\n const isDirty = data !== initialValueRef.current\n\n // Call onDirty only on first content modification\n if (isDirty && !isDirtyState) {\n setIsDirtyState(true)\n onDirty?.()\n }\n\n onChange?.(data, isDirty)\n }\n\n const handleReady = (editor: ClassicEditor) => {\n addButtonDataAttributes(editor)\n editorInstanceRef.current = editor\n setIsEditorReady(true)\n\n if (initialValue) {\n editor.setData(initialValue)\n }\n\n // Bind keydown handler when editor is ready\n bindKeyDownHandler(editor)\n\n onInit?.(editor)\n }\n\n const handleBlur = (\n event: EventInfo<string, unknown>,\n editor: ClassicEditor\n ) => {\n onBlur?.(event, editor)\n }\n\n useStickyToolbar({\n enabled: enableStickyToolbar,\n editor: isEditorReady ? editorInstanceRef.current : null,\n editorRef,\n cssLoading,\n })\n\n const { config } = useTabAsNavigation({\n config: mergedConfig,\n enabled: enableTabAsNavigation,\n editor: isEditorReady ? editorInstanceRef.current : null,\n })\n\n const editorKey = `${locale}-${enableTabAsNavigation}`\n\n if (cssLoading) {\n return null\n }\n\n return (\n <StyledTextEditor ref={editorRef} key={editorKey} error={error}>\n <GlobalEditorStyles zIndex={zIndex + 1} />\n <TextEditorTheme />\n <CKEditor\n {...restProps}\n editor={ClassicEditor}\n config={config}\n disabled={disabled}\n data={value}\n onChange={handleChange}\n onReady={handleReady}\n onBlur={handleBlur}\n />\n </StyledTextEditor>\n )\n}\n"],"mappings":";;;;;;;;;;;;;;;;AAAA,SAASA,QAAQ,QAAQ,2BAA2B;AAEpD,SAASC,aAAa,QAAwB,WAAW;AACzD,OAAOC,KAAK,MAAM,OAAO;AAEzB,SACEC,+BAA+B,EAC/BC,cAAc,EACdC,gBAAgB,QACX,qBAAqB;AAC5B,SAASC,gBAAgB,QAAQ,iBAAiB;AAClD,SAASC,kBAAkB,EAAEC,gBAAgB,QAAQ,qBAAqB;AAE1E,SAASC,iBAAiB,QAAQ,sBAAsB;AACxD,SAASC,eAAe,QAAQ,qBAAqB;AACrD,SAASC,cAAc,QAAQ,kBAAkB;AACjD,SAASC,kBAAkB,QAAQ,sBAAsB;AACzD,SACEC,uBAAuB,EACvBC,yBAAyB,EACzBC,gBAAgB,QACX,SAAS;;AAEhB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,UAAUA,CAAAC,IAAA,EAmBN;EAAA,IAlBlBC,QAAQ,GAAAD,IAAA,CAARC,QAAQ;IACRC,KAAK,GAAAF,IAAA,CAALE,KAAK;IACLC,KAAK,GAAAH,IAAA,CAALG,KAAK;IACLC,YAAY,GAAAJ,IAAA,CAAZI,YAAY;IACZC,QAAQ,GAAAL,IAAA,CAARK,QAAQ;IACRC,MAAM,GAAAN,IAAA,CAANM,MAAM;IACNC,MAAM,GAAAP,IAAA,CAANO,MAAM;IACNC,SAAS,GAAAR,IAAA,CAAT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A,GAAmBjG,kBAAkB,CAAC;MACpCe,MAAM,EAAEqD,YAAY;MACpB4B,OAAO,EAAE9B,qBAAqB;MAC9Be,MAAM,EAAEjC,aAAa,GAAGX,iBAAiB,CAACiB,OAAO,GAAG;IACtD,CAAC,CAAC;IAJMvC,MAAM,GAAAkF,mBAAA,CAANlF,MAAM;EAMd,IAAMmF,SAAS,MAAAC,MAAA,CAAMhF,MAAM,OAAAgF,MAAA,CAAIjC,qBAAqB,CAAE;EAEtD,IAAIjC,UAAU,EAAE;IACd,OAAO,IAAI;EACb;EAEA,oBACE3C,KAAA,CAAA8G,aAAA,CAACxG,gBAAgB;IAACyG,GAAG,EAAElE,SAAU;IAACmE,GAAG,EAAEJ,SAAU;IAAC3F,KAAK,EAAEA;EAAM,gBAC7DjB,KAAA,CAAA8G,aAAA,CAACzG,kBAAkB;IAACiE,MAAM,EAAEA,MAAM,GAAG;EAAE,CAAE,CAAC,eAC1CtE,KAAA,CAAA8G,aAAA,CAACtG,eAAe,MAAE,CAAC,eACnBR,KAAA,CAAA8G,aAAA,CAAChH,QAAQ,EAAAmH,QAAA,KACH1E,SAAS;IACboD,MAAM,EAAE5F,aAAc;IACtB0B,MAAM,EAAEA,MAAO;IACfT,QAAQ,EAAEA,QAAS;IACnBgF,IAAI,EAAE9E,KAAM;IACZE,QAAQ,EAAE+E,YAAa;IACvBe,OAAO,EAAEZ,WAAY;IACrBhF,MAAM,EAAEkF;EAAW,EACpB,CACe,CAAC;AAEvB"}
@@ -0,0 +1,26 @@
1
+ import { colors } from '@procore/core-react';
2
+ import styled, { createGlobalStyle } from 'styled-components';
3
+ export var GlobalEditorStyles = /*#__PURE__*/createGlobalStyle([":root{--ck-z-default:", ";--ck-z-modal:", ";}.ck-body-wrapper{--ck-z-default:", ";--ck-z-modal:", ";}.ck-balloon-panel{z-index:", " !important;}.ck-content{padding:16px 28px !important;font-family:-apple-system,BlinkMacSystemFont,\"Segoe UI\",Roboto,Oxygen,Ubuntu,Cantarell,\"Open Sans\",\"Helvetica Neue\",sans-serif;line-height:1.4;p{margin-top:0 !important;margin-bottom:0 !important;}ol,ol ol,ol ol ol{list-style-type:revert-layer;}}[data-id=\"modal\"] .ck-sticky-panel__content_sticky{top:var(--modal-header-height,84px) !important;}"], function (_ref) {
4
+ var zIndex = _ref.zIndex;
5
+ return zIndex;
6
+ }, function (_ref2) {
7
+ var zIndex = _ref2.zIndex;
8
+ return zIndex + 999;
9
+ }, function (_ref3) {
10
+ var zIndex = _ref3.zIndex;
11
+ return zIndex;
12
+ }, function (_ref4) {
13
+ var zIndex = _ref4.zIndex;
14
+ return zIndex + 999;
15
+ }, function (_ref5) {
16
+ var zIndex = _ref5.zIndex;
17
+ return zIndex + 1000;
18
+ });
19
+ export var StyledTextEditor = /*#__PURE__*/styled.div.withConfig({
20
+ displayName: "StyledTextEditor",
21
+ componentId: "text-editor-0_0_1__sc-iim79x-0"
22
+ })(["", ""], function (_ref6) {
23
+ var error = _ref6.error;
24
+ return error && "\n .ck-sticky-panel__content {\n border-top-color: ".concat(colors.red50, " !important;\n border-left-color: ").concat(colors.red50, " !important;\n border-right-color: ").concat(colors.red50, " !important;\n }\n\n .ck-editor__editable {\n border-left-color: ").concat(colors.red50, " !important;\n border-right-color: ").concat(colors.red50, " !important;\n border-bottom-color: ").concat(colors.red50, " !important;\n }\n ");
25
+ });
26
+ //# sourceMappingURL=TextEditor.styles.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"TextEditor.styles.js","names":["colors","styled","createGlobalStyle","GlobalEditorStyles","_ref","zIndex","_ref2","_ref3","_ref4","_ref5","StyledTextEditor","div","withConfig","displayName","componentId","_ref6","error","concat","red50"],"sources":["../../src/TextEditor/TextEditor.styles.ts"],"sourcesContent":["import { colors } from '@procore/core-react'\nimport styled, { createGlobalStyle } from 'styled-components'\n\nexport const GlobalEditorStyles = createGlobalStyle<{\n zIndex: number\n}>`\n :root {\n --ck-z-default: ${({ zIndex }) => zIndex};\n --ck-z-modal: ${({ zIndex }) => zIndex + 999};\n }\n \n .ck-body-wrapper {\n --ck-z-default: ${({ zIndex }) => zIndex};\n --ck-z-modal: ${({ zIndex }) => zIndex + 999};\n }\n \n .ck-balloon-panel {\n z-index: ${({ zIndex }) => zIndex + 1000} !important;\n }\n\n .ck-content {\n padding: 16px 28px !important;\n font-family:\n -apple-system,\n BlinkMacSystemFont,\n \"Segoe UI\",\n Roboto,\n Oxygen,\n Ubuntu,\n Cantarell,\n \"Open Sans\",\n \"Helvetica Neue\",\n sans-serif;\n line-height: 1.4;\n\n p {\n margin-top: 0 !important;\n margin-bottom: 0 !important;\n }\n\n ol,\n ol ol,\n ol ol ol {\n list-style-type: revert-layer;\n }\n }\n\n [data-id=\"modal\"] .ck-sticky-panel__content_sticky {\n top: var(--modal-header-height, 84px) !important;\n }\n`\n\nexport const StyledTextEditor = styled.div<{\n error?: boolean\n}>`\n ${({ error }) =>\n error &&\n `\n .ck-sticky-panel__content {\n border-top-color: ${colors.red50} !important;\n border-left-color: ${colors.red50} !important;\n border-right-color: ${colors.red50} !important;\n }\n\n .ck-editor__editable {\n border-left-color: ${colors.red50} !important;\n border-right-color: ${colors.red50} !important;\n border-bottom-color: ${colors.red50} !important;\n }\n `}\n`\n"],"mappings":"AAAA,SAASA,MAAM,QAAQ,qBAAqB;AAC5C,OAAOC,MAAM,IAAIC,iBAAiB,QAAQ,mBAAmB;AAE7D,OAAO,IAAMC,kBAAkB,gBAAGD,iBAAiB,iiBAI7B,UAAAE,IAAA;EAAA,IAAGC,MAAM,GAAAD,IAAA,CAANC,MAAM;EAAA,OAAOA,MAAM;AAAA,GACxB,UAAAC,KAAA;EAAA,IAAGD,MAAM,GAAAC,KAAA,CAAND,MAAM;EAAA,OAAOA,MAAM,GAAG,GAAG;AAAA,GAI1B,UAAAE,KAAA;EAAA,IAAGF,MAAM,GAAAE,KAAA,CAANF,MAAM;EAAA,OAAOA,MAAM;AAAA,GACxB,UAAAG,KAAA;EAAA,IAAGH,MAAM,GAAAG,KAAA,CAANH,MAAM;EAAA,OAAOA,MAAM,GAAG,GAAG;AAAA,GAIjC,UAAAI,KAAA;EAAA,IAAGJ,MAAM,GAAAI,KAAA,CAANJ,MAAM;EAAA,OAAOA,MAAM,GAAG,IAAI;AAAA,EAiC3C;AAED,OAAO,IAAMK,gBAAgB,gBAAGT,MAAM,CAACU,GAAG,CAAAC,UAAA;EAAAC,WAAA;EAAAC,WAAA;AAAA,aAGtC,UAAAC,KAAA;EAAA,IAAGC,KAAK,GAAAD,KAAA,CAALC,KAAK;EAAA,OACRA,KAAK,sEAAAC,MAAA,CAGmBjB,MAAM,CAACkB,KAAK,+CAAAD,MAAA,CACXjB,MAAM,CAACkB,KAAK,gDAAAD,MAAA,CACXjB,MAAM,CAACkB,KAAK,wFAAAD,MAAA,CAIbjB,MAAM,CAACkB,KAAK,gDAAAD,MAAA,CACXjB,MAAM,CAACkB,KAAK,iDAAAD,MAAA,CACXjB,MAAM,CAACkB,KAAK,gCAEtC;AAAA,EACJ"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=TextEditor.types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"TextEditor.types.js","names":[],"sources":["../../src/TextEditor/TextEditor.types.ts"],"sourcesContent":["import type { Locale } from '@procore/core-react'\nimport type { ClassicEditor, EditorConfig, EventInfo } from 'ckeditor5'\n\nexport interface TextEditorProps {\n /**\n * Unique identifier for the editor\n *\n * @since 10.19.0\n */\n id?: string\n\n /**\n * Initial value of the editor\n *\n * @deprecated `initialValue` has been deprecated and will be removed in a future version.\n * Please use the `value` prop instead\n * @deprecatedSince 10.20.0\n * @since 10.19.0\n */\n initialValue?: string\n\n /**\n * The current value of the editor\n *\n * @since 10.19.0\n */\n value?: string\n\n /**\n * Indicates if the editor is disabled\n *\n * @since 10.19.0\n */\n disabled?: boolean\n\n /**\n * Indicates if the editor is in an error state\n *\n * @since 10.19.0\n */\n error?: boolean\n\n /**\n * Locale which will be used for localization. Can be passed directly or\n * set by wrapping components in I18n provider.\n * @since 10.19.0\n */\n locale?: Locale\n\n /**\n * Array of plugin names to add to the editor in addition to the defaults.\n * This provides backward compatibility with the deprecated TinyMCE version of the editor.\n * Supports plugin names like 'link', 'image', 'table', etc.\n *\n * @since 12.26.0\n */\n plugins?: string[]\n\n /**\n * Configuration function for customizing the editor\n *\n * @param defaultConfig - The default CKEditor configuration\n * @returns Customized configuration object\n * @since 12.26.0\n */\n config?: (defaultConfig: EditorConfig) => EditorConfig\n\n /**\n * Callback fired when the editor content changes\n *\n * @param value - The current content of the editor\n * @param isDirty - Whether the content differs from the initial value\n * @since 10.19.0\n */\n onChange?: (value: string, isDirty?: boolean) => void\n\n /**\n * Callback fired when the editor gains focus\n *\n * @since 10.19.0\n */\n onFocus?: (event: EventInfo, editor: ClassicEditor) => void\n\n /**\n * Callback fired when the editor loses focus\n *\n * @since 10.19.0\n */\n onBlur?: (event: EventInfo, editor: ClassicEditor) => void\n\n /**\n * Callback fired when an error occurs in the editor\n *\n * @since 10.19.0\n */\n onError?: (\n error: Error,\n details: {\n phase: 'initialization' | 'runtime'\n willEditorRestart?: boolean\n }\n ) => void\n\n /**\n * Callback fired when the editor is ready\n *\n * @since 10.19.0\n */\n onInit?: (editor: ClassicEditor) => void\n\n /**\n * Callback fired after the editor instance is destroyed\n *\n * @since 10.19.0\n */\n onAfterDestroy?: () => void\n\n /**\n * Callback fired when the editor becomes dirty (content differs from initial value)\n *\n * @since 12.26.0\n */\n onDirty?: () => void\n\n /**\n * Callback fired when a key is pressed in the editor\n *\n * @param event - The keyboard event\n * @param editor - The CKEditor instance\n * @since 12.29.0\n */\n onKeyDown?: (event: KeyboardEvent, editor: ClassicEditor) => void\n\n //--- Deprecated TinyMCE-specific props\n\n /**\n * If you experience problems with the new editor implementation, you can use this to **temporarily** switch back to legacy version while you report the issue.\n *\n * @deprecated This property will be removed in a future version. TinyMCE support has been removed.\n * @since 10.19.0\n */\n tinyMCE?: boolean\n\n /**\n * Config for when the editor is initialized. **Changes after the editor has initialized are ignored.**\n *\n * @link [TinyMCE React Init](https://www.tiny.cloud/docs/integrations/react/#init)\n * @unsupported Use at your own risk. DST makes no guarantees about this API,\n * and is subject to removal at any point without warning or deprecation.\n * @deprecated `init` has been deprecated and will be removed in a future version. TinyMCE support has been removed.\n * @since 10.19.0\n */\n init?: any\n\n /**\n * Callback fired when the editor content changes\n *\n * @deprecated `onEditorChange` has been deprecated and will be removed in a future version. TinyMCE support has been removed. Use `onChange` instead.\n * @since 10.19.0\n */\n onEditorChange?: (value: string) => void\n\n /**\n * Callback fired when the editor gains focus\n *\n * @deprecated `onFocusIn` has been deprecated and will be removed in a future version. TinyMCE support has been removed. Use `onFocus` instead.\n * @since 10.19.0\n */\n onFocusIn?: (...args: any[]) => void\n\n /**\n * Callback fired when the editor loses focus\n *\n * @deprecated `onFocusOut` has been deprecated and will be removed in a future version. TinyMCE support has been removed. Use `onBlur` instead.\n * @since 10.19.0\n */\n onFocusOut?: (...args: any[]) => void\n}\n\nexport type KeyDownListener = (\n event: EventInfo,\n data: { domEvent: Event }\n) => void\n"],"mappings":""}