@procore/text-editor 0.4.2 → 0.5.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 +14 -0
- package/dist/DebouncedTextEditor/DebouncedTextEditor.d.ts +3 -0
- package/dist/DebouncedTextEditor/DebouncedTextEditor.js +3 -0
- package/dist/DebouncedTextEditor/DebouncedTextEditor.js.map +1 -1
- package/dist/TextEditor/TextEditor.js +18 -10
- package/dist/TextEditor/TextEditor.js.map +1 -1
- package/dist/TextEditor/TextEditor.styles.d.ts +1 -0
- package/dist/TextEditor/TextEditor.styles.js +7 -4
- package/dist/TextEditor/TextEditor.styles.js.map +1 -1
- package/dist/TextEditorOutput/TextEditorOutput.styles.js +2 -2
- package/dist/TextEditorOutput/TextEditorOutput.styles.js.map +1 -1
- package/dist/_typedoc/TextEditor/TextEditor.types.json +17 -17
- package/dist/_typedoc/TextEditor/TextEditorProvider.types.json +2 -2
- package/dist/_typedoc/TextEditorOutput/TextEditorOutput.types.json +3 -3
- package/dist/utils/debounce.d.ts +4 -1
- package/dist/utils/debounce.js +14 -1
- package/dist/utils/debounce.js.map +1 -1
- package/package.json +3 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,19 @@
|
|
|
1
1
|
# @procore/text-editor
|
|
2
2
|
|
|
3
|
+
## 0.5.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- e81ec86: Debounce the `onChange` callback internally (flushing pending edits on blur) to fix typing and pointer lag caused by expensive work running on every keystroke.
|
|
8
|
+
|
|
9
|
+
### Patch Changes
|
|
10
|
+
|
|
11
|
+
- 4ff6292: - Fix text overflowing editor and output containers (word-break, overflow-wrap)
|
|
12
|
+
- Prevent showing editor until fully initialized (opacity gate on ready state)
|
|
13
|
+
- Updated dependencies [8da8b1d]
|
|
14
|
+
- Updated dependencies [ce61ed8]
|
|
15
|
+
- @procore/core-react@12.49.1
|
|
16
|
+
|
|
3
17
|
## 0.4.2
|
|
4
18
|
|
|
5
19
|
### Patch Changes
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import type { TextEditorProps } from '../TextEditor';
|
|
3
3
|
/**
|
|
4
|
+
* @deprecated `DebouncedTextEditor` is deprecated and will be removed in a future version.
|
|
5
|
+
* Use `TextEditor` directly instead — it now debounces `getData()` internally.
|
|
6
|
+
*
|
|
4
7
|
* A performance-optimized version of `TextEditor` with built-in debounce on the `onChange` callback.
|
|
5
8
|
*
|
|
6
9
|
* ## When to use `DebouncedTextEditor`
|
|
@@ -14,6 +14,9 @@ import { debounce } from '../utils/debounce';
|
|
|
14
14
|
var DEBOUNCE_MS = 300;
|
|
15
15
|
|
|
16
16
|
/**
|
|
17
|
+
* @deprecated `DebouncedTextEditor` is deprecated and will be removed in a future version.
|
|
18
|
+
* Use `TextEditor` directly instead — it now debounces `getData()` internally.
|
|
19
|
+
*
|
|
17
20
|
* A performance-optimized version of `TextEditor` with built-in debounce on the `onChange` callback.
|
|
18
21
|
*
|
|
19
22
|
* ## When to use `DebouncedTextEditor`
|
|
@@ -1 +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"}
|
|
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 * @deprecated `DebouncedTextEditor` is deprecated and will be removed in a future version.\n * Use `TextEditor` directly instead — it now debounces `getData()` internally.\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;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"}
|
|
@@ -13,6 +13,7 @@ import { ClassicEditor } from 'ckeditor5';
|
|
|
13
13
|
import React from 'react';
|
|
14
14
|
import { useI18nContext, useZIndexContext } from '@procore/core-react';
|
|
15
15
|
import { TextEditorOutput } from '../TextEditorOutput';
|
|
16
|
+
import { debounce } from '../utils/debounce';
|
|
16
17
|
import { useStickyToolbar } from './StickyToolbar';
|
|
17
18
|
import { GlobalEditorStyles, StyledTextEditor } from './TextEditor.styles';
|
|
18
19
|
import { TextEditorContext } from './TextEditorProvider';
|
|
@@ -21,6 +22,7 @@ import { useCKEditorCss } from './useCKEditorCss';
|
|
|
21
22
|
import { useCKEditorFocusScope } from './useCKEditorFocusScope';
|
|
22
23
|
import { useTabAsNavigation } from './useTabAsNavigation';
|
|
23
24
|
import { addButtonDataAttributes, getDefaultConfig } from './utils';
|
|
25
|
+
var DEBOUNCE_MS = 300;
|
|
24
26
|
|
|
25
27
|
/**
|
|
26
28
|
* To ensure your Jest tests work with the CKEditor implementation, wrap your Jest configuration with `textEditorJestConfig`:
|
|
@@ -84,6 +86,7 @@ export function TextEditor(props) {
|
|
|
84
86
|
var editorRef = React.useRef(null);
|
|
85
87
|
var editorInstanceRef = React.useRef(null);
|
|
86
88
|
var initialValueRef = React.useRef(value || initialValue || '');
|
|
89
|
+
var lastExternalValueRef = React.useRef(value || initialValue || '');
|
|
87
90
|
var keyDownListenerRef = React.useRef(null);
|
|
88
91
|
var _React$useState = React.useState(false),
|
|
89
92
|
_React$useState2 = _slicedToArray(_React$useState, 2),
|
|
@@ -98,9 +101,16 @@ export function TextEditor(props) {
|
|
|
98
101
|
var locale = propLocale || contextLocale;
|
|
99
102
|
React.useEffect(function () {
|
|
100
103
|
if (value !== undefined) {
|
|
101
|
-
|
|
104
|
+
lastExternalValueRef.current = value;
|
|
102
105
|
}
|
|
103
106
|
}, [value]);
|
|
107
|
+
React.useEffect(function () {
|
|
108
|
+
var editor = editorInstanceRef.current;
|
|
109
|
+
if (!isEditorReady || !editor || value === undefined) return;
|
|
110
|
+
if (editor.editing.view.document.isFocused) return;
|
|
111
|
+
if (value === editor.getData()) return;
|
|
112
|
+
editor.data.set(value);
|
|
113
|
+
}, [value, isEditorReady]);
|
|
104
114
|
|
|
105
115
|
// Cleanup keydown listener on unmount
|
|
106
116
|
React.useEffect(function () {
|
|
@@ -189,24 +199,20 @@ export function TextEditor(props) {
|
|
|
189
199
|
// Add the keydown listener
|
|
190
200
|
editor.editing.view.document.on('keydown', keyDownListener);
|
|
191
201
|
}, [onKeyDown]);
|
|
192
|
-
var
|
|
202
|
+
var debouncedChange = debounce(function (_event, editor) {
|
|
193
203
|
var data = editor.getData();
|
|
194
|
-
var isDirty = data !==
|
|
195
|
-
|
|
196
|
-
// Call onDirty only on first content modification
|
|
204
|
+
var isDirty = data !== lastExternalValueRef.current.trim();
|
|
197
205
|
if (isDirty && !isDirtyState) {
|
|
198
206
|
setIsDirtyState(true);
|
|
199
207
|
onDirty === null || onDirty === void 0 ? void 0 : onDirty();
|
|
200
208
|
}
|
|
201
209
|
onChange === null || onChange === void 0 ? void 0 : onChange(data, isDirty);
|
|
202
|
-
};
|
|
210
|
+
}, DEBOUNCE_MS);
|
|
211
|
+
var handleChange = debouncedChange;
|
|
203
212
|
var handleReady = function handleReady(editor) {
|
|
204
213
|
addButtonDataAttributes(editor);
|
|
205
214
|
editorInstanceRef.current = editor;
|
|
206
215
|
setIsEditorReady(true);
|
|
207
|
-
if (initialValue) {
|
|
208
|
-
editor.setData(initialValue);
|
|
209
|
-
}
|
|
210
216
|
|
|
211
217
|
// Set aria-label and aria-description on the editable area if provided
|
|
212
218
|
// These provide accessible context to screen reader users
|
|
@@ -227,6 +233,7 @@ export function TextEditor(props) {
|
|
|
227
233
|
onInit === null || onInit === void 0 ? void 0 : onInit(editor);
|
|
228
234
|
};
|
|
229
235
|
var handleBlur = function handleBlur(event, editor) {
|
|
236
|
+
debouncedChange.flush();
|
|
230
237
|
onBlur === null || onBlur === void 0 ? void 0 : onBlur(event, editor);
|
|
231
238
|
};
|
|
232
239
|
useStickyToolbar({
|
|
@@ -256,6 +263,7 @@ export function TextEditor(props) {
|
|
|
256
263
|
ref: editorRef,
|
|
257
264
|
key: editorKey,
|
|
258
265
|
error: error,
|
|
266
|
+
ready: isEditorReady,
|
|
259
267
|
"aria-invalid": error ? 'true' : 'false'
|
|
260
268
|
}, /*#__PURE__*/React.createElement(GlobalEditorStyles, {
|
|
261
269
|
zIndex: zIndex + 1
|
|
@@ -263,7 +271,7 @@ export function TextEditor(props) {
|
|
|
263
271
|
editor: ClassicEditor,
|
|
264
272
|
config: config,
|
|
265
273
|
disabled: disabled,
|
|
266
|
-
data:
|
|
274
|
+
data: initialValueRef.current,
|
|
267
275
|
onChange: handleChange,
|
|
268
276
|
onReady: handleReady,
|
|
269
277
|
onBlur: handleBlur
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TextEditor.js","names":["CKEditor","ClassicEditor","React","useI18nContext","useZIndexContext","TextEditorOutput","useStickyToolbar","GlobalEditorStyles","StyledTextEditor","TextEditorContext","TextEditorTheme","useCKEditorCss","useCKEditorFocusScope","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 { useCKEditorFocusScope } from './useCKEditorFocusScope'\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 useCKEditorFocusScope()\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,qBAAqB,QAAQ,yBAAyB;AAC/D,SAASC,kBAAkB,QAAQ,sBAAsB;AACzD,SAASC,uBAAuB,EAAEC,gBAAgB,QAAQ,SAAS;;AAEnE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,UAAUA,CAACC,KAAgC,EAAE;EAC3D,IACEC,QAAQ,GAYND,KAAK,CAZPC,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AS;IACnBqE,IAAI,EAAElE,KAAK,aAALA,KAAK,cAALA,KAAK,GAAI,EAAG;IAClBE,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","debounce","useStickyToolbar","GlobalEditorStyles","StyledTextEditor","TextEditorContext","TextEditorTheme","useCKEditorCss","useCKEditorFocusScope","useTabAsNavigation","addButtonDataAttributes","getDefaultConfig","DEBOUNCE_MS","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","lastExternalValueRef","keyDownListenerRef","_React$useState","useState","_React$useState2","_slicedToArray","isDirtyState","setIsDirtyState","_React$useState3","_React$useState4","isEditorReady","setIsEditorReady","_useI18nContext","contextLocale","useEffect","undefined","current","editor","editing","view","document","isFocused","getData","data","set","off","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","domEvent","key","stopPropagation","on","debouncedChange","isDirty","trim","handleChange","handleReady","handleBlur","event","flush","enabled","_useTabAsNavigation","config","editorKey","concat","createElement","ref","ready","_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 { debounce } from '../utils/debounce'\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 { useCKEditorFocusScope } from './useCKEditorFocusScope'\nimport { useTabAsNavigation } from './useTabAsNavigation'\nimport { addButtonDataAttributes, getDefaultConfig } from './utils'\n\nconst DEBOUNCE_MS = 300\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 useCKEditorFocusScope()\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 lastExternalValueRef = 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 lastExternalValueRef.current = value\n }\n }, [value])\n\n React.useEffect(() => {\n const editor = editorInstanceRef.current\n if (!isEditorReady || !editor || value === undefined) return\n if (editor.editing.view.document.isFocused) return\n if (value === editor.getData()) return\n\n editor.data.set(value)\n }, [value, isEditorReady])\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 debouncedChange = debounce(\n (_event: EventInfo<string, unknown>, editor: ClassicEditor) => {\n const data = editor.getData()\n const isDirty = data !== lastExternalValueRef.current.trim()\n\n if (isDirty && !isDirtyState) {\n setIsDirtyState(true)\n onDirty?.()\n }\n\n onChange?.(data, isDirty)\n },\n DEBOUNCE_MS\n )\n\n const handleChange = debouncedChange\n\n const handleReady = (editor: ClassicEditor) => {\n addButtonDataAttributes(editor)\n editorInstanceRef.current = editor\n setIsEditorReady(true)\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 debouncedChange.flush()\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 ready={isEditorReady}\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={initialValueRef.current}\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,QAAQ,QAAQ,mBAAmB;AAC5C,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,qBAAqB,QAAQ,yBAAyB;AAC/D,SAASC,kBAAkB,QAAQ,sBAAsB;AACzD,SAASC,uBAAuB,EA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,EAAEP,aAAa,GAAGZ,iBAAiB,CAACkB,OAAO,GAAG;IACtD,CAAC,CAAC;IAJMgD,MAAM,GAAAD,mBAAA,CAANC,MAAM;EAMd,IAAMC,SAAS,MAAAC,MAAA,CAAMhF,MAAM,OAAAgF,MAAA,CAAI3B,qBAAqB,CAAE;EAEtD,IAAI7C,UAAU,EAAE;IACd,OAAO,IAAI;EACb;EAEA,IAAIhB,QAAQ,EAAE;IACZ,oBACEpB,KAAA,CAAA6G,aAAA,CAAC1G,gBAAgB;MACfkB,KAAK,EAAEA,KAAM;MACb,cAAYY,SAAU;MACtB,oBAAkBC;IAAgB,CACnC,CAAC;EAEN;EAEA,oBACElC,KAAA,CAAA6G,aAAA,CAACtG,gBAAgB;IACfuG,GAAG,EAAExE,SAAU;IACfuD,GAAG,EAAEc,SAAU;IACfxF,KAAK,EAAEA,KAAM;IACb4F,KAAK,EAAE3D,aAAc;IACrB,gBAAcjC,KAAK,GAAG,MAAM,GAAG;EAAQ,gBAEvCnB,KAAA,CAAA6G,aAAA,CAACvG,kBAAkB;IAACqE,MAAM,EAAEA,MAAM,GAAG;EAAE,CAAE,CAAC,eAC1C3E,KAAA,CAAA6G,aAAA,CAACpG,eAAe,MAAE,CAAC,eACnBT,KAAA,CAAA6G,aAAA,CAAC/G,QAAQ,EAAAkH,QAAA,KACHlF,SAAS;IACb6B,MAAM,EAAE5D,aAAc;IACtB2G,MAAM,EAAEA,MAAO;IACfxF,QAAQ,EAAEA,QAAS;IACnB+C,IAAI,EAAExB,eAAe,CAACiB,OAAQ;IAC9BnC,QAAQ,EAAE4E,YAAa;IACvBc,OAAO,EAAEb,WAAY;IACrB3E,MAAM,EAAE4E;EAAW,EACpB,CACe,CAAC;AAEvB"}
|
|
@@ -4,4 +4,5 @@ export declare const GlobalEditorStyles: import("react").NamedExoticComponent<im
|
|
|
4
4
|
}>;
|
|
5
5
|
export declare const StyledTextEditor: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components/dist/types").Substitute<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, {
|
|
6
6
|
error?: boolean | undefined;
|
|
7
|
+
ready?: boolean | undefined;
|
|
7
8
|
}>> & string;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { colors } from '@procore/core-react';
|
|
2
2
|
import styled, { createGlobalStyle } from 'styled-components';
|
|
3
|
-
export var GlobalEditorStyles = /*#__PURE__*/createGlobalStyle([":root{--ck-z-default:", ";--ck-z-modal:", ";--ck-z-dialog:", ";}.ck-body-wrapper{--ck-z-default:", ";--ck-z-modal:", ";--ck-z-dialog:", ";}.ck-balloon-panel{z-index:", " !important;}.ck-dropdown__panel{z-index:", " !important;}.ck.ck-toolbar_grouping{container-type:inline-size;}.ck.ck-toolbar__grouped-dropdown > .ck-dropdown__panel{max-width:100cqw !important;z-index:", " !important;}.ck.ck-toolbar__grouped-dropdown > .ck-dropdown__panel .ck-toolbar__items{flex-wrap:wrap !important;}.ck-content{padding:16px 28px !important;--ck-content-font-family:Inter,'Noto Sans JP','Noto Sans KR','Noto Sans SC','Noto Sans TC',sans-serif;--ck-content-font-size:14px
|
|
3
|
+
export var GlobalEditorStyles = /*#__PURE__*/createGlobalStyle([":root{--ck-z-default:", ";--ck-z-modal:", ";--ck-z-dialog:", ";}.ck-body-wrapper{--ck-z-default:", ";--ck-z-modal:", ";--ck-z-dialog:", ";}.ck-balloon-panel{z-index:", " !important;}.ck-dropdown__panel{z-index:", " !important;}.ck.ck-toolbar_grouping{container-type:inline-size;}.ck.ck-toolbar__grouped-dropdown > .ck-dropdown__panel{max-width:100cqw !important;z-index:", " !important;}.ck.ck-toolbar__grouped-dropdown > .ck-dropdown__panel .ck-toolbar__items{flex-wrap:wrap !important;}.ck-content{padding:16px 28px !important;--ck-content-font-family:Inter,'Noto Sans JP','Noto Sans KR','Noto Sans SC','Noto Sans TC',sans-serif;--ck-content-font-size:14px;--ck-content-word-break:break-word;--ck-content-overflow-wrap:break-word;--ck-content-line-height:1.4;p{margin-top:0 !important;margin-bottom:0 !important;}}[data-id=\"modal\"] .ck-sticky-panel__content_sticky{top:var(--modal-header-height,84px) !important;}"], function (_ref) {
|
|
4
4
|
var zIndex = _ref.zIndex;
|
|
5
5
|
return zIndex;
|
|
6
6
|
}, function (_ref2) {
|
|
@@ -30,9 +30,12 @@ export var GlobalEditorStyles = /*#__PURE__*/createGlobalStyle([":root{--ck-z-de
|
|
|
30
30
|
});
|
|
31
31
|
export var StyledTextEditor = /*#__PURE__*/styled.div.withConfig({
|
|
32
32
|
displayName: "StyledTextEditor",
|
|
33
|
-
componentId: "text-editor-
|
|
34
|
-
})(["", ""], function (_ref0) {
|
|
35
|
-
var
|
|
33
|
+
componentId: "text-editor-0_5_0__sc-iim79x-0"
|
|
34
|
+
})([".ck.ck-editor{opacity:", ";}", ""], function (_ref0) {
|
|
35
|
+
var ready = _ref0.ready;
|
|
36
|
+
return ready ? 1 : 0;
|
|
37
|
+
}, function (_ref1) {
|
|
38
|
+
var error = _ref1.error;
|
|
36
39
|
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 ");
|
|
37
40
|
});
|
|
38
41
|
//# sourceMappingURL=TextEditor.styles.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TextEditor.styles.js","names":["colors","styled","createGlobalStyle","GlobalEditorStyles","_ref","zIndex","_ref2","_ref3","_ref4","_ref5","_ref6","_ref7","_ref8","_ref9","StyledTextEditor","div","withConfig","displayName","componentId","_ref0","error","concat","red50"],"sources":["../../src/TextEditor/TextEditor.styles.ts"],"sourcesContent":["import { colors } from '@procore/core-react'\nimport styled, { createGlobalStyle } from 'styled-components'\n\nexport const GlobalEditorStyles = createGlobalStyle<{\n zIndex: number\n}>`\n :root {\n --ck-z-default: ${({ zIndex }) => zIndex};\n --ck-z-modal: ${({ zIndex }) => zIndex + 999};\n --ck-z-dialog: ${({ zIndex }) => zIndex + 1000};\n }\n \n .ck-body-wrapper {\n --ck-z-default: ${({ zIndex }) => zIndex};\n --ck-z-modal: ${({ zIndex }) => zIndex + 999};\n --ck-z-dialog: ${({ zIndex }) => zIndex + 1000};\n }\n \n .ck-balloon-panel {\n z-index: ${({ zIndex }) => zIndex + 1000} !important;\n }\n\n .ck-dropdown__panel {\n z-index: ${({ zIndex }) => zIndex + 1000} !important;\n }\n\n .ck.ck-toolbar_grouping {\n container-type: inline-size;\n }\n\n .ck.ck-toolbar__grouped-dropdown > .ck-dropdown__panel {\n max-width: 100cqw !important;\n z-index: ${({ zIndex }) => zIndex + 1000} !important;\n }\n\n .ck.ck-toolbar__grouped-dropdown > .ck-dropdown__panel .ck-toolbar__items {\n flex-wrap: wrap !important;\n }\n\n .ck-content {\n padding: 16px 28px !important;\n --ck-content-font-family: Inter, 'Noto Sans JP', 'Noto Sans KR', 'Noto Sans SC', 'Noto Sans TC', sans-serif;\n --ck-content-font-size: 14px;\n line-height: 1.4;\n\n p {\n margin-top: 0 !important;\n margin-bottom: 0 !important;\n }\n }\n\n [data-id=\"modal\"] .ck-sticky-panel__content_sticky {\n top: var(--modal-header-height, 84px) !important;\n }\n`\n\nexport const StyledTextEditor = styled.div<{\n error?: boolean\n}>`\n ${({ error }) =>\n error &&\n `\n .ck-sticky-panel__content {\n border-top-color: ${colors.red50} !important;\n border-left-color: ${colors.red50} !important;\n border-right-color: ${colors.red50} !important;\n }\n\n .ck-editor__editable {\n border-left-color: ${colors.red50} !important;\n border-right-color: ${colors.red50} !important;\n border-bottom-color: ${colors.red50} !important;\n }\n `}\n`\n"],"mappings":"AAAA,SAASA,MAAM,QAAQ,qBAAqB;AAC5C,OAAOC,MAAM,IAAIC,iBAAiB,QAAQ,mBAAmB;AAE7D,OAAO,IAAMC,kBAAkB,gBAAGD,iBAAiB,
|
|
1
|
+
{"version":3,"file":"TextEditor.styles.js","names":["colors","styled","createGlobalStyle","GlobalEditorStyles","_ref","zIndex","_ref2","_ref3","_ref4","_ref5","_ref6","_ref7","_ref8","_ref9","StyledTextEditor","div","withConfig","displayName","componentId","_ref0","ready","_ref1","error","concat","red50"],"sources":["../../src/TextEditor/TextEditor.styles.ts"],"sourcesContent":["import { colors } from '@procore/core-react'\nimport styled, { createGlobalStyle } from 'styled-components'\n\nexport const GlobalEditorStyles = createGlobalStyle<{\n zIndex: number\n}>`\n :root {\n --ck-z-default: ${({ zIndex }) => zIndex};\n --ck-z-modal: ${({ zIndex }) => zIndex + 999};\n --ck-z-dialog: ${({ zIndex }) => zIndex + 1000};\n }\n \n .ck-body-wrapper {\n --ck-z-default: ${({ zIndex }) => zIndex};\n --ck-z-modal: ${({ zIndex }) => zIndex + 999};\n --ck-z-dialog: ${({ zIndex }) => zIndex + 1000};\n }\n \n .ck-balloon-panel {\n z-index: ${({ zIndex }) => zIndex + 1000} !important;\n }\n\n .ck-dropdown__panel {\n z-index: ${({ zIndex }) => zIndex + 1000} !important;\n }\n\n .ck.ck-toolbar_grouping {\n container-type: inline-size;\n }\n\n .ck.ck-toolbar__grouped-dropdown > .ck-dropdown__panel {\n max-width: 100cqw !important;\n z-index: ${({ zIndex }) => zIndex + 1000} !important;\n }\n\n .ck.ck-toolbar__grouped-dropdown > .ck-dropdown__panel .ck-toolbar__items {\n flex-wrap: wrap !important;\n }\n\n .ck-content {\n padding: 16px 28px !important;\n --ck-content-font-family: Inter, 'Noto Sans JP', 'Noto Sans KR', 'Noto Sans SC', 'Noto Sans TC', sans-serif;\n --ck-content-font-size: 14px;\n --ck-content-word-break: break-word;\n --ck-content-overflow-wrap: break-word;\n --ck-content-line-height: 1.4;\n\n p {\n margin-top: 0 !important;\n margin-bottom: 0 !important;\n }\n }\n\n [data-id=\"modal\"] .ck-sticky-panel__content_sticky {\n top: var(--modal-header-height, 84px) !important;\n }\n`\n\nexport const StyledTextEditor = styled.div<{\n error?: boolean\n ready?: boolean\n}>`\n .ck.ck-editor {\n opacity: ${({ ready }) => (ready ? 1 : 0)};\n }\n\n ${({ error }) =>\n error &&\n `\n .ck-sticky-panel__content {\n border-top-color: ${colors.red50} !important;\n border-left-color: ${colors.red50} !important;\n border-right-color: ${colors.red50} !important;\n }\n\n .ck-editor__editable {\n border-left-color: ${colors.red50} !important;\n border-right-color: ${colors.red50} !important;\n border-bottom-color: ${colors.red50} !important;\n }\n `}\n`\n"],"mappings":"AAAA,SAASA,MAAM,QAAQ,qBAAqB;AAC5C,OAAOC,MAAM,IAAIC,iBAAiB,QAAQ,mBAAmB;AAE7D,OAAO,IAAMC,kBAAkB,gBAAGD,iBAAiB,45BAI7B,UAAAE,IAAA;EAAA,IAAGC,MAAM,GAAAD,IAAA,CAANC,MAAM;EAAA,OAAOA,MAAM;AAAA,GACxB,UAAAC,KAAA;EAAA,IAAGD,MAAM,GAAAC,KAAA,CAAND,MAAM;EAAA,OAAOA,MAAM,GAAG,GAAG;AAAA,GAC3B,UAAAE,KAAA;EAAA,IAAGF,MAAM,GAAAE,KAAA,CAANF,MAAM;EAAA,OAAOA,MAAM,GAAG,IAAI;AAAA,GAI5B,UAAAG,KAAA;EAAA,IAAGH,MAAM,GAAAG,KAAA,CAANH,MAAM;EAAA,OAAOA,MAAM;AAAA,GACxB,UAAAI,KAAA;EAAA,IAAGJ,MAAM,GAAAI,KAAA,CAANJ,MAAM;EAAA,OAAOA,MAAM,GAAG,GAAG;AAAA,GAC3B,UAAAK,KAAA;EAAA,IAAGL,MAAM,GAAAK,KAAA,CAANL,MAAM;EAAA,OAAOA,MAAM,GAAG,IAAI;AAAA,GAInC,UAAAM,KAAA;EAAA,IAAGN,MAAM,GAAAM,KAAA,CAANN,MAAM;EAAA,OAAOA,MAAM,GAAG,IAAI;AAAA,GAI7B,UAAAO,KAAA;EAAA,IAAGP,MAAM,GAAAO,KAAA,CAANP,MAAM;EAAA,OAAOA,MAAM,GAAG,IAAI;AAAA,GAS7B,UAAAQ,KAAA;EAAA,IAAGR,MAAM,GAAAQ,KAAA,CAANR,MAAM;EAAA,OAAOA,MAAM,GAAG,IAAI;AAAA,EAwB3C;AAED,OAAO,IAAMS,gBAAgB,gBAAGb,MAAM,CAACc,GAAG,CAAAC,UAAA;EAAAC,WAAA;EAAAC,WAAA;AAAA,yCAK3B,UAAAC,KAAA;EAAA,IAAGC,KAAK,GAAAD,KAAA,CAALC,KAAK;EAAA,OAAQA,KAAK,GAAG,CAAC,GAAG,CAAC;AAAA,CAAC,EAGzC,UAAAC,KAAA;EAAA,IAAGC,KAAK,GAAAD,KAAA,CAALC,KAAK;EAAA,OACRA,KAAK,sEAAAC,MAAA,CAGmBvB,MAAM,CAACwB,KAAK,+CAAAD,MAAA,CACXvB,MAAM,CAACwB,KAAK,gDAAAD,MAAA,CACXvB,MAAM,CAACwB,KAAK,wFAAAD,MAAA,CAIbvB,MAAM,CAACwB,KAAK,gDAAAD,MAAA,CACXvB,MAAM,CAACwB,KAAK,iDAAAD,MAAA,CACXvB,MAAM,CAACwB,KAAK,gCAEtC;AAAA,EACJ"}
|
|
@@ -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-
|
|
5
|
-
})([".ck-editor__top{height:0 !important;}.ck-content{border:none !important;padding:0 !important;--ck-content-font-family:Inter,'Noto Sans JP','Noto Sans KR','Noto Sans SC','Noto Sans TC',sans-serif;--ck-content-font-size:14px;p{margin:0;}img{margin-left:auto;margin-right:auto;}figure.table{display:table;margin:0.9em
|
|
4
|
+
componentId: "text-editor-0_5_0__sc-1oujb2g-0"
|
|
5
|
+
})([".ck-editor__top{height:0 !important;}.ck-content{border:none !important;padding:0 !important;--ck-content-font-family:Inter,'Noto Sans JP','Noto Sans KR','Noto Sans SC','Noto Sans TC',sans-serif;--ck-content-font-size:14px;--ck-content-word-break:break-word;--ck-content-overflow-wrap:break-word;--ck-content-line-height:1.4;p{margin:0;}img{margin-left:auto;margin-right:auto;}figure.table{display:table;margin-top:0.9em;margin-bottom:0.9em;}figure.table table,table{width:100%;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
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TextEditorOutput.styles.js","names":["styled","StyledEditor","div","withConfig","displayName","componentId"],"sources":["../../src/TextEditorOutput/TextEditorOutput.styles.ts"],"sourcesContent":["import styled from 'styled-components'\n\nexport const StyledEditor = styled.div`\n .ck-editor__top {\n height: 0 !important;\n }\n\n .ck-content {\n border: none !important;\n padding: 0 !important;\n --ck-content-font-family: Inter, 'Noto Sans JP', 'Noto Sans KR',\n 'Noto Sans SC', 'Noto Sans TC', sans-serif;\n --ck-content-font-size: 14px;\n\n p {\n margin: 0;\n }\n\n img {\n margin-left: auto;\n margin-right: auto;\n }\n\n figure.table {\n display: table;\n margin: 0.9em
|
|
1
|
+
{"version":3,"file":"TextEditorOutput.styles.js","names":["styled","StyledEditor","div","withConfig","displayName","componentId"],"sources":["../../src/TextEditorOutput/TextEditorOutput.styles.ts"],"sourcesContent":["import styled from 'styled-components'\n\nexport const StyledEditor = styled.div`\n .ck-editor__top {\n height: 0 !important;\n }\n\n .ck-content {\n border: none !important;\n padding: 0 !important;\n --ck-content-font-family: Inter, 'Noto Sans JP', 'Noto Sans KR',\n 'Noto Sans SC', 'Noto Sans TC', sans-serif;\n --ck-content-font-size: 14px;\n --ck-content-word-break: break-word;\n --ck-content-overflow-wrap: break-word;\n --ck-content-line-height: 1.4;\n\n p {\n margin: 0;\n }\n\n img {\n margin-left: auto;\n margin-right: auto;\n }\n\n figure.table {\n display: table;\n margin-top: 0.9em;\n margin-bottom: 0.9em;\n }\n\n figure.table table,\n table {\n width: 100%;\n border: 1px double #b3b3b3;\n border-collapse: collapse;\n border-spacing: 0;\n\n th {\n text-align: left;\n }\n\n & > thead,\n & > tbody {\n & > tr > td,\n & > tr > th {\n border: 1px solid #bfbfbf;\n min-width: 2em;\n padding: 0.4em;\n }\n\n & > tr > th {\n background: rgba(0, 0, 0, 0.05);\n font-weight: 700;\n }\n }\n }\n }\n`\n"],"mappings":"AAAA,OAAOA,MAAM,MAAM,mBAAmB;AAEtC,OAAO,IAAMC,YAAY,gBAAGD,MAAM,CAACE,GAAG,CAAAC,UAAA;EAAAC,WAAA;EAAAC,WAAA;AAAA,4tBAyDrC"}
|
|
@@ -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'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/
|
|
13
|
+
"sourceUrl": "https://github.com/procore/core/blob/b6d942e/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'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.</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/
|
|
23
|
+
"sourceUrl": "https://github.com/procore/core/blob/b6d942e/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/
|
|
33
|
+
"sourceUrl": "https://github.com/procore/core/blob/b6d942e/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/
|
|
43
|
+
"sourceUrl": "https://github.com/procore/core/blob/b6d942e/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/
|
|
53
|
+
"sourceUrl": "https://github.com/procore/core/blob/b6d942e/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/
|
|
65
|
+
"sourceUrl": "https://github.com/procore/core/blob/b6d942e/packages/text-editor/src/TextEditor/TextEditor.types.ts#L20"
|
|
66
66
|
},
|
|
67
67
|
{
|
|
68
68
|
"name": "locale",
|
|
@@ -72,7 +72,7 @@
|
|
|
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/
|
|
75
|
+
"sourceUrl": "https://github.com/procore/core/blob/b6d942e/packages/text-editor/src/TextEditor/TextEditor.types.ts#L75"
|
|
76
76
|
},
|
|
77
77
|
{
|
|
78
78
|
"name": "readonly",
|
|
@@ -82,7 +82,7 @@
|
|
|
82
82
|
"description": "Indicates if the editor is in readonly mode.\nWhen true, renders the content using TextEditorOutput instead of the editable editor.",
|
|
83
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
84
|
"sourceFile": "TextEditor/TextEditor.types.ts",
|
|
85
|
-
"sourceUrl": "https://github.com/procore/core/blob/
|
|
85
|
+
"sourceUrl": "https://github.com/procore/core/blob/b6d942e/packages/text-editor/src/TextEditor/TextEditor.types.ts#L49"
|
|
86
86
|
},
|
|
87
87
|
{
|
|
88
88
|
"name": "value",
|
|
@@ -92,7 +92,7 @@
|
|
|
92
92
|
"description": "The current value of the editor",
|
|
93
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>",
|
|
94
94
|
"sourceFile": "TextEditor/TextEditor.types.ts",
|
|
95
|
-
"sourceUrl": "https://github.com/procore/core/blob/
|
|
95
|
+
"sourceUrl": "https://github.com/procore/core/blob/b6d942e/packages/text-editor/src/TextEditor/TextEditor.types.ts#L27"
|
|
96
96
|
},
|
|
97
97
|
{
|
|
98
98
|
"name": "onAfterDestroy",
|
|
@@ -102,7 +102,7 @@
|
|
|
102
102
|
"description": "Callback fired after the editor instance is destroyed",
|
|
103
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>",
|
|
104
104
|
"sourceFile": "TextEditor/TextEditor.types.ts",
|
|
105
|
-
"sourceUrl": "https://github.com/procore/core/blob/
|
|
105
|
+
"sourceUrl": "https://github.com/procore/core/blob/b6d942e/packages/text-editor/src/TextEditor/TextEditor.types.ts#L125"
|
|
106
106
|
},
|
|
107
107
|
{
|
|
108
108
|
"name": "onBlur",
|
|
@@ -112,7 +112,7 @@
|
|
|
112
112
|
"description": "Callback fired when the editor loses focus",
|
|
113
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>",
|
|
114
114
|
"sourceFile": "TextEditor/TextEditor.types.ts",
|
|
115
|
-
"sourceUrl": "https://github.com/procore/core/blob/
|
|
115
|
+
"sourceUrl": "https://github.com/procore/core/blob/b6d942e/packages/text-editor/src/TextEditor/TextEditor.types.ts#L98"
|
|
116
116
|
},
|
|
117
117
|
{
|
|
118
118
|
"name": "onChange",
|
|
@@ -122,7 +122,7 @@
|
|
|
122
122
|
"description": "Callback fired when the editor content changes",
|
|
123
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>",
|
|
124
124
|
"sourceFile": "TextEditor/TextEditor.types.ts",
|
|
125
|
-
"sourceUrl": "https://github.com/procore/core/blob/
|
|
125
|
+
"sourceUrl": "https://github.com/procore/core/blob/b6d942e/packages/text-editor/src/TextEditor/TextEditor.types.ts#L84"
|
|
126
126
|
},
|
|
127
127
|
{
|
|
128
128
|
"name": "onDirty",
|
|
@@ -132,7 +132,7 @@
|
|
|
132
132
|
"description": "Callback fired when the editor becomes dirty (content differs from initial value)",
|
|
133
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>",
|
|
134
134
|
"sourceFile": "TextEditor/TextEditor.types.ts",
|
|
135
|
-
"sourceUrl": "https://github.com/procore/core/blob/
|
|
135
|
+
"sourceUrl": "https://github.com/procore/core/blob/b6d942e/packages/text-editor/src/TextEditor/TextEditor.types.ts#L132"
|
|
136
136
|
},
|
|
137
137
|
{
|
|
138
138
|
"name": "onError",
|
|
@@ -142,7 +142,7 @@
|
|
|
142
142
|
"description": "Callback fired when an error occurs in the editor",
|
|
143
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>",
|
|
144
144
|
"sourceFile": "TextEditor/TextEditor.types.ts",
|
|
145
|
-
"sourceUrl": "https://github.com/procore/core/blob/
|
|
145
|
+
"sourceUrl": "https://github.com/procore/core/blob/b6d942e/packages/text-editor/src/TextEditor/TextEditor.types.ts#L105"
|
|
146
146
|
},
|
|
147
147
|
{
|
|
148
148
|
"name": "onFocus",
|
|
@@ -152,7 +152,7 @@
|
|
|
152
152
|
"description": "Callback fired when the editor gains focus",
|
|
153
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>",
|
|
154
154
|
"sourceFile": "TextEditor/TextEditor.types.ts",
|
|
155
|
-
"sourceUrl": "https://github.com/procore/core/blob/
|
|
155
|
+
"sourceUrl": "https://github.com/procore/core/blob/b6d942e/packages/text-editor/src/TextEditor/TextEditor.types.ts#L91"
|
|
156
156
|
},
|
|
157
157
|
{
|
|
158
158
|
"name": "onInit",
|
|
@@ -162,7 +162,7 @@
|
|
|
162
162
|
"description": "Callback fired when the editor is ready",
|
|
163
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>",
|
|
164
164
|
"sourceFile": "TextEditor/TextEditor.types.ts",
|
|
165
|
-
"sourceUrl": "https://github.com/procore/core/blob/
|
|
165
|
+
"sourceUrl": "https://github.com/procore/core/blob/b6d942e/packages/text-editor/src/TextEditor/TextEditor.types.ts#L118"
|
|
166
166
|
},
|
|
167
167
|
{
|
|
168
168
|
"name": "onKeyDown",
|
|
@@ -172,7 +172,7 @@
|
|
|
172
172
|
"description": "Callback fired when a key is pressed in the editor",
|
|
173
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>",
|
|
174
174
|
"sourceFile": "TextEditor/TextEditor.types.ts",
|
|
175
|
-
"sourceUrl": "https://github.com/procore/core/blob/
|
|
175
|
+
"sourceUrl": "https://github.com/procore/core/blob/b6d942e/packages/text-editor/src/TextEditor/TextEditor.types.ts#L141"
|
|
176
176
|
}
|
|
177
177
|
],
|
|
178
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/
|
|
13
|
+
"sourceUrl": "https://github.com/procore/core/blob/b6d942e/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/
|
|
23
|
+
"sourceUrl": "https://github.com/procore/core/blob/b6d942e/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/
|
|
13
|
+
"sourceUrl": "https://github.com/procore/core/blob/b6d942e/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/
|
|
23
|
+
"sourceUrl": "https://github.com/procore/core/blob/b6d942e/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/
|
|
33
|
+
"sourceUrl": "https://github.com/procore/core/blob/b6d942e/packages/text-editor/src/TextEditorOutput/TextEditorOutput.types.ts#L7"
|
|
34
34
|
}
|
|
35
35
|
],
|
|
36
36
|
"description": ""
|
package/dist/utils/debounce.d.ts
CHANGED
|
@@ -1 +1,4 @@
|
|
|
1
|
-
export declare function debounce<T extends (...args: any[]) => void>(func: T, wait: number, immediate?: boolean):
|
|
1
|
+
export declare function debounce<T extends (...args: any[]) => void>(func: T, wait: number, immediate?: boolean): {
|
|
2
|
+
(this: ThisParameterType<T>, ...args: Parameters<T>): void;
|
|
3
|
+
flush(): void;
|
|
4
|
+
};
|
package/dist/utils/debounce.js
CHANGED
|
@@ -1,11 +1,15 @@
|
|
|
1
1
|
export function debounce(func, wait) {
|
|
2
2
|
var immediate = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
|
|
3
3
|
var timeout = null;
|
|
4
|
-
|
|
4
|
+
var pending = null;
|
|
5
|
+
var debounced = function debounced() {
|
|
5
6
|
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
6
7
|
args[_key] = arguments[_key];
|
|
7
8
|
}
|
|
8
9
|
var context = this;
|
|
10
|
+
pending = function pending() {
|
|
11
|
+
return func.apply(context, args);
|
|
12
|
+
};
|
|
9
13
|
var callNow = immediate && timeout === null;
|
|
10
14
|
if (timeout !== null) {
|
|
11
15
|
clearTimeout(timeout);
|
|
@@ -20,5 +24,14 @@ export function debounce(func, wait) {
|
|
|
20
24
|
func.apply(context, args);
|
|
21
25
|
}
|
|
22
26
|
};
|
|
27
|
+
debounced.flush = function () {
|
|
28
|
+
if (timeout !== null) {
|
|
29
|
+
var _pending;
|
|
30
|
+
clearTimeout(timeout);
|
|
31
|
+
timeout = null;
|
|
32
|
+
(_pending = pending) === null || _pending === void 0 ? void 0 : _pending();
|
|
33
|
+
}
|
|
34
|
+
};
|
|
35
|
+
return debounced;
|
|
23
36
|
}
|
|
24
37
|
//# sourceMappingURL=debounce.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"debounce.js","names":["debounce","func","wait","immediate","arguments","length","undefined","timeout","_len","args","Array","_key","context","callNow","clearTimeout","setTimeout","
|
|
1
|
+
{"version":3,"file":"debounce.js","names":["debounce","func","wait","immediate","arguments","length","undefined","timeout","pending","debounced","_len","args","Array","_key","context","apply","callNow","clearTimeout","setTimeout","flush","_pending"],"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 let pending: (() => void) | null = null\n\n const debounced = function (\n this: ThisParameterType<T>,\n ...args: Parameters<T>\n ): void {\n const context = this\n pending = () => func.apply(context, args)\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 debounced.flush = () => {\n if (timeout !== null) {\n clearTimeout(timeout)\n timeout = null\n pending?.()\n }\n }\n\n return debounced\n}\n"],"mappings":"AAAA,OAAO,SA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;IACb;EACF,CAAC;EAED,OAAOX,SAAS;AAClB"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@procore/text-editor",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.5.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",
|
|
@@ -69,7 +69,7 @@
|
|
|
69
69
|
"test:watch": "yarn run test --watch"
|
|
70
70
|
},
|
|
71
71
|
"peerDependencies": {
|
|
72
|
-
"@procore/core-react": "^12.49.
|
|
72
|
+
"@procore/core-react": "^12.49.1",
|
|
73
73
|
"@procore/globalization-toolkit": ">= 3 < 4",
|
|
74
74
|
"ckeditor5": ">= 47 < 49",
|
|
75
75
|
"ckeditor5-premium-features": ">= 47 < 49",
|
|
@@ -94,7 +94,7 @@
|
|
|
94
94
|
"@babel/preset-react": "7.18.6",
|
|
95
95
|
"@babel/preset-typescript": "7.18.6",
|
|
96
96
|
"@babel/register": "7.18.9",
|
|
97
|
-
"@procore/core-react": "^12.49.
|
|
97
|
+
"@procore/core-react": "^12.49.1",
|
|
98
98
|
"@procore/globalization-toolkit": "3.0.0",
|
|
99
99
|
"@storybook/addon-webpack5-compiler-swc": "^4.0.2",
|
|
100
100
|
"@storybook/jest": "^0.2.3",
|