Skip to content

Commit ced91ed

Browse files
committed
Add allow-multiple-selections prop.
1 parent 5b8b255 commit ced91ed

File tree

2 files changed

+39
-30
lines changed

2 files changed

+39
-30
lines changed

README.md

Lines changed: 24 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -31,28 +31,29 @@ This component can handle bidirectional binding by `v-model` like a general Vue
3131

3232
## Props
3333

34-
| Props | Type | Information |
35-
| -------------- | --------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
36-
| model-value | string \| Text | Text value. (Not `value`) |
37-
| basic | boolean | Use [basicSetup](https://codemirror.net/docs/ref/#codemirror.basicSetup). |
38-
| minimal | boolean | Use [miniSetup](https://codemirror.net/docs/ref/#codemirror.minimalSetup). If a `basic` prop is also specified, that setting will take precedence. |
39-
| dark | boolean | Toggle Darkmode. |
40-
| placeholder | string | Add placeholder text (or HTML DOM) when blank |
41-
| wrap | boolean | Line text wrapping. see [lineWrapping](https://codemirror.net/6/docs/ref/#view.EditorView.lineWrapping). |
42-
| tab | boolean | Enables tab indentation. |
43-
| tab-size | number | Configures the tab size to use in this state. |
44-
| line-separator | string | Set line break (separetor) char. (Default is `\n`.) |
45-
| theme | { [selector: string]: StyleSpec } | Specify the theme. For example, if you use [@codemirror/theme-one-dark](https://github.com/codemirror/theme-one-dark), import `oneDark` and put it in this prop. |
46-
| readonly | boolean | Makes the cursor visible or you can drag the text but not edit the value. |
47-
| disabled | boolean | This is the reversed value of the CodeMirror editable. Similar to `readonly`, but setting this value to true disables dragging. |
48-
| lang | LanguageSupport | The language you want to have syntax highlighting. see <https://codemirror.net/6/#languages> |
49-
| phrases | Record&lt;string, string&gt; | Specify here if you want to make the displayed character string multilingual. see <https://codemirror.net/6/examples/translate/> |
50-
| extensions | Extension[] | Includes enhancements to extend CodeMirror. |
51-
| linter | LintSource | Set Linter. Enter a linter (eg `esLint([arbitrary rule])` function for `@codemirror/lang-javascript`, `jsonParseLinter()`function for`@codemirror/json`). See the sources for various language libraries for more information. |
52-
| linterConfig | Object | see <https://codemirror.net/docs/ref/#lint.linter^config> |
53-
| gutter | boolean | Display 🔴 on the line where there was an error when `linter` was specified. It will not work if `linter` is not specified. |
54-
| gutterConfig | Object | see <https://codemirror.net/docs/ref/#lint.lintGutter^config> |
55-
| tag | string | HTML tags used in the component. (Default is `div` tag.) |
34+
| Props | Type | Information |
35+
| ------------------------- | --------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
36+
| model-value | string \| Text | Text value. (Not `value`) |
37+
| basic | boolean | Use [basicSetup](https://codemirror.net/docs/ref/#codemirror.basicSetup). |
38+
| minimal | boolean | Use [miniSetup](https://codemirror.net/docs/ref/#codemirror.minimalSetup). If a `basic` prop is also specified, that setting will take precedence. |
39+
| dark | boolean | Toggle Darkmode. |
40+
| placeholder | string | Add placeholder text (or HTML DOM) when blank |
41+
| wrap | boolean | Line text wrapping. see [lineWrapping](https://codemirror.net/6/docs/ref/#view.EditorView.lineWrapping). |
42+
| tab | boolean | Enables tab indentation. |
43+
| allow-multiple-selections | boolean | Allow Multiple Selection. See [allowMultipleSelections](https://codemirror.net/docs/ref/#state.EditorState^allowMultipleSelections) |
44+
| tab-size | number | Configures the tab size to use in this state. |
45+
| line-separator | string | Set line break (separetor) char. (Default is `\n`.) |
46+
| theme | { [selector: string]: StyleSpec } | Specify the theme. For example, if you use [@codemirror/theme-one-dark](https://github.com/codemirror/theme-one-dark), import `oneDark` and put it in this prop. |
47+
| readonly | boolean | Makes the cursor visible or you can drag the text but not edit the value. |
48+
| disabled | boolean | This is the reversed value of the CodeMirror editable. Similar to `readonly`, but setting this value to true disables dragging. |
49+
| lang | LanguageSupport | The language you want to have syntax highlighting. see <https://codemirror.net/6/#languages> |
50+
| phrases | Record&lt;string, string&gt; | Specify here if you want to make the displayed character string multilingual. see <https://codemirror.net/6/examples/translate/> |
51+
| extensions | Extension[] | Includes enhancements to extend CodeMirror. |
52+
| linter | LintSource | Set Linter. Enter a linter (eg `esLint([arbitrary rule])` function for `@codemirror/lang-javascript`, `jsonParseLinter()`function for`@codemirror/json`). See the sources for various language libraries for more information. |
53+
| linterConfig | Object | see <https://codemirror.net/docs/ref/#lint.linter^config> |
54+
| gutter | boolean | Display 🔴 on the line where there was an error when `linter` was specified. It will not work if `linter` is not specified. |
55+
| gutterConfig | Object | see <https://codemirror.net/docs/ref/#lint.lintGutter^config> |
56+
| tag | string | HTML tags used in the component. (Default is `div` tag.) |
5657

5758
⚠ Notice: `lang` and `linter` can also be set together in `extensions`. These are separated for compatibility with previous versions of CodeMirror settings and for typing props.
5859

@@ -391,6 +392,4 @@ const config: UserConfig = {
391392

392393
## LICENSE
393394

394-
[MIT](LICENSE)
395-
396-
&copy; 2022 by Logue.
395+
©2022-2023 by Logue. Licensed under the [MIT License](LICENSE).

src/components/CodeMirror.ts

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -67,8 +67,6 @@ export interface CodeMirrorEmitsOptions extends ObjectEmitsOptions {
6767
(e: 'destroy'): void;
6868
/** State Changed */
6969
(e: 'change', value: EditorState): void;
70-
/** Diagnostic Count */
71-
(e: 'diagnosticCount'): number;
7270
}
7371

7472
/** CodeMirror Component */
@@ -148,6 +146,15 @@ export default defineComponent({
148146
type: Boolean,
149147
default: false,
150148
},
149+
/**
150+
* Allow Multiple Selection.
151+
*
152+
* @see {@link https://codemirror.net/docs/ref/#state.EditorState^allowMultipleSelections}
153+
*/
154+
allowMultipleSelections: {
155+
type: Boolean,
156+
default: false,
157+
},
151158
/**
152159
* Tab size
153160
*
@@ -358,6 +365,8 @@ export default defineComponent({
358365
props.wrap ? EditorView.lineWrapping : undefined,
359366
// Indent with tab
360367
props.tab ? keymap.of([indentWithTab]) : undefined,
368+
// Allow Multiple Selections
369+
EditorState.allowMultipleSelections.of(props.allowMultipleSelections),
361370
// Indent tab size
362371
props.tabSize ? EditorState.tabSize.of(props.tabSize) : undefined,
363372
// locale settings
@@ -371,7 +380,7 @@ export default defineComponent({
371380
? EditorState.lineSeparator.of(props.lineSeparator)
372381
: undefined,
373382
// Lang
374-
props.lang ? props.lang : undefined,
383+
props.lang ? props.lang.extension : undefined,
375384
// Append Linter settings
376385
props.linter ? linter(props.linter, props.linterConfig) : undefined,
377386
// Show 🔴 to error line when linter enabled.
@@ -380,7 +389,7 @@ export default defineComponent({
380389
: undefined,
381390
// Placeholder
382391
props.placeholder ? placeholder(props.placeholder) : undefined,
383-
// Append Extensions (such as basic-setup)
392+
// Append Extensions
384393
...props.extensions,
385394
])
386395
);
@@ -416,7 +425,8 @@ export default defineComponent({
416425
view.value.dispatch({
417426
effects: StateEffect.reconfigure.of(exts),
418427
});
419-
}
428+
},
429+
{ deep: true }
420430
);
421431

422432
// focus changed

0 commit comments

Comments
 (0)