vue-codemirror6 1.4.3 → 1.5.1
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 +11 -2
- package/README.ja.md +1 -0
- package/README.md +1 -0
- package/dist/index.cjs.js +3 -3
- package/dist/index.d.ts +26 -1
- package/dist/index.es.js +296 -532
- package/dist/index.iife.js +3 -3
- package/dist/index.umd.js +3 -3
- package/dist/src/Meta.d.ts +3 -0
- package/dist/src/index.d.ts +674 -0
- package/package.json +29 -31
- package/dist/Meta.d.ts +0 -3
- /package/dist/{helpers → src/helpers}/h-demi.d.ts +0 -0
- /package/dist/{interfaces → src/interfaces}/MetaInterface.d.ts +0 -0
package/CHANGELOG.md
CHANGED
|
@@ -4,10 +4,19 @@ All notable changes to this project will be documented in this file. Dates are d
|
|
|
4
4
|
|
|
5
5
|
Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
|
|
6
6
|
|
|
7
|
+
#### [1.5.0](https://github.com/logue/vue-codemirror6/compare/1.4.3...1.5.0)
|
|
8
|
+
|
|
9
|
+
- Add AI instructions. [`75fecba`](https://github.com/logue/vue-codemirror6/commit/75fecba1d79bbd308864dbbfb5884026c1c20be6)
|
|
10
|
+
- Fixed warnings output during the build process. [`4721a8d`](https://github.com/logue/vue-codemirror6/commit/4721a8d94faf0a32c5a7b2459f989e361acb0a27)
|
|
11
|
+
- Update Dependencies. [`c8c3d2a`](https://github.com/logue/vue-codemirror6/commit/c8c3d2a23ef8eecc6ab28d42d53bdc7f457ceac5)
|
|
12
|
+
|
|
7
13
|
#### [1.4.3](https://github.com/logue/vue-codemirror6/compare/1.4.2...1.4.3)
|
|
8
14
|
|
|
15
|
+
> 5 March 2026
|
|
16
|
+
|
|
9
17
|
- Replace eslint-plugin-import to eslint-plugin-x. [`e46491a`](https://github.com/logue/vue-codemirror6/commit/e46491a24270f8ea392a3354bbecbaf7092f8ef9)
|
|
10
18
|
- Add Japanese Readme. [`e279cc0`](https://github.com/logue/vue-codemirror6/commit/e279cc0e1b23bba6c1dd690fb6a963b82e8508f6)
|
|
19
|
+
- Update ChangeLog/ [`8648633`](https://github.com/logue/vue-codemirror6/commit/86486330c50af4c4c13eeabcc3b6a498ab8a65d1)
|
|
11
20
|
|
|
12
21
|
#### [1.4.2](https://github.com/logue/vue-codemirror6/compare/1.4.0...1.4.2)
|
|
13
22
|
|
|
@@ -38,7 +47,7 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
|
|
|
38
47
|
|
|
39
48
|
> 22 November 2024
|
|
40
49
|
|
|
41
|
-
- Fix sample code syntax
|
|
50
|
+
- Fix sample code syntax error [`#47`](https://github.com/logue/vue-codemirror6/pull/47)
|
|
42
51
|
- chore: demo docs [`#43`](https://github.com/logue/vue-codemirror6/pull/43)
|
|
43
52
|
- fix: editor not update content when `modelValue` change and selection is out of range [`#44`](https://github.com/logue/vue-codemirror6/pull/44)
|
|
44
53
|
- chore: props and readme doc [`#31`](https://github.com/logue/vue-codemirror6/pull/31)
|
|
@@ -70,7 +79,7 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
|
|
|
70
79
|
|
|
71
80
|
- chore(CODEOWNERS): CODEOWNERS.com Bot, at your service! [`#14`](https://github.com/logue/vue-codemirror6/pull/14)
|
|
72
81
|
- Update demo code. (Replaced @codemirror/html to @codemirror/vue.) [`8da1a8a`](https://github.com/logue/vue-codemirror6/commit/8da1a8a4e37d713cc78281ce9c304c42a06940dc)
|
|
73
|
-
- Changed implementation to generate
|
|
82
|
+
- Changed implementation to generate \*.d.ts with vite-plugin-dts. [`1caaa20`](https://github.com/logue/vue-codemirror6/commit/1caaa20b1423a3d252a6c770a630fb60e2e3440d)
|
|
74
83
|
- Update README.md. [`f8dd493`](https://github.com/logue/vue-codemirror6/commit/f8dd4934a7b9cc089cd830473db5250d28b3389b)
|
|
75
84
|
|
|
76
85
|
#### [1.1.11](https://github.com/logue/vue-codemirror6/compare/1.1.3...1.1.11)
|
package/README.ja.md
CHANGED
|
@@ -58,6 +58,7 @@ yarn add vue-codemirror6 @vue/composition-api
|
|
|
58
58
|
| gutterConfig | Object | <https://codemirror.net/docs/ref/#lint.lintGutter^config>を参照してください。 |
|
|
59
59
|
| tag | string | コンポーネントで使用されるHTMLタグ。(デフォルトは`div`タグです。) |
|
|
60
60
|
| scrollIntoView | boolean | 外部更新でフォームをスクロールできるようにします。(デフォルトは`true`です。) |
|
|
61
|
+
| preserveScrollPosition | boolean | `modelValue` が外部から更新されたときにエディタのスクロール位置を保持します。追記更新時に先頭へ戻る挙動の抑止に使えます。(デフォルトは`false`です。) |
|
|
61
62
|
| keymap | KeyBinding[] | キーバインディングは、キー名をコマンドスタイルの関数に関連付けます。<https://codemirror.net/docs/ref/#view.KeyBinding>を参照してください。 |
|
|
62
63
|
|
|
63
64
|
⚠ 注意: `lang`と`linter`は、`extensions`にまとめて設定することもできます。これらは、以前のバージョンのCodeMirror設定との互換性とpropsの型付けのために分離されています。
|
package/README.md
CHANGED
|
@@ -58,6 +58,7 @@ This component can handle bidirectional binding by `v-model` like a general Vue
|
|
|
58
58
|
| gutterConfig | Object | see <https://codemirror.net/docs/ref/#lint.lintGutter^config> |
|
|
59
59
|
| tag | string | HTML tags used in the component. (Default is `div` tag.) |
|
|
60
60
|
| scrollIntoView | boolean | Allows an external update to scroll the form. (Default is `true`) |
|
|
61
|
+
| preserveScrollPosition | boolean | Preserves the editor scroll position when `modelValue` is updated externally. Useful to prevent jumping to the top during appended updates. (Default is `false`) |
|
|
61
62
|
| keymap | KeyBinding[] | Key bindings associate key names with command-style functions. See <https://codemirror.net/docs/ref/#view.KeyBinding> |
|
|
62
63
|
|
|
63
64
|
⚠ 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.
|
package/dist/index.cjs.js
CHANGED
|
@@ -5,9 +5,9 @@
|
|
|
5
5
|
* @author Logue <logue@hotmail.co.jp>
|
|
6
6
|
* @copyright 2022-2026 By Masashi Yoshikawa All rights reserved.
|
|
7
7
|
* @license MIT
|
|
8
|
-
* @version 1.
|
|
8
|
+
* @version 1.5.1
|
|
9
9
|
* @see {@link https://github.com/logue/vue-codemirror6}
|
|
10
10
|
*/
|
|
11
11
|
|
|
12
|
-
|
|
13
|
-
`)===
|
|
12
|
+
Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:`Module`}});let e=require(`@codemirror/commands`),t=require(`@codemirror/language`),n=require(`@codemirror/lint`),r=require(`@codemirror/state`),i=require(`@codemirror/view`),a=require(`codemirror`),o=require(`vue-demi`);var s={version:`1.5.1`,date:`2026-04-03T05:31:33.377Z`},c=e=>e?Object.entries(e).reduce((e,[t,n])=>(t=t.charAt(0).toUpperCase()+t.slice(1),t=`on${t}`,{...e,[t]:n}),{}):{};function l(e,t={},n){if(o.isVue2)return(0,o.h)(e,t,n);let{props:r,domProps:i,on:a,...s}=t,l=a?c(a):{};return(0,o.h)(e,{...s,...r,...i,...l},n)}var u=e=>typeof e==`function`?e():e,d=(0,o.defineComponent)({name:`CodeMirror`,model:{prop:`modelValue`,event:`update:modelValue`},props:{modelValue:{type:String,default:``},theme:{type:Object,default:()=>({})},dark:{type:Boolean,default:!1},basic:{type:Boolean,default:!1},minimal:{type:Boolean,default:!1},placeholder:{type:String,default:void 0},wrap:{type:Boolean,default:!1},tab:{type:Boolean,default:!1},indentUnit:{type:String,default:void 0},allowMultipleSelections:{type:Boolean,default:!1},tabSize:{type:Number,default:void 0},lineSeparator:{type:String,default:void 0},readonly:{type:Boolean,default:!1},disabled:{type:Boolean,default:!1},extensions:{type:Array,default:()=>[]},phrases:{type:Object,default:void 0},lang:{type:Object,default:void 0},linter:{type:Function,default:void 0},linterConfig:{type:Object,default:()=>({})},forceLinting:{type:Boolean,default:!1},gutter:{type:Boolean,default:!1},gutterConfig:{type:Object,default:void 0},tag:{type:String,default:`div`},scrollIntoView:{type:Boolean,default:!0},preserveScrollPosition:{type:Boolean,default:!1},keymap:{type:Array,default:()=>[]}},emits:{"update:modelValue":(e=``)=>!0,update:e=>!0,ready:e=>!0,focus:e=>!0,change:e=>!0,destroy:()=>!0},setup(s,c){let l=(0,o.ref)(),u=(0,o.ref)(s.modelValue),d=(0,o.shallowRef)(void 0),f=(0,o.computed)({get:()=>d.value?.hasFocus??!1,set:e=>{e&&d.value&&d.value.focus()}}),p=(0,o.computed)({get:()=>d.value?.state.selection,set:e=>{d.value&&e&&d.value.dispatch({selection:e})}}),m=(0,o.computed)({get:()=>d.value?.state.selection.main.head??0,set:e=>{d.value&&d.value.dispatch({selection:{anchor:e}})}}),h=(0,o.computed)({get:()=>d.value?.state.toJSON(),set:e=>{d.value&&e&&d.value.setState(r.EditorState.fromJSON(e))}}),g=(0,o.ref)(0),_=(0,o.ref)(0),v=(0,o.computed)(()=>{let o=new r.Compartment,l=new r.Compartment;if(s.basic&&s.minimal)throw Error(`[Vue CodeMirror] Both basic and minimal cannot be specified.`);let u=[];return s.keymap&&s.keymap.length>0&&(u=s.keymap),s.tab&&u.push(e.indentWithTab),[s.basic&&!s.minimal?a.basicSetup:void 0,s.minimal&&!s.basic?a.minimalSetup:void 0,i.EditorView.updateListener.of(e=>{d.value&&(c.emit(`focus`,d.value.hasFocus),g.value=d.value.state.doc?.length,!(e.changes.empty||!e.docChanged)&&(s.linter&&(s.forceLinting&&(0,n.forceLinting)(d.value),_.value=s.linter(d.value).length),c.emit(`update`,e)))}),i.EditorView.theme(s.theme,{dark:s.dark}),s.wrap?i.EditorView.lineWrapping:void 0,s.indentUnit?t.indentUnit.of(s.indentUnit):void 0,r.EditorState.allowMultipleSelections.of(s.allowMultipleSelections),s.tabSize?l.of(r.EditorState.tabSize.of(s.tabSize)):void 0,s.phrases?r.EditorState.phrases.of(s.phrases):void 0,r.EditorState.readOnly.of(s.readonly),i.EditorView.editable.of(!s.disabled),s.lineSeparator?r.EditorState.lineSeparator.of(s.lineSeparator):void 0,s.lang?o.of(s.lang):void 0,s.linter?(0,n.linter)(s.linter,s.linterConfig):void 0,s.linter&&s.gutter?(0,n.lintGutter)(s.gutterConfig):void 0,s.placeholder?(0,i.placeholder)(s.placeholder):void 0,u.length>0?i.keymap.of(u):void 0,...s.extensions].filter(e=>!!e)});(0,o.watch)(v,e=>d.value?.dispatch({effects:r.StateEffect.reconfigure.of(e)}),{immediate:!0}),(0,o.watch)(()=>s.modelValue,async e=>{if(!d.value||d.value.composing||d.value.state.doc.toJSON().join(s.lineSeparator??`
|
|
13
|
+
`)===e)return;let t=!d.value.state.selection.ranges.every(t=>t.anchor<e.length&&t.head<e.length),n={from:0,to:d.value.state.doc.length,insert:e},r=s.preserveScrollPosition?d.value.scrollSnapshot().map(d.value.state.changes(n)):void 0;d.value.dispatch({changes:n,selection:t?{anchor:0,head:0}:d.value.state.selection,scrollIntoView:s.scrollIntoView,effects:r?[r]:void 0})},{immediate:!0}),(0,o.onMounted)(async()=>{if(globalThis.window===void 0||!l.value)return;let e=u.value;l.value.childNodes[0]&&(u.value!==``&&console.warn("[CodeMirror.vue] The <code-mirror> tag contains child elements that overwrite the `v-model` values."),e=l.value.childNodes[0].innerText.trim()),d.value=new i.EditorView({parent:l.value,state:r.EditorState.create({doc:e,extensions:v.value}),dispatch:e=>{d.value&&(d.value.update([e]),!(e.changes.empty||!e.docChanged)&&(c.emit(`update:modelValue`,e.state.doc.toString()),c.emit(`change`,e.state)))}}),await(0,o.nextTick)(),c.emit(`ready`,{view:d.value,state:d.value.state,container:l.value})}),(0,o.onUnmounted)(()=>{d.value&&(d.value.destroy(),c.emit(`destroy`))});let y={editor:l,view:d,cursor:m,selection:p,focus:f,length:g,json:h,diagnosticCount:_,dom:d.value?.contentDOM,lint:()=>{!s.linter||!d.value||(s.forceLinting&&(0,n.forceLinting)(d.value),_.value=(0,n.diagnosticCount)(d.value.state))},forceReconfigure:()=>{d.value?.dispatch({effects:r.StateEffect.reconfigure.of([])}),d.value?.dispatch({effects:r.StateEffect.appendConfig.of(v.value)})},getRange:(e,t)=>d.value?.state.sliceDoc(e,t),getLine:e=>d.value?.state.doc.line(e+1).text,lineCount:()=>d.value?.state.doc.lines??0,getCursor:()=>d.value?.state.selection.main.head??0,listSelections:()=>d.value?.state.selection.ranges??[],getSelection:()=>d.value?d.value.state.sliceDoc(d.value.state.selection.main.from,d.value.state.selection.main.to):``,getSelections:()=>{let e=d.value?.state;return e?e.selection.ranges.map(t=>e.sliceDoc(t.from,t.to)):[]},somethingSelected:()=>d.value?.state.selection.ranges.some(e=>!e.empty)??!1,replaceRange:(e,t,n)=>{d.value&&d.value.dispatch({changes:{from:t,to:n,insert:e}})},replaceSelection:e=>{d.value&&d.value.dispatch(d.value.state.replaceSelection(e))},setCursor:e=>{d.value&&d.value.dispatch({selection:{anchor:e}})},setSelection:(e,t)=>{d.value&&d.value.dispatch({selection:{anchor:e,head:t}})},setSelections:(e,t)=>{d.value&&d.value.dispatch({selection:r.EditorSelection.create(e,t)})},extendSelectionsBy:e=>{d.value&&p.value&&d.value.dispatch({selection:r.EditorSelection.create(p.value.ranges.map(t=>t.extend(e(t))))})}};return c.expose(y),y},render(){return l(this.$props.tag,{ref:`editor`,class:`vue-codemirror`},this.$slots.default?l(`aside`,{style:`display: none;`,"aria-hidden":`true`},u(this.$slots.default)):void 0)}}),f=e=>e.component(`CodeMirror`,d);exports.Meta=s,exports.default=d,exports.install=f;
|
package/dist/index.d.ts
CHANGED
|
@@ -4,7 +4,7 @@ import { EditorSelection, EditorState, Extension, SelectionRange, StateField, Te
|
|
|
4
4
|
import { EditorView, KeyBinding, ViewUpdate } from '@codemirror/view';
|
|
5
5
|
import { PropType, Ref, ShallowRef, WritableComputedRef } from 'vue-demi';
|
|
6
6
|
import { StyleSpec } from 'style-mod';
|
|
7
|
-
import { default as Meta } from './Meta';
|
|
7
|
+
import { default as Meta } from './src/Meta';
|
|
8
8
|
/** CodeMirror Component */
|
|
9
9
|
declare const CodeMirror: import('vue').DefineComponent<import('vue').ExtractPropTypes<{
|
|
10
10
|
/** Model value */
|
|
@@ -274,6 +274,18 @@ declare const CodeMirror: import('vue').DefineComponent<import('vue').ExtractPro
|
|
|
274
274
|
type: BooleanConstructor;
|
|
275
275
|
default: boolean;
|
|
276
276
|
};
|
|
277
|
+
/**
|
|
278
|
+
* Preserve the current scroll position on external updates.
|
|
279
|
+
*
|
|
280
|
+
* This keeps the editor's own scroll container from jumping when
|
|
281
|
+
* `modelValue` is updated from outside the component.
|
|
282
|
+
*
|
|
283
|
+
* @see {@link https://codemirror.net/docs/ref/#view.EditorView.scrollSnapshot}
|
|
284
|
+
*/
|
|
285
|
+
preserveScrollPosition: {
|
|
286
|
+
type: BooleanConstructor;
|
|
287
|
+
default: boolean;
|
|
288
|
+
};
|
|
277
289
|
/**
|
|
278
290
|
* Key map
|
|
279
291
|
* This is a CodeMirror Facet that allows you to define custom key bindings.
|
|
@@ -596,6 +608,18 @@ declare const CodeMirror: import('vue').DefineComponent<import('vue').ExtractPro
|
|
|
596
608
|
type: BooleanConstructor;
|
|
597
609
|
default: boolean;
|
|
598
610
|
};
|
|
611
|
+
/**
|
|
612
|
+
* Preserve the current scroll position on external updates.
|
|
613
|
+
*
|
|
614
|
+
* This keeps the editor's own scroll container from jumping when
|
|
615
|
+
* `modelValue` is updated from outside the component.
|
|
616
|
+
*
|
|
617
|
+
* @see {@link https://codemirror.net/docs/ref/#view.EditorView.scrollSnapshot}
|
|
618
|
+
*/
|
|
619
|
+
preserveScrollPosition: {
|
|
620
|
+
type: BooleanConstructor;
|
|
621
|
+
default: boolean;
|
|
622
|
+
};
|
|
599
623
|
/**
|
|
600
624
|
* Key map
|
|
601
625
|
* This is a CodeMirror Facet that allows you to define custom key bindings.
|
|
@@ -643,6 +667,7 @@ declare const CodeMirror: import('vue').DefineComponent<import('vue').ExtractPro
|
|
|
643
667
|
gutterConfig: Record<string, any>;
|
|
644
668
|
tag: string;
|
|
645
669
|
scrollIntoView: boolean;
|
|
670
|
+
preserveScrollPosition: boolean;
|
|
646
671
|
keymap: KeyBinding[];
|
|
647
672
|
}, {}, {}, {}, string, import('vue').ComponentProvideOptions, true, {}, any>;
|
|
648
673
|
declare const installCodeMirror: (app: any) => void;
|