@procore/text-editor 0.0.3 → 0.1.0

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/CHANGELOG.md CHANGED
@@ -1,5 +1,12 @@
1
1
  # @procore/text-editor
2
2
 
3
+ ## 0.1.0
4
+
5
+ ### Minor Changes
6
+
7
+ - New toolbar defaults. Remove `plugins` and `config` props to rely on the TextEditor package's default internal configuration.
8
+ - Add Enter key `stopPropagation` to prevent form submission when pressing Enter in the editor.
9
+
3
10
  ## 0.0.3
4
11
 
5
12
  ### Patch Changes
package/README.md CHANGED
@@ -10,7 +10,7 @@ yarn add @procore/text-editor
10
10
 
11
11
  ## Usage
12
12
 
13
- ### Basic Usage
13
+ ### TextEditor Usage
14
14
 
15
15
  ```tsx
16
16
  import { TextEditor } from '@procore/text-editor'
@@ -27,27 +27,6 @@ function MyComponent() {
27
27
  }
28
28
  ```
29
29
 
30
- ### With Custom Configuration
31
-
32
- ```tsx
33
- import { TextEditor } from '@procore/text-editor'
34
-
35
- function MyComponent() {
36
- const [value, setValue] = React.useState('')
37
-
38
- return (
39
- <TextEditor
40
- value={value}
41
- onChange={(newValue) => setValue(newValue)}
42
- plugins={['link', 'table']}
43
- config={(defaultConfig) => ({
44
- ...defaultConfig,
45
- // Your custom CKEditor configuration
46
- })}
47
- />
48
- )
49
- }
50
- ```
51
30
 
52
31
  ### TextEditorProvider
53
32
 
@@ -1,4 +1,4 @@
1
- import { Form } from '@procore/core-react'
1
+ import { Form, TextEditor } from '@procore/core-react'
2
2
  import React from 'react'
3
3
 
4
4
  export const MultilineFormRichText = () => {
@@ -9,6 +9,7 @@ export const MultilineFormRichText = () => {
9
9
  label="Description"
10
10
  plugins={['table']}
11
11
  />
12
+ <TextEditor value="notes" plugins={['links']} />
12
13
  </Form>
13
14
  )
14
15
  }
@@ -9,6 +9,7 @@
9
9
  * 2. Updates Form.RichText usage to include textEditorComponent prop
10
10
  * 3. Updates Jest configuration to use textEditorJestConfig
11
11
  * 4. Adds ckeditor5 singleton to module federation shared config
12
+ * 5. Remove deprecated plugins prop from TextEditor and Form.RichText components
12
13
  */
13
14
 
14
15
  const fs = require('fs')
@@ -168,6 +169,52 @@ function transformImports(fileContent) {
168
169
  return { content: newContent, modified, needsTextEditorImport }
169
170
  }
170
171
 
172
+ /**
173
+ * Remove deprecated plugins prop from TextEditor and Form.RichText components
174
+ */
175
+ function removeDeprecatedProps(fileContent) {
176
+ let modified = false
177
+ let newContent = fileContent
178
+
179
+ // Pattern to match TextEditor components with plugins prop
180
+ const textEditorRegex = /(<TextEditor)([\s\S]*?)(\/>|>)/g
181
+ newContent = newContent.replace(
182
+ textEditorRegex,
183
+ (match, opening, props, closing) => {
184
+ let updatedProps = props
185
+ const hasPlugins = props.includes('plugins=')
186
+
187
+ if (hasPlugins) {
188
+ // Remove plugins prop
189
+ updatedProps = updatedProps.replace(/\s*plugins\s*=\s*\{[^}]*\}/g, '')
190
+ modified = true
191
+ }
192
+
193
+ return opening + updatedProps + closing
194
+ }
195
+ )
196
+
197
+ // Pattern to match Form.RichText components with plugins prop
198
+ const formRichTextRegex = /(<Form\.RichText(?:Field)?)([\s\S]*?)(\/>|>)/g
199
+ newContent = newContent.replace(
200
+ formRichTextRegex,
201
+ (match, opening, props, closing) => {
202
+ let updatedProps = props
203
+ const hasPlugins = props.includes('plugins=')
204
+
205
+ if (hasPlugins) {
206
+ // Remove plugins prop
207
+ updatedProps = updatedProps.replace(/\s*plugins\s*=\s*\{[^}]*\}/g, '')
208
+ modified = true
209
+ }
210
+
211
+ return opening + updatedProps + closing
212
+ }
213
+ )
214
+
215
+ return { content: newContent, modified }
216
+ }
217
+
171
218
  /**
172
219
  * Transform Form.RichText usage
173
220
  */
@@ -692,6 +739,13 @@ function processFile(filePath) {
692
739
  newContent = formResult.content
693
740
  wasModified = true
694
741
  }
742
+
743
+ // Remove deprecated plugins prop
744
+ const deprecatedPropsResult = removeDeprecatedProps(newContent)
745
+ if (deprecatedPropsResult.modified) {
746
+ newContent = deprecatedPropsResult.content
747
+ wasModified = true
748
+ }
695
749
  }
696
750
 
697
751
  // Write back if modified
@@ -129,6 +129,15 @@ describe('text-editor-migrate codemod', () => {
129
129
  expect(content).not.toContain('textEditorComponent={TextEditor}')
130
130
  expect(content).not.toContain('@procore/text-editor')
131
131
  })
132
+
133
+ it('should remove deprecated plugins prop from Form.RichText', () => {
134
+ execFileSync('node', [codemodPath, testDir], { stdio: 'ignore' })
135
+
136
+ const content = readFile('src/components/MultilineFormRichText.tsx')
137
+
138
+ expect(content).not.toContain('plugins=')
139
+ expect(content).toContain('textEditorComponent={TextEditor}')
140
+ })
132
141
  })
133
142
 
134
143
  describe('Jest configuration transformations', () => {
@@ -41,4 +41,4 @@ import type { TextEditorProps } from './TextEditor.types';
41
41
  * }),
42
42
  * })
43
43
  */
44
- export declare function TextEditor({ disabled, error, value, initialValue, onChange, onInit, onBlur, onKeyDown, config: externalConfig, plugins: stringPlugins, locale: propLocale, onDirty, ...restProps }: TextEditorProps): React.JSX.Element | null;
44
+ export declare function TextEditor(props: Readonly<TextEditorProps>): React.JSX.Element | null;
@@ -1,11 +1,5 @@
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"];
1
+ var _excluded = ["disabled", "error", "value", "initialValue", "onChange", "onInit", "onBlur", "onKeyDown", "locale", "onDirty"];
3
2
  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
3
  function _slicedToArray(r, e) { return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _nonIterableRest(); }
10
4
  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
5
  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; } }
@@ -24,7 +18,7 @@ import { TextEditorContext } from './TextEditorProvider';
24
18
  import { TextEditorTheme } from './textEditorTheming';
25
19
  import { useCKEditorCss } from './useCKEditorCss';
26
20
  import { useTabAsNavigation } from './useTabAsNavigation';
27
- import { addButtonDataAttributes, addPluginsFromStringArray, getDefaultConfig } from './utils';
21
+ import { addButtonDataAttributes, getDefaultConfig } from './utils';
28
22
 
29
23
  /**
30
24
  * To ensure your Jest tests work with the CKEditor implementation, wrap your Jest configuration with `textEditorJestConfig`:
@@ -67,20 +61,20 @@ import { addButtonDataAttributes, addPluginsFromStringArray, getDefaultConfig }
67
61
  * }),
68
62
  * })
69
63
  */
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
- restProps = _objectWithoutProperties(_ref, _excluded);
64
+ export function TextEditor(props) {
65
+ var disabled = props.disabled,
66
+ error = props.error,
67
+ value = props.value,
68
+ initialValue = props.initialValue,
69
+ onChange = props.onChange,
70
+ onInit = props.onInit,
71
+ onBlur = props.onBlur,
72
+ onKeyDown = props.onKeyDown,
73
+ propLocale = props.locale,
74
+ onDirty = props.onDirty,
75
+ restProps = _objectWithoutProperties(props, _excluded);
76
+ var ariaLabel = props['aria-label'];
77
+ var ariaDescription = props['aria-description'];
84
78
  var _useCKEditorCss = useCKEditorCss(),
85
79
  cssLoading = _useCKEditorCss.isLoading;
86
80
  var editorRef = React.useRef(null);
@@ -113,6 +107,42 @@ export function TextEditor(_ref) {
113
107
  }
114
108
  };
115
109
  }, []);
110
+
111
+ // Update aria-label when ariaLabel prop changes
112
+ React.useEffect(function () {
113
+ if (!isEditorReady || !editorInstanceRef.current) {
114
+ return;
115
+ }
116
+ var editor = editorInstanceRef.current;
117
+ editor.editing.view.change(function (writer) {
118
+ var viewEditableRoot = editor.editing.view.document.getRoot();
119
+ if (viewEditableRoot) {
120
+ if (ariaLabel) {
121
+ writer.setAttribute('aria-label', ariaLabel, viewEditableRoot);
122
+ } else {
123
+ writer.removeAttribute('aria-label', viewEditableRoot);
124
+ }
125
+ }
126
+ });
127
+ }, [ariaLabel, isEditorReady]);
128
+
129
+ // Update aria-description when ariaDescription prop changes
130
+ React.useEffect(function () {
131
+ if (!isEditorReady || !editorInstanceRef.current) {
132
+ return;
133
+ }
134
+ var editor = editorInstanceRef.current;
135
+ editor.editing.view.change(function (writer) {
136
+ var viewEditableRoot = editor.editing.view.document.getRoot();
137
+ if (viewEditableRoot) {
138
+ if (ariaDescription) {
139
+ writer.setAttribute('aria-description', ariaDescription, viewEditableRoot);
140
+ } else {
141
+ writer.removeAttribute('aria-description', viewEditableRoot);
142
+ }
143
+ }
144
+ });
145
+ }, [ariaDescription, isEditorReady]);
116
146
  var _useZIndexContext = useZIndexContext(),
117
147
  zIndex = _useZIndexContext.value;
118
148
  var _React$useContext = React.useContext(TextEditorContext),
@@ -122,19 +152,14 @@ export function TextEditor(_ref) {
122
152
  var mergedConfig = React.useMemo(function () {
123
153
  var defaultConfig = getDefaultConfig(locale);
124
154
 
125
- // Handle string plugins for backward compatibility
126
- var configWithPlugins = stringPlugins !== null && stringPlugins !== void 0 && stringPlugins.length ? addPluginsFromStringArray(defaultConfig, stringPlugins) : defaultConfig;
127
-
128
- // Apply any external CKEditor config overrides provided by the consumer
129
- var externalResult = typeof externalConfig === 'function' ? externalConfig(configWithPlugins) : undefined;
130
- // Merge default config (with plugins) and consumer overrides
131
- var finalConfig = _objectSpread(_objectSpread({}, configWithPlugins), externalResult !== null && externalResult !== void 0 ? externalResult : {});
132
- return finalConfig;
133
- }, [externalConfig, locale, stringPlugins]);
134
- var bindKeyDownHandler = React.useCallback(function (editor) {
135
- if (!onKeyDown) {
136
- return;
155
+ // Set accessible label for the editable area if provided
156
+ // This is used by screen readers to announce the editor's purpose
157
+ if (ariaLabel) {
158
+ defaultConfig.label = ariaLabel;
137
159
  }
160
+ return defaultConfig;
161
+ }, [ariaLabel, locale]);
162
+ var bindKeyDownHandler = React.useCallback(function (editor) {
138
163
  var editorElement = editor.editing.view.document.getRoot();
139
164
  if (!editorElement) {
140
165
  return;
@@ -148,7 +173,12 @@ export function TextEditor(_ref) {
148
173
  // Create and store the new listener
149
174
  var keyDownListener = function keyDownListener(_event, data) {
150
175
  var domEvent = data.domEvent;
151
- onKeyDown(domEvent, editor);
176
+ // Prevent Enter from propagating to parent forms so the
177
+ // editor can handle newlines without accidentally submitting.
178
+ if (domEvent.key === 'Enter') {
179
+ domEvent.stopPropagation();
180
+ }
181
+ onKeyDown === null || onKeyDown === void 0 ? void 0 : onKeyDown(domEvent, editor);
152
182
  };
153
183
  keyDownListenerRef.current = keyDownListener;
154
184
 
@@ -174,6 +204,20 @@ export function TextEditor(_ref) {
174
204
  editor.setData(initialValue);
175
205
  }
176
206
 
207
+ // Set aria-label and aria-description on the editable area if provided
208
+ // These provide accessible context to screen reader users
209
+ editor.editing.view.change(function (writer) {
210
+ var viewEditableRoot = editor.editing.view.document.getRoot();
211
+ if (viewEditableRoot) {
212
+ if (ariaLabel) {
213
+ writer.setAttribute('aria-label', ariaLabel, viewEditableRoot);
214
+ }
215
+ if (ariaDescription) {
216
+ writer.setAttribute('aria-description', ariaDescription, viewEditableRoot);
217
+ }
218
+ }
219
+ });
220
+
177
221
  // Bind keydown handler when editor is ready
178
222
  bindKeyDownHandler(editor);
179
223
  onInit === null || onInit === void 0 ? void 0 : onInit(editor);
@@ -200,7 +244,8 @@ export function TextEditor(_ref) {
200
244
  return /*#__PURE__*/React.createElement(StyledTextEditor, {
201
245
  ref: editorRef,
202
246
  key: editorKey,
203
- error: error
247
+ error: error,
248
+ "aria-invalid": error ? 'true' : 'false'
204
249
  }, /*#__PURE__*/React.createElement(GlobalEditorStyles, {
205
250
  zIndex: zIndex + 1
206
251
  }), /*#__PURE__*/React.createElement(TextEditorTheme, null), /*#__PURE__*/React.createElement(CKEditor, _extends({}, restProps, {
@@ -1 +1 @@
1
- {"version":3,"file":"TextEditor.js","names":["CKEditor","ClassicEditor","React","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","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","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 { useI18nContext, useZIndexContext } 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 ...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 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,SAASC,cAAc,EAAEC,gBAAgB,QAAQ,qBAAqB;AACtE,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,OAA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EAAE6C,YAAY;MACpByB,OAAO,EAAE3B,qBAAqB;MAC9BY,MAAM,EAAE9B,aAAa,GAAGX,iBAAiB,CAACiB,OAAO,GAAG;IACtD,CAAC,CAAC;IAJM/B,MAAM,GAAAuE,mBAAA,CAANvE,MAAM;EAMd,IAAMwE,SAAS,MAAAC,MAAA,CAAMrE,MAAM,OAAAqE,MAAA,CAAI9B,qBAAqB,CAAE;EAEtD,IAAIjC,UAAU,EAAE;IACd,OAAO,IAAI;EACb;EAEA,oBACElC,KAAA,CAAAkG,aAAA,CAAC7F,gBAAgB;IAAC8F,GAAG,EAAE/D,SAAU;IAACgE,GAAG,EAAEJ,SAAU;IAAChF,KAAK,EAAEA;EAAM,gBAC7DhB,KAAA,CAAAkG,aAAA,CAAC9F,kBAAkB;IAACyD,MAAM,EAAEA,MAAM,GAAG;EAAE,CAAE,CAAC,eAC1C7D,KAAA,CAAAkG,aAAA,CAAC3F,eAAe,MAAE,CAAC,eACnBP,KAAA,CAAAkG,aAAA,CAACpG,QAAQ,EAAAuG,QAAA,KACHvE,SAAS;IACbiD,MAAM,EAAEhF,aAAc;IACtByB,MAAM,EAAEA,MAAO;IACfT,QAAQ,EAAEA,QAAS;IACnBqE,IAAI,EAAEnE,KAAM;IACZE,QAAQ,EAAEoE,YAAa;IACvBe,OAAO,EAAEZ,WAAY;IACrBrE,MAAM,EAAEuE;EAAW,EACpB,CACe,CAAC;AAEvB"}
1
+ {"version":3,"file":"TextEditor.js","names":["CKEditor","ClassicEditor","React","useI18nContext","useZIndexContext","useStickyToolbar","GlobalEditorStyles","StyledTextEditor","TextEditorContext","TextEditorTheme","useCKEditorCss","useTabAsNavigation","addButtonDataAttributes","getDefaultConfig","TextEditor","props","disabled","error","value","initialValue","onChange","onInit","onBlur","onKeyDown","propLocale","locale","onDirty","restProps","_objectWithoutProperties","_excluded","ariaLabel","ariaDescription","_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","editor","change","writer","viewEditableRoot","getRoot","setAttribute","removeAttribute","_useZIndexContext","zIndex","_React$useContext","useContext","features","enableStickyToolbar","stickyToolbar","enableTabAsNavigation","tabAsNavigation","mergedConfig","useMemo","defaultConfig","label","bindKeyDownHandler","useCallback","editorElement","keyDownListener","_event","data","domEvent","key","stopPropagation","on","handleChange","getData","isDirty","handleReady","setData","handleBlur","event","enabled","_useTabAsNavigation","config","editorKey","concat","createElement","ref","_extends","onReady"],"sources":["../../src/TextEditor/TextEditor.tsx"],"sourcesContent":["import { CKEditor } from '@ckeditor/ckeditor5-react'\nimport { ClassicEditor, type EventInfo } from 'ckeditor5'\nimport React from 'react'\n\nimport { useI18nContext, useZIndexContext } 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 { addButtonDataAttributes, getDefaultConfig } 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(props: Readonly<TextEditorProps>) {\n const {\n disabled,\n error,\n value,\n initialValue,\n onChange,\n onInit,\n onBlur,\n onKeyDown,\n locale: propLocale,\n onDirty,\n ...restProps\n } = props\n const ariaLabel = props['aria-label']\n const ariaDescription = props['aria-description']\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 // Update aria-label when ariaLabel prop changes\n React.useEffect(() => {\n if (!isEditorReady || !editorInstanceRef.current) {\n return\n }\n\n const editor = editorInstanceRef.current\n editor.editing.view.change((writer) => {\n const viewEditableRoot = editor.editing.view.document.getRoot()\n if (viewEditableRoot) {\n if (ariaLabel) {\n writer.setAttribute('aria-label', ariaLabel, viewEditableRoot)\n } else {\n writer.removeAttribute('aria-label', viewEditableRoot)\n }\n }\n })\n }, [ariaLabel, isEditorReady])\n\n // Update aria-description when ariaDescription prop changes\n React.useEffect(() => {\n if (!isEditorReady || !editorInstanceRef.current) {\n return\n }\n\n const editor = editorInstanceRef.current\n editor.editing.view.change((writer) => {\n const viewEditableRoot = editor.editing.view.document.getRoot()\n if (viewEditableRoot) {\n if (ariaDescription) {\n writer.setAttribute(\n 'aria-description',\n ariaDescription,\n viewEditableRoot\n )\n } else {\n writer.removeAttribute('aria-description', viewEditableRoot)\n }\n }\n })\n }, [ariaDescription, isEditorReady])\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 // Set accessible label for the editable area if provided\n // This is used by screen readers to announce the editor's purpose\n if (ariaLabel) {\n defaultConfig.label = ariaLabel\n }\n\n return defaultConfig\n }, [ariaLabel, locale])\n\n const bindKeyDownHandler = React.useCallback(\n (editor: ClassicEditor) => {\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 // Prevent Enter from propagating to parent forms so the\n // editor can handle newlines without accidentally submitting.\n if (domEvent.key === 'Enter') {\n domEvent.stopPropagation()\n }\n\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 // Set aria-label and aria-description on the editable area if provided\n // These provide accessible context to screen reader users\n editor.editing.view.change((writer) => {\n const viewEditableRoot = editor.editing.view.document.getRoot()\n if (viewEditableRoot) {\n if (ariaLabel) {\n writer.setAttribute('aria-label', ariaLabel, viewEditableRoot)\n }\n if (ariaDescription) {\n writer.setAttribute(\n 'aria-description',\n ariaDescription,\n viewEditableRoot\n )\n }\n }\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\n ref={editorRef}\n key={editorKey}\n error={error}\n aria-invalid={error ? 'true' : 'false'}\n >\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;AACpD,SAASC,aAAa,QAAwB,WAAW;AACzD,OAAOC,KAAK,MAAM,OAAO;AAEzB,SAASC,cAAc,EAAEC,gBAAgB,QAAQ,qBAAqB;AACtE,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,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KAAA,CAAAmG,aAAA,CAACrG,QAAQ,EAAAuG,QAAA,KACH5E,SAAS;IACbgC,MAAM,EAAE1D,aAAc;IACtBiG,MAAM,EAAEA,MAAO;IACflF,QAAQ,EAAEA,QAAS;IACnBoE,IAAI,EAAElE,KAAM;IACZE,QAAQ,EAAEqE,YAAa;IACvBe,OAAO,EAAEZ,WAAY;IACrBtE,MAAM,EAAEwE;EAAW,EACpB,CACe,CAAC;AAEvB"}
@@ -18,7 +18,7 @@ export var GlobalEditorStyles = /*#__PURE__*/createGlobalStyle([":root{--ck-z-de
18
18
  });
19
19
  export var StyledTextEditor = /*#__PURE__*/styled.div.withConfig({
20
20
  displayName: "StyledTextEditor",
21
- componentId: "text-editor-0_0_3__sc-iim79x-0"
21
+ componentId: "text-editor-0_1_0__sc-iim79x-0"
22
22
  })(["", ""], function (_ref6) {
23
23
  var error = _ref6.error;
24
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 ");
@@ -1,10 +1,10 @@
1
- import type { Locale } from '@procore/core-react';
2
- import type { ClassicEditor, EditorConfig, EventInfo } from 'ckeditor5';
1
+ import type { Locale } from '@procore/globalization-toolkit';
2
+ import type { ClassicEditor, EventInfo } from 'ckeditor5';
3
3
  export interface TextEditorProps {
4
4
  /**
5
5
  * Unique identifier for the editor
6
6
  *
7
- * @since 10.19.0
7
+ * @since 0.0.1
8
8
  */
9
9
  id?: string;
10
10
  /**
@@ -12,74 +12,75 @@ export interface TextEditorProps {
12
12
  *
13
13
  * @deprecated `initialValue` has been deprecated and will be removed in a future version.
14
14
  * Please use the `value` prop instead
15
- * @deprecatedSince 10.20.0
16
- * @since 10.19.0
15
+ * @deprecatedSince 0.0.1
16
+ * @since 0.0.1
17
17
  */
18
18
  initialValue?: string;
19
19
  /**
20
20
  * The current value of the editor
21
21
  *
22
- * @since 10.19.0
22
+ * @since 0.0.1
23
23
  */
24
24
  value?: string;
25
25
  /**
26
26
  * Indicates if the editor is disabled
27
27
  *
28
- * @since 10.19.0
28
+ * @since 0.0.1
29
29
  */
30
30
  disabled?: boolean;
31
31
  /**
32
32
  * Indicates if the editor is in an error state
33
33
  *
34
- * @since 10.19.0
34
+ * @since 0.0.1
35
35
  */
36
36
  error?: boolean;
37
37
  /**
38
- * Locale which will be used for localization. Can be passed directly or
39
- * set by wrapping components in I18n provider.
40
- * @since 10.19.0
38
+ * Accessible label for the editor's editable area. This text will be
39
+ * announced by screen readers when the user focuses the editor. It should
40
+ * match or include the visible label associated with this editor field.
41
+ * If not provided, screen readers will announce a generic "Rich Text Editor" message.
42
+ *
43
+ * @since 0.1.0
41
44
  */
42
- locale?: Locale;
45
+ 'aria-label'?: string;
43
46
  /**
44
- * Array of plugin names to add to the editor in addition to the defaults.
45
- * This provides backward compatibility with the deprecated TinyMCE version of the editor.
46
- * Supports plugin names like 'link', 'image', 'table', etc.
47
+ * Accessible description for the editor's editable area.
48
+ * This text provides additional context to screen reader users. It will be
49
+ * announced after the label when the user focuses the editor.
47
50
  *
48
- * @since 12.26.0
51
+ * @since 0.1.0
49
52
  */
50
- plugins?: string[];
53
+ 'aria-description'?: string;
51
54
  /**
52
- * Configuration function for customizing the editor
53
- *
54
- * @param defaultConfig - The default CKEditor configuration
55
- * @returns Customized configuration object
56
- * @since 12.26.0
55
+ * Locale which will be used for localization. Can be passed directly or
56
+ * set by wrapping components in I18n provider.
57
+ * @since 0.0.1
57
58
  */
58
- config?: (defaultConfig: EditorConfig) => EditorConfig;
59
+ locale?: Locale;
59
60
  /**
60
61
  * Callback fired when the editor content changes
61
62
  *
62
63
  * @param value - The current content of the editor
63
64
  * @param isDirty - Whether the content differs from the initial value
64
- * @since 10.19.0
65
+ * @since 0.0.1
65
66
  */
66
67
  onChange?: (value: string, isDirty?: boolean) => void;
67
68
  /**
68
69
  * Callback fired when the editor gains focus
69
70
  *
70
- * @since 10.19.0
71
+ * @since 0.0.1
71
72
  */
72
73
  onFocus?: (event: EventInfo, editor: ClassicEditor) => void;
73
74
  /**
74
75
  * Callback fired when the editor loses focus
75
76
  *
76
- * @since 10.19.0
77
+ * @since 0.0.1
77
78
  */
78
79
  onBlur?: (event: EventInfo, editor: ClassicEditor) => void;
79
80
  /**
80
81
  * Callback fired when an error occurs in the editor
81
82
  *
82
- * @since 10.19.0
83
+ * @since 0.0.1
83
84
  */
84
85
  onError?: (error: Error, details: {
85
86
  phase: 'initialization' | 'runtime';
@@ -88,19 +89,19 @@ export interface TextEditorProps {
88
89
  /**
89
90
  * Callback fired when the editor is ready
90
91
  *
91
- * @since 10.19.0
92
+ * @since 0.0.1
92
93
  */
93
94
  onInit?: (editor: ClassicEditor) => void;
94
95
  /**
95
96
  * Callback fired after the editor instance is destroyed
96
97
  *
97
- * @since 10.19.0
98
+ * @since 0.0.1
98
99
  */
99
100
  onAfterDestroy?: () => void;
100
101
  /**
101
102
  * Callback fired when the editor becomes dirty (content differs from initial value)
102
103
  *
103
- * @since 12.26.0
104
+ * @since 0.0.1
104
105
  */
105
106
  onDirty?: () => void;
106
107
  /**
@@ -108,7 +109,7 @@ export interface TextEditorProps {
108
109
  *
109
110
  * @param event - The keyboard event
110
111
  * @param editor - The CKEditor instance
111
- * @since 12.29.0
112
+ * @since 0.0.1
112
113
  */
113
114
  onKeyDown?: (event: KeyboardEvent, editor: ClassicEditor) => void;
114
115
  }
@@ -1 +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\nexport type KeyDownListener = (\n event: EventInfo,\n data: { domEvent: Event }\n) => void\n"],"mappings":""}
1
+ {"version":3,"file":"TextEditor.types.js","names":[],"sources":["../../src/TextEditor/TextEditor.types.ts"],"sourcesContent":["import type { Locale } from '@procore/globalization-toolkit'\nimport type { ClassicEditor, EventInfo } from 'ckeditor5'\n\nexport interface TextEditorProps {\n /**\n * Unique identifier for the editor\n *\n * @since 0.0.1\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 0.0.1\n * @since 0.0.1\n */\n initialValue?: string\n\n /**\n * The current value of the editor\n *\n * @since 0.0.1\n */\n value?: string\n\n /**\n * Indicates if the editor is disabled\n *\n * @since 0.0.1\n */\n disabled?: boolean\n\n /**\n * Indicates if the editor is in an error state\n *\n * @since 0.0.1\n */\n error?: boolean\n\n /**\n * Accessible label for the editor's editable area. This text will be\n * announced by screen readers when the user focuses the editor. It should\n * match or include the visible label associated with this editor field.\n * If not provided, screen readers will announce a generic \"Rich Text Editor\" message.\n *\n * @since 0.1.0\n */\n 'aria-label'?: string\n\n /**\n * Accessible description for the editor's editable area.\n * This text provides additional context to screen reader users. It will be\n * announced after the label when the user focuses the editor.\n *\n * @since 0.1.0\n */\n 'aria-description'?: string\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 0.0.1\n */\n locale?: Locale\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 0.0.1\n */\n onChange?: (value: string, isDirty?: boolean) => void\n\n /**\n * Callback fired when the editor gains focus\n *\n * @since 0.0.1\n */\n onFocus?: (event: EventInfo, editor: ClassicEditor) => void\n\n /**\n * Callback fired when the editor loses focus\n *\n * @since 0.0.1\n */\n onBlur?: (event: EventInfo, editor: ClassicEditor) => void\n\n /**\n * Callback fired when an error occurs in the editor\n *\n * @since 0.0.1\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 0.0.1\n */\n onInit?: (editor: ClassicEditor) => void\n\n /**\n * Callback fired after the editor instance is destroyed\n *\n * @since 0.0.1\n */\n onAfterDestroy?: () => void\n\n /**\n * Callback fired when the editor becomes dirty (content differs from initial value)\n *\n * @since 0.0.1\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 0.0.1\n */\n onKeyDown?: (event: KeyboardEvent, editor: ClassicEditor) => void\n}\n\nexport type KeyDownListener = (\n event: EventInfo,\n data: { domEvent: Event }\n) => void\n"],"mappings":""}
@@ -1,3 +1,4 @@
1
+ import { colors, spacing } from '@procore/core-react';
1
2
  import { createGlobalStyle } from 'styled-components';
2
3
  import { alignCenterIcon, alignLeftIcon, alignRightIcon, bgColorIcon, boldIcon, checkmarkIcon, cutIcon, fontSizeIcon, imageIcon, indentIcon, italicIcon, linkIcon, orderedListIcon, outdentIcon, pasteAsTextIcon, pasteIcon, redoIcon, strikeThroughIcon, tableIcon, textColorIcon, underlineIcon, undoIcon, unorderedListIcon } from './icons';
3
4
  var getIconUrl = function getIconUrl(icon) {
@@ -6,5 +7,5 @@ var getIconUrl = function getIconUrl(icon) {
6
7
  }
7
8
  return "data:image/svg+xml;charset=utf-8,".concat(encodeURIComponent(icon));
8
9
  };
9
- export var TextEditorTheme = /*#__PURE__*/createGlobalStyle([".ck-button:first-child .ck-icon:first-child{background-size:24px;background-repeat:no-repeat;background-position:center;}[data-cke-command=\"bold\"],[data-cke-command=\"italic\"],[data-cke-command=\"underline\"],[data-cke-command=\"strikethrough\"],[data-cke-command=\"alignment:left\"],[data-cke-command=\"alignment:center\"],[data-cke-command=\"alignment:right\"],[data-cke-command=\"bulletedList\"],[data-cke-command=\"numberedList\"],[data-cke-command=\"outdent\"],[data-cke-command=\"indent\"],[data-cke-command=\"cut\"],[data-cke-command=\"paste\"],[data-cke-command=\"pasteAsText\"],[data-cke-command=\"fontSize\"],[data-cke-command=\"fontColor\"],[data-cke-command=\"fontBackgroundColor\"],[data-cke-command=\"link\"],[data-cke-command=\"insertTable\"],[data-cke-command=\"insertImageViaUrl\"],[data-cke-command=\"undo\"],[data-cke-command=\"redo\"]{> .ck-icon:first-child > *,> .ck-button:first-child > .ck-icon:first-child > *,> .ck-splitbutton > .ck-button:first-child > .ck-icon:first-child > *{display:none;}> .ck-icon:first-child,> .ck-splitbutton > .ck-button:first-child .ck-icon:first-child,> .ck-button > .ck-icon:first-child{width:24px !important;height:24px !important;}}[data-cke-command=\"bold\"] > .ck-icon:first-child{background-image:url('", "');}[data-cke-command=\"italic\"] > .ck-icon:first-child{background-image:url('", "');}[data-cke-command=\"underline\"] > .ck-icon:first-child{background-image:url('", "');}[data-cke-command=\"strikethrough\"] > .ck-icon:first-child{background-image:url('", "');}[data-cke-command=\"alignment:left\"] > .ck-icon:first-child{background-image:url('", "');}[data-cke-command=\"alignment:center\"] > .ck-icon:first-child{background-image:url('", "');}[data-cke-command=\"alignment:right\"] > .ck-icon:first-child{background-image:url('", "');}[data-cke-command=\"bulletedList\"] > .ck-splitbutton > .ck-button:first-child .ck-icon:first-child{background-image:url('", "');}[data-cke-command=\"numberedList\"] > .ck-splitbutton > .ck-button:first-child .ck-icon:first-child{background-image:url('", "');}[data-cke-command=\"outdent\"] > .ck-icon:first-child{background-image:url('", "');}[data-cke-command=\"indent\"] > .ck-icon:first-child{background-image:url('", "');}[data-cke-command=\"cut\"] > .ck-icon:first-child{background-image:url('", "');}[data-cke-command=\"paste\"] > .ck-icon:first-child{background-image:url('", "');}[data-cke-command=\"pasteAsText\"] > .ck-icon:first-child{background-image:url('", "');}[data-cke-command=\"fontSize\"] > .ck-button > .ck-icon:first-child{background-image:url('", "');background-size:19px;}[data-cke-command=\"fontColor\"] > .ck-button > .ck-icon:first-child{background-image:url('", "');}[data-cke-command=\"fontBackgroundColor\"] > .ck-button > .ck-icon:first-child{background-image:url('", "');}[data-cke-command=\"link\"] > .ck-icon:first-child{background-image:url('", "');}[data-cke-command=\"insertTable\"] > .ck-button > .ck-icon:first-child{background-image:url('", "');}[data-cke-command=\"insertImageViaUrl\"] > .ck-icon:first-child{background-image:url('", "');}[data-cke-command=\"undo\"] > .ck-icon:first-child{background-image:url('", "');}[data-cke-command=\"redo\"] > .ck-icon:first-child{background-image:url('", "');}[data-cke-command=\"fontSize\"] .ck-dropdown__panel{max-width:130px !important;.ck-list__item{min-width:128px !important;}.ck-list{.ck-button{padding:4px 12px !important;font-size:14px !important;line-height:24px !important;.ck-button__label{font-size:14px !important;font-weight:normal !important;font-family:inherit !important;line-height:24px !important;}&[data-cke-tooltip-text]{font-size:14px !important;.ck-button__label{font-size:14px !important;}}&.ck-on{position:relative;padding-right:32px !important;&::after{content:\"\";position:absolute;right:8px;top:50%;transform:translateY(-50%);width:24px !important;height:24px !important;background-image:url('", "');background-size:24px 24px;background-repeat:no-repeat;background-position:center;line-height:1;}}}}.ck-list-item-button__check-holder{display:none !important;}}"], getIconUrl(boldIcon), getIconUrl(italicIcon), getIconUrl(underlineIcon), getIconUrl(strikeThroughIcon), getIconUrl(alignLeftIcon), getIconUrl(alignCenterIcon), getIconUrl(alignRightIcon), getIconUrl(unorderedListIcon), getIconUrl(orderedListIcon), getIconUrl(outdentIcon), getIconUrl(indentIcon), getIconUrl(cutIcon), getIconUrl(pasteIcon), getIconUrl(pasteAsTextIcon), getIconUrl(fontSizeIcon), getIconUrl(textColorIcon), getIconUrl(bgColorIcon), getIconUrl(linkIcon), getIconUrl(tableIcon), getIconUrl(imageIcon), getIconUrl(undoIcon), getIconUrl(redoIcon), getIconUrl(checkmarkIcon));
10
+ export var TextEditorTheme = /*#__PURE__*/createGlobalStyle([".ck-button:first-child .ck-icon:first-child{background-size:24px;background-repeat:no-repeat;background-position:center;}.ck-link-form .ck-button-action{font-size:13px !important;line-height:", " !important;background:", " !important;color:", " !important;border-radius:", " !important;font-family:inherit !important;font-weight:600 !important;height:", " !important;justify-content:center !important;align-items:center !important;cursor:pointer !important;&:hover{background:", " !important;}}[data-cke-command=\"bold\"],[data-cke-command=\"italic\"],[data-cke-command=\"underline\"],[data-cke-command=\"strikethrough\"],[data-cke-command=\"alignment:left\"],[data-cke-command=\"alignment:center\"],[data-cke-command=\"alignment:right\"],[data-cke-command=\"bulletedList\"],[data-cke-command=\"numberedList\"],[data-cke-command=\"outdent\"],[data-cke-command=\"indent\"],[data-cke-command=\"cut\"],[data-cke-command=\"paste\"],[data-cke-command=\"pasteAsText\"],[data-cke-command=\"fontSize\"],[data-cke-command=\"fontColor\"],[data-cke-command=\"fontBackgroundColor\"],[data-cke-command=\"link\"],[data-cke-command=\"insertTable\"],[data-cke-command=\"insertImageViaUrl\"],[data-cke-command=\"undo\"],[data-cke-command=\"redo\"]{> .ck-icon:first-child > *,> .ck-button:first-child > .ck-icon:first-child > *,> .ck-splitbutton > .ck-button:first-child > .ck-icon:first-child > *{display:none;}> .ck-icon:first-child,> .ck-splitbutton > .ck-button:first-child .ck-icon:first-child,> .ck-button > .ck-icon:first-child{width:24px !important;height:24px !important;}}[data-cke-command=\"bold\"] > .ck-icon:first-child{background-image:url('", "');}[data-cke-command=\"italic\"] > .ck-icon:first-child{background-image:url('", "');}[data-cke-command=\"underline\"] > .ck-icon:first-child{background-image:url('", "');}[data-cke-command=\"strikethrough\"] > .ck-icon:first-child{background-image:url('", "');}[data-cke-command=\"alignment:left\"] > .ck-icon:first-child{background-image:url('", "');}[data-cke-command=\"alignment:center\"] > .ck-icon:first-child{background-image:url('", "');}[data-cke-command=\"alignment:right\"] > .ck-icon:first-child{background-image:url('", "');}[data-cke-command=\"bulletedList\"] > .ck-splitbutton > .ck-button:first-child .ck-icon:first-child{background-image:url('", "');}[data-cke-command=\"numberedList\"] > .ck-splitbutton > .ck-button:first-child .ck-icon:first-child{background-image:url('", "');}[data-cke-command=\"outdent\"] > .ck-icon:first-child{background-image:url('", "');}[data-cke-command=\"indent\"] > .ck-icon:first-child{background-image:url('", "');}[data-cke-command=\"cut\"] > .ck-icon:first-child{background-image:url('", "');}[data-cke-command=\"paste\"] > .ck-icon:first-child{background-image:url('", "');}[data-cke-command=\"pasteAsText\"] > .ck-icon:first-child{background-image:url('", "');}[data-cke-command=\"fontSize\"] > .ck-button > .ck-icon:first-child{background-image:url('", "');background-size:19px;}[data-cke-command=\"fontColor\"] > .ck-button > .ck-icon:first-child{background-image:url('", "');}[data-cke-command=\"fontBackgroundColor\"] > .ck-button > .ck-icon:first-child{background-image:url('", "');}[data-cke-command=\"link\"] > .ck-icon:first-child{background-image:url('", "');}[data-cke-command=\"insertTable\"] > .ck-button > .ck-icon:first-child{background-image:url('", "');}[data-cke-command=\"insertImageViaUrl\"] > .ck-icon:first-child{background-image:url('", "');}[data-cke-command=\"undo\"] > .ck-icon:first-child{background-image:url('", "');}[data-cke-command=\"redo\"] > .ck-icon:first-child{background-image:url('", "');}[data-cke-command=\"fontSize\"] .ck-dropdown__panel{max-width:130px !important;.ck-list__item{min-width:128px !important;}.ck-list{.ck-button{padding:4px 12px !important;font-size:14px !important;line-height:24px !important;.ck-button__label{font-size:14px !important;font-weight:normal !important;font-family:inherit !important;line-height:24px !important;}&[data-cke-tooltip-text]{font-size:14px !important;.ck-button__label{font-size:14px !important;}}&.ck-on{position:relative;padding-right:32px !important;&::after{content:\"\";position:absolute;right:8px;top:50%;transform:translateY(-50%);width:24px !important;height:24px !important;background-image:url('", "');background-size:24px 24px;background-repeat:no-repeat;background-position:center;line-height:1;}}}}.ck-list-item-button__check-holder{display:none !important;}}"], spacing.lg, colors.gray90, colors.gray15, spacing.xs, spacing.xl, colors.gray85, getIconUrl(boldIcon), getIconUrl(italicIcon), getIconUrl(underlineIcon), getIconUrl(strikeThroughIcon), getIconUrl(alignLeftIcon), getIconUrl(alignCenterIcon), getIconUrl(alignRightIcon), getIconUrl(unorderedListIcon), getIconUrl(orderedListIcon), getIconUrl(outdentIcon), getIconUrl(indentIcon), getIconUrl(cutIcon), getIconUrl(pasteIcon), getIconUrl(pasteAsTextIcon), getIconUrl(fontSizeIcon), getIconUrl(textColorIcon), getIconUrl(bgColorIcon), getIconUrl(linkIcon), getIconUrl(tableIcon), getIconUrl(imageIcon), getIconUrl(undoIcon), getIconUrl(redoIcon), getIconUrl(checkmarkIcon));
10
11
  //# sourceMappingURL=textEditorTheming.styles.js.map