@instructure/ui-source-code-editor 11.7.10 → 11.7.11-pr-snapshot-1794841957152
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 +17 -0
- package/es/SourceCodeEditor/v1/SearchPanel.js +81 -104
- package/es/SourceCodeEditor/v1/customKeybinding.js +85 -98
- package/es/SourceCodeEditor/v1/index.js +463 -507
- package/es/SourceCodeEditor/v1/props.js +30 -28
- package/es/SourceCodeEditor/v1/styles.js +198 -222
- package/es/SourceCodeEditor/v1/theme.js +19 -53
- package/es/SourceCodeEditor/v2/SearchPanel.js +81 -109
- package/es/SourceCodeEditor/v2/customKeybinding.js +85 -98
- package/es/SourceCodeEditor/v2/index.js +519 -545
- package/es/SourceCodeEditor/v2/props.js +30 -28
- package/es/SourceCodeEditor/v2/styles.js +208 -232
- package/es/exports/a.js +1 -24
- package/es/exports/b.js +1 -24
- package/package.json +16 -22
- package/src/SourceCodeEditor/v1/index.tsx +10 -5
- package/src/SourceCodeEditor/v2/index.tsx +47 -12
- package/tsconfig.build.json +0 -1
- package/tsconfig.build.tsbuildinfo +1 -1
- package/types/SourceCodeEditor/v1/index.d.ts +3 -1
- package/types/SourceCodeEditor/v1/index.d.ts.map +1 -1
- package/types/SourceCodeEditor/v2/index.d.ts +6 -1
- package/types/SourceCodeEditor/v2/index.d.ts.map +1 -1
- package/lib/SourceCodeEditor/v1/SearchPanel.js +0 -119
- package/lib/SourceCodeEditor/v1/customKeybinding.js +0 -105
- package/lib/SourceCodeEditor/v1/index.js +0 -550
- package/lib/SourceCodeEditor/v1/props.js +0 -33
- package/lib/SourceCodeEditor/v1/styles.js +0 -230
- package/lib/SourceCodeEditor/v1/theme.js +0 -60
- package/lib/SourceCodeEditor/v2/SearchPanel.js +0 -125
- package/lib/SourceCodeEditor/v2/customKeybinding.js +0 -105
- package/lib/SourceCodeEditor/v2/index.js +0 -591
- package/lib/SourceCodeEditor/v2/props.js +0 -33
- package/lib/SourceCodeEditor/v2/styles.js +0 -240
- package/lib/exports/a.js +0 -12
- package/lib/exports/b.js +0 -12
- package/lib/package.json +0 -1
package/package.json
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@instructure/ui-source-code-editor",
|
|
3
|
-
"version": "11.7.
|
|
3
|
+
"version": "11.7.11-pr-snapshot-1794841957152",
|
|
4
|
+
"type": "module",
|
|
4
5
|
"description": "A UI component library made by Instructure Inc.",
|
|
5
6
|
"author": "Instructure, Inc. Engineering and Product Design",
|
|
6
7
|
"module": "./es/index.js",
|
|
7
|
-
"main": "./lib/index.js",
|
|
8
8
|
"types": "./types/index.d.ts",
|
|
9
9
|
"repository": {
|
|
10
10
|
"type": "git",
|
|
@@ -14,7 +14,6 @@
|
|
|
14
14
|
"bugs": "https://github.com/instructure/instructure-ui/issues",
|
|
15
15
|
"license": "MIT",
|
|
16
16
|
"dependencies": {
|
|
17
|
-
"@babel/runtime": "^7.29.7",
|
|
18
17
|
"@codemirror/autocomplete": "^6.18.1",
|
|
19
18
|
"@codemirror/commands": "^6.6.2",
|
|
20
19
|
"@codemirror/lang-css": "^6.3.0",
|
|
@@ -28,21 +27,21 @@
|
|
|
28
27
|
"@codemirror/search": "^6.5.6",
|
|
29
28
|
"@codemirror/state": "^6.4.1",
|
|
30
29
|
"@codemirror/view": "^6.34.1",
|
|
31
|
-
"@instructure/emotion": "11.7.
|
|
32
|
-
"@instructure/shared-types": "11.7.
|
|
33
|
-
"@instructure/ui-a11y-content": "11.7.
|
|
34
|
-
"@instructure/ui-buttons": "11.7.
|
|
35
|
-
"@instructure/ui-dom-utils": "11.7.
|
|
36
|
-
"@instructure/ui-i18n": "11.7.
|
|
37
|
-
"@instructure/ui-icons": "11.7.
|
|
38
|
-
"@instructure/ui-react-utils": "11.7.
|
|
39
|
-
"@instructure/ui-text-input": "11.7.
|
|
40
|
-
"@instructure/ui-themes": "11.7.
|
|
41
|
-
"@instructure/ui-utils": "11.7.
|
|
42
|
-
"@lezer/highlight": "1.2.3"
|
|
30
|
+
"@instructure/emotion": "11.7.11-pr-snapshot-1794841957152",
|
|
31
|
+
"@instructure/shared-types": "11.7.11-pr-snapshot-1794841957152",
|
|
32
|
+
"@instructure/ui-a11y-content": "11.7.11-pr-snapshot-1794841957152",
|
|
33
|
+
"@instructure/ui-buttons": "11.7.11-pr-snapshot-1794841957152",
|
|
34
|
+
"@instructure/ui-dom-utils": "11.7.11-pr-snapshot-1794841957152",
|
|
35
|
+
"@instructure/ui-i18n": "11.7.11-pr-snapshot-1794841957152",
|
|
36
|
+
"@instructure/ui-icons": "11.7.11-pr-snapshot-1794841957152",
|
|
37
|
+
"@instructure/ui-react-utils": "11.7.11-pr-snapshot-1794841957152",
|
|
38
|
+
"@instructure/ui-text-input": "11.7.11-pr-snapshot-1794841957152",
|
|
39
|
+
"@instructure/ui-themes": "11.7.11-pr-snapshot-1794841957152",
|
|
40
|
+
"@instructure/ui-utils": "11.7.11-pr-snapshot-1794841957152",
|
|
41
|
+
"@lezer/highlight": "1.2.3",
|
|
42
|
+
"@swc/helpers": "^0.5.23"
|
|
43
43
|
},
|
|
44
44
|
"devDependencies": {
|
|
45
|
-
"@instructure/ui-babel-preset": "11.7.10",
|
|
46
45
|
"vitest": "^5.0.0"
|
|
47
46
|
},
|
|
48
47
|
"peerDependencies": {
|
|
@@ -54,7 +53,6 @@
|
|
|
54
53
|
},
|
|
55
54
|
"sideEffects": false,
|
|
56
55
|
"exports": {
|
|
57
|
-
"./lib/*": "./lib/*",
|
|
58
56
|
"./es/*": "./es/*",
|
|
59
57
|
"./types/*": "./types/*",
|
|
60
58
|
"./package.json": "./package.json",
|
|
@@ -63,28 +61,24 @@
|
|
|
63
61
|
"src": "./src/exports/a.ts",
|
|
64
62
|
"types": "./types/exports/a.d.ts",
|
|
65
63
|
"import": "./es/exports/a.js",
|
|
66
|
-
"require": "./lib/exports/a.js",
|
|
67
64
|
"default": "./es/exports/a.js"
|
|
68
65
|
},
|
|
69
66
|
"./v11_6": {
|
|
70
67
|
"src": "./src/exports/a.ts",
|
|
71
68
|
"types": "./types/exports/a.d.ts",
|
|
72
69
|
"import": "./es/exports/a.js",
|
|
73
|
-
"require": "./lib/exports/a.js",
|
|
74
70
|
"default": "./es/exports/a.js"
|
|
75
71
|
},
|
|
76
72
|
"./v11_7": {
|
|
77
73
|
"src": "./src/exports/b.ts",
|
|
78
74
|
"types": "./types/exports/b.d.ts",
|
|
79
75
|
"import": "./es/exports/b.js",
|
|
80
|
-
"require": "./lib/exports/b.js",
|
|
81
76
|
"default": "./es/exports/b.js"
|
|
82
77
|
},
|
|
83
78
|
"./latest": {
|
|
84
79
|
"src": "./src/exports/b.ts",
|
|
85
80
|
"types": "./types/exports/b.d.ts",
|
|
86
81
|
"import": "./es/exports/b.js",
|
|
87
|
-
"require": "./lib/exports/b.js",
|
|
88
82
|
"default": "./es/exports/b.js"
|
|
89
83
|
}
|
|
90
84
|
},
|
|
@@ -92,7 +86,7 @@
|
|
|
92
86
|
"lint": "ui-scripts lint",
|
|
93
87
|
"lint:fix": "ui-scripts lint --fix",
|
|
94
88
|
"clean": "ui-scripts clean",
|
|
95
|
-
"build": "ui-scripts build
|
|
89
|
+
"build": "ui-scripts build",
|
|
96
90
|
"build:watch": "pnpm run ts:check -- --watch & ui-scripts build --watch",
|
|
97
91
|
"build:types": "tsc -p tsconfig.build.json",
|
|
98
92
|
"ts:check": "tsc -p tsconfig.build.json --noEmit --emitDeclarationOnly false"
|
|
@@ -104,10 +104,7 @@ import type { SourceCodeEditorProps } from './props'
|
|
|
104
104
|
category: components
|
|
105
105
|
---
|
|
106
106
|
**/
|
|
107
|
-
|
|
108
|
-
@withStyle(generateStyle, generateComponentTheme)
|
|
109
|
-
@textDirectionContextConsumer()
|
|
110
|
-
class SourceCodeEditor extends Component<SourceCodeEditorProps> {
|
|
107
|
+
export class SourceCodeEditorBase extends Component<SourceCodeEditorProps> {
|
|
111
108
|
static displayName = 'SourceCodeEditor'
|
|
112
109
|
static readonly componentId = 'SourceCodeEditor'
|
|
113
110
|
|
|
@@ -364,7 +361,7 @@ class SourceCodeEditor extends Component<SourceCodeEditorProps> {
|
|
|
364
361
|
|
|
365
362
|
get direction() {
|
|
366
363
|
// comes from the `direction` prop and
|
|
367
|
-
// falls back to the `dir` prop coming from the
|
|
364
|
+
// falls back to the `dir` prop coming from the `textDirectionContextConsumer` HOC
|
|
368
365
|
return this.props.direction || this.props.dir
|
|
369
366
|
}
|
|
370
367
|
|
|
@@ -683,5 +680,13 @@ class SourceCodeEditor extends Component<SourceCodeEditorProps> {
|
|
|
683
680
|
}
|
|
684
681
|
}
|
|
685
682
|
|
|
683
|
+
const SourceCodeEditor = withDeterministicId()(
|
|
684
|
+
withStyle(
|
|
685
|
+
generateStyle,
|
|
686
|
+
generateComponentTheme
|
|
687
|
+
)(textDirectionContextConsumer()(SourceCodeEditorBase))
|
|
688
|
+
)
|
|
689
|
+
type SourceCodeEditor = SourceCodeEditorBase
|
|
690
|
+
|
|
686
691
|
export default SourceCodeEditor
|
|
687
692
|
export { SourceCodeEditor }
|
|
@@ -114,10 +114,7 @@ type SourceCodeEditorState = {
|
|
|
114
114
|
category: components
|
|
115
115
|
---
|
|
116
116
|
**/
|
|
117
|
-
|
|
118
|
-
@withStyleNew(generateStyle)
|
|
119
|
-
@textDirectionContextConsumer()
|
|
120
|
-
class SourceCodeEditor extends Component<
|
|
117
|
+
export class SourceCodeEditorBase extends Component<
|
|
121
118
|
SourceCodeEditorProps,
|
|
122
119
|
SourceCodeEditorState
|
|
123
120
|
> {
|
|
@@ -156,6 +153,7 @@ class SourceCodeEditor extends Component<
|
|
|
156
153
|
|
|
157
154
|
private _searchPanelId = 0
|
|
158
155
|
private _isUnmounting = false
|
|
156
|
+
private _resizeObserver?: ResizeObserver
|
|
159
157
|
|
|
160
158
|
private _newSelectionAfterValueChange?: EditorSelection
|
|
161
159
|
|
|
@@ -327,13 +325,8 @@ class SourceCodeEditor extends Component<
|
|
|
327
325
|
parent: this._containerRef
|
|
328
326
|
})
|
|
329
327
|
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
// which can be observed while navigating with keyboard:
|
|
333
|
-
// Ensure elements that have scrollable content are accessible by keyboard
|
|
334
|
-
// To solve this problem, you need to fix at least (1) of the following:
|
|
335
|
-
// Element should have focusable content, Element should be focusable
|
|
336
|
-
this._editorView.scrollDOM.tabIndex = 0
|
|
328
|
+
this.updateScrollerFocusability()
|
|
329
|
+
this.observeScrollerOverflow()
|
|
337
330
|
|
|
338
331
|
if (autofocus) {
|
|
339
332
|
this.focus()
|
|
@@ -347,6 +340,7 @@ class SourceCodeEditor extends Component<
|
|
|
347
340
|
|
|
348
341
|
componentWillUnmount() {
|
|
349
342
|
this._isUnmounting = true
|
|
343
|
+
this._resizeObserver?.disconnect()
|
|
350
344
|
this._editorView?.destroy()
|
|
351
345
|
|
|
352
346
|
this.cancelAnimationFrames()
|
|
@@ -401,7 +395,7 @@ class SourceCodeEditor extends Component<
|
|
|
401
395
|
|
|
402
396
|
get direction() {
|
|
403
397
|
// comes from the `direction` prop and
|
|
404
|
-
// falls back to the `dir` prop coming from the
|
|
398
|
+
// falls back to the `dir` prop coming from the `textDirectionContextConsumer` HOC
|
|
405
399
|
return this.props.direction || this.props.dir
|
|
406
400
|
}
|
|
407
401
|
|
|
@@ -652,6 +646,40 @@ class SourceCodeEditor extends Component<
|
|
|
652
646
|
|
|
653
647
|
refreshExtensions() {
|
|
654
648
|
this.dispatchViewEffects(StateEffect.reconfigure.of(this.extensions))
|
|
649
|
+
this.updateScrollerFocusability()
|
|
650
|
+
}
|
|
651
|
+
|
|
652
|
+
// a scrollable region must be keyboard reachable (axe: scrollable-region-focusable).
|
|
653
|
+
// An editable textbox already is, so the scroller only needs a tab stop when the
|
|
654
|
+
// textbox can't take focus and the content actually overflows.
|
|
655
|
+
private updateScrollerFocusability() {
|
|
656
|
+
const scroller = this._editorView?.scrollDOM
|
|
657
|
+
if (!scroller) return
|
|
658
|
+
|
|
659
|
+
const overflows =
|
|
660
|
+
scroller.scrollHeight > scroller.clientHeight ||
|
|
661
|
+
scroller.scrollWidth > scroller.clientWidth
|
|
662
|
+
|
|
663
|
+
if (this.props.editable === false && overflows) {
|
|
664
|
+
scroller.tabIndex = 0
|
|
665
|
+
scroller.setAttribute('role', 'region')
|
|
666
|
+
scroller.setAttribute('aria-labelledby', this._id)
|
|
667
|
+
} else {
|
|
668
|
+
scroller.removeAttribute('tabindex')
|
|
669
|
+
scroller.removeAttribute('role')
|
|
670
|
+
scroller.removeAttribute('aria-labelledby')
|
|
671
|
+
}
|
|
672
|
+
}
|
|
673
|
+
|
|
674
|
+
// overflow changes with content, wrapping and container size
|
|
675
|
+
private observeScrollerOverflow() {
|
|
676
|
+
if (!this._editorView || typeof ResizeObserver === 'undefined') return
|
|
677
|
+
|
|
678
|
+
this._resizeObserver = new ResizeObserver(() =>
|
|
679
|
+
this.updateScrollerFocusability()
|
|
680
|
+
)
|
|
681
|
+
this._resizeObserver.observe(this._editorView.scrollDOM)
|
|
682
|
+
this._resizeObserver.observe(this._editorView.contentDOM)
|
|
655
683
|
}
|
|
656
684
|
|
|
657
685
|
refreshEditorValue() {
|
|
@@ -741,5 +769,12 @@ class SourceCodeEditor extends Component<
|
|
|
741
769
|
}
|
|
742
770
|
}
|
|
743
771
|
|
|
772
|
+
const SourceCodeEditor = withDeterministicId()(
|
|
773
|
+
withStyleNew(generateStyle)(
|
|
774
|
+
textDirectionContextConsumer()(SourceCodeEditorBase)
|
|
775
|
+
)
|
|
776
|
+
)
|
|
777
|
+
type SourceCodeEditor = SourceCodeEditorBase
|
|
778
|
+
|
|
744
779
|
export default SourceCodeEditor
|
|
745
780
|
export { SourceCodeEditor }
|
package/tsconfig.build.json
CHANGED