@onereach/ui-components 5.7.0-beta.3264.0 → 5.7.0-beta.3276.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/dist/bundled/v2/components/OrCodeV3/OrCode.js +34 -25
- package/dist/bundled/v2/components/OrCodeV3/OrCode.vue.d.ts +0 -2
- package/dist/bundled/v3/{OrCode.vue_vue_type_script_lang-df4f6357.js → OrCode.vue_vue_type_script_lang-8d6195d1.js} +34 -25
- package/dist/bundled/v3/components/OrCodeV3/OrCode.js +2 -2
- package/dist/bundled/v3/components/OrCodeV3/OrCode.vue.d.ts +0 -1
- package/dist/bundled/v3/components/OrCodeV3/index.js +1 -1
- package/dist/bundled/v3/components/index.js +1 -1
- package/dist/bundled/v3/index.js +1 -1
- package/dist/esm/v2/{OrCode-b03b12f1.js → OrCode-12ab60ec.js} +35 -26
- package/dist/esm/v2/components/index.js +1 -1
- package/dist/esm/v2/components/or-code-v3/OrCode.vue.d.ts +0 -2
- package/dist/esm/v2/components/or-code-v3/index.js +1 -1
- package/dist/esm/v2/index.js +1 -1
- package/dist/esm/v3/{OrCode-8e70f55f.js → OrCode-18511f67.js} +35 -26
- package/dist/esm/v3/components/index.js +1 -1
- package/dist/esm/v3/components/or-code-v3/OrCode.vue.d.ts +0 -1
- package/dist/esm/v3/components/or-code-v3/index.js +1 -1
- package/dist/esm/v3/index.js +1 -1
- package/package.json +1 -1
- package/src/components/or-code-v3/OrCode.vue +45 -41
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { defineComponent, ref, computed, reactive, toRef, watch, onMounted, onUnmounted } from 'vue-demi';
|
|
2
2
|
import { b as basicSetup, i as indentWithTab } from '../../index-dbeba01e.js';
|
|
3
|
-
import {
|
|
3
|
+
import { d as Compartment, a4 as keymap, e as EditorState, w as EditorView } from '../../index-df5748fb.js';
|
|
4
4
|
import { j as javascript, c as css, h as html } from '../../index-7020020d.js';
|
|
5
5
|
import { j as json } from '../../index-4ee5b5e5.js';
|
|
6
6
|
import { m as markdown } from '../../index-1d9c1371.js';
|
|
@@ -81,6 +81,7 @@ var script = defineComponent({
|
|
|
81
81
|
// Styles
|
|
82
82
|
const rootStyles = computed(() => ['or-code-v3', ...Code]);
|
|
83
83
|
const controlStyles = computed(() => [...CodeControl]);
|
|
84
|
+
const addedExtensionCompartment = new Compartment();
|
|
84
85
|
// State
|
|
85
86
|
const controlAttributes = reactive({
|
|
86
87
|
id: useIdAttribute(),
|
|
@@ -88,8 +89,8 @@ var script = defineComponent({
|
|
|
88
89
|
...useValidationAttributes()
|
|
89
90
|
});
|
|
90
91
|
const proxyModelValue = useProxyModelValue(toRef(props, 'modelValue'), context.emit);
|
|
91
|
-
const
|
|
92
|
-
switch (
|
|
92
|
+
const getLanguageExtension = async language => {
|
|
93
|
+
switch (language) {
|
|
93
94
|
case CodeLanguage.HTML:
|
|
94
95
|
return html();
|
|
95
96
|
case CodeLanguage.CSS:
|
|
@@ -105,7 +106,7 @@ var script = defineComponent({
|
|
|
105
106
|
case CodeLanguage.MD:
|
|
106
107
|
return markdown();
|
|
107
108
|
}
|
|
108
|
-
}
|
|
109
|
+
};
|
|
109
110
|
// Methods
|
|
110
111
|
function focus() {
|
|
111
112
|
var _a;
|
|
@@ -116,14 +117,8 @@ var script = defineComponent({
|
|
|
116
117
|
(_a = control.value) === null || _a === void 0 ? void 0 : _a.blur();
|
|
117
118
|
}
|
|
118
119
|
// #region Codemirror
|
|
119
|
-
const editorView = new EditorView({
|
|
120
|
-
dispatch: transaction => {
|
|
121
|
-
editorView.update([transaction]);
|
|
122
|
-
proxyModelValue.value = String(editorView.state.doc);
|
|
123
|
-
}
|
|
124
|
-
});
|
|
125
120
|
const theme = useTheme();
|
|
126
|
-
const
|
|
121
|
+
const defaultExtensions = [basicSetup, keymap.of([indentWithTab]), EditorState.readOnly.of(props.readonly), EditorView.editable.of(!props.disabled), EditorView.domEventHandlers({
|
|
127
122
|
keydown: event => {
|
|
128
123
|
context.emit('keydown', event);
|
|
129
124
|
},
|
|
@@ -158,19 +153,34 @@ var script = defineComponent({
|
|
|
158
153
|
'.cm-activeLineGutter, .cm-activeLine': {
|
|
159
154
|
backgroundColor: theme.backgroundColor['primary-opacity-0-08']
|
|
160
155
|
}
|
|
161
|
-
})
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
156
|
+
})];
|
|
157
|
+
const state = EditorState.create({
|
|
158
|
+
doc: proxyModelValue.value,
|
|
159
|
+
extensions: [...defaultExtensions, addedExtensionCompartment.of([])]
|
|
160
|
+
// selection: selection.ranges.some((range) => range.to > modelValue.length)
|
|
161
|
+
// ? { anchor: modelValue.length }
|
|
162
|
+
// : selection,
|
|
163
|
+
});
|
|
164
|
+
|
|
165
|
+
const editorView = new EditorView({
|
|
166
|
+
state,
|
|
167
|
+
dispatch: transaction => {
|
|
168
|
+
editorView.update([transaction]);
|
|
169
|
+
if (transaction.docChanged) {
|
|
170
|
+
proxyModelValue.value = String(editorView.state.doc);
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
});
|
|
174
|
+
watch([() => props.extensions, () => props.language], async _ref => {
|
|
175
|
+
let [extensions, language] = _ref;
|
|
176
|
+
const languageExt = await getLanguageExtension(language);
|
|
177
|
+
extensions.forEach(extension => {
|
|
178
|
+
Reflect.setPrototypeOf(extension, Reflect.getPrototypeOf(state));
|
|
179
|
+
});
|
|
180
|
+
const effect = addedExtensionCompartment.reconfigure([...extensions, languageExt]);
|
|
181
|
+
editorView.dispatch({
|
|
182
|
+
effects: [effect]
|
|
183
|
+
});
|
|
174
184
|
}, {
|
|
175
185
|
immediate: true
|
|
176
186
|
});
|
|
@@ -207,7 +217,6 @@ var script = defineComponent({
|
|
|
207
217
|
controlStyles,
|
|
208
218
|
controlAttributes,
|
|
209
219
|
proxyModelValue,
|
|
210
|
-
proxyLanguage,
|
|
211
220
|
focus,
|
|
212
221
|
blur
|
|
213
222
|
};
|
|
@@ -28,7 +28,6 @@ declare const _default: import("vue").ComponentOptions<import("vue").default, im
|
|
|
28
28
|
id: string | undefined;
|
|
29
29
|
};
|
|
30
30
|
proxyModelValue: import("../../hooks").UseProxyModelValueReturn<string>;
|
|
31
|
-
proxyLanguage: import("@vue/composition-api").ComputedRef<import("@codemirror/language").LanguageSupport>;
|
|
32
31
|
focus: () => void;
|
|
33
32
|
blur: () => void;
|
|
34
33
|
}> & import("@vue/composition-api").Data, {}, {}, {
|
|
@@ -143,7 +142,6 @@ declare const _default: import("vue").ComponentOptions<import("vue").default, im
|
|
|
143
142
|
id: string | undefined;
|
|
144
143
|
};
|
|
145
144
|
proxyModelValue: import("../../hooks").UseProxyModelValueReturn<string>;
|
|
146
|
-
proxyLanguage: import("@vue/composition-api").ComputedRef<import("@codemirror/language").LanguageSupport>;
|
|
147
145
|
focus: () => void;
|
|
148
146
|
blur: () => void;
|
|
149
147
|
}>, import("@vue/composition-api").Data, {}, {}, {}, {}, string[], {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { defineComponent, ref, computed, reactive, toRef, watch, onMounted, onUnmounted } from 'vue-demi';
|
|
2
2
|
import { b as basicSetup, i as indentWithTab } from './index-dbeba01e.js';
|
|
3
|
-
import {
|
|
3
|
+
import { d as Compartment, a4 as keymap, e as EditorState, w as EditorView } from './index-df5748fb.js';
|
|
4
4
|
import { j as javascript, c as css, h as html } from './index-7020020d.js';
|
|
5
5
|
import { j as json } from './index-4ee5b5e5.js';
|
|
6
6
|
import { m as markdown } from './index-1d9c1371.js';
|
|
@@ -86,6 +86,7 @@ var script = defineComponent({
|
|
|
86
86
|
// Styles
|
|
87
87
|
const rootStyles = computed(() => ['or-code-v3', ...Code]);
|
|
88
88
|
const controlStyles = computed(() => [...CodeControl]);
|
|
89
|
+
const addedExtensionCompartment = new Compartment();
|
|
89
90
|
// State
|
|
90
91
|
const controlAttributes = reactive({
|
|
91
92
|
id: useIdAttribute(),
|
|
@@ -93,8 +94,8 @@ var script = defineComponent({
|
|
|
93
94
|
...useValidationAttributes()
|
|
94
95
|
});
|
|
95
96
|
const proxyModelValue = useProxyModelValue(toRef(props, 'modelValue'), context.emit);
|
|
96
|
-
const
|
|
97
|
-
switch (
|
|
97
|
+
const getLanguageExtension = async language => {
|
|
98
|
+
switch (language) {
|
|
98
99
|
case CodeLanguage.HTML:
|
|
99
100
|
return html();
|
|
100
101
|
case CodeLanguage.CSS:
|
|
@@ -110,7 +111,7 @@ var script = defineComponent({
|
|
|
110
111
|
case CodeLanguage.MD:
|
|
111
112
|
return markdown();
|
|
112
113
|
}
|
|
113
|
-
}
|
|
114
|
+
};
|
|
114
115
|
// Methods
|
|
115
116
|
function focus() {
|
|
116
117
|
var _a;
|
|
@@ -121,14 +122,8 @@ var script = defineComponent({
|
|
|
121
122
|
(_a = control.value) === null || _a === void 0 ? void 0 : _a.blur();
|
|
122
123
|
}
|
|
123
124
|
// #region Codemirror
|
|
124
|
-
const editorView = new EditorView({
|
|
125
|
-
dispatch: transaction => {
|
|
126
|
-
editorView.update([transaction]);
|
|
127
|
-
proxyModelValue.value = String(editorView.state.doc);
|
|
128
|
-
}
|
|
129
|
-
});
|
|
130
125
|
const theme = useTheme();
|
|
131
|
-
const
|
|
126
|
+
const defaultExtensions = [basicSetup, keymap.of([indentWithTab]), EditorState.readOnly.of(props.readonly), EditorView.editable.of(!props.disabled), EditorView.domEventHandlers({
|
|
132
127
|
keydown: event => {
|
|
133
128
|
context.emit('keydown', event);
|
|
134
129
|
},
|
|
@@ -163,19 +158,34 @@ var script = defineComponent({
|
|
|
163
158
|
'.cm-activeLineGutter, .cm-activeLine': {
|
|
164
159
|
backgroundColor: theme.backgroundColor['primary-opacity-0-08']
|
|
165
160
|
}
|
|
166
|
-
})
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
161
|
+
})];
|
|
162
|
+
const state = EditorState.create({
|
|
163
|
+
doc: proxyModelValue.value,
|
|
164
|
+
extensions: [...defaultExtensions, addedExtensionCompartment.of([])]
|
|
165
|
+
// selection: selection.ranges.some((range) => range.to > modelValue.length)
|
|
166
|
+
// ? { anchor: modelValue.length }
|
|
167
|
+
// : selection,
|
|
168
|
+
});
|
|
169
|
+
|
|
170
|
+
const editorView = new EditorView({
|
|
171
|
+
state,
|
|
172
|
+
dispatch: transaction => {
|
|
173
|
+
editorView.update([transaction]);
|
|
174
|
+
if (transaction.docChanged) {
|
|
175
|
+
proxyModelValue.value = String(editorView.state.doc);
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
});
|
|
179
|
+
watch([() => props.extensions, () => props.language], async _ref => {
|
|
180
|
+
let [extensions, language] = _ref;
|
|
181
|
+
const languageExt = await getLanguageExtension(language);
|
|
182
|
+
extensions.forEach(extension => {
|
|
183
|
+
Reflect.setPrototypeOf(extension, Reflect.getPrototypeOf(state));
|
|
184
|
+
});
|
|
185
|
+
const effect = addedExtensionCompartment.reconfigure([...extensions, languageExt]);
|
|
186
|
+
editorView.dispatch({
|
|
187
|
+
effects: [effect]
|
|
188
|
+
});
|
|
179
189
|
}, {
|
|
180
190
|
immediate: true
|
|
181
191
|
});
|
|
@@ -212,7 +222,6 @@ var script = defineComponent({
|
|
|
212
222
|
controlStyles,
|
|
213
223
|
controlAttributes,
|
|
214
224
|
proxyModelValue,
|
|
215
|
-
proxyLanguage,
|
|
216
225
|
focus,
|
|
217
226
|
blur
|
|
218
227
|
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { s as script } from '../../OrCode.vue_vue_type_script_lang-
|
|
2
|
-
export { s as default } from '../../OrCode.vue_vue_type_script_lang-
|
|
1
|
+
import { s as script } from '../../OrCode.vue_vue_type_script_lang-8d6195d1.js';
|
|
2
|
+
export { s as default } from '../../OrCode.vue_vue_type_script_lang-8d6195d1.js';
|
|
3
3
|
import { resolveComponent, openBlock, createElementBlock, normalizeClass, createBlock, withCtx, createElementVNode, renderSlot, createVNode, withModifiers, createTextVNode, toDisplayString, createCommentVNode, withDirectives, vShow } from 'vue';
|
|
4
4
|
|
|
5
5
|
const _hoisted_1 = {
|
|
@@ -61,7 +61,6 @@ declare const _default: import("vue-demi").DefineComponent<{
|
|
|
61
61
|
id: string | undefined;
|
|
62
62
|
};
|
|
63
63
|
proxyModelValue: import("../../hooks").UseProxyModelValueReturn<string | undefined>;
|
|
64
|
-
proxyLanguage: import("vue-demi").ComputedRef<import("@codemirror/language").LanguageSupport>;
|
|
65
64
|
focus: () => void;
|
|
66
65
|
blur: () => void;
|
|
67
66
|
}, unknown, {}, {}, import("vue-demi").ComponentOptionsMixin, import("vue-demi").ComponentOptionsMixin, ("update:modelValue" | "keydown" | "keyup" | "focus" | "blur")[], "update:modelValue" | "keydown" | "keyup" | "focus" | "blur", import("vue-demi").VNodeProps & import("vue-demi").AllowedComponentProps & import("vue-demi").ComponentCustomProps, Readonly<import("vue-demi").ExtractPropTypes<{
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export { CodeLanguage } from './props.js';
|
|
2
|
-
export { s as OrCodeV3 } from '../../OrCode.vue_vue_type_script_lang-
|
|
2
|
+
export { s as OrCodeV3 } from '../../OrCode.vue_vue_type_script_lang-8d6195d1.js';
|
|
3
3
|
export { a as lintGutter, l as linter } from '../../index-1e36d007.js';
|
|
4
4
|
export { j as json, a as jsonParseLinter } from '../../index-4ee5b5e5.js';
|
|
5
5
|
export { A as Annotation, a as AnnotationType, B as BidiSpan, t as BlockInfo, u as BlockType, C as ChangeDesc, b as ChangeSet, c as CharCategory, d as Compartment, D as Decoration, v as Direction, E as EditorSelection, e as EditorState, w as EditorView, F as Facet, G as GutterMarker, L as Line, M as MapMode, x as MatchDecorator, P as Prec, R as Range, f as RangeSet, g as RangeSetBuilder, h as RangeValue, y as RectangleMarker, S as SelectionRange, i as StateEffect, j as StateEffectType, k as StateField, T as Text, l as Transaction, V as ViewPlugin, z as ViewUpdate, W as WidgetType, _ as __test, H as closeHoverTooltips, m as codePointAt, n as codePointSize, o as combineConfig, p as countColumn, I as crosshairCursor, J as drawSelection, K as dropCursor, q as findClusterBreak, r as findColumn, s as fromCodePoint, N as getPanel, O as getTooltip, Q as gutter, U as gutterLineClass, X as gutters, Y as hasHoverTooltips, Z as highlightActiveLine, $ as highlightActiveLineGutter, a0 as highlightSpecialChars, a1 as highlightTrailingWhitespace, a2 as highlightWhitespace, a3 as hoverTooltip, a4 as keymap, a5 as layer, a6 as lineNumberMarkers, a7 as lineNumbers, a8 as logException, a9 as panels, aa as placeholder, ab as rectangularSelection, ac as repositionTooltips, ad as runScopeHandlers, ae as scrollPastEnd, af as showPanel, ag as showTooltip, ah as tooltips } from '../../index-df5748fb.js';
|
|
@@ -29,7 +29,7 @@ export { b as basicSetup } from '../index-dbeba01e.js';
|
|
|
29
29
|
export { a as lintGutter, l as linter } from '../index-1e36d007.js';
|
|
30
30
|
export { h as html, j as javascript } from '../index-7020020d.js';
|
|
31
31
|
export { j as json, a as jsonParseLinter } from '../index-4ee5b5e5.js';
|
|
32
|
-
export { s as OrCodeV3 } from '../OrCode.vue_vue_type_script_lang-
|
|
32
|
+
export { s as OrCodeV3 } from '../OrCode.vue_vue_type_script_lang-8d6195d1.js';
|
|
33
33
|
export { CodeLanguage } from './OrCodeV3/props.js';
|
|
34
34
|
export { A as Annotation, a as AnnotationType, B as BidiSpan, t as BlockInfo, u as BlockType, C as ChangeDesc, b as ChangeSet, c as CharCategory, d as Compartment, D as Decoration, v as Direction, E as EditorSelection, e as EditorState, w as EditorView, F as Facet, G as GutterMarker, L as Line, M as MapMode, x as MatchDecorator, P as Prec, R as Range, f as RangeSet, g as RangeSetBuilder, h as RangeValue, y as RectangleMarker, S as SelectionRange, i as StateEffect, j as StateEffectType, k as StateField, T as Text, l as Transaction, V as ViewPlugin, z as ViewUpdate, W as WidgetType, _ as __test, H as closeHoverTooltips, m as codePointAt, n as codePointSize, o as combineConfig, p as countColumn, I as crosshairCursor, J as drawSelection, K as dropCursor, q as findClusterBreak, r as findColumn, s as fromCodePoint, N as getPanel, O as getTooltip, Q as gutter, U as gutterLineClass, X as gutters, Y as hasHoverTooltips, Z as highlightActiveLine, $ as highlightActiveLineGutter, a0 as highlightSpecialChars, a1 as highlightTrailingWhitespace, a2 as highlightWhitespace, a3 as hoverTooltip, a4 as keymap, a5 as layer, a6 as lineNumberMarkers, a7 as lineNumbers, a8 as logException, a9 as panels, aa as placeholder, ab as rectangularSelection, ac as repositionTooltips, ad as runScopeHandlers, ae as scrollPastEnd, af as showPanel, ag as showTooltip, ah as tooltips } from '../index-df5748fb.js';
|
|
35
35
|
export { s as OrCollapse } from '../OrCollapse.vue_vue_type_script_lang-69503c45.js';
|
package/dist/bundled/v3/index.js
CHANGED
|
@@ -18,7 +18,7 @@ export { s as OrChips } from './OrChips.vue_vue_type_script_lang-be1e7c30.js';
|
|
|
18
18
|
import './components/OrCode/OrCode.js';
|
|
19
19
|
export { s as OrCode } from './OrCode.vue_vue_type_script_lang-0edc76c5.js';
|
|
20
20
|
import './components/OrCodeV3/OrCode.js';
|
|
21
|
-
export { s as OrCodeV3 } from './OrCode.vue_vue_type_script_lang-
|
|
21
|
+
export { s as OrCodeV3 } from './OrCode.vue_vue_type_script_lang-8d6195d1.js';
|
|
22
22
|
import './components/OrColorPicker/OrColorPicker.js';
|
|
23
23
|
export { s as OrColorPicker } from './OrColorPicker.vue_vue_type_script_lang-250f679e.js';
|
|
24
24
|
import './components/OrCombinedInputV3/OrCombinedInput.js';
|
|
@@ -6,9 +6,9 @@ import '@onereach/styles/tailwind/plugins/core';
|
|
|
6
6
|
import { u as useTheme } from './useTheme-0ef25778.js';
|
|
7
7
|
import { u as useValidationAttributes } from './useValidationAttributes-d1abbe34.js';
|
|
8
8
|
import { basicSetup } from 'codemirror';
|
|
9
|
-
import {
|
|
9
|
+
import { keymap, EditorView } from '@codemirror/view';
|
|
10
10
|
import { indentWithTab } from '@codemirror/commands';
|
|
11
|
-
import { EditorState } from '@codemirror/state';
|
|
11
|
+
import { Compartment, EditorState } from '@codemirror/state';
|
|
12
12
|
import { css } from '@codemirror/lang-css';
|
|
13
13
|
import { html } from '@codemirror/lang-html';
|
|
14
14
|
import { javascript } from '@codemirror/lang-javascript';
|
|
@@ -110,6 +110,7 @@ var script = defineComponent({
|
|
|
110
110
|
// Styles
|
|
111
111
|
const rootStyles = computed(() => ['or-code-v3', ...Code]);
|
|
112
112
|
const controlStyles = computed(() => [...CodeControl]);
|
|
113
|
+
const addedExtensionCompartment = new Compartment();
|
|
113
114
|
// State
|
|
114
115
|
const controlAttributes = reactive({
|
|
115
116
|
id: useIdAttribute(),
|
|
@@ -117,8 +118,8 @@ var script = defineComponent({
|
|
|
117
118
|
...useValidationAttributes()
|
|
118
119
|
});
|
|
119
120
|
const proxyModelValue = useProxyModelValue(toRef(props, 'modelValue'), context.emit);
|
|
120
|
-
const
|
|
121
|
-
switch (
|
|
121
|
+
const getLanguageExtension = async language => {
|
|
122
|
+
switch (language) {
|
|
122
123
|
case CodeLanguage.HTML:
|
|
123
124
|
return html();
|
|
124
125
|
case CodeLanguage.CSS:
|
|
@@ -134,7 +135,7 @@ var script = defineComponent({
|
|
|
134
135
|
case CodeLanguage.MD:
|
|
135
136
|
return markdown();
|
|
136
137
|
}
|
|
137
|
-
}
|
|
138
|
+
};
|
|
138
139
|
// Methods
|
|
139
140
|
function focus() {
|
|
140
141
|
var _a;
|
|
@@ -145,14 +146,8 @@ var script = defineComponent({
|
|
|
145
146
|
(_a = control.value) === null || _a === void 0 ? void 0 : _a.blur();
|
|
146
147
|
}
|
|
147
148
|
// #region Codemirror
|
|
148
|
-
const editorView = new EditorView({
|
|
149
|
-
dispatch: transaction => {
|
|
150
|
-
editorView.update([transaction]);
|
|
151
|
-
proxyModelValue.value = String(editorView.state.doc);
|
|
152
|
-
}
|
|
153
|
-
});
|
|
154
149
|
const theme = useTheme();
|
|
155
|
-
const
|
|
150
|
+
const defaultExtensions = [basicSetup, keymap.of([indentWithTab]), EditorState.readOnly.of(props.readonly), EditorView.editable.of(!props.disabled), EditorView.domEventHandlers({
|
|
156
151
|
keydown: event => {
|
|
157
152
|
context.emit('keydown', event);
|
|
158
153
|
},
|
|
@@ -187,19 +182,34 @@ var script = defineComponent({
|
|
|
187
182
|
'.cm-activeLineGutter, .cm-activeLine': {
|
|
188
183
|
backgroundColor: theme.backgroundColor['primary-opacity-0-08']
|
|
189
184
|
}
|
|
190
|
-
})
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
185
|
+
})];
|
|
186
|
+
const state = EditorState.create({
|
|
187
|
+
doc: proxyModelValue.value,
|
|
188
|
+
extensions: [...defaultExtensions, addedExtensionCompartment.of([])]
|
|
189
|
+
// selection: selection.ranges.some((range) => range.to > modelValue.length)
|
|
190
|
+
// ? { anchor: modelValue.length }
|
|
191
|
+
// : selection,
|
|
192
|
+
});
|
|
193
|
+
|
|
194
|
+
const editorView = new EditorView({
|
|
195
|
+
state,
|
|
196
|
+
dispatch: transaction => {
|
|
197
|
+
editorView.update([transaction]);
|
|
198
|
+
if (transaction.docChanged) {
|
|
199
|
+
proxyModelValue.value = String(editorView.state.doc);
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
});
|
|
203
|
+
watch([() => props.extensions, () => props.language], async _ref => {
|
|
204
|
+
let [extensions, language] = _ref;
|
|
205
|
+
const languageExt = await getLanguageExtension(language);
|
|
206
|
+
extensions.forEach(extension => {
|
|
207
|
+
Reflect.setPrototypeOf(extension, Reflect.getPrototypeOf(state));
|
|
208
|
+
});
|
|
209
|
+
const effect = addedExtensionCompartment.reconfigure([...extensions, languageExt]);
|
|
210
|
+
editorView.dispatch({
|
|
211
|
+
effects: [effect]
|
|
212
|
+
});
|
|
203
213
|
}, {
|
|
204
214
|
immediate: true
|
|
205
215
|
});
|
|
@@ -236,7 +246,6 @@ var script = defineComponent({
|
|
|
236
246
|
controlStyles,
|
|
237
247
|
controlAttributes,
|
|
238
248
|
proxyModelValue,
|
|
239
|
-
proxyLanguage,
|
|
240
249
|
focus,
|
|
241
250
|
blur
|
|
242
251
|
};
|
|
@@ -22,7 +22,7 @@ export { lintGutter, linter } from '@codemirror/lint';
|
|
|
22
22
|
export { javascript } from '@codemirror/lang-javascript';
|
|
23
23
|
export { json, jsonParseLinter } from '@codemirror/lang-json';
|
|
24
24
|
export { html } from '@codemirror/lang-html';
|
|
25
|
-
export { C as CodeLanguage, _ as OrCodeV3 } from '../OrCode-
|
|
25
|
+
export { C as CodeLanguage, _ as OrCodeV3 } from '../OrCode-12ab60ec.js';
|
|
26
26
|
export * from '@codemirror/state';
|
|
27
27
|
export * from '@codemirror/view';
|
|
28
28
|
export { _ as OrCollapse } from '../OrCollapse-9d22b072.js';
|
|
@@ -28,7 +28,6 @@ declare const _default: import("vue").ComponentOptions<import("vue").default, im
|
|
|
28
28
|
id: string | undefined;
|
|
29
29
|
};
|
|
30
30
|
proxyModelValue: import("../../hooks").UseProxyModelValueReturn<string>;
|
|
31
|
-
proxyLanguage: import("@vue/composition-api").ComputedRef<import("@codemirror/language").LanguageSupport>;
|
|
32
31
|
focus: () => void;
|
|
33
32
|
blur: () => void;
|
|
34
33
|
}> & import("@vue/composition-api").Data, {}, {}, {
|
|
@@ -143,7 +142,6 @@ declare const _default: import("vue").ComponentOptions<import("vue").default, im
|
|
|
143
142
|
id: string | undefined;
|
|
144
143
|
};
|
|
145
144
|
proxyModelValue: import("../../hooks").UseProxyModelValueReturn<string>;
|
|
146
|
-
proxyLanguage: import("@vue/composition-api").ComputedRef<import("@codemirror/language").LanguageSupport>;
|
|
147
145
|
focus: () => void;
|
|
148
146
|
blur: () => void;
|
|
149
147
|
}>, import("@vue/composition-api").Data, {}, {}, {}, {}, string[], {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { C as CodeLanguage, _ as OrCodeV3 } from '../../OrCode-
|
|
1
|
+
export { C as CodeLanguage, _ as OrCodeV3 } from '../../OrCode-12ab60ec.js';
|
|
2
2
|
export { lintGutter, linter } from '@codemirror/lint';
|
|
3
3
|
export { json, jsonParseLinter } from '@codemirror/lang-json';
|
|
4
4
|
export * from '@codemirror/state';
|
package/dist/esm/v2/index.js
CHANGED
|
@@ -22,7 +22,7 @@ export { lintGutter, linter } from '@codemirror/lint';
|
|
|
22
22
|
export { javascript } from '@codemirror/lang-javascript';
|
|
23
23
|
export { json, jsonParseLinter } from '@codemirror/lang-json';
|
|
24
24
|
export { html } from '@codemirror/lang-html';
|
|
25
|
-
export { C as CodeLanguage, _ as OrCodeV3 } from './OrCode-
|
|
25
|
+
export { C as CodeLanguage, _ as OrCodeV3 } from './OrCode-12ab60ec.js';
|
|
26
26
|
export * from '@codemirror/state';
|
|
27
27
|
export * from '@codemirror/view';
|
|
28
28
|
export { _ as OrCollapse } from './OrCollapse-9d22b072.js';
|
|
@@ -6,9 +6,9 @@ import '@onereach/styles/tailwind/plugins/core';
|
|
|
6
6
|
import { u as useTheme } from './useTheme-0ef25778.js';
|
|
7
7
|
import { u as useValidationAttributes } from './useValidationAttributes-d1abbe34.js';
|
|
8
8
|
import { basicSetup } from 'codemirror';
|
|
9
|
-
import {
|
|
9
|
+
import { keymap, EditorView } from '@codemirror/view';
|
|
10
10
|
import { indentWithTab } from '@codemirror/commands';
|
|
11
|
-
import { EditorState } from '@codemirror/state';
|
|
11
|
+
import { Compartment, EditorState } from '@codemirror/state';
|
|
12
12
|
import { css } from '@codemirror/lang-css';
|
|
13
13
|
import { html } from '@codemirror/lang-html';
|
|
14
14
|
import { javascript } from '@codemirror/lang-javascript';
|
|
@@ -109,6 +109,7 @@ var script = defineComponent({
|
|
|
109
109
|
// Styles
|
|
110
110
|
const rootStyles = computed(() => ['or-code-v3', ...Code]);
|
|
111
111
|
const controlStyles = computed(() => [...CodeControl]);
|
|
112
|
+
const addedExtensionCompartment = new Compartment();
|
|
112
113
|
// State
|
|
113
114
|
const controlAttributes = reactive({
|
|
114
115
|
id: useIdAttribute(),
|
|
@@ -116,8 +117,8 @@ var script = defineComponent({
|
|
|
116
117
|
...useValidationAttributes()
|
|
117
118
|
});
|
|
118
119
|
const proxyModelValue = useProxyModelValue(toRef(props, 'modelValue'), context.emit);
|
|
119
|
-
const
|
|
120
|
-
switch (
|
|
120
|
+
const getLanguageExtension = async language => {
|
|
121
|
+
switch (language) {
|
|
121
122
|
case CodeLanguage.HTML:
|
|
122
123
|
return html();
|
|
123
124
|
case CodeLanguage.CSS:
|
|
@@ -133,7 +134,7 @@ var script = defineComponent({
|
|
|
133
134
|
case CodeLanguage.MD:
|
|
134
135
|
return markdown();
|
|
135
136
|
}
|
|
136
|
-
}
|
|
137
|
+
};
|
|
137
138
|
// Methods
|
|
138
139
|
function focus() {
|
|
139
140
|
var _a;
|
|
@@ -144,14 +145,8 @@ var script = defineComponent({
|
|
|
144
145
|
(_a = control.value) === null || _a === void 0 ? void 0 : _a.blur();
|
|
145
146
|
}
|
|
146
147
|
// #region Codemirror
|
|
147
|
-
const editorView = new EditorView({
|
|
148
|
-
dispatch: transaction => {
|
|
149
|
-
editorView.update([transaction]);
|
|
150
|
-
proxyModelValue.value = String(editorView.state.doc);
|
|
151
|
-
}
|
|
152
|
-
});
|
|
153
148
|
const theme = useTheme();
|
|
154
|
-
const
|
|
149
|
+
const defaultExtensions = [basicSetup, keymap.of([indentWithTab]), EditorState.readOnly.of(props.readonly), EditorView.editable.of(!props.disabled), EditorView.domEventHandlers({
|
|
155
150
|
keydown: event => {
|
|
156
151
|
context.emit('keydown', event);
|
|
157
152
|
},
|
|
@@ -186,19 +181,34 @@ var script = defineComponent({
|
|
|
186
181
|
'.cm-activeLineGutter, .cm-activeLine': {
|
|
187
182
|
backgroundColor: theme.backgroundColor['primary-opacity-0-08']
|
|
188
183
|
}
|
|
189
|
-
})
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
184
|
+
})];
|
|
185
|
+
const state = EditorState.create({
|
|
186
|
+
doc: proxyModelValue.value,
|
|
187
|
+
extensions: [...defaultExtensions, addedExtensionCompartment.of([])]
|
|
188
|
+
// selection: selection.ranges.some((range) => range.to > modelValue.length)
|
|
189
|
+
// ? { anchor: modelValue.length }
|
|
190
|
+
// : selection,
|
|
191
|
+
});
|
|
192
|
+
|
|
193
|
+
const editorView = new EditorView({
|
|
194
|
+
state,
|
|
195
|
+
dispatch: transaction => {
|
|
196
|
+
editorView.update([transaction]);
|
|
197
|
+
if (transaction.docChanged) {
|
|
198
|
+
proxyModelValue.value = String(editorView.state.doc);
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
});
|
|
202
|
+
watch([() => props.extensions, () => props.language], async _ref => {
|
|
203
|
+
let [extensions, language] = _ref;
|
|
204
|
+
const languageExt = await getLanguageExtension(language);
|
|
205
|
+
extensions.forEach(extension => {
|
|
206
|
+
Reflect.setPrototypeOf(extension, Reflect.getPrototypeOf(state));
|
|
207
|
+
});
|
|
208
|
+
const effect = addedExtensionCompartment.reconfigure([...extensions, languageExt]);
|
|
209
|
+
editorView.dispatch({
|
|
210
|
+
effects: [effect]
|
|
211
|
+
});
|
|
202
212
|
}, {
|
|
203
213
|
immediate: true
|
|
204
214
|
});
|
|
@@ -235,7 +245,6 @@ var script = defineComponent({
|
|
|
235
245
|
controlStyles,
|
|
236
246
|
controlAttributes,
|
|
237
247
|
proxyModelValue,
|
|
238
|
-
proxyLanguage,
|
|
239
248
|
focus,
|
|
240
249
|
blur
|
|
241
250
|
};
|
|
@@ -21,7 +21,7 @@ export { lintGutter, linter } from '@codemirror/lint';
|
|
|
21
21
|
export { javascript } from '@codemirror/lang-javascript';
|
|
22
22
|
export { json, jsonParseLinter } from '@codemirror/lang-json';
|
|
23
23
|
export { html } from '@codemirror/lang-html';
|
|
24
|
-
export { C as CodeLanguage, s as OrCodeV3 } from '../OrCode-
|
|
24
|
+
export { C as CodeLanguage, s as OrCodeV3 } from '../OrCode-18511f67.js';
|
|
25
25
|
export * from '@codemirror/state';
|
|
26
26
|
export * from '@codemirror/view';
|
|
27
27
|
export { s as OrCollapse } from '../OrCollapse-d7c0afae.js';
|
|
@@ -61,7 +61,6 @@ declare const _default: import("vue-demi").DefineComponent<{
|
|
|
61
61
|
id: string | undefined;
|
|
62
62
|
};
|
|
63
63
|
proxyModelValue: import("../../hooks").UseProxyModelValueReturn<string | undefined>;
|
|
64
|
-
proxyLanguage: import("vue-demi").ComputedRef<import("@codemirror/language").LanguageSupport>;
|
|
65
64
|
focus: () => void;
|
|
66
65
|
blur: () => void;
|
|
67
66
|
}, unknown, {}, {}, import("vue-demi").ComponentOptionsMixin, import("vue-demi").ComponentOptionsMixin, ("update:modelValue" | "keydown" | "keyup" | "focus" | "blur")[], "update:modelValue" | "keydown" | "keyup" | "focus" | "blur", import("vue-demi").VNodeProps & import("vue-demi").AllowedComponentProps & import("vue-demi").ComponentCustomProps, Readonly<import("vue-demi").ExtractPropTypes<{
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { C as CodeLanguage, s as OrCodeV3 } from '../../OrCode-
|
|
1
|
+
export { C as CodeLanguage, s as OrCodeV3 } from '../../OrCode-18511f67.js';
|
|
2
2
|
export { lintGutter, linter } from '@codemirror/lint';
|
|
3
3
|
export { json, jsonParseLinter } from '@codemirror/lang-json';
|
|
4
4
|
export * from '@codemirror/state';
|
package/dist/esm/v3/index.js
CHANGED
|
@@ -21,7 +21,7 @@ export { lintGutter, linter } from '@codemirror/lint';
|
|
|
21
21
|
export { javascript } from '@codemirror/lang-javascript';
|
|
22
22
|
export { json, jsonParseLinter } from '@codemirror/lang-json';
|
|
23
23
|
export { html } from '@codemirror/lang-html';
|
|
24
|
-
export { C as CodeLanguage, s as OrCodeV3 } from './OrCode-
|
|
24
|
+
export { C as CodeLanguage, s as OrCodeV3 } from './OrCode-18511f67.js';
|
|
25
25
|
export * from '@codemirror/state';
|
|
26
26
|
export * from '@codemirror/view';
|
|
27
27
|
export { s as OrCollapse } from './OrCollapse-d7c0afae.js';
|
package/package.json
CHANGED
|
@@ -82,7 +82,7 @@ import { useControlAttributes, useIdAttribute, useProxyModelValue, useTheme, use
|
|
|
82
82
|
import { basicSetup } from 'codemirror';
|
|
83
83
|
import { EditorView, keymap } from '@codemirror/view';
|
|
84
84
|
import { indentWithTab } from '@codemirror/commands';
|
|
85
|
-
import { EditorState, Extension } from '@codemirror/state';
|
|
85
|
+
import { EditorState, Extension, Compartment } from '@codemirror/state';
|
|
86
86
|
|
|
87
87
|
/* Codemirror languages */
|
|
88
88
|
import { css } from '@codemirror/lang-css';
|
|
@@ -199,6 +199,8 @@ export default defineComponent({
|
|
|
199
199
|
...CodeControl,
|
|
200
200
|
]);
|
|
201
201
|
|
|
202
|
+
const addedExtensionCompartment = new Compartment();
|
|
203
|
+
|
|
202
204
|
// State
|
|
203
205
|
const controlAttributes = reactive({
|
|
204
206
|
id: useIdAttribute(),
|
|
@@ -208,8 +210,8 @@ export default defineComponent({
|
|
|
208
210
|
|
|
209
211
|
const proxyModelValue = useProxyModelValue(toRef(props, 'modelValue'), context.emit);
|
|
210
212
|
|
|
211
|
-
const
|
|
212
|
-
switch (
|
|
213
|
+
const getLanguageExtension = async (language: CodeLanguage) => {
|
|
214
|
+
switch (language) {
|
|
213
215
|
case CodeLanguage.HTML:
|
|
214
216
|
return html();
|
|
215
217
|
|
|
@@ -228,7 +230,7 @@ export default defineComponent({
|
|
|
228
230
|
case CodeLanguage.MD:
|
|
229
231
|
return markdown();
|
|
230
232
|
}
|
|
231
|
-
}
|
|
233
|
+
};
|
|
232
234
|
|
|
233
235
|
// Methods
|
|
234
236
|
function focus(): void {
|
|
@@ -240,19 +242,8 @@ export default defineComponent({
|
|
|
240
242
|
}
|
|
241
243
|
|
|
242
244
|
// #region Codemirror
|
|
243
|
-
const editorView = new EditorView({
|
|
244
|
-
dispatch: (transaction) => {
|
|
245
|
-
editorView.update([
|
|
246
|
-
transaction,
|
|
247
|
-
]);
|
|
248
|
-
|
|
249
|
-
proxyModelValue.value = String(editorView.state.doc);
|
|
250
|
-
},
|
|
251
|
-
});
|
|
252
|
-
|
|
253
245
|
const theme = useTheme();
|
|
254
|
-
|
|
255
|
-
const extensions = computed<Extension[]>(() => [
|
|
246
|
+
const defaultExtensions = [
|
|
256
247
|
basicSetup,
|
|
257
248
|
|
|
258
249
|
keymap.of([
|
|
@@ -307,33 +298,47 @@ export default defineComponent({
|
|
|
307
298
|
backgroundColor: theme.backgroundColor['primary-opacity-0-08'],
|
|
308
299
|
},
|
|
309
300
|
}),
|
|
301
|
+
];
|
|
302
|
+
|
|
303
|
+
const state = EditorState.create({
|
|
304
|
+
doc: proxyModelValue.value,
|
|
305
|
+
extensions: [
|
|
306
|
+
...defaultExtensions,
|
|
307
|
+
addedExtensionCompartment.of([]),
|
|
308
|
+
],
|
|
309
|
+
|
|
310
|
+
// selection: selection.ranges.some((range) => range.to > modelValue.length)
|
|
311
|
+
// ? { anchor: modelValue.length }
|
|
312
|
+
// : selection,
|
|
313
|
+
});
|
|
310
314
|
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
315
|
+
const editorView = new EditorView({
|
|
316
|
+
state,
|
|
317
|
+
dispatch: (transaction) => {
|
|
318
|
+
editorView.update([
|
|
319
|
+
transaction,
|
|
320
|
+
]);
|
|
314
321
|
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
modelValue = '',
|
|
320
|
-
extensions,
|
|
321
|
-
]) => {
|
|
322
|
-
const { selection } = editorView.state;
|
|
323
|
-
|
|
324
|
-
editorView.setState(
|
|
325
|
-
EditorState.create({
|
|
326
|
-
doc: modelValue,
|
|
327
|
-
extensions,
|
|
328
|
-
|
|
329
|
-
selection: selection.ranges.some((range) => range.to > modelValue.length)
|
|
330
|
-
? { anchor: modelValue.length }
|
|
331
|
-
: selection,
|
|
332
|
-
}),
|
|
333
|
-
);
|
|
334
|
-
}, {
|
|
335
|
-
immediate: true,
|
|
322
|
+
if (transaction.docChanged) {
|
|
323
|
+
proxyModelValue.value = String(editorView.state.doc);
|
|
324
|
+
}
|
|
325
|
+
},
|
|
336
326
|
});
|
|
327
|
+
|
|
328
|
+
watch([() => props.extensions, () => props.language], async ([extensions, language]) => {
|
|
329
|
+
const languageExt = await getLanguageExtension(language as CodeLanguage);
|
|
330
|
+
|
|
331
|
+
extensions.forEach((extension) => {
|
|
332
|
+
Reflect.setPrototypeOf(extension, Reflect.getPrototypeOf(state));
|
|
333
|
+
});
|
|
334
|
+
|
|
335
|
+
const effect = addedExtensionCompartment.reconfigure([
|
|
336
|
+
...extensions,
|
|
337
|
+
languageExt,
|
|
338
|
+
]);
|
|
339
|
+
|
|
340
|
+
editorView!.dispatch({ effects: [effect] });
|
|
341
|
+
}, { immediate: true });
|
|
337
342
|
// #endregion
|
|
338
343
|
|
|
339
344
|
// Effects
|
|
@@ -366,7 +371,6 @@ export default defineComponent({
|
|
|
366
371
|
controlStyles,
|
|
367
372
|
controlAttributes,
|
|
368
373
|
proxyModelValue,
|
|
369
|
-
proxyLanguage,
|
|
370
374
|
focus,
|
|
371
375
|
blur,
|
|
372
376
|
};
|