@procore/text-editor 0.1.0 → 0.2.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,13 @@
1
1
  # @procore/text-editor
2
2
 
3
+ ## 0.2.0
4
+
5
+ ### Minor Changes
6
+
7
+ - ffdc97f: - Add optional `readonly` prop to display content in read-only mode.
8
+ - Remove Accessibility icons from the toolbar.
9
+ - Expose `DebouncedTextEditor` component for debounced value updates.
10
+
3
11
  ## 0.1.0
4
12
 
5
13
  ### Minor Changes
package/README.md CHANGED
@@ -10,7 +10,7 @@ yarn add @procore/text-editor
10
10
 
11
11
  ## Usage
12
12
 
13
- ### TextEditor Usage
13
+ ### Standalone Usage
14
14
 
15
15
  ```tsx
16
16
  import { TextEditor } from '@procore/text-editor'
@@ -27,26 +27,39 @@ function MyComponent() {
27
27
  }
28
28
  ```
29
29
 
30
-
31
- ### TextEditorProvider
32
-
33
- Use `TextEditorProvider` to enable advanced features:
30
+ ### With @procore/core-react Forms
34
31
 
35
32
  ```tsx
36
- import { TextEditor, TextEditorProvider } from '@procore/text-editor'
33
+ import { Form } from '@procore/core-react'
34
+ import { TextEditor } from '@procore/text-editor'
37
35
 
38
36
  function MyComponent() {
39
37
  return (
40
- <TextEditorProvider features={{ stickyToolbar: true, tabAsNavigation: true }}>
41
- <TextEditor value={value} onChange={setValue} />
42
- </TextEditorProvider>
38
+ <Form.RichText
39
+ name="richtext"
40
+ label="Richtext"
41
+ textEditorComponent={TextEditor}
42
+ />
43
43
  )
44
44
  }
45
45
  ```
46
46
 
47
- ### TextEditorOutput
48
47
 
49
- Display formatted text from the editor:
48
+ ### Displaying Read-Only Content
49
+
50
+ You can display formatted text in two ways:
51
+
52
+ **Option 1:** Use `TextEditor` with `readonly` prop:
53
+
54
+ ```tsx
55
+ import { TextEditor } from '@procore/text-editor'
56
+
57
+ function MyComponent({ htmlContent }) {
58
+ return <TextEditor value={htmlContent} readonly />
59
+ }
60
+ ```
61
+
62
+ **Option 2:** Use the `TextEditorOutput` component:
50
63
 
51
64
  ```tsx
52
65
  import { TextEditorOutput } from '@procore/text-editor'
@@ -56,6 +69,40 @@ function MyComponent({ htmlContent }) {
56
69
  }
57
70
  ```
58
71
 
72
+ ## Features
73
+
74
+
75
+ ### Toolbar Features
76
+
77
+ The editor includes a comprehensive toolbar with the following capabilities:
78
+
79
+ | Feature | Description |
80
+ |---------|-------------|
81
+ | **Bold** | Apply bold formatting |
82
+ | **Italic** | Apply italic formatting |
83
+ | **Underline** | Apply underline formatting |
84
+ | **Strikethrough** | Apply strikethrough formatting |
85
+ | **Alignment** | Left, center, and right text alignment |
86
+ | **Bulleted List** | Create unordered lists |
87
+ | **Numbered List** | Create ordered lists with start index and reversed options |
88
+ | **Indent/Outdent** | Increase or decrease text indentation |
89
+ | **Cut/Paste** | Cut and paste content with clipboard support |
90
+ | **Paste as Text** | Paste content as plain text without formatting |
91
+ | **Font Size** | Choose from 8pt, 10pt, 12pt, 14pt, 18pt, 24pt, 36pt |
92
+ | **Font Color** | Apply text color from a 22-color palette |
93
+ | **Background Color** | Apply background highlight from a 22-color palette |
94
+ | **Insert Table** | Create and edit tables with cell properties |
95
+ | **Link** | Insert and edit hyperlinks with auto-link detection |
96
+ | **Block Quote** | Create block quotations |
97
+ | **Heading** | Apply heading styles |
98
+ | **Horizontal Line** | Insert horizontal dividers |
99
+ | **Remove Format** | Clear all formatting from selected text |
100
+ | **Special Characters** | Insert special characters and symbols |
101
+ | **Subscript** | Apply subscript formatting |
102
+ | **Superscript** | Apply superscript formatting |
103
+ | **Code Block** | Insert formatted code blocks |
104
+ | **Undo/Redo** | Undo and redo editing actions |
105
+
59
106
  ## Jest Configuration
60
107
 
61
108
  To ensure your Jest tests work with CKEditor, wrap your Jest configuration with `textEditorJestConfig`:
@@ -0,0 +1,35 @@
1
+ import React from 'react';
2
+ import type { TextEditorProps } from '../TextEditor';
3
+ /**
4
+ * A performance-optimized version of `TextEditor` with built-in debounce on the `onChange` callback.
5
+ *
6
+ * ## When to use `DebouncedTextEditor`
7
+ *
8
+ * Use this component when:
9
+ * - The `onChange` handler triggers expensive operations (API calls, complex state updates, re-renders)
10
+ * - You want to reduce the frequency of updates while the user is actively typing
11
+ * - Performance is a concern in forms with multiple rich text editors
12
+ *
13
+ * ## How it works
14
+ *
15
+ * The component waits 300ms after the user stops typing before calling `onChange`.
16
+ * If the user continues typing, the timer resets. This reduces unnecessary updates
17
+ * while maintaining a responsive editing experience.
18
+ *
19
+ * @example
20
+ * ```tsx
21
+ * import { DebouncedTextEditor } from '@procore/text-editor'
22
+ *
23
+ * function MyComponent() {
24
+ * const [value, setValue] = React.useState('')
25
+ *
26
+ * return (
27
+ * <DebouncedTextEditor
28
+ * value={value}
29
+ * onChange={(newValue) => setValue(newValue)}
30
+ * />
31
+ * )
32
+ * }
33
+ * ```
34
+ */
35
+ export declare const DebouncedTextEditor: ({ onChange, value, ...rest }: TextEditorProps) => React.JSX.Element;
@@ -0,0 +1,71 @@
1
+ var _excluded = ["onChange", "value"];
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); }
3
+ function _slicedToArray(r, e) { return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _nonIterableRest(); }
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."); }
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; } }
6
+ 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; }
7
+ 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; } }
8
+ function _arrayWithHoles(r) { if (Array.isArray(r)) return r; }
9
+ 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; }
10
+ 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; }
11
+ import React, { useCallback, useEffect, useState } from 'react';
12
+ import { TextEditor } from '../TextEditor';
13
+ import { debounce } from '../utils/debounce';
14
+ var DEBOUNCE_MS = 300;
15
+
16
+ /**
17
+ * A performance-optimized version of `TextEditor` with built-in debounce on the `onChange` callback.
18
+ *
19
+ * ## When to use `DebouncedTextEditor`
20
+ *
21
+ * Use this component when:
22
+ * - The `onChange` handler triggers expensive operations (API calls, complex state updates, re-renders)
23
+ * - You want to reduce the frequency of updates while the user is actively typing
24
+ * - Performance is a concern in forms with multiple rich text editors
25
+ *
26
+ * ## How it works
27
+ *
28
+ * The component waits 300ms after the user stops typing before calling `onChange`.
29
+ * If the user continues typing, the timer resets. This reduces unnecessary updates
30
+ * while maintaining a responsive editing experience.
31
+ *
32
+ * @example
33
+ * ```tsx
34
+ * import { DebouncedTextEditor } from '@procore/text-editor'
35
+ *
36
+ * function MyComponent() {
37
+ * const [value, setValue] = React.useState('')
38
+ *
39
+ * return (
40
+ * <DebouncedTextEditor
41
+ * value={value}
42
+ * onChange={(newValue) => setValue(newValue)}
43
+ * />
44
+ * )
45
+ * }
46
+ * ```
47
+ */
48
+ export var DebouncedTextEditor = function DebouncedTextEditor(_ref) {
49
+ var onChange = _ref.onChange,
50
+ value = _ref.value,
51
+ rest = _objectWithoutProperties(_ref, _excluded);
52
+ var _useState = useState(value !== null && value !== void 0 ? value : ''),
53
+ _useState2 = _slicedToArray(_useState, 2),
54
+ internalValue = _useState2[0],
55
+ setInternalValue = _useState2[1];
56
+ var debouncedOnChange = useCallback(debounce(function (newValue) {
57
+ onChange === null || onChange === void 0 ? void 0 : onChange(newValue);
58
+ }, DEBOUNCE_MS), []);
59
+ function handleChange(newValue) {
60
+ setInternalValue(newValue);
61
+ debouncedOnChange(newValue);
62
+ }
63
+ useEffect(function () {
64
+ setInternalValue(value !== null && value !== void 0 ? value : '');
65
+ }, [value]);
66
+ return /*#__PURE__*/React.createElement(TextEditor, _extends({}, rest, {
67
+ value: internalValue,
68
+ onChange: handleChange
69
+ }));
70
+ };
71
+ //# sourceMappingURL=DebouncedTextEditor.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"DebouncedTextEditor.js","names":["React","useCallback","useEffect","useState","TextEditor","debounce","DEBOUNCE_MS","DebouncedTextEditor","_ref","onChange","value","rest","_objectWithoutProperties","_excluded","_useState","_useState2","_slicedToArray","internalValue","setInternalValue","debouncedOnChange","newValue","handleChange","createElement","_extends"],"sources":["../../src/DebouncedTextEditor/DebouncedTextEditor.tsx"],"sourcesContent":["import React, { useCallback, useEffect, useState } from 'react'\nimport type { TextEditorProps } from '../TextEditor'\nimport { TextEditor } from '../TextEditor'\nimport { debounce } from '../utils/debounce'\n\nconst DEBOUNCE_MS = 300\n\n/**\n * A performance-optimized version of `TextEditor` with built-in debounce on the `onChange` callback.\n *\n * ## When to use `DebouncedTextEditor`\n *\n * Use this component when:\n * - The `onChange` handler triggers expensive operations (API calls, complex state updates, re-renders)\n * - You want to reduce the frequency of updates while the user is actively typing\n * - Performance is a concern in forms with multiple rich text editors\n *\n * ## How it works\n *\n * The component waits 300ms after the user stops typing before calling `onChange`.\n * If the user continues typing, the timer resets. This reduces unnecessary updates\n * while maintaining a responsive editing experience.\n *\n * @example\n * ```tsx\n * import { DebouncedTextEditor } from '@procore/text-editor'\n *\n * function MyComponent() {\n * const [value, setValue] = React.useState('')\n *\n * return (\n * <DebouncedTextEditor\n * value={value}\n * onChange={(newValue) => setValue(newValue)}\n * />\n * )\n * }\n * ```\n */\nexport const DebouncedTextEditor = ({\n onChange,\n value,\n ...rest\n}: TextEditorProps) => {\n const [internalValue, setInternalValue] = useState(value ?? '')\n\n const debouncedOnChange = useCallback(\n debounce((newValue: string) => {\n onChange?.(newValue)\n }, DEBOUNCE_MS),\n []\n )\n\n function handleChange(newValue: string) {\n setInternalValue(newValue)\n debouncedOnChange(newValue)\n }\n\n useEffect(() => {\n setInternalValue(value ?? '')\n }, [value])\n\n return <TextEditor {...rest} value={internalValue} onChange={handleChange} />\n}\n"],"mappings":";;;;;;;;;;AAAA,OAAOA,KAAK,IAAIC,WAAW,EAAEC,SAAS,EAAEC,QAAQ,QAAQ,OAAO;AAE/D,SAASC,UAAU,QAAQ,eAAe;AAC1C,SAASC,QAAQ,QAAQ,mBAAmB;AAE5C,IAAMC,WAAW,GAAG,GAAG;;AAEvB;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,IAAMC,mBAAmB,GAAG,SAAtBA,mBAAmBA,CAAAC,IAAA,EAIT;EAAA,IAHrBC,QAAQ,GAAAD,IAAA,CAARC,QAAQ;IACRC,KAAK,GAAAF,IAAA,CAALE,KAAK;IACFC,IAAI,GAAAC,wBAAA,CAAAJ,IAAA,EAAAK,SAAA;EAEP,IAAAC,SAAA,GAA0CX,QAAQ,CAACO,KAAK,aAALA,KAAK,cAALA,KAAK,GAAI,EAAE,CAAC;IAAAK,UAAA,GAAAC,cAAA,CAAAF,SAAA;IAAxDG,aAAa,GAAAF,UAAA;IAAEG,gBAAgB,GAAAH,UAAA;EAEtC,IAAMI,iBAAiB,GAAGlB,WAAW,CACnCI,QAAQ,CAAC,UAACe,QAAgB,EAAK;IAC7BX,QAAQ,aAARA,QAAQ,uBAARA,QAAQ,CAAGW,QAAQ,CAAC;EACtB,CAAC,EAAEd,WAAW,CAAC,EACf,EACF,CAAC;EAED,SAASe,YAAYA,CAACD,QAAgB,EAAE;IACtCF,gBAAgB,CAACE,QAAQ,CAAC;IAC1BD,iBAAiB,CAACC,QAAQ,CAAC;EAC7B;EAEAlB,SAAS,CAAC,YAAM;IACdgB,gBAAgB,CAACR,KAAK,aAALA,KAAK,cAALA,KAAK,GAAI,EAAE,CAAC;EAC/B,CAAC,EAAE,CAACA,KAAK,CAAC,CAAC;EAEX,oBAAOV,KAAA,CAAAsB,aAAA,CAAClB,UAAU,EAAAmB,QAAA,KAAKZ,IAAI;IAAED,KAAK,EAAEO,aAAc;IAACR,QAAQ,EAAEY;EAAa,EAAE,CAAC;AAC/E,CAAC"}
@@ -0,0 +1 @@
1
+ export { DebouncedTextEditor } from './DebouncedTextEditor';
@@ -0,0 +1,2 @@
1
+ export { DebouncedTextEditor } from './DebouncedTextEditor';
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","names":["DebouncedTextEditor"],"sources":["../../src/DebouncedTextEditor/index.ts"],"sourcesContent":["export { DebouncedTextEditor } from './DebouncedTextEditor'\n"],"mappings":"AAAA,SAASA,mBAAmB,QAAQ,uBAAuB"}
@@ -1,4 +1,4 @@
1
- var _excluded = ["disabled", "error", "value", "initialValue", "onChange", "onInit", "onBlur", "onKeyDown", "locale", "onDirty"];
1
+ var _excluded = ["disabled", "error", "readonly", "value", "initialValue", "onChange", "onInit", "onBlur", "onKeyDown", "locale", "onDirty"];
2
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); }
3
3
  function _slicedToArray(r, e) { return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _nonIterableRest(); }
4
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."); }
@@ -12,6 +12,7 @@ import { CKEditor } from '@ckeditor/ckeditor5-react';
12
12
  import { ClassicEditor } from 'ckeditor5';
13
13
  import React from 'react';
14
14
  import { useI18nContext, useZIndexContext } from '@procore/core-react';
15
+ import { TextEditorOutput } from '../TextEditorOutput';
15
16
  import { useStickyToolbar } from './StickyToolbar';
16
17
  import { GlobalEditorStyles, StyledTextEditor } from './TextEditor.styles';
17
18
  import { TextEditorContext } from './TextEditorProvider';
@@ -64,6 +65,7 @@ import { addButtonDataAttributes, getDefaultConfig } from './utils';
64
65
  export function TextEditor(props) {
65
66
  var disabled = props.disabled,
66
67
  error = props.error,
68
+ readonly = props.readonly,
67
69
  value = props.value,
68
70
  initialValue = props.initialValue,
69
71
  onChange = props.onChange,
@@ -241,6 +243,13 @@ export function TextEditor(props) {
241
243
  if (cssLoading) {
242
244
  return null;
243
245
  }
246
+ if (readonly) {
247
+ return /*#__PURE__*/React.createElement(TextEditorOutput, {
248
+ value: value,
249
+ "aria-label": ariaLabel,
250
+ "aria-description": ariaDescription
251
+ });
252
+ }
244
253
  return /*#__PURE__*/React.createElement(StyledTextEditor, {
245
254
  ref: editorRef,
246
255
  key: editorKey,
@@ -1 +1 @@
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}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IAAIxC,UAAU,EAAE;IACd,OAAO,IAAI;EACb;EAEA,oBACE/B,KAAA,CAAAmG,aAAA,CAAC9F,gBAAgB;IACf+F,GAAG,EAAEnE,SAAU;IACfmD,GAAG,EAAEa,SAAU;IACflF,KAAK,EAAEA,KAAM;IACb,gBAAcA,KAAK,GAAG,MAAM,GAAG;EAAQ,gBAEvCf,KAAA,CAAAmG,aAAA,CAAC/F,kBAAkB;IAAC6D,MAAM,EAAEA,MAAM,GAAG;EAAE,CAAE,CAAC,eAC1CjE,KAAA,CAAAmG,aAAA,CAAC5F,eAAe,MAAE,CAAC,eACnBP,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"}
1
+ {"version":3,"file":"TextEditor.js","names":["CKEditor","ClassicEditor","React","useI18nContext","useZIndexContext","TextEditorOutput","useStickyToolbar","GlobalEditorStyles","StyledTextEditor","TextEditorContext","TextEditorTheme","useCKEditorCss","useTabAsNavigation","addButtonDataAttributes","getDefaultConfig","TextEditor","props","disabled","error","readonly","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 { TextEditorOutput } from '../TextEditorOutput'\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 readonly,\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 if (readonly) {\n return (\n <TextEditorOutput\n value={value}\n aria-label={ariaLabel}\n aria-description={ariaDescription}\n />\n )\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,qBAAqB;AACtD,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;AAC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EvChB,KAAA,CAAAqG,aAAA,CAAChG,kBAAkB;IAAC8D,MAAM,EAAEA,MAAM,GAAG;EAAE,CAAE,CAAC,eAC1CnE,KAAA,CAAAqG,aAAA,CAAC7F,eAAe,MAAE,CAAC,eACnBR,KAAA,CAAAqG,aAAA,CAACvG,QAAQ,EAAAyG,QAAA,KACH5E,SAAS;IACbgC,MAAM,EAAE5D,aAAc;IACtBmG,MAAM,EAAEA,MAAO;IACfnF,QAAQ,EAAEA,QAAS;IACnBqE,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_1_0__sc-iim79x-0"
21
+ componentId: "text-editor-0_2_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 ");
@@ -34,6 +34,13 @@ export interface TextEditorProps {
34
34
  * @since 0.0.1
35
35
  */
36
36
  error?: boolean;
37
+ /**
38
+ * Indicates if the editor is in readonly mode.
39
+ * When true, renders the content using TextEditorOutput instead of the editable editor.
40
+ *
41
+ * @since 0.2.0
42
+ */
43
+ readonly?: boolean;
37
44
  /**
38
45
  * Accessible label for the editor's editable area. This text will be
39
46
  * announced by screen readers when the user focuses the editor. It should
@@ -1 +1 @@
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
+ {"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 * Indicates if the editor is in readonly mode.\n * When true, renders the content using TextEditorOutput instead of the editable editor.\n *\n * @since 0.2.0\n */\n readonly?: 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":""}
@@ -60,7 +60,7 @@ export var getDefaultConfig = function getDefaultConfig() {
60
60
  plugins: [Alignment, AutoLink, Bold, Clipboard, Essentials, FontBackgroundColor, FontColor, FontSize, GeneralHtmlSupport, Indent, IndentBlock, Italic, Link, List, ListProperties, Paragraph, Strikethrough, Table, TableCaption, TableCellProperties, TableColumnResize, TableProperties, TableToolbar, Underline, CutPlugin, PastePlugin, PasteAsTextPlugin, IndentPaddingToMarginPlugin, BlockQuote, Heading, Autoformat, SpecialCharacters, SpecialCharactersEssentials, Subscript, Superscript, HorizontalLine, RemoveFormat, CodeBlock, TabSpacesPlugin // TODO - delete
61
61
  ],
62
62
 
63
- toolbar: ['AccessibilityHelp', '|', 'bold', 'italic', 'underline', 'strikethrough', '|', 'alignment:left', 'alignment:center', 'alignment:right', '|', 'bulletedList', 'numberedList', '|', 'outdent', 'indent', '|', 'cut', 'paste', 'pasteAsText', '|', 'fontSize', '|', 'fontColor', 'fontBackgroundColor', '|', 'insertTable', 'link', '|', 'blockquote', 'heading', '|', 'horizontalLine', 'removeFormat', 'specialCharacters', 'subscript', 'superscript', 'codeblock', '|', 'undo', 'redo'],
63
+ toolbar: ['bold', 'italic', 'underline', 'strikethrough', '|', 'alignment:left', 'alignment:center', 'alignment:right', '|', 'bulletedList', 'numberedList', '|', 'outdent', 'indent', '|', 'cut', 'paste', 'pasteAsText', '|', 'fontSize', '|', 'fontColor', 'fontBackgroundColor', '|', 'insertTable', 'link', '|', 'blockquote', 'heading', '|', 'horizontalLine', 'removeFormat', 'specialCharacters', 'subscript', 'superscript', 'codeblock', '|', 'undo', 'redo'],
64
64
  fontSize: {
65
65
  options: [{
66
66
  title: '8pt',
@@ -1 +1 @@
1
- {"version":3,"file":"config.js","names":["Alignment","Autoformat","AutoLink","BlockQuote","Bold","Clipboard","CodeBlock","Essentials","FontBackgroundColor","FontColor","FontSize","GeneralHtmlSupport","Heading","HorizontalLine","Indent","IndentBlock","Italic","Link","List","ListProperties","Paragraph","RemoveFormat","SpecialCharacters","SpecialCharactersEssentials","Strikethrough","Subscript","Superscript","Table","TableCaption","TableCellProperties","TableColumnResize","TableProperties","TableToolbar","Underline","CK_EDITOR_LICENSE_KEY","CutPlugin","IndentPaddingToMarginPlugin","PasteAsTextPlugin","PastePlugin","TabSpacesPlugin","getEditorTranslation","getValidEditorLocale","TEXT_COLOR_PALETTE","color","getDefaultConfig","locale","arguments","length","undefined","licenseKey","language","translations","plugins","toolbar","fontSize","options","title","model","supportAllValues","fontColor","colors","fontBackgroundColor","indentBlock","offset","unit","htmlSupport","allow","name","styles","list","properties","useAttribute","startIndex","reversed","image","insert","integrations","table","contentToolbar","tableProperties","borderColors","backgroundColors","tableCellProperties","addButtonDataAttributes","editor","applyAttributes","toolbarElement","ui","view","element","toolbarChildren","Array","from","querySelectorAll","moreDropdownButtons","allToolbarElements","concat","toolbarItems","config","get","elementIndex","forEach","itemName","classList","contains","setAttribute","observer","MutationObserver","observe","childList","subtree","on","disconnect"],"sources":["../../../src/TextEditor/utils/config.ts"],"sourcesContent":["import type { ClassicEditor, EditorConfig } from 'ckeditor5'\nimport {\n Alignment,\n Autoformat,\n AutoLink,\n BlockQuote,\n Bold,\n Clipboard,\n CodeBlock,\n Essentials,\n FontBackgroundColor,\n FontColor,\n FontSize,\n GeneralHtmlSupport,\n Heading,\n HorizontalLine,\n Indent,\n IndentBlock,\n Italic,\n Link,\n List,\n ListProperties,\n Paragraph,\n RemoveFormat,\n SpecialCharacters,\n SpecialCharactersEssentials,\n Strikethrough,\n Subscript,\n Superscript,\n Table,\n TableCaption,\n TableCellProperties,\n TableColumnResize,\n TableProperties,\n TableToolbar,\n Underline,\n} from 'ckeditor5'\n\nimport { CK_EDITOR_LICENSE_KEY } from '../license_key'\nimport { CutPlugin } from '../plugins/CutPlugin'\nimport { IndentPaddingToMarginPlugin } from '../plugins/IndentPaddingToMarginPlugin'\nimport { PasteAsTextPlugin } from '../plugins/PasteAsTextPlugin'\nimport { PastePlugin } from '../plugins/PastePlugin'\nimport { TabSpacesPlugin } from '../plugins/TabSpacesPlugin'\nimport { getEditorTranslation, getValidEditorLocale } from './locale'\n\nconst TEXT_COLOR_PALETTE = [\n { color: '#BFEDD2' },\n { color: '#FBEEB8' },\n { color: '#F8CAC6' },\n { color: '#ECCAFA' },\n { color: '#C2E0F4' },\n { color: '#2DC26B' },\n { color: '#F1C40F' },\n { color: '#E03E2D' },\n { color: '#B96AD9' },\n { color: '#3598DB' },\n { color: '#169179' },\n { color: '#E67E23' },\n { color: '#BA372A' },\n { color: '#843FA1' },\n { color: '#236FA1' },\n { color: '#ECF0F1' },\n { color: '#CED4D9' },\n { color: '#95A5A6' },\n { color: '#7E8C8D' },\n { color: '#34495E' },\n { color: '#000000' },\n { color: '#FFFFFF' },\n]\n\nexport const getDefaultConfig = (locale: string = 'en'): EditorConfig => ({\n licenseKey: CK_EDITOR_LICENSE_KEY,\n language: getValidEditorLocale(locale),\n translations: [getEditorTranslation(locale)],\n plugins: [\n Alignment,\n AutoLink,\n Bold,\n Clipboard,\n Essentials,\n FontBackgroundColor,\n FontColor,\n FontSize,\n GeneralHtmlSupport,\n Indent,\n IndentBlock,\n Italic,\n Link,\n List,\n ListProperties,\n Paragraph,\n Strikethrough,\n Table,\n TableCaption,\n TableCellProperties,\n TableColumnResize,\n TableProperties,\n TableToolbar,\n Underline,\n CutPlugin,\n PastePlugin,\n PasteAsTextPlugin,\n IndentPaddingToMarginPlugin,\n BlockQuote,\n Heading,\n Autoformat,\n SpecialCharacters,\n SpecialCharactersEssentials,\n Subscript,\n Superscript,\n HorizontalLine,\n RemoveFormat,\n CodeBlock,\n TabSpacesPlugin, // TODO - delete\n ],\n toolbar: [\n 'AccessibilityHelp',\n '|',\n 'bold',\n 'italic',\n 'underline',\n 'strikethrough',\n '|',\n 'alignment:left',\n 'alignment:center',\n 'alignment:right',\n '|',\n 'bulletedList',\n 'numberedList',\n '|',\n 'outdent',\n 'indent',\n '|',\n 'cut',\n 'paste',\n 'pasteAsText',\n '|',\n 'fontSize',\n '|',\n 'fontColor',\n 'fontBackgroundColor',\n '|',\n 'insertTable',\n 'link',\n '|',\n 'blockquote',\n 'heading',\n '|',\n 'horizontalLine',\n 'removeFormat',\n 'specialCharacters',\n 'subscript',\n 'superscript',\n 'codeblock',\n '|',\n 'undo',\n 'redo',\n ],\n fontSize: {\n options: [\n { title: '8pt', model: '8px' },\n { title: '10pt', model: '10px' },\n { title: '12pt', model: '12px' },\n { title: '14pt', model: '14px' },\n { title: '18pt', model: '18px' },\n { title: '24pt', model: '24px' },\n { title: '36pt', model: '36px' },\n ],\n supportAllValues: true,\n },\n fontColor: {\n colors: TEXT_COLOR_PALETTE,\n },\n fontBackgroundColor: {\n colors: TEXT_COLOR_PALETTE,\n },\n indentBlock: {\n offset: 40,\n unit: 'px',\n },\n htmlSupport: {\n allow: [\n {\n name: 'p',\n styles: {\n 'margin-left': true,\n },\n },\n ],\n },\n list: {\n properties: {\n styles: {\n useAttribute: true,\n },\n startIndex: true,\n reversed: true,\n },\n },\n image: {\n insert: {\n integrations: ['insertImageViaUrl'],\n },\n toolbar: ['imageTextAlternative'],\n },\n table: {\n contentToolbar: [\n 'tableColumn',\n 'tableRow',\n 'mergeTableCells',\n 'tableProperties',\n 'tableCellProperties',\n ],\n tableProperties: {\n borderColors: TEXT_COLOR_PALETTE,\n backgroundColors: TEXT_COLOR_PALETTE,\n },\n tableCellProperties: {\n borderColors: TEXT_COLOR_PALETTE,\n backgroundColors: TEXT_COLOR_PALETTE,\n },\n },\n})\n\n// Add stable data attributes to toolbar buttons for the styling (or testing) purposes\nexport const addButtonDataAttributes = (editor: ClassicEditor) => {\n const applyAttributes = () => {\n const toolbarElement = editor.ui.view.toolbar.element\n if (!toolbarElement) {\n return\n }\n\n // Get buttons in the main toolbar\n const toolbarChildren = Array.from(\n toolbarElement.querySelectorAll('.ck-toolbar__items > *')\n )\n\n // Get buttons hidden in \"more\" dropdown\n const moreDropdownButtons = Array.from(\n toolbarElement.querySelectorAll('.ck-dropdown__panel .ck-list .ck-button')\n )\n\n const allToolbarElements = [...toolbarChildren, ...moreDropdownButtons]\n\n // Create mapping based on toolbar configuration order\n const toolbarItems = (editor.config.get('toolbar') || []) as string[]\n let elementIndex = 0\n\n toolbarItems.forEach((itemName) => {\n const element = allToolbarElements[elementIndex]\n if (\n itemName !== '|' &&\n element &&\n !element.classList.contains('ck-toolbar__separator')\n ) {\n // Use the toolbar item name as the stable identifier\n element.setAttribute('data-cke-command', itemName)\n }\n elementIndex++\n })\n }\n\n // Apply attributes initially\n applyAttributes()\n\n // Re-apply when dropdown menus are opened (buttons get created dynamically)\n const toolbarElement = editor.ui.view.toolbar.element\n if (toolbarElement) {\n const observer = new MutationObserver(() => {\n applyAttributes()\n })\n observer.observe(toolbarElement, {\n childList: true,\n subtree: true,\n })\n editor.on('destroy', () => {\n observer.disconnect()\n })\n }\n}\n"],"mappings":"AACA,SACEA,SAAS,EACTC,UAAU,EACVC,QAAQ,EACRC,UAAU,EACVC,IAAI,EACJC,SAAS,EACTC,SAAS,EACTC,UAAU,EACVC,mBAAmB,EACnBC,SAAS,EACTC,QAAQ,EACRC,kBAAkB,EAClBC,OAAO,EACPC,cAAc,EACdC,MAAM,EACNC,WAAW,EACXC,MAAM,EACNC,IAAI,EACJC,IAAI,EACJC,cAAc,EACdC,SAAS,EACTC,YAAY,EACZC,iBAAiB,EACjBC,2BAA2B,EAC3BC,aAAa,EACbC,SAAS,EACTC,WAAW,EACXC,KAAK,EACLC,YAAY,EACZC,mBAAmB,EACnBC,iBAAiB,EACjBC,eAAe,EACfC,YAAY,EACZC,SAAS,QACJ,WAAW;AAElB,SAASC,qBAAqB,QAAQ,gBAAgB;AACtD,SAASC,SAAS,QAAQ,sBAAsB;AAChD,SAASC,2BAA2B,QAAQ,wCAAwC;AACpF,SAASC,iBAAiB,QAAQ,8BAA8B;AAChE,SAASC,WAAW,QAAQ,wBAAwB;AACpD,SAASC,eAAe,QAAQ,4BAA4B;AAC5D,SAASC,oBAAoB,EAAEC,oBAAoB,QAAQ,UAAU;AAErE,IAAMC,kBAAkB,GAAG,CACzB;EAAEC,KAAK,EAAE;AAAU,CAAC,EACpB;EAAEA,KAAK,EAAE;AAAU,CAAC,EACpB;EAAEA,KAAK,EAAE;AAAU,CAAC,EACpB;EAAEA,KAAK,EAAE;AAAU,CAAC,EACpB;EAAEA,KAAK,EAAE;AAAU,CAAC,EACpB;EAAEA,KAAK,EAAE;AAAU,CAAC,EACpB;EAAEA,KAAK,EAAE;AAAU,CAA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AK,CAACC,IAAI,CACpCN,cAAc,CAACO,gBAAgB,CAAC,yCAAyC,CAC3E,CAAC;IAED,IAAME,kBAAkB,MAAAC,MAAA,CAAON,eAAe,EAAKI,mBAAmB,CAAC;;IAEvE;IACA,IAAMG,YAAY,GAAIb,MAAM,CAACc,MAAM,CAACC,GAAG,CAAC,SAAS,CAAC,IAAI,EAAe;IACrE,IAAIC,YAAY,GAAG,CAAC;IAEpBH,YAAY,CAACI,OAAO,CAAC,UAACC,QAAQ,EAAK;MACjC,IAAMb,OAAO,GAAGM,kBAAkB,CAACK,YAAY,CAAC;MAChD,IACEE,QAAQ,KAAK,GAAG,IAChBb,OAAO,IACP,CAACA,OAAO,CAACc,SAAS,CAACC,QAAQ,CAAC,uBAAuB,CAAC,EACpD;QACA;QACAf,OAAO,CAACgB,YAAY,CAAC,kBAAkB,EAAEH,QAAQ,CAAC;MACpD;MACAF,YAAY,EAAE;IAChB,CAAC,CAAC;EACJ,CAAC;;EAED;EACAf,eAAe,CAAC,CAAC;;EAEjB;EACA,IAAMC,cAAc,GAAGF,MAAM,CAACG,EAAE,CAACC,IAAI,CAACnC,OAAO,CAACoC,OAAO;EACrD,IAAIH,cAAc,EAAE;IAClB,IAAMoB,QAAQ,GAAG,IAAIC,gBAAgB,CAAC,YAAM;MAC1CtB,eAAe,CAAC,CAAC;IACnB,CAAC,CAAC;IACFqB,QAAQ,CAACE,OAAO,CAACtB,cAAc,EAAE;MAC/BuB,SAAS,EAAE,IAAI;MACfC,OAAO,EAAE;IACX,CAAC,CAAC;IACF1B,MAAM,CAAC2B,EAAE,CAAC,SAAS,EAAE,YAAM;MACzBL,QAAQ,CAACM,UAAU,CAAC,CAAC;IACvB,CAAC,CAAC;EACJ;AACF,CAAC"}
1
+ {"version":3,"file":"config.js","names":["Alignment","Autoformat","AutoLink","BlockQuote","Bold","Clipboard","CodeBlock","Essentials","FontBackgroundColor","FontColor","FontSize","GeneralHtmlSupport","Heading","HorizontalLine","Indent","IndentBlock","Italic","Link","List","ListProperties","Paragraph","RemoveFormat","SpecialCharacters","SpecialCharactersEssentials","Strikethrough","Subscript","Superscript","Table","TableCaption","TableCellProperties","TableColumnResize","TableProperties","TableToolbar","Underline","CK_EDITOR_LICENSE_KEY","CutPlugin","IndentPaddingToMarginPlugin","PasteAsTextPlugin","PastePlugin","TabSpacesPlugin","getEditorTranslation","getValidEditorLocale","TEXT_COLOR_PALETTE","color","getDefaultConfig","locale","arguments","length","undefined","licenseKey","language","translations","plugins","toolbar","fontSize","options","title","model","supportAllValues","fontColor","colors","fontBackgroundColor","indentBlock","offset","unit","htmlSupport","allow","name","styles","list","properties","useAttribute","startIndex","reversed","image","insert","integrations","table","contentToolbar","tableProperties","borderColors","backgroundColors","tableCellProperties","addButtonDataAttributes","editor","applyAttributes","toolbarElement","ui","view","element","toolbarChildren","Array","from","querySelectorAll","moreDropdownButtons","allToolbarElements","concat","toolbarItems","config","get","elementIndex","forEach","itemName","classList","contains","setAttribute","observer","MutationObserver","observe","childList","subtree","on","disconnect"],"sources":["../../../src/TextEditor/utils/config.ts"],"sourcesContent":["import type { ClassicEditor, EditorConfig } from 'ckeditor5'\nimport {\n Alignment,\n Autoformat,\n AutoLink,\n BlockQuote,\n Bold,\n Clipboard,\n CodeBlock,\n Essentials,\n FontBackgroundColor,\n FontColor,\n FontSize,\n GeneralHtmlSupport,\n Heading,\n HorizontalLine,\n Indent,\n IndentBlock,\n Italic,\n Link,\n List,\n ListProperties,\n Paragraph,\n RemoveFormat,\n SpecialCharacters,\n SpecialCharactersEssentials,\n Strikethrough,\n Subscript,\n Superscript,\n Table,\n TableCaption,\n TableCellProperties,\n TableColumnResize,\n TableProperties,\n TableToolbar,\n Underline,\n} from 'ckeditor5'\n\nimport { CK_EDITOR_LICENSE_KEY } from '../license_key'\nimport { CutPlugin } from '../plugins/CutPlugin'\nimport { IndentPaddingToMarginPlugin } from '../plugins/IndentPaddingToMarginPlugin'\nimport { PasteAsTextPlugin } from '../plugins/PasteAsTextPlugin'\nimport { PastePlugin } from '../plugins/PastePlugin'\nimport { TabSpacesPlugin } from '../plugins/TabSpacesPlugin'\nimport { getEditorTranslation, getValidEditorLocale } from './locale'\n\nconst TEXT_COLOR_PALETTE = [\n { color: '#BFEDD2' },\n { color: '#FBEEB8' },\n { color: '#F8CAC6' },\n { color: '#ECCAFA' },\n { color: '#C2E0F4' },\n { color: '#2DC26B' },\n { color: '#F1C40F' },\n { color: '#E03E2D' },\n { color: '#B96AD9' },\n { color: '#3598DB' },\n { color: '#169179' },\n { color: '#E67E23' },\n { color: '#BA372A' },\n { color: '#843FA1' },\n { color: '#236FA1' },\n { color: '#ECF0F1' },\n { color: '#CED4D9' },\n { color: '#95A5A6' },\n { color: '#7E8C8D' },\n { color: '#34495E' },\n { color: '#000000' },\n { color: '#FFFFFF' },\n]\n\nexport const getDefaultConfig = (locale: string = 'en'): EditorConfig => ({\n licenseKey: CK_EDITOR_LICENSE_KEY,\n language: getValidEditorLocale(locale),\n translations: [getEditorTranslation(locale)],\n plugins: [\n Alignment,\n AutoLink,\n Bold,\n Clipboard,\n Essentials,\n FontBackgroundColor,\n FontColor,\n FontSize,\n GeneralHtmlSupport,\n Indent,\n IndentBlock,\n Italic,\n Link,\n List,\n ListProperties,\n Paragraph,\n Strikethrough,\n Table,\n TableCaption,\n TableCellProperties,\n TableColumnResize,\n TableProperties,\n TableToolbar,\n Underline,\n CutPlugin,\n PastePlugin,\n PasteAsTextPlugin,\n IndentPaddingToMarginPlugin,\n BlockQuote,\n Heading,\n Autoformat,\n SpecialCharacters,\n SpecialCharactersEssentials,\n Subscript,\n Superscript,\n HorizontalLine,\n RemoveFormat,\n CodeBlock,\n TabSpacesPlugin, // TODO - delete\n ],\n toolbar: [\n 'bold',\n 'italic',\n 'underline',\n 'strikethrough',\n '|',\n 'alignment:left',\n 'alignment:center',\n 'alignment:right',\n '|',\n 'bulletedList',\n 'numberedList',\n '|',\n 'outdent',\n 'indent',\n '|',\n 'cut',\n 'paste',\n 'pasteAsText',\n '|',\n 'fontSize',\n '|',\n 'fontColor',\n 'fontBackgroundColor',\n '|',\n 'insertTable',\n 'link',\n '|',\n 'blockquote',\n 'heading',\n '|',\n 'horizontalLine',\n 'removeFormat',\n 'specialCharacters',\n 'subscript',\n 'superscript',\n 'codeblock',\n '|',\n 'undo',\n 'redo',\n ],\n fontSize: {\n options: [\n { title: '8pt', model: '8px' },\n { title: '10pt', model: '10px' },\n { title: '12pt', model: '12px' },\n { title: '14pt', model: '14px' },\n { title: '18pt', model: '18px' },\n { title: '24pt', model: '24px' },\n { title: '36pt', model: '36px' },\n ],\n supportAllValues: true,\n },\n fontColor: {\n colors: TEXT_COLOR_PALETTE,\n },\n fontBackgroundColor: {\n colors: TEXT_COLOR_PALETTE,\n },\n indentBlock: {\n offset: 40,\n unit: 'px',\n },\n htmlSupport: {\n allow: [\n {\n name: 'p',\n styles: {\n 'margin-left': true,\n },\n },\n ],\n },\n list: {\n properties: {\n styles: {\n useAttribute: true,\n },\n startIndex: true,\n reversed: true,\n },\n },\n image: {\n insert: {\n integrations: ['insertImageViaUrl'],\n },\n toolbar: ['imageTextAlternative'],\n },\n table: {\n contentToolbar: [\n 'tableColumn',\n 'tableRow',\n 'mergeTableCells',\n 'tableProperties',\n 'tableCellProperties',\n ],\n tableProperties: {\n borderColors: TEXT_COLOR_PALETTE,\n backgroundColors: TEXT_COLOR_PALETTE,\n },\n tableCellProperties: {\n borderColors: TEXT_COLOR_PALETTE,\n backgroundColors: TEXT_COLOR_PALETTE,\n },\n },\n})\n\n// Add stable data attributes to toolbar buttons for the styling (or testing) purposes\nexport const addButtonDataAttributes = (editor: ClassicEditor) => {\n const applyAttributes = () => {\n const toolbarElement = editor.ui.view.toolbar.element\n if (!toolbarElement) {\n return\n }\n\n // Get buttons in the main toolbar\n const toolbarChildren = Array.from(\n toolbarElement.querySelectorAll('.ck-toolbar__items > *')\n )\n\n // Get buttons hidden in \"more\" dropdown\n const moreDropdownButtons = Array.from(\n toolbarElement.querySelectorAll('.ck-dropdown__panel .ck-list .ck-button')\n )\n\n const allToolbarElements = [...toolbarChildren, ...moreDropdownButtons]\n\n // Create mapping based on toolbar configuration order\n const toolbarItems = (editor.config.get('toolbar') || []) as string[]\n let elementIndex = 0\n\n toolbarItems.forEach((itemName) => {\n const element = allToolbarElements[elementIndex]\n if (\n itemName !== '|' &&\n element &&\n !element.classList.contains('ck-toolbar__separator')\n ) {\n // Use the toolbar item name as the stable identifier\n element.setAttribute('data-cke-command', itemName)\n }\n elementIndex++\n })\n }\n\n // Apply attributes initially\n applyAttributes()\n\n // Re-apply when dropdown menus are opened (buttons get created dynamically)\n const toolbarElement = editor.ui.view.toolbar.element\n if (toolbarElement) {\n const observer = new MutationObserver(() => {\n applyAttributes()\n })\n observer.observe(toolbarElement, {\n childList: true,\n subtree: true,\n })\n editor.on('destroy', () => {\n observer.disconnect()\n })\n }\n}\n"],"mappings":"AACA,SACEA,SAAS,EACTC,UAAU,EACVC,QAAQ,EACRC,UAAU,EACVC,IAAI,EACJC,SAAS,EACTC,SAAS,EACTC,UAAU,EACVC,mBAAmB,EACnBC,SAAS,EACTC,QAAQ,EACRC,kBAAkB,EAClBC,OAAO,EACPC,cAAc,EACdC,MAAM,EACNC,WAAW,EACXC,MAAM,EACNC,IAAI,EACJC,IAAI,EACJC,cAAc,EACdC,SAAS,EACTC,YAAY,EACZC,iBAAiB,EACjBC,2BAA2B,EAC3BC,aAAa,EACbC,SAAS,EACTC,WAAW,EACXC,KAAK,EACLC,YAAY,EACZC,mBAAmB,EACnBC,iBAAiB,EACjBC,eAAe,EACfC,YAAY,EACZC,SAAS,QACJ,WAAW;AAElB,SAASC,qBAAqB,QAAQ,gBAAgB;AACtD,SAASC,SAAS,QAAQ,sBAAsB;AAChD,SAASC,2BAA2B,QAAQ,wCAAwC;AACpF,SAASC,iBAAiB,QAAQ,8BAA8B;AAChE,SAASC,WAAW,QAAQ,wBAAwB;AACpD,SAASC,eAAe,QAAQ,4BAA4B;AAC5D,SAASC,o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E;IACX,CAAC,CAAC;IACF1B,MAAM,CAAC2B,EAAE,CAAC,SAAS,EAAE,YAAM;MACzBL,QAAQ,CAACM,UAAU,CAAC,CAAC;IACvB,CAAC,CAAC;EACJ;AACF,CAAC"}
@@ -1,6 +1,6 @@
1
1
  import styled from 'styled-components';
2
2
  export var StyledEditor = /*#__PURE__*/styled.div.withConfig({
3
3
  displayName: "StyledEditor",
4
- componentId: "text-editor-0_1_0__sc-1oujb2g-0"
4
+ componentId: "text-editor-0_2_0__sc-1oujb2g-0"
5
5
  })([".ck-editor__top{height:0 !important;}.ck-content{border:none !important;padding:0 !important;p{margin:0;}table,img{margin-left:auto;margin-right:auto;}img{display:block;}table{border:1px double #b3b3b3;border-collapse:collapse;border-spacing:0;th{text-align:left;}& > thead,& > tbody{& > tr > td,& > tr > th{border:1px solid #bfbfbf;min-width:2em;padding:0.4em;}& > tr > th{background:rgba(0,0,0,0.05);font-weight:700;}}}}"]);
6
6
  //# sourceMappingURL=TextEditorOutput.styles.js.map
@@ -6,6 +6,7 @@ export declare const exampleText: {
6
6
  long_ipsum: string;
7
7
  longest_ipsum: string;
8
8
  long_ipsum_one_line: string;
9
+ formatted_content: string;
9
10
  };
10
11
  export declare function Ipsum(lengthOrOptions: number | {
11
12
  length: number;
@@ -5,7 +5,8 @@ export var exampleText = {
5
5
  short_sentence: 'Did you think you have mastery over fire? Incredible!',
6
6
  long_ipsum: "Lorem ip sum dolor sit amet, consectetur adipiscing elit,\n ed do eiusmod tempor incididunt ut labore et dolore magna aliqua.\n Scelerisque eleifend donec pretium vulputate sapien nec sagittis.\n Ultricies tristique nulla aliquet enim tortor at auctor urna nunc.\n Vitae turpis massa sed elementum tempus egestas.\n Nunc consequat interdum varius sit amet",
7
7
  longest_ipsum: "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod\n tempor incididunt ut labore et dolore magna aliqua. Ac tortor dignissim\n convallis aenean et. Facilisis volutpat est velit egestas dui id. In\n nulla posuere sollicitudin aliquam ultrices. Lorem mollis aliquam ut\n porttitor. Convallis aenean et tortor at risus viverra adipiscing at.\n Euismod nisi porta lorem mollis aliquam ut porttitor. Hac habitasse\n platea dictumst vestibulum rhoncus est pellentesque elit ullamcorper.\n Viverra tellus in hac habitasse platea dictumst. Scelerisque viverra lawn\n gnome in aliquam sem fringilla ut morbi tincidunt. Ullamcorper morbi tincidunt\n ornare massa eget. Gravida cum sociis natoque penatibus. Leo vel fringilla est\n ullamcorper eget nulla. Vitae proin sagittis nisl rhoncus mattis rhoncus urna.\n Mauris commodo quis imperdiet massa tincidunt nunc pulvinar sapien et. Id aliquet\n lectus proin nibh troll condimentum id venenatis.",
8
- long_ipsum_one_line: "Lorem ip sum dolor sit amet, consectetur adipiscing elit, ed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Scelerisque eleifend donec pretium vulputate sapien nec sagittis. Ultricies tristique nulla aliquet enim tortor at auctor urna nunc. Vitae turpis massa sed elementum tempus egestas. Nunc consequat interdum varius sit amet"
8
+ long_ipsum_one_line: "Lorem ip sum dolor sit amet, consectetur adipiscing elit, ed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Scelerisque eleifend donec pretium vulputate sapien nec sagittis. Ultricies tristique nulla aliquet enim tortor at auctor urna nunc. Vitae turpis massa sed elementum tempus egestas. Nunc consequat interdum varius sit amet",
9
+ formatted_content: "\n <p><strong>Bold text</strong> and <em>italic text</em></p>\n <ul>\n <li>List item 1</li>\n <li>List item 2</li>\n </ul>\n <p style=\"text-align: center;\">Centered text</p>\n "
9
10
  };
10
11
  export function Ipsum(lengthOrOptions) {
11
12
  if (typeof lengthOrOptions === 'number') {
@@ -1 +1 @@
1
- {"version":3,"file":"constants.js","names":["exampleText","none","short_ipsum","short_sentence","long_ipsum","longest_ipsum","long_ipsum_one_line","Ipsum","lengthOrOptions","recursiveGrow","length","lettercase","trailingPeriod","longString","lastChar","includes","slice","replace","s","toUpperCase","arguments","undefined","out"],"sources":["../../src/_storyHelpers/constants.ts"],"sourcesContent":["export const exampleText = {\n default: 'Click me!',\n none: '',\n short_ipsum: 'Lorum',\n short_sentence: 'Did you think you have mastery over fire? Incredible!',\n long_ipsum: `Lorem ip sum dolor sit amet, consectetur adipiscing elit,\n ed do eiusmod tempor incididunt ut labore et dolore magna aliqua.\n Scelerisque eleifend donec pretium vulputate sapien nec sagittis.\n Ultricies tristique nulla aliquet enim tortor at auctor urna nunc.\n Vitae turpis massa sed elementum tempus egestas.\n Nunc consequat interdum varius sit amet`,\n longest_ipsum: `Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod\n tempor incididunt ut labore et dolore magna aliqua. Ac tortor dignissim\n convallis aenean et. Facilisis volutpat est velit egestas dui id. In\n nulla posuere sollicitudin aliquam ultrices. Lorem mollis aliquam ut\n porttitor. Convallis aenean et tortor at risus viverra adipiscing at.\n Euismod nisi porta lorem mollis aliquam ut porttitor. Hac habitasse\n platea dictumst vestibulum rhoncus est pellentesque elit ullamcorper.\n Viverra tellus in hac habitasse platea dictumst. Scelerisque viverra lawn\n gnome in aliquam sem fringilla ut morbi tincidunt. Ullamcorper morbi tincidunt\n ornare massa eget. Gravida cum sociis natoque penatibus. Leo vel fringilla est\n ullamcorper eget nulla. Vitae proin sagittis nisl rhoncus mattis rhoncus urna.\n Mauris commodo quis imperdiet massa tincidunt nunc pulvinar sapien et. Id aliquet\n lectus proin nibh troll condimentum id venenatis.`,\n long_ipsum_one_line: `Lorem ip sum dolor sit amet, consectetur adipiscing elit, ed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Scelerisque eleifend donec pretium vulputate sapien nec sagittis. Ultricies tristique nulla aliquet enim tortor at auctor urna nunc. Vitae turpis massa sed elementum tempus egestas. Nunc consequat interdum varius sit amet`,\n}\n\nexport function Ipsum(\n lengthOrOptions:\n | number\n | {\n length: number\n lettercase?: 'sentence' | 'title'\n trailingPeriod?: boolean\n }\n) {\n if (typeof lengthOrOptions === 'number') {\n return recursiveGrow(lengthOrOptions)\n }\n const { length, lettercase, trailingPeriod } = lengthOrOptions\n let longString = recursiveGrow(length)\n const lastChar = longString[longString.length - 1]\n if (!trailingPeriod && ['.', ','].includes(lastChar)) {\n longString = longString.slice(0, -1)\n }\n if (lettercase === 'title') {\n longString = longString.replace(/\\b\\w/g, (s) => s.toUpperCase())\n }\n return longString\n}\n\n/**\n * Creates a sentence case sentence.\n * @returns string\n */\nconst recursiveGrow = (length = 1, out = exampleText.longest_ipsum): string => {\n if (!length) {\n return ''\n }\n if (out.length < length) {\n return recursiveGrow(length, out + exampleText.longest_ipsum)\n }\n if (out.length >= length) {\n return out.slice(0, length - 1) + '.'\n }\n return 'Lorem ipsum grow failed.'\n}\n"],"mappings":"AAAA,OAAO,IAAMA,WAAW,GAAG;EACzB,WAAS,WAAW;EACpBC,IAAI,EAAE,EAAE;EACRC,WAAW,EAAE,OAAO;EACpBC,cAAc,EAAE,uDAAuD;EACvEC,UAAU,sXAKgC;EAC1CC,aAAa,o+BAYuC;EACpDC,mBAAmB;AACrB,CAAC;AAED,OAAO,SAASC,KAAKA,CACnBC,eAMK,EACL;EACA,IAAI,OAAOA,eAAe,KAAK,QAAQ,EAAE;IACvC,OAAOC,cAAa,CAACD,eAAe,CAAC;EACvC;EACA,IAAQE,MAAM,GAAiCF,eAAe,CAAtDE,MAAM;IAAEC,UAAU,GAAqBH,eAAe,CAA9CG,UAAU;IAAEC,cAAc,GAAKJ,eAAe,CAAlCI,cAAc;EAC1C,IAAIC,UAAU,GAAGJ,cAAa,CAACC,MAAM,CAAC;EACtC,IAAMI,QAAQ,GAAGD,UAAU,CAACA,UAAU,CAACH,MAAM,GAAG,CAAC,CAAC;EAClD,IAAI,CAACE,cAAc,IAAI,CAAC,GAAG,EAAE,GAAG,CAAC,CAACG,QAAQ,CAACD,QAAQ,CAAC,EAAE;IACpDD,UAAU,GAAGA,UAAU,CAACG,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;EACtC;EACA,IAAIL,UAAU,KAAK,OAAO,EAAE;IAC1BE,UAAU,GAAGA,UAAU,CAACI,OAAO,CAAC,OAAO,EAAE,UAACC,CAAC;MAAA,OAAKA,CAAC,CAACC,WAAW,CAAC,CAAC;IAAA,EAAC;EAClE;EACA,OAAON,UAAU;AACnB;;AAEA;AACA;AACA;AACA;AACA,IAAMJ,cAAa,GAAG,SAAhBA,aAAaA,CAAA,EAA4D;EAAA,IAAxDC,MAAM,GAAAU,SAAA,CAAAV,MAAA,QAAAU,SAAA,QAAAC,SAAA,GAAAD,SAAA,MAAG,CAAC;EAAA,IAAEE,GAAG,GAAAF,SAAA,CAAAV,MAAA,QAAAU,SAAA,QAAAC,SAAA,GAAAD,SAAA,MAAGpB,WAAW,CAACK,aAAa;EAChE,IAAI,CAACK,MAAM,EAAE;IACX,OAAO,EAAE;EACX;EACA,IAAIY,GAAG,CAACZ,MAAM,GAAGA,MAAM,EAAE;IACvB,OAAOD,cAAa,CAACC,MAAM,EAAEY,GAAG,GAAGtB,WAAW,CAACK,aAAa,CAAC;EAC/D;EACA,IAAIiB,GAAG,CAACZ,MAAM,IAAIA,MAAM,EAAE;IACxB,OAAOY,GAAG,CAACN,KAAK,CAAC,CAAC,EAAEN,MAAM,GAAG,CAAC,CAAC,GAAG,GAAG;EACvC;EACA,OAAO,0BAA0B;AACnC,CAAC"}
1
+ {"version":3,"file":"constants.js","names":["exampleText","none","short_ipsum","short_sentence","long_ipsum","longest_ipsum","long_ipsum_one_line","formatted_content","Ipsum","lengthOrOptions","recursiveGrow","length","lettercase","trailingPeriod","longString","lastChar","includes","slice","replace","s","toUpperCase","arguments","undefined","out"],"sources":["../../src/_storyHelpers/constants.ts"],"sourcesContent":["export const exampleText = {\n default: 'Click me!',\n none: '',\n short_ipsum: 'Lorum',\n short_sentence: 'Did you think you have mastery over fire? Incredible!',\n long_ipsum: `Lorem ip sum dolor sit amet, consectetur adipiscing elit,\n ed do eiusmod tempor incididunt ut labore et dolore magna aliqua.\n Scelerisque eleifend donec pretium vulputate sapien nec sagittis.\n Ultricies tristique nulla aliquet enim tortor at auctor urna nunc.\n Vitae turpis massa sed elementum tempus egestas.\n Nunc consequat interdum varius sit amet`,\n longest_ipsum: `Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod\n tempor incididunt ut labore et dolore magna aliqua. Ac tortor dignissim\n convallis aenean et. Facilisis volutpat est velit egestas dui id. In\n nulla posuere sollicitudin aliquam ultrices. Lorem mollis aliquam ut\n porttitor. Convallis aenean et tortor at risus viverra adipiscing at.\n Euismod nisi porta lorem mollis aliquam ut porttitor. Hac habitasse\n platea dictumst vestibulum rhoncus est pellentesque elit ullamcorper.\n Viverra tellus in hac habitasse platea dictumst. Scelerisque viverra lawn\n gnome in aliquam sem fringilla ut morbi tincidunt. Ullamcorper morbi tincidunt\n ornare massa eget. Gravida cum sociis natoque penatibus. Leo vel fringilla est\n ullamcorper eget nulla. Vitae proin sagittis nisl rhoncus mattis rhoncus urna.\n Mauris commodo quis imperdiet massa tincidunt nunc pulvinar sapien et. Id aliquet\n lectus proin nibh troll condimentum id venenatis.`,\n long_ipsum_one_line: `Lorem ip sum dolor sit amet, consectetur adipiscing elit, ed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Scelerisque eleifend donec pretium vulputate sapien nec sagittis. Ultricies tristique nulla aliquet enim tortor at auctor urna nunc. Vitae turpis massa sed elementum tempus egestas. Nunc consequat interdum varius sit amet`,\n formatted_content: `\n <p><strong>Bold text</strong> and <em>italic text</em></p>\n <ul>\n <li>List item 1</li>\n <li>List item 2</li>\n </ul>\n <p style=\"text-align: center;\">Centered text</p>\n `,\n}\n\nexport function Ipsum(\n lengthOrOptions:\n | number\n | {\n length: number\n lettercase?: 'sentence' | 'title'\n trailingPeriod?: boolean\n }\n) {\n if (typeof lengthOrOptions === 'number') {\n return recursiveGrow(lengthOrOptions)\n }\n const { length, lettercase, trailingPeriod } = lengthOrOptions\n let longString = recursiveGrow(length)\n const lastChar = longString[longString.length - 1]\n if (!trailingPeriod && ['.', ','].includes(lastChar)) {\n longString = longString.slice(0, -1)\n }\n if (lettercase === 'title') {\n longString = longString.replace(/\\b\\w/g, (s) => s.toUpperCase())\n }\n return longString\n}\n\n/**\n * Creates a sentence case sentence.\n * @returns string\n */\nconst recursiveGrow = (length = 1, out = exampleText.longest_ipsum): string => {\n if (!length) {\n return ''\n }\n if (out.length < length) {\n return recursiveGrow(length, out + exampleText.longest_ipsum)\n }\n if (out.length >= length) {\n return out.slice(0, length - 1) + '.'\n }\n return 'Lorem ipsum grow failed.'\n}\n"],"mappings":"AAAA,OAAO,IAAMA,WAAW,GAAG;EACzB,WAAS,WAAW;EACpBC,IAAI,EAAE,EAAE;EACRC,WAAW,EAAE,OAAO;EACpBC,cAAc,EAAE,uDAAuD;EACvEC,UAAU,sXAKgC;EAC1CC,aAAa,o+BAYuC;EACpDC,mBAAmB,6VAA6V;EAChXC,iBAAiB;AAQnB,CAAC;AAED,OAAO,SAASC,KAAKA,CACnBC,eAMK,EACL;EACA,IAAI,OAAOA,eAAe,KAAK,QAAQ,EAAE;IACvC,OAAOC,cAAa,CAACD,eAAe,CAAC;EACvC;EACA,IAAQE,MAAM,GAAiCF,eAAe,CAAtDE,MAAM;IAAEC,UAAU,GAAqBH,eAAe,CAA9CG,UAAU;IAAEC,cAAc,GAAKJ,eAAe,CAAlCI,cAAc;EAC1C,IAAIC,UAAU,GAAGJ,cAAa,CAACC,MAAM,CAAC;EACtC,IAAMI,QAAQ,GAAGD,UAAU,CAACA,UAAU,CAACH,MAAM,GAAG,CAAC,CAAC;EAClD,IAAI,CAACE,cAAc,IAAI,CAAC,GAAG,EAAE,GAAG,CAAC,CAACG,QAAQ,CAACD,QAAQ,CAAC,EAAE;IACpDD,UAAU,GAAGA,UAAU,CAACG,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;EACtC;EACA,IAAIL,UAAU,KAAK,OAAO,EAAE;IAC1BE,UAAU,GAAGA,UAAU,CAACI,OAAO,CAAC,OAAO,EAAE,UAACC,CAAC;MAAA,OAAKA,CAAC,CAACC,WAAW,CAAC,CAAC;IAAA,EAAC;EAClE;EACA,OAAON,UAAU;AACnB;;AAEA;AACA;AACA;AACA;AACA,IAAMJ,cAAa,GAAG,SAAhBA,aAAaA,CAAA,EAA4D;EAAA,IAAxDC,MAAM,GAAAU,SAAA,CAAAV,MAAA,QAAAU,SAAA,QAAAC,SAAA,GAAAD,SAAA,MAAG,CAAC;EAAA,IAAEE,GAAG,GAAAF,SAAA,CAAAV,MAAA,QAAAU,SAAA,QAAAC,SAAA,GAAAD,SAAA,MAAGrB,WAAW,CAACK,aAAa;EAChE,IAAI,CAACM,MAAM,EAAE;IACX,OAAO,EAAE;EACX;EACA,IAAIY,GAAG,CAACZ,MAAM,GAAGA,MAAM,EAAE;IACvB,OAAOD,cAAa,CAACC,MAAM,EAAEY,GAAG,GAAGvB,WAAW,CAACK,aAAa,CAAC;EAC/D;EACA,IAAIkB,GAAG,CAACZ,MAAM,IAAIA,MAAM,EAAE;IACxB,OAAOY,GAAG,CAACN,KAAK,CAAC,CAAC,EAAEN,MAAM,GAAG,CAAC,CAAC,GAAG,GAAG;EACvC;EACA,OAAO,0BAA0B;AACnC,CAAC"}
@@ -10,7 +10,7 @@
10
10
  "description": "Accessible description for the editor's editable area.\nThis text provides additional context to screen reader users. It will be\nannounced after the label when the user focuses the editor.",
11
11
  "descriptionHtml": "<div class=\"tsd-comment tsd-typography\"><div class=\"lead\">\n<p>Accessible description for the editor&#39;s editable area.\nThis text provides additional context to screen reader users. It will be\nannounced after the label when the user focuses the editor.</p>\n</div><dl class=\"tsd-comment-tags\"><dt>since</dt><dd><p>0.1.0</p>\n</dd></dl></div>",
12
12
  "sourceFile": "TextEditor/TextEditor.types.ts",
13
- "sourceUrl": "https://github.com/procore/core/blob/77cfaf0/packages/text-editor/src/TextEditor/TextEditor.types.ts#L60"
13
+ "sourceUrl": "https://github.com/procore/core/blob/5a7d81e/packages/text-editor/src/TextEditor/TextEditor.types.ts#L68"
14
14
  },
15
15
  {
16
16
  "name": "aria-label",
@@ -20,7 +20,7 @@
20
20
  "description": "Accessible label for the editor's editable area. This text will be\nannounced by screen readers when the user focuses the editor. It should\nmatch or include the visible label associated with this editor field.\nIf not provided, screen readers will announce a generic \"Rich Text Editor\" message.",
21
21
  "descriptionHtml": "<div class=\"tsd-comment tsd-typography\"><div class=\"lead\">\n<p>Accessible label for the editor&#39;s editable area. This text will be\nannounced by screen readers when the user focuses the editor. It should\nmatch or include the visible label associated with this editor field.\nIf not provided, screen readers will announce a generic &quot;Rich Text Editor&quot; message.</p>\n</div><dl class=\"tsd-comment-tags\"><dt>since</dt><dd><p>0.1.0</p>\n</dd></dl></div>",
22
22
  "sourceFile": "TextEditor/TextEditor.types.ts",
23
- "sourceUrl": "https://github.com/procore/core/blob/77cfaf0/packages/text-editor/src/TextEditor/TextEditor.types.ts#L51"
23
+ "sourceUrl": "https://github.com/procore/core/blob/5a7d81e/packages/text-editor/src/TextEditor/TextEditor.types.ts#L59"
24
24
  },
25
25
  {
26
26
  "name": "disabled",
@@ -30,7 +30,7 @@
30
30
  "description": "Indicates if the editor is disabled",
31
31
  "descriptionHtml": "<div class=\"tsd-comment tsd-typography\"><div class=\"lead\">\n<p>Indicates if the editor is disabled</p>\n</div><dl class=\"tsd-comment-tags\"><dt>since</dt><dd><p>0.0.1</p>\n</dd></dl></div>",
32
32
  "sourceFile": "TextEditor/TextEditor.types.ts",
33
- "sourceUrl": "https://github.com/procore/core/blob/77cfaf0/packages/text-editor/src/TextEditor/TextEditor.types.ts#L34"
33
+ "sourceUrl": "https://github.com/procore/core/blob/5a7d81e/packages/text-editor/src/TextEditor/TextEditor.types.ts#L34"
34
34
  },
35
35
  {
36
36
  "name": "error",
@@ -40,7 +40,7 @@
40
40
  "description": "Indicates if the editor is in an error state",
41
41
  "descriptionHtml": "<div class=\"tsd-comment tsd-typography\"><div class=\"lead\">\n<p>Indicates if the editor is in an error state</p>\n</div><dl class=\"tsd-comment-tags\"><dt>since</dt><dd><p>0.0.1</p>\n</dd></dl></div>",
42
42
  "sourceFile": "TextEditor/TextEditor.types.ts",
43
- "sourceUrl": "https://github.com/procore/core/blob/77cfaf0/packages/text-editor/src/TextEditor/TextEditor.types.ts#L41"
43
+ "sourceUrl": "https://github.com/procore/core/blob/5a7d81e/packages/text-editor/src/TextEditor/TextEditor.types.ts#L41"
44
44
  },
45
45
  {
46
46
  "name": "id",
@@ -50,7 +50,7 @@
50
50
  "description": "Unique identifier for the editor",
51
51
  "descriptionHtml": "<div class=\"tsd-comment tsd-typography\"><div class=\"lead\">\n<p>Unique identifier for the editor</p>\n</div><dl class=\"tsd-comment-tags\"><dt>since</dt><dd><p>0.0.1</p>\n</dd></dl></div>",
52
52
  "sourceFile": "TextEditor/TextEditor.types.ts",
53
- "sourceUrl": "https://github.com/procore/core/blob/77cfaf0/packages/text-editor/src/TextEditor/TextEditor.types.ts#L10"
53
+ "sourceUrl": "https://github.com/procore/core/blob/5a7d81e/packages/text-editor/src/TextEditor/TextEditor.types.ts#L10"
54
54
  },
55
55
  {
56
56
  "name": "initialValue",
@@ -62,7 +62,7 @@
62
62
  "deprecated": "`initialValue` has been deprecated and will be removed in a future version.\nPlease use the `value` prop instead",
63
63
  "deprecatedSince": "0.0.1",
64
64
  "sourceFile": "TextEditor/TextEditor.types.ts",
65
- "sourceUrl": "https://github.com/procore/core/blob/77cfaf0/packages/text-editor/src/TextEditor/TextEditor.types.ts#L20"
65
+ "sourceUrl": "https://github.com/procore/core/blob/5a7d81e/packages/text-editor/src/TextEditor/TextEditor.types.ts#L20"
66
66
  },
67
67
  {
68
68
  "name": "locale",
@@ -72,7 +72,17 @@
72
72
  "description": "Locale which will be used for localization. Can be passed directly or\nset by wrapping components in I18n provider.",
73
73
  "descriptionHtml": "<div class=\"tsd-comment tsd-typography\"><div class=\"lead\">\n<p>Locale which will be used for localization. Can be passed directly or\nset by wrapping components in I18n provider.</p>\n</div><dl class=\"tsd-comment-tags\"><dt>since</dt><dd><p>0.0.1</p>\n</dd></dl></div>",
74
74
  "sourceFile": "TextEditor/TextEditor.types.ts",
75
- "sourceUrl": "https://github.com/procore/core/blob/77cfaf0/packages/text-editor/src/TextEditor/TextEditor.types.ts#L67"
75
+ "sourceUrl": "https://github.com/procore/core/blob/5a7d81e/packages/text-editor/src/TextEditor/TextEditor.types.ts#L75"
76
+ },
77
+ {
78
+ "name": "readonly",
79
+ "required": false,
80
+ "type": "<span class=\"tsd-signature-type\">boolean</span>",
81
+ "typeDetail": "<span class=\"tsd-signature-type\">boolean</span>",
82
+ "description": "Indicates if the editor is in readonly mode.\nWhen true, renders the content using TextEditorOutput instead of the editable editor.",
83
+ "descriptionHtml": "<div class=\"tsd-comment tsd-typography\"><div class=\"lead\">\n<p>Indicates if the editor is in readonly mode.\nWhen true, renders the content using TextEditorOutput instead of the editable editor.</p>\n</div><dl class=\"tsd-comment-tags\"><dt>since</dt><dd><p>0.2.0</p>\n</dd></dl></div>",
84
+ "sourceFile": "TextEditor/TextEditor.types.ts",
85
+ "sourceUrl": "https://github.com/procore/core/blob/5a7d81e/packages/text-editor/src/TextEditor/TextEditor.types.ts#L49"
76
86
  },
77
87
  {
78
88
  "name": "value",
@@ -82,7 +92,7 @@
82
92
  "description": "The current value of the editor",
83
93
  "descriptionHtml": "<div class=\"tsd-comment tsd-typography\"><div class=\"lead\">\n<p>The current value of the editor</p>\n</div><dl class=\"tsd-comment-tags\"><dt>since</dt><dd><p>0.0.1</p>\n</dd></dl></div>",
84
94
  "sourceFile": "TextEditor/TextEditor.types.ts",
85
- "sourceUrl": "https://github.com/procore/core/blob/77cfaf0/packages/text-editor/src/TextEditor/TextEditor.types.ts#L27"
95
+ "sourceUrl": "https://github.com/procore/core/blob/5a7d81e/packages/text-editor/src/TextEditor/TextEditor.types.ts#L27"
86
96
  },
87
97
  {
88
98
  "name": "onAfterDestroy",
@@ -92,7 +102,7 @@
92
102
  "description": "Callback fired after the editor instance is destroyed",
93
103
  "descriptionHtml": "<div class=\"tsd-comment tsd-typography\"><div class=\"lead\">\n<p>Callback fired after the editor instance is destroyed</p>\n</div><dl class=\"tsd-comment-tags\"><dt>since</dt><dd><p>0.0.1</p>\n</dd></dl></div>",
94
104
  "sourceFile": "TextEditor/TextEditor.types.ts",
95
- "sourceUrl": "https://github.com/procore/core/blob/77cfaf0/packages/text-editor/src/TextEditor/TextEditor.types.ts#L117"
105
+ "sourceUrl": "https://github.com/procore/core/blob/5a7d81e/packages/text-editor/src/TextEditor/TextEditor.types.ts#L125"
96
106
  },
97
107
  {
98
108
  "name": "onBlur",
@@ -102,7 +112,7 @@
102
112
  "description": "Callback fired when the editor loses focus",
103
113
  "descriptionHtml": "<div class=\"tsd-comment tsd-typography\"><div class=\"lead\">\n<p>Callback fired when the editor loses focus</p>\n</div><dl class=\"tsd-comment-tags\"><dt>since</dt><dd><p>0.0.1</p>\n</dd></dl></div>",
104
114
  "sourceFile": "TextEditor/TextEditor.types.ts",
105
- "sourceUrl": "https://github.com/procore/core/blob/77cfaf0/packages/text-editor/src/TextEditor/TextEditor.types.ts#L90"
115
+ "sourceUrl": "https://github.com/procore/core/blob/5a7d81e/packages/text-editor/src/TextEditor/TextEditor.types.ts#L98"
106
116
  },
107
117
  {
108
118
  "name": "onChange",
@@ -112,7 +122,7 @@
112
122
  "description": "Callback fired when the editor content changes",
113
123
  "descriptionHtml": "<div class=\"tsd-comment tsd-typography\"><div class=\"lead\">\n<p>Callback fired when the editor content changes</p>\n</div><dl class=\"tsd-comment-tags\"><dt>since</dt><dd><p>0.0.1</p>\n</dd></dl></div>",
114
124
  "sourceFile": "TextEditor/TextEditor.types.ts",
115
- "sourceUrl": "https://github.com/procore/core/blob/77cfaf0/packages/text-editor/src/TextEditor/TextEditor.types.ts#L76"
125
+ "sourceUrl": "https://github.com/procore/core/blob/5a7d81e/packages/text-editor/src/TextEditor/TextEditor.types.ts#L84"
116
126
  },
117
127
  {
118
128
  "name": "onDirty",
@@ -122,7 +132,7 @@
122
132
  "description": "Callback fired when the editor becomes dirty (content differs from initial value)",
123
133
  "descriptionHtml": "<div class=\"tsd-comment tsd-typography\"><div class=\"lead\">\n<p>Callback fired when the editor becomes dirty (content differs from initial value)</p>\n</div><dl class=\"tsd-comment-tags\"><dt>since</dt><dd><p>0.0.1</p>\n</dd></dl></div>",
124
134
  "sourceFile": "TextEditor/TextEditor.types.ts",
125
- "sourceUrl": "https://github.com/procore/core/blob/77cfaf0/packages/text-editor/src/TextEditor/TextEditor.types.ts#L124"
135
+ "sourceUrl": "https://github.com/procore/core/blob/5a7d81e/packages/text-editor/src/TextEditor/TextEditor.types.ts#L132"
126
136
  },
127
137
  {
128
138
  "name": "onError",
@@ -132,7 +142,7 @@
132
142
  "description": "Callback fired when an error occurs in the editor",
133
143
  "descriptionHtml": "<div class=\"tsd-comment tsd-typography\"><div class=\"lead\">\n<p>Callback fired when an error occurs in the editor</p>\n</div><dl class=\"tsd-comment-tags\"><dt>since</dt><dd><p>0.0.1</p>\n</dd></dl></div>",
134
144
  "sourceFile": "TextEditor/TextEditor.types.ts",
135
- "sourceUrl": "https://github.com/procore/core/blob/77cfaf0/packages/text-editor/src/TextEditor/TextEditor.types.ts#L97"
145
+ "sourceUrl": "https://github.com/procore/core/blob/5a7d81e/packages/text-editor/src/TextEditor/TextEditor.types.ts#L105"
136
146
  },
137
147
  {
138
148
  "name": "onFocus",
@@ -142,7 +152,7 @@
142
152
  "description": "Callback fired when the editor gains focus",
143
153
  "descriptionHtml": "<div class=\"tsd-comment tsd-typography\"><div class=\"lead\">\n<p>Callback fired when the editor gains focus</p>\n</div><dl class=\"tsd-comment-tags\"><dt>since</dt><dd><p>0.0.1</p>\n</dd></dl></div>",
144
154
  "sourceFile": "TextEditor/TextEditor.types.ts",
145
- "sourceUrl": "https://github.com/procore/core/blob/77cfaf0/packages/text-editor/src/TextEditor/TextEditor.types.ts#L83"
155
+ "sourceUrl": "https://github.com/procore/core/blob/5a7d81e/packages/text-editor/src/TextEditor/TextEditor.types.ts#L91"
146
156
  },
147
157
  {
148
158
  "name": "onInit",
@@ -152,7 +162,7 @@
152
162
  "description": "Callback fired when the editor is ready",
153
163
  "descriptionHtml": "<div class=\"tsd-comment tsd-typography\"><div class=\"lead\">\n<p>Callback fired when the editor is ready</p>\n</div><dl class=\"tsd-comment-tags\"><dt>since</dt><dd><p>0.0.1</p>\n</dd></dl></div>",
154
164
  "sourceFile": "TextEditor/TextEditor.types.ts",
155
- "sourceUrl": "https://github.com/procore/core/blob/77cfaf0/packages/text-editor/src/TextEditor/TextEditor.types.ts#L110"
165
+ "sourceUrl": "https://github.com/procore/core/blob/5a7d81e/packages/text-editor/src/TextEditor/TextEditor.types.ts#L118"
156
166
  },
157
167
  {
158
168
  "name": "onKeyDown",
@@ -162,7 +172,7 @@
162
172
  "description": "Callback fired when a key is pressed in the editor",
163
173
  "descriptionHtml": "<div class=\"tsd-comment tsd-typography\"><div class=\"lead\">\n<p>Callback fired when a key is pressed in the editor</p>\n</div><dl class=\"tsd-comment-tags\"><dt>since</dt><dd><p>0.0.1</p>\n</dd></dl></div>",
164
174
  "sourceFile": "TextEditor/TextEditor.types.ts",
165
- "sourceUrl": "https://github.com/procore/core/blob/77cfaf0/packages/text-editor/src/TextEditor/TextEditor.types.ts#L133"
175
+ "sourceUrl": "https://github.com/procore/core/blob/5a7d81e/packages/text-editor/src/TextEditor/TextEditor.types.ts#L141"
166
176
  }
167
177
  ],
168
178
  "description": ""
@@ -10,7 +10,7 @@
10
10
  "description": "",
11
11
  "descriptionHtml": "",
12
12
  "sourceFile": "TextEditor/TextEditorProvider.types.ts",
13
- "sourceUrl": "https://github.com/procore/core/blob/77cfaf0/packages/text-editor/src/TextEditor/TextEditorProvider.types.ts#L9"
13
+ "sourceUrl": "https://github.com/procore/core/blob/5a7d81e/packages/text-editor/src/TextEditor/TextEditorProvider.types.ts#L9"
14
14
  },
15
15
  {
16
16
  "name": "features",
@@ -20,7 +20,7 @@
20
20
  "description": "- `stickyToolbar` - Have the editor toolbar stick to the top when content is longer than the page length.\n- `tabAsNavigation` - Have `Tab` key exit the editor. Support `Alt`/`Opt` + `Tab` as triple space indent.",
21
21
  "descriptionHtml": "<div class=\"tsd-comment tsd-typography\"><div class=\"lead\">\n<ul>\n<li><code>stickyToolbar</code> - Have the editor toolbar stick to the top when content is longer than the page length.</li>\n<li><code>tabAsNavigation</code> - Have <code>Tab</code> key exit the editor. Support <code>Alt</code>/<code>Opt</code> + <code>Tab</code> as triple space indent.</li>\n</ul>\n</div></div>",
22
22
  "sourceFile": "TextEditor/TextEditorProvider.types.ts",
23
- "sourceUrl": "https://github.com/procore/core/blob/77cfaf0/packages/text-editor/src/TextEditor/TextEditorProvider.types.ts#L14"
23
+ "sourceUrl": "https://github.com/procore/core/blob/5a7d81e/packages/text-editor/src/TextEditor/TextEditorProvider.types.ts#L14"
24
24
  }
25
25
  ],
26
26
  "description": ""
@@ -10,7 +10,7 @@
10
10
  "description": "Additional classNames",
11
11
  "descriptionHtml": "<div class=\"tsd-comment tsd-typography\"><div class=\"lead\">\n<p>Additional classNames</p>\n</div><dl class=\"tsd-comment-tags\"><dt>since</dt><dd><p>10.24.0</p>\n</dd></dl></div>",
12
12
  "sourceFile": "TextEditorOutput/TextEditorOutput.types.ts",
13
- "sourceUrl": "https://github.com/procore/core/blob/77cfaf0/packages/text-editor/src/TextEditorOutput/TextEditorOutput.types.ts#L14"
13
+ "sourceUrl": "https://github.com/procore/core/blob/5a7d81e/packages/text-editor/src/TextEditorOutput/TextEditorOutput.types.ts#L14"
14
14
  },
15
15
  {
16
16
  "name": "style",
@@ -20,7 +20,7 @@
20
20
  "description": "Additional CSS styles",
21
21
  "descriptionHtml": "<div class=\"tsd-comment tsd-typography\"><div class=\"lead\">\n<p>Additional CSS styles</p>\n</div><dl class=\"tsd-comment-tags\"><dt>since</dt><dd><p>10.24.0</p>\n</dd></dl></div>",
22
22
  "sourceFile": "TextEditorOutput/TextEditorOutput.types.ts",
23
- "sourceUrl": "https://github.com/procore/core/blob/77cfaf0/packages/text-editor/src/TextEditorOutput/TextEditorOutput.types.ts#L21"
23
+ "sourceUrl": "https://github.com/procore/core/blob/5a7d81e/packages/text-editor/src/TextEditorOutput/TextEditorOutput.types.ts#L21"
24
24
  },
25
25
  {
26
26
  "name": "value",
@@ -30,7 +30,7 @@
30
30
  "description": "Formatted text from `TextEditor`",
31
31
  "descriptionHtml": "<div class=\"tsd-comment tsd-typography\"><div class=\"lead\">\n<p>Formatted text from <code>TextEditor</code></p>\n</div><dl class=\"tsd-comment-tags\"><dt>since</dt><dd><p>10.24.0</p>\n</dd></dl></div>",
32
32
  "sourceFile": "TextEditorOutput/TextEditorOutput.types.ts",
33
- "sourceUrl": "https://github.com/procore/core/blob/77cfaf0/packages/text-editor/src/TextEditorOutput/TextEditorOutput.types.ts#L7"
33
+ "sourceUrl": "https://github.com/procore/core/blob/5a7d81e/packages/text-editor/src/TextEditorOutput/TextEditorOutput.types.ts#L7"
34
34
  }
35
35
  ],
36
36
  "description": ""
package/dist/index.d.ts CHANGED
@@ -1,2 +1,3 @@
1
+ export * from './DebouncedTextEditor';
1
2
  export * from './TextEditor';
2
3
  export * from './TextEditorOutput';
package/dist/index.js CHANGED
@@ -1,3 +1,4 @@
1
+ export * from './DebouncedTextEditor';
1
2
  export * from './TextEditor';
2
3
  export * from './TextEditorOutput';
3
4
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":[],"sources":["../src/index.ts"],"sourcesContent":["export * from './TextEditor'\nexport * from './TextEditorOutput'\n"],"mappings":"AAAA,cAAc,cAAc;AAC5B,cAAc,oBAAoB"}
1
+ {"version":3,"file":"index.js","names":[],"sources":["../src/index.ts"],"sourcesContent":["export * from './DebouncedTextEditor'\nexport * from './TextEditor'\nexport * from './TextEditorOutput'\n"],"mappings":"AAAA,cAAc,uBAAuB;AACrC,cAAc,cAAc;AAC5B,cAAc,oBAAoB"}
@@ -0,0 +1 @@
1
+ export declare function debounce<T extends (...args: any[]) => void>(func: T, wait: number, immediate?: boolean): (this: ThisParameterType<T>, ...args: Parameters<T>) => void;
@@ -0,0 +1,24 @@
1
+ export function debounce(func, wait) {
2
+ var immediate = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
3
+ var timeout = null;
4
+ return function () {
5
+ for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
6
+ args[_key] = arguments[_key];
7
+ }
8
+ var context = this;
9
+ var callNow = immediate && timeout === null;
10
+ if (timeout !== null) {
11
+ clearTimeout(timeout);
12
+ }
13
+ timeout = setTimeout(function () {
14
+ timeout = null;
15
+ if (!immediate) {
16
+ func.apply(context, args);
17
+ }
18
+ }, wait);
19
+ if (callNow) {
20
+ func.apply(context, args);
21
+ }
22
+ };
23
+ }
24
+ //# sourceMappingURL=debounce.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"debounce.js","names":["debounce","func","wait","immediate","arguments","length","undefined","timeout","_len","args","Array","_key","context","callNow","clearTimeout","setTimeout","apply"],"sources":["../../src/utils/debounce.ts"],"sourcesContent":["export function debounce<T extends (...args: any[]) => void>(\n func: T,\n wait: number,\n immediate: boolean = false\n) {\n let timeout: ReturnType<typeof setTimeout> | null = null\n\n return function (this: ThisParameterType<T>, ...args: Parameters<T>): void {\n const context = this\n\n const callNow = immediate && timeout === null\n\n if (timeout !== null) {\n clearTimeout(timeout)\n }\n\n timeout = setTimeout(() => {\n timeout = null\n if (!immediate) {\n func.apply(context, args)\n }\n }, wait)\n\n if (callNow) {\n func.apply(context, args)\n }\n }\n}\n"],"mappings":"AAAA,OAAO,SAASA,QAAQA,CACtBC,IAAO,EACPC,IAAY,EAEZ;EAAA,IADAC,SAAkB,GAAAC,SAAA,CAAAC,MAAA,QAAAD,SAAA,QAAAE,SAAA,GAAAF,SAAA,MAAG,KAAK;EAE1B,IAAIG,OAA6C,GAAG,IAAI;EAExD,OAAO,YAAoE;IAAA,SAAAC,IAAA,GAAAJ,SAAA,CAAAC,MAAA,EAA3BI,IAAI,OAAAC,KAAA,CAAAF,IAAA,GAAAG,IAAA,MAAAA,IAAA,GAAAH,IAAA,EAAAG,IAAA;MAAJF,IAAI,CAAAE,IAAA,IAAAP,SAAA,CAAAO,IAAA;IAAA;IAClD,IAAMC,OAAO,GAAG,IAAI;IAEpB,IAAMC,OAAO,GAAGV,SAAS,IAAII,OAAO,KAAK,IAAI;IAE7C,IAAIA,OAAO,KAAK,IAAI,EAAE;MACpBO,YAAY,CAACP,OAAO,CAAC;IACvB;IAEAA,OAAO,GAAGQ,UAAU,CAAC,YAAM;MACzBR,OAAO,GAAG,IAAI;MACd,IAAI,CAACJ,SAAS,EAAE;QACdF,IAAI,CAACe,KAAK,CAACJ,OAAO,EAAEH,IAAI,CAAC;MAC3B;IACF,CAAC,EAAEP,IAAI,CAAC;IAER,IAAIW,OAAO,EAAE;MACXZ,IAAI,CAACe,KAAK,CAACJ,OAAO,EAAEH,IAAI,CAAC;IAC3B;EACF,CAAC;AACH"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@procore/text-editor",
3
- "version": "0.1.0",
3
+ "version": "0.2.0",
4
4
  "description": "Rich text editor component based on CKEditor 5",
5
5
  "author": "Procore Technologies",
6
6
  "homepage": "https://github.com/procore/core/tree/main/packages/text-editor",
@@ -12,16 +12,16 @@
12
12
  "bugs": "https://github.com/procore/core/issues",
13
13
  "license": "SEE LICENSE IN LICENSE",
14
14
  "keywords": [
15
- "javascript",
15
+ "ckeditor",
16
16
  "components",
17
- "react",
17
+ "javascript",
18
18
  "js",
19
19
  "jsx",
20
20
  "library",
21
21
  "procore",
22
- "text-editor",
22
+ "react",
23
23
  "rich-text",
24
- "ckeditor"
24
+ "text-editor"
25
25
  ],
26
26
  "publishConfig": {
27
27
  "access": "public"
@@ -30,8 +30,8 @@
30
30
  ".": "./dist/index.js",
31
31
  "./jestConfig": {
32
32
  "types": "./jestConfig.d.ts",
33
- "require": "./jestConfig.js",
34
- "import": "./jestConfig.js"
33
+ "import": "./jestConfig.js",
34
+ "require": "./jestConfig.js"
35
35
  },
36
36
  "./dist/_typedoc/*.json": "./dist/_typedoc/*.json",
37
37
  "./dist/_typedoc/**/*.json": "./dist/_typedoc/**/*.json"
@@ -69,7 +69,7 @@
69
69
  "test:watch": "yarn run test --watch"
70
70
  },
71
71
  "peerDependencies": {
72
- "@procore/core-react": "^12.38.0",
72
+ "@procore/core-react": "^12.40.0",
73
73
  "@procore/globalization-toolkit": ">= 3 < 4",
74
74
  "ckeditor5": "^46.0.1",
75
75
  "react": ">=16.8.0 < 19",
@@ -79,7 +79,7 @@
79
79
  "dependencies": {
80
80
  "@ckeditor/ckeditor5-react": "^11.0.0",
81
81
  "@procore/core-i18n-js": "^10.30.0",
82
- "@procore/core-icons": "^12.12.0",
82
+ "@procore/core-icons": "^12.13.0",
83
83
  "@react-aria/focus": "3.16.2",
84
84
  "@react-aria/utils": "3.23.2",
85
85
  "sanitize-html": "^2.17.0"
@@ -93,7 +93,7 @@
93
93
  "@babel/preset-react": "7.18.6",
94
94
  "@babel/preset-typescript": "7.18.6",
95
95
  "@babel/register": "7.18.9",
96
- "@procore/core-react": "^12.38.0",
96
+ "@procore/core-react": "^12.40.0",
97
97
  "@procore/globalization-toolkit": "3.0.0",
98
98
  "@storybook/addon-webpack5-compiler-swc": "^4.0.2",
99
99
  "@storybook/jest": "^0.2.3",