qword 1.1.0 → 1.1.2
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 +13 -0
- package/client/content.d.ts +1 -1
- package/client/create.d.ts +2 -1
- package/client/create.js +2 -0
- package/client/decorations.d.ts +3 -5
- package/client/dom.d.ts +2 -1
- package/client/editor.d.ts +8 -34
- package/client/editor.js +14 -0
- package/client/editor.spec.js +11 -0
- package/client/events.d.ts +2 -1
- package/client/highlight.d.ts +1 -1
- package/client/history.d.ts +2 -1
- package/client/history.js +4 -6
- package/client/index.d.ts +1 -1
- package/client/index.js +1 -0
- package/client/options.d.ts +3 -2
- package/client/options.js +5 -2
- package/client/position.d.ts +3 -5
- package/client/qword.js +4 -0
- package/client/scroll.d.ts +2 -1
- package/client/types.d.ts +6 -2
- package/dist/qword.js +2 -2
- package/dist/qword.js.map +1 -1
- package/dist-dev/qword.js +3 -3
- package/package.json +8 -8
- package/server/edit.spec.js +1 -0
- package/test/errors.ts +0 -1
- package/test/types.ts +27 -11
package/dist-dev/qword.js
CHANGED
|
@@ -722,7 +722,7 @@ eval("{__webpack_require__.r(__webpack_exports__);\n__webpack_require__.d(__webp
|
|
|
722
722
|
\**************************/
|
|
723
723
|
(__unused_rspack___webpack_module__, __webpack_exports__, __webpack_require__) {
|
|
724
724
|
"use strict";
|
|
725
|
-
eval("{__webpack_require__.r(__webpack_exports__);\n__webpack_require__.d(__webpack_exports__, {\n createEditor: () => (createEditor)\n});\n/* import */ var _codemirror_state__rspack_import_3 = __webpack_require__(/*! @codemirror/state */ \"./node_modules/@codemirror/state/dist/index.js\");\n/* import */ var _codemirror_view__rspack_import_4 = __webpack_require__(/*! @codemirror/view */ \"./node_modules/@codemirror/view/dist/index.js\");\n/* import */ var _codemirror_commands__rspack_import_5 = __webpack_require__(/*! @codemirror/commands */ \"./node_modules/@codemirror/commands/dist/index.js\");\n/* import */ var _codemirror_language__rspack_import_6 = __webpack_require__(/*! @codemirror/language */ \"./node_modules/@codemirror/language/dist/index.js\");\n/* import */ var _highlight_js__rspack_import_0 = __webpack_require__(/*! ./highlight.js */ \"./client/highlight.js\");\n/* import */ var _options_js__rspack_import_1 = __webpack_require__(/*! ./options.js */ \"./client/options.js\");\n/* import */ var _decorations_js__rspack_import_2 = __webpack_require__(/*! ./decorations.js */ \"./client/decorations.js\");\n\n\n\n\n\n\n\nfunction createEditor(element, options = {}) {\n const { value = '', mode = 'javascript', keyMap = 'default', theme = 'default', lineNumbers = true, readOnly = false, foldGutter: fold = false, updateListener } = options;\n const themeCompartment = new _codemirror_state__rspack_import_3.Compartment();\n const keymapCompartment = new _codemirror_state__rspack_import_3.Compartment();\n const langCompartment = new _codemirror_state__rspack_import_3.Compartment();\n const historyCompartment = new _codemirror_state__rspack_import_3.Compartment();\n const hideCursorOnBlur = _codemirror_view__rspack_import_4.EditorView.theme({\n '&:not(.cm-focused) .cm-fat-cursor': {\n display: 'none'\n }\n });\n const extensions = [\n historyCompartment.of([\n (0,_codemirror_commands__rspack_import_5.history)(),\n _codemirror_view__rspack_import_4.keymap.of(_codemirror_commands__rspack_import_5.historyKeymap)\n ]),\n _decorations_js__rspack_import_2.markField,\n _decorations_js__rspack_import_2.lineField,\n themeCompartment.of((0,_options_js__rspack_import_1.themeExtension)(theme)),\n keymapCompartment.of((0,_options_js__rspack_import_1.keymapExtension)(keyMap)),\n langCompartment.of((0,_options_js__rspack_import_1.languageExtension)(mode)),\n (0,_codemirror_language__rspack_import_6.syntaxHighlighting)(_highlight_js__rspack_import_0.highlightStyle),\n ...lineNumbers ? [\n (0,_codemirror_view__rspack_import_4.lineNumbers)()\n ] : [],\n ...fold ? [\n (0,_codemirror_language__rspack_import_6.foldGutter)(),\n (0,_codemirror_language__rspack_import_6.codeFolding)()\n ] : [],\n ...readOnly ? [\n _codemirror_state__rspack_import_3.EditorState.readOnly.of(true)\n ] : [],\n ...updateListener ? [\n _codemirror_view__rspack_import_4.EditorView.updateListener.of(updateListener)\n ] : [],\n (0,_codemirror_view__rspack_import_4.drawSelection)(),\n hideCursorOnBlur\n ];\n const view = new _codemirror_view__rspack_import_4.EditorView({\n state: _codemirror_state__rspack_import_3.EditorState.create({\n doc: value,\n extensions\n }),\n parent: element\n });\n view._themeCompartment = themeCompartment;\n view._keymapCompartment = keymapCompartment;\n view._langCompartment = langCompartment;\n view._historyCompartment = historyCompartment;\n return view;\n}\n\n\n//# sourceURL=webpack://qword/./client/create.js?af24\n}");
|
|
725
|
+
eval("{__webpack_require__.r(__webpack_exports__);\n__webpack_require__.d(__webpack_exports__, {\n createEditor: () => (createEditor)\n});\n/* import */ var _codemirror_state__rspack_import_3 = __webpack_require__(/*! @codemirror/state */ \"./node_modules/@codemirror/state/dist/index.js\");\n/* import */ var _codemirror_view__rspack_import_4 = __webpack_require__(/*! @codemirror/view */ \"./node_modules/@codemirror/view/dist/index.js\");\n/* import */ var _codemirror_commands__rspack_import_5 = __webpack_require__(/*! @codemirror/commands */ \"./node_modules/@codemirror/commands/dist/index.js\");\n/* import */ var _codemirror_language__rspack_import_6 = __webpack_require__(/*! @codemirror/language */ \"./node_modules/@codemirror/language/dist/index.js\");\n/* import */ var _highlight_js__rspack_import_0 = __webpack_require__(/*! ./highlight.js */ \"./client/highlight.js\");\n/* import */ var _options_js__rspack_import_1 = __webpack_require__(/*! ./options.js */ \"./client/options.js\");\n/* import */ var _decorations_js__rspack_import_2 = __webpack_require__(/*! ./decorations.js */ \"./client/decorations.js\");\n\n\n\n\n\n\n\nfunction createEditor(element, options = {}) {\n const { value = '', mode = 'javascript', keyMap = 'default', theme = 'default', lineNumbers = true, readOnly = false, foldGutter: fold = false, updateListener } = options;\n const themeCompartment = new _codemirror_state__rspack_import_3.Compartment();\n const keymapCompartment = new _codemirror_state__rspack_import_3.Compartment();\n const langCompartment = new _codemirror_state__rspack_import_3.Compartment();\n const historyCompartment = new _codemirror_state__rspack_import_3.Compartment();\n const hideCursorOnBlur = _codemirror_view__rspack_import_4.EditorView.theme({\n '&:not(.cm-focused) .cm-fat-cursor': {\n display: 'none'\n }\n });\n const extensions = [\n historyCompartment.of([\n (0,_codemirror_commands__rspack_import_5.history)(),\n _codemirror_view__rspack_import_4.keymap.of(_codemirror_commands__rspack_import_5.historyKeymap)\n ]),\n _decorations_js__rspack_import_2.markField,\n _decorations_js__rspack_import_2.lineField,\n themeCompartment.of((0,_options_js__rspack_import_1.themeExtension)(theme)),\n keymapCompartment.of((0,_options_js__rspack_import_1.keymapExtension)(keyMap)),\n langCompartment.of((0,_options_js__rspack_import_1.languageExtension)(mode)),\n (0,_codemirror_language__rspack_import_6.syntaxHighlighting)(_highlight_js__rspack_import_0.highlightStyle),\n _codemirror_language__rspack_import_6.indentUnit.of(' '),\n ...lineNumbers ? [\n (0,_codemirror_view__rspack_import_4.lineNumbers)()\n ] : [],\n ...fold ? [\n (0,_codemirror_language__rspack_import_6.foldGutter)(),\n (0,_codemirror_language__rspack_import_6.codeFolding)()\n ] : [],\n ...readOnly ? [\n _codemirror_state__rspack_import_3.EditorState.readOnly.of(true)\n ] : [],\n ...updateListener ? [\n _codemirror_view__rspack_import_4.EditorView.updateListener.of(updateListener)\n ] : [],\n (0,_codemirror_view__rspack_import_4.drawSelection)(),\n hideCursorOnBlur\n ];\n const view = new _codemirror_view__rspack_import_4.EditorView({\n state: _codemirror_state__rspack_import_3.EditorState.create({\n doc: value,\n extensions\n }),\n parent: element\n });\n view._themeCompartment = themeCompartment;\n view._keymapCompartment = keymapCompartment;\n view._langCompartment = langCompartment;\n view._historyCompartment = historyCompartment;\n return view;\n}\n\n\n//# sourceURL=webpack://qword/./client/create.js?af24\n}");
|
|
726
726
|
|
|
727
727
|
},
|
|
728
728
|
"./client/decorations.js"
|
|
@@ -749,7 +749,7 @@ eval("{__webpack_require__.r(__webpack_exports__);\n__webpack_require__.d(__webp
|
|
|
749
749
|
\**************************/
|
|
750
750
|
(__unused_rspack___webpack_module__, __webpack_exports__, __webpack_require__) {
|
|
751
751
|
"use strict";
|
|
752
|
-
eval("{__webpack_require__.r(__webpack_exports__);\n__webpack_require__.d(__webpack_exports__, {\n \"default\": () => (Editor)\n});\n/* import */ var emitify__rspack_import_0 = __webpack_require__(/*! emitify */ \"./node_modules/emitify/lib/emitify.js\");\n/* import */ var _create_js__rspack_import_1 = __webpack_require__(/*! ./create.js */ \"./client/create.js\");\n/* import */ var _content_js__rspack_import_2 = __webpack_require__(/*! ./content.js */ \"./client/content.js\");\n/* import */ var _position_js__rspack_import_3 = __webpack_require__(/*! ./position.js */ \"./client/position.js\");\n/* import */ var _decorations_js__rspack_import_4 = __webpack_require__(/*! ./decorations.js */ \"./client/decorations.js\");\n/* import */ var _options_js__rspack_import_5 = __webpack_require__(/*! ./options.js */ \"./client/options.js\");\n/* import */ var _history_js__rspack_import_6 = __webpack_require__(/*! ./history.js */ \"./client/history.js\");\n/* import */ var _dom_js__rspack_import_7 = __webpack_require__(/*! ./dom.js */ \"./client/dom.js\");\n\n\n\n\n\n\n\n\nclass Editor {\n #view;\n #vimEnabled = false;\n #savedValue = '';\n #emitter;\n constructor(element, options = {}){\n this.#emitter = emitify__rspack_import_0();\n this.#view = (0,_create_js__rspack_import_1.createEditor)(element, {\n ...options,\n updateListener: (update)=>{\n if (update.docChanged) this.#emitter.emit('change', {\n value: this.getValue(),\n cursor: this.getCursorIndex()\n });\n if (update.selectionSet) this.#emitter.emit('cursorMove', this.getCursorIndex());\n }\n });\n (0,_dom_js__rspack_import_7.observeResize)(this.#view, element);\n }\n getValue() {\n return (0,_content_js__rspack_import_2.getValue)(this.#view);\n }\n setValue(value) {\n (0,_content_js__rspack_import_2.setValue)(this.#view, value);\n return this;\n }\n getCursorIndex() {\n return (0,_position_js__rspack_import_3.getCursorIndex)(this.#view);\n }\n getCursor() {\n return (0,_position_js__rspack_import_3.getCursor)(this.#view);\n }\n posFromIndex(index) {\n return (0,_position_js__rspack_import_3.posFromIndex)(this.#view, index);\n }\n focus() {\n this.#view.focus();\n return this;\n }\n moveCursorTo(row, column = 0) {\n const line = this.#view.state.doc.line(row + 1);\n this.#view.dispatch({\n selection: {\n anchor: line.from + column\n },\n scrollIntoView: true\n });\n return this;\n }\n markRange(from, to, className) {\n return (0,_decorations_js__rspack_import_4.markText)(this.#view, from, to, {\n className\n });\n }\n addLineClass(line, className) {\n (0,_decorations_js__rspack_import_4.addLineClass)(this.#view, line, 'text', className);\n return this;\n }\n removeLineClass(line, className) {\n (0,_decorations_js__rspack_import_4.removeLineClass)(this.#view, line, 'text', className);\n return this;\n }\n setOption(name, value) {\n if (name === 'keyMap') this.#vimEnabled = value === 'vim';\n (0,_options_js__rspack_import_5.setOption)(this.#view, name, value);\n return this;\n }\n setMode(mode) {\n return this.setOption('mode', mode);\n }\n setTheme(theme) {\n return this.setOption('theme', theme);\n }\n setKeyMap(name) {\n return this.setOption('keyMap', name);\n }\n setModeForPath(path) {\n return this.setMode(path.split('.').pop());\n }\n isChanged() {\n return this.getValue() !== this.#savedValue;\n }\n clearHistory() {\n (0,_history_js__rspack_import_6.clearHistory)(this.#view, this.#view._historyCompartment, this.#vimEnabled);\n return this;\n }\n on(event, handler) {\n this.#emitter.on(event, handler);\n return this;\n }\n addListener(event, handler) {\n return this.on(event, handler);\n }\n once(event, handler) {\n this.#emitter.once(event, handler);\n return this;\n }\n removeListener(event, handler) {\n this.#emitter.removeListener(event, handler);\n return this;\n }\n emit(...args) {\n this.#emitter.emit(...args);\n return this;\n }\n get _view() {\n return this.#view;\n }\n}\n\n\n//# sourceURL=webpack://qword/./client/editor.js?e6cc\n}");
|
|
752
|
+
eval("{__webpack_require__.r(__webpack_exports__);\n__webpack_require__.d(__webpack_exports__, {\n \"default\": () => (Editor)\n});\n/* import */ var emitify__rspack_import_0 = __webpack_require__(/*! emitify */ \"./node_modules/emitify/lib/emitify.js\");\n/* import */ var _codemirror_view__rspack_import_8 = __webpack_require__(/*! @codemirror/view */ \"./node_modules/@codemirror/view/dist/index.js\");\n/* import */ var _create_js__rspack_import_1 = __webpack_require__(/*! ./create.js */ \"./client/create.js\");\n/* import */ var _content_js__rspack_import_2 = __webpack_require__(/*! ./content.js */ \"./client/content.js\");\n/* import */ var _position_js__rspack_import_3 = __webpack_require__(/*! ./position.js */ \"./client/position.js\");\n/* import */ var _decorations_js__rspack_import_4 = __webpack_require__(/*! ./decorations.js */ \"./client/decorations.js\");\n/* import */ var _options_js__rspack_import_5 = __webpack_require__(/*! ./options.js */ \"./client/options.js\");\n/* import */ var _history_js__rspack_import_6 = __webpack_require__(/*! ./history.js */ \"./client/history.js\");\n/* import */ var _dom_js__rspack_import_7 = __webpack_require__(/*! ./dom.js */ \"./client/dom.js\");\n\n\n\n\n\n\n\n\n\nclass Editor {\n #view;\n #vimEnabled = false;\n #savedValue = '';\n #emitter;\n constructor(element, options = {}){\n this.#emitter = emitify__rspack_import_0();\n this.#view = (0,_create_js__rspack_import_1.createEditor)(element, {\n ...options,\n updateListener: (update)=>{\n if (update.docChanged) this.#emitter.emit('change', {\n value: this.getValue(),\n cursor: this.getCursorIndex()\n });\n if (update.selectionSet) this.#emitter.emit('cursorMove', this.getCursorIndex());\n }\n });\n (0,_dom_js__rspack_import_7.observeResize)(this.#view, element);\n }\n getValue() {\n return (0,_content_js__rspack_import_2.getValue)(this.#view);\n }\n setValue(value) {\n (0,_content_js__rspack_import_2.setValue)(this.#view, value);\n return this;\n }\n getCursorIndex() {\n return (0,_position_js__rspack_import_3.getCursorIndex)(this.#view);\n }\n getCursor() {\n return (0,_position_js__rspack_import_3.getCursor)(this.#view);\n }\n posFromIndex(index) {\n return (0,_position_js__rspack_import_3.posFromIndex)(this.#view, index);\n }\n focus() {\n this.#view.focus();\n return this;\n }\n moveCursorTo(row, column = 0) {\n const line = this.#view.state.doc.line(row + 1);\n this.#view.dispatch({\n selection: {\n anchor: line.from + column\n },\n scrollIntoView: true\n });\n return this;\n }\n markRange(from, to, className) {\n return (0,_decorations_js__rspack_import_4.markText)(this.#view, from, to, {\n className\n });\n }\n addLineClass(line, className) {\n (0,_decorations_js__rspack_import_4.addLineClass)(this.#view, line, 'text', className);\n return this;\n }\n removeLineClass(line, className) {\n (0,_decorations_js__rspack_import_4.removeLineClass)(this.#view, line, 'text', className);\n return this;\n }\n setOption(name, value) {\n if (name === 'keyMap') this.#vimEnabled = value === 'vim';\n (0,_options_js__rspack_import_5.setOption)(this.#view, name, value);\n return this;\n }\n setMode(mode) {\n return this.setOption('mode', mode);\n }\n setTheme(theme) {\n return this.setOption('theme', theme);\n }\n setKeyMap(name) {\n return this.setOption('keyMap', name);\n }\n setModeForPath(path) {\n return this.setMode(path.split('.').pop());\n }\n isChanged() {\n return this.getValue() !== this.#savedValue;\n }\n clearHistory() {\n (0,_history_js__rspack_import_6.clearHistory)(this.#view, this.#view._historyCompartment, this.#vimEnabled);\n return this;\n }\n on(event, handler) {\n this.#emitter.on(event, handler);\n return this;\n }\n addListener(event, handler) {\n return this.on(event, handler);\n }\n once(event, handler) {\n this.#emitter.once(event, handler);\n return this;\n }\n removeListener(event, handler) {\n this.#emitter.removeListener(event, handler);\n return this;\n }\n emit(...args) {\n this.#emitter.emit(...args);\n return this;\n }\n setOptions(options = {}) {\n if (options.fontSize) this._view.dispatch({\n effects: this._view._themeCompartment.reconfigure(_codemirror_view__rspack_import_8.EditorView.theme({\n '&': {\n fontSize: `${options.fontSize}px`\n }\n }))\n });\n return this;\n }\n get _view() {\n return this.#view;\n }\n}\n\n\n//# sourceURL=webpack://qword/./client/editor.js?e6cc\n}");
|
|
753
753
|
|
|
754
754
|
},
|
|
755
755
|
"./client/highlight.js"
|
|
@@ -785,7 +785,7 @@ eval("{__webpack_require__.r(__webpack_exports__);\n__webpack_require__.d(__webp
|
|
|
785
785
|
\***************************/
|
|
786
786
|
(__unused_rspack___webpack_module__, __webpack_exports__, __webpack_require__) {
|
|
787
787
|
"use strict";
|
|
788
|
-
eval("{__webpack_require__.r(__webpack_exports__);\n__webpack_require__.d(__webpack_exports__, {\n keymapExtension: () => (keymapExtension),\n languageExtension: () => (languageExtension),\n setOption: () => (setOption),\n themeExtension: () => (themeExtension)\n});\n/* import */ var _codemirror_view__rspack_import_2 = __webpack_require__(/*! @codemirror/view */ \"./node_modules/@codemirror/view/dist/index.js\");\n/* import */ var _codemirror_lang_javascript__rspack_import_4 = __webpack_require__(/*! @codemirror/lang-javascript */ \"./node_modules/@codemirror/lang-javascript/dist/index.js\");\n/* import */ var _codemirror_lang_json__rspack_import_5 = __webpack_require__(/*! @codemirror/lang-json */ \"./node_modules/@codemirror/lang-json/dist/index.js\");\n/* import */ var _codemirror_lang_html__rspack_import_6 = __webpack_require__(/*! @codemirror/lang-html */ \"./node_modules/@codemirror/lang-html/dist/index.js\");\n/* import */ var _replit_codemirror_vim__rspack_import_1 = __webpack_require__(/*! @replit/codemirror-vim */ \"./node_modules/@replit/codemirror-vim/dist/index.js\");\n/* import */ var _uiw_codemirror_theme_nord__rspack_import_0 = __webpack_require__(/*! @uiw/codemirror-theme-nord */ \"./node_modules/@uiw/codemirror-theme-nord/esm/index.js\");\n/* import */ var _codemirror_commands__rspack_import_3 = __webpack_require__(/*! @codemirror/commands */ \"./node_modules/@codemirror/commands/dist/index.js\");\n\n\n\n\n\n\n\nfunction keymapExtension(name) {\n if (name === 'vim') return (0,_replit_codemirror_vim__rspack_import_1.vim)();\n if (name === 'emacs') return _codemirror_view__rspack_import_2.keymap.of(_codemirror_commands__rspack_import_3.emacsStyleKeymap);\n return _codemirror_view__rspack_import_2.keymap.of(_codemirror_commands__rspack_import_3.defaultKeymap);\n}\nfunction themeExtension(name) {\n if (name === 'nord' || name === 'dark' || name === 'one-dark') return _uiw_codemirror_theme_nord__rspack_import_0.nord;\n return [];\n}\nfunction languageExtension(mode) {\n const name = typeof mode === 'object' ? mode?.name : mode;\n if (name === 'javascript' || name === 'js') return (0,_codemirror_lang_javascript__rspack_import_4.javascript)();\n if (name === 'json') return (0,_codemirror_lang_json__rspack_import_5.json)();\n if (name === 'html') return (0,_codemirror_lang_html__rspack_import_6.html)();\n return [];\n}\nfunction setOption(view, key, value) {\n if (key === 'theme') return view.dispatch({\n effects: view._themeCompartment.reconfigure(themeExtension(value))\n });\n if (key === 'keyMap') return view.dispatch({\n effects: view._keymapCompartment.reconfigure(keymapExtension(value))\n });\n if (key === 'mode') return view.dispatch({\n effects: view._langCompartment.reconfigure(languageExtension(value))\n });\n}\n\n\n//# sourceURL=webpack://qword/./client/options.js?1904\n}");
|
|
788
|
+
eval("{__webpack_require__.r(__webpack_exports__);\n__webpack_require__.d(__webpack_exports__, {\n indentKeymap: () => (indentKeymap),\n keymapExtension: () => (keymapExtension),\n languageExtension: () => (languageExtension),\n setOption: () => (setOption),\n themeExtension: () => (themeExtension)\n});\n/* import */ var _codemirror_view__rspack_import_2 = __webpack_require__(/*! @codemirror/view */ \"./node_modules/@codemirror/view/dist/index.js\");\n/* import */ var _codemirror_lang_javascript__rspack_import_4 = __webpack_require__(/*! @codemirror/lang-javascript */ \"./node_modules/@codemirror/lang-javascript/dist/index.js\");\n/* import */ var _codemirror_lang_json__rspack_import_5 = __webpack_require__(/*! @codemirror/lang-json */ \"./node_modules/@codemirror/lang-json/dist/index.js\");\n/* import */ var _codemirror_lang_html__rspack_import_6 = __webpack_require__(/*! @codemirror/lang-html */ \"./node_modules/@codemirror/lang-html/dist/index.js\");\n/* import */ var _replit_codemirror_vim__rspack_import_1 = __webpack_require__(/*! @replit/codemirror-vim */ \"./node_modules/@replit/codemirror-vim/dist/index.js\");\n/* import */ var _uiw_codemirror_theme_nord__rspack_import_0 = __webpack_require__(/*! @uiw/codemirror-theme-nord */ \"./node_modules/@uiw/codemirror-theme-nord/esm/index.js\");\n/* import */ var _codemirror_commands__rspack_import_3 = __webpack_require__(/*! @codemirror/commands */ \"./node_modules/@codemirror/commands/dist/index.js\");\n\n\n\n\n\n\n\nfunction keymapExtension(name) {\n if (name === 'vim') return (0,_replit_codemirror_vim__rspack_import_1.vim)();\n if (name === 'emacs') return _codemirror_view__rspack_import_2.keymap.of([\n ..._codemirror_commands__rspack_import_3.emacsStyleKeymap,\n _codemirror_commands__rspack_import_3.indentWithTab\n ]);\n return _codemirror_view__rspack_import_2.keymap.of([\n ..._codemirror_commands__rspack_import_3.defaultKeymap,\n _codemirror_commands__rspack_import_3.indentWithTab\n ]);\n}\nfunction themeExtension(name) {\n if (name === 'nord' || name === 'dark' || name === 'one-dark') return _uiw_codemirror_theme_nord__rspack_import_0.nord;\n return [];\n}\nconst indentKeymap = _codemirror_view__rspack_import_2.keymap.of([\n _codemirror_commands__rspack_import_3.indentWithTab\n]);\nfunction languageExtension(mode) {\n const name = typeof mode === 'object' ? mode?.name : mode;\n if (name === 'javascript' || name === 'js') return (0,_codemirror_lang_javascript__rspack_import_4.javascript)();\n if (name === 'json') return (0,_codemirror_lang_json__rspack_import_5.json)();\n if (name === 'html') return (0,_codemirror_lang_html__rspack_import_6.html)();\n return [];\n}\nfunction setOption(view, key, value) {\n if (key === 'theme') return view.dispatch({\n effects: view._themeCompartment.reconfigure(themeExtension(value))\n });\n if (key === 'keyMap') return view.dispatch({\n effects: view._keymapCompartment.reconfigure(keymapExtension(value))\n });\n if (key === 'mode') return view.dispatch({\n effects: view._langCompartment.reconfigure(languageExtension(value))\n });\n}\n\n\n//# sourceURL=webpack://qword/./client/options.js?1904\n}");
|
|
789
789
|
|
|
790
790
|
},
|
|
791
791
|
"./client/position.js"
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "qword",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.2",
|
|
4
4
|
"description": "Web editor based on CodeMirror 6",
|
|
5
5
|
"main": "./server/index.js",
|
|
6
6
|
"exports": {
|
|
@@ -57,11 +57,7 @@
|
|
|
57
57
|
"restbox": "^4.0.1",
|
|
58
58
|
"socket-file": "^8.0.0",
|
|
59
59
|
"socket.io": "^4.0.0",
|
|
60
|
-
"try-to-catch": "^4.0.5"
|
|
61
|
-
},
|
|
62
|
-
"devDependencies": {
|
|
63
|
-
"@cloudcmd/clipboard": "^2.0.0",
|
|
64
|
-
"@cloudcmd/create-element": "^2.0.2",
|
|
60
|
+
"try-to-catch": "^4.0.5",
|
|
65
61
|
"@codemirror/commands": "^6.10.3",
|
|
66
62
|
"@codemirror/lang-html": "^6.4.11",
|
|
67
63
|
"@codemirror/lang-javascript": "^6.2.5",
|
|
@@ -71,15 +67,19 @@
|
|
|
71
67
|
"@codemirror/theme-one-dark": "^6.1.3",
|
|
72
68
|
"@codemirror/view": "^6.42.1",
|
|
73
69
|
"@lezer/highlight": "^1.2.3",
|
|
70
|
+
"@replit/codemirror-vim": "^6.3.0",
|
|
71
|
+
"@uiw/codemirror-theme-nord": "^4.25.11"
|
|
72
|
+
},
|
|
73
|
+
"devDependencies": {
|
|
74
|
+
"@cloudcmd/clipboard": "^2.0.0",
|
|
75
|
+
"@cloudcmd/create-element": "^2.0.2",
|
|
74
76
|
"@putout/eslint-flat": "^4.0.0",
|
|
75
77
|
"@putout/plugin-convert-webpack-to-rspack": "^1.0.1",
|
|
76
|
-
"@replit/codemirror-vim": "^6.3.0",
|
|
77
78
|
"@rspack/cli": "^2.2.1",
|
|
78
79
|
"@rspack/core": "^2.2.1",
|
|
79
80
|
"@supertape/loader-css": "^1.0.0",
|
|
80
81
|
"@supertape/loader-dom": "^1.0.0",
|
|
81
82
|
"@testing-library/dom": "^10.4.1",
|
|
82
|
-
"@uiw/codemirror-theme-nord": "^4.25.11",
|
|
83
83
|
"callbackify": "^1.1.0",
|
|
84
84
|
"check-dts": "^1.0.0",
|
|
85
85
|
"css-loader": "^7.1.3",
|
package/server/edit.spec.js
CHANGED
package/test/errors.ts
CHANGED
package/test/types.ts
CHANGED
|
@@ -23,6 +23,8 @@ import {
|
|
|
23
23
|
clearHistory,
|
|
24
24
|
} from '../client/index.js';
|
|
25
25
|
|
|
26
|
+
const noop = () => {};
|
|
27
|
+
|
|
26
28
|
const view = createEditor(document.body, {
|
|
27
29
|
value: 'const a = 3',
|
|
28
30
|
mode: 'javascript',
|
|
@@ -35,19 +37,24 @@ const view = createEditor(document.body, {
|
|
|
35
37
|
|
|
36
38
|
// content
|
|
37
39
|
const value: string = getValue(view);
|
|
40
|
+
|
|
38
41
|
setValue(view, 'const b = 4');
|
|
39
42
|
|
|
40
43
|
// position
|
|
41
44
|
const position = offsetToPosition(view.state.doc, 10);
|
|
45
|
+
|
|
42
46
|
const offset: number = positionToOffset(view.state.doc, {
|
|
43
47
|
line: 0,
|
|
44
48
|
ch: 0,
|
|
45
49
|
});
|
|
50
|
+
|
|
46
51
|
const pos = posFromIndex(view, 0);
|
|
52
|
+
|
|
47
53
|
const idx = indexFromPos(view, {
|
|
48
54
|
line: 0,
|
|
49
55
|
ch: 0,
|
|
50
56
|
});
|
|
57
|
+
|
|
51
58
|
const cursor = getCursorIndex(view);
|
|
52
59
|
const {row, column} = getCursor(view);
|
|
53
60
|
|
|
@@ -61,22 +68,27 @@ const handle = markText(view, {
|
|
|
61
68
|
}, {
|
|
62
69
|
className: 'hl-keyword',
|
|
63
70
|
});
|
|
71
|
+
|
|
64
72
|
handle.clear();
|
|
65
73
|
addLineClass(view, 0, 'text', 'hl-string');
|
|
66
74
|
removeLineClass(view, 0, 'text', 'hl-string');
|
|
67
75
|
|
|
68
76
|
// events
|
|
69
|
-
const binding = on(view, 'keydown',
|
|
70
|
-
|
|
77
|
+
const binding = on(view, 'keydown', noop);
|
|
78
|
+
|
|
79
|
+
off(view, 'keydown', noop);
|
|
71
80
|
|
|
72
81
|
// scroll
|
|
73
82
|
const {left, top} = getScrollInfo(view);
|
|
83
|
+
|
|
74
84
|
scrollTo(view, left, top);
|
|
75
85
|
|
|
76
86
|
// dom
|
|
77
87
|
const found = getView(document.body);
|
|
88
|
+
|
|
78
89
|
refresh(view);
|
|
79
90
|
const unobserve = observeResize(view, document.body);
|
|
91
|
+
|
|
80
92
|
unobserve();
|
|
81
93
|
|
|
82
94
|
// options
|
|
@@ -94,6 +106,7 @@ const editor = new Editor(document.body, {
|
|
|
94
106
|
theme: 'default',
|
|
95
107
|
keyMap: 'default',
|
|
96
108
|
});
|
|
109
|
+
|
|
97
110
|
editor
|
|
98
111
|
.setValue('const b = 4')
|
|
99
112
|
.focus()
|
|
@@ -105,18 +118,21 @@ editor
|
|
|
105
118
|
.setKeyMap('vim')
|
|
106
119
|
.setModeForPath('a.js')
|
|
107
120
|
.clearHistory()
|
|
108
|
-
.on('change',
|
|
121
|
+
.on('change', noop)
|
|
109
122
|
.emit('change', {});
|
|
110
123
|
const editorValue: string = editor.getValue();
|
|
111
124
|
const editorCursor = editor.getCursor();
|
|
112
125
|
const editorPos = editor.posFromIndex(0);
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
126
|
+
|
|
127
|
+
editor
|
|
128
|
+
.markRange({
|
|
129
|
+
line: 0,
|
|
130
|
+
ch: 0,
|
|
131
|
+
}, {
|
|
132
|
+
line: 0,
|
|
133
|
+
ch: 1,
|
|
134
|
+
}, 'className')
|
|
135
|
+
.clear();
|
|
120
136
|
|
|
121
137
|
// types compile
|
|
122
138
|
void value;
|
|
@@ -131,4 +147,4 @@ void binding;
|
|
|
131
147
|
void found;
|
|
132
148
|
void editorValue;
|
|
133
149
|
void editorCursor;
|
|
134
|
-
void editorPos;
|
|
150
|
+
void editorPos;
|