@haklex/cm-editor 0.0.64 → 0.0.66

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.
Files changed (3) hide show
  1. package/README.md +82 -0
  2. package/package.json +6 -1
  3. package/LICENSE +0 -28
package/README.md ADDED
@@ -0,0 +1,82 @@
1
+ # @haklex/cm-editor
2
+
3
+ Shared CodeMirror 6 editor utilities for the Haklex ecosystem.
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ pnpm add @haklex/cm-editor
9
+ ```
10
+
11
+ ## Peer Dependencies
12
+
13
+ None. All CodeMirror dependencies are bundled.
14
+
15
+ ## Usage
16
+
17
+ ### Language Loading
18
+
19
+ ```ts
20
+ import {
21
+ getLanguageCandidates,
22
+ languageAliases,
23
+ loadLanguageExtension,
24
+ } from '@haklex/cm-editor'
25
+
26
+ // Resolve language aliases (e.g. "js" -> "javascript")
27
+ const candidates = getLanguageCandidates('js')
28
+
29
+ // Load a CodeMirror language extension dynamically
30
+ const extension = await loadLanguageExtension('typescript')
31
+ ```
32
+
33
+ ### Selection Utilities
34
+
35
+ ```ts
36
+ import { isOnFirstLine, isOnLastLine } from '@haklex/cm-editor'
37
+
38
+ // Check cursor position relative to the document
39
+ const atTop = isOnFirstLine(editorState)
40
+ const atBottom = isOnLastLine(editorState)
41
+ ```
42
+
43
+ ### Theme
44
+
45
+ ```ts
46
+ import { baseTheme, getThemeExtensions } from '@haklex/cm-editor'
47
+
48
+ // Apply the base theme or get full theme extensions for a color scheme
49
+ const extensions = getThemeExtensions('dark')
50
+ ```
51
+
52
+ ## Exports
53
+
54
+ ### Language Utilities
55
+
56
+ | Export | Description |
57
+ | --- | --- |
58
+ | `getLanguageCandidates(alias)` | Resolve a language alias to candidate language names |
59
+ | `languageAliases` | Map of language alias strings |
60
+ | `loadLanguageExtension(lang)` | Dynamically load a CodeMirror language extension |
61
+
62
+ ### Selection Utilities
63
+
64
+ | Export | Description |
65
+ | --- | --- |
66
+ | `isOnFirstLine(state)` | Check if the cursor is on the first line |
67
+ | `isOnLastLine(state)` | Check if the cursor is on the last line |
68
+
69
+ ### Theme Utilities
70
+
71
+ | Export | Description |
72
+ | --- | --- |
73
+ | `baseTheme` | Base CodeMirror theme extension |
74
+ | `getThemeExtensions(scheme)` | Get theme extensions for a given color scheme |
75
+
76
+ ## Part of Haklex
77
+
78
+ This package is part of the [Haklex](../../README.md) rich editor ecosystem.
79
+
80
+ ## License
81
+
82
+ MIT
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@haklex/cm-editor",
3
3
  "type": "module",
4
- "version": "0.0.64",
4
+ "version": "0.0.66",
5
5
  "description": "Shared CodeMirror 6 editor utilities",
6
6
  "license": "MIT",
7
7
  "exports": {
@@ -29,6 +29,11 @@
29
29
  "publishConfig": {
30
30
  "access": "public"
31
31
  },
32
+ "repository": {
33
+ "type": "git",
34
+ "url": "https://github.com/Innei/haklex.git",
35
+ "directory": "packages/cm-editor"
36
+ },
32
37
  "scripts": {
33
38
  "build": "vite build",
34
39
  "dev:build": "vite build --watch"
package/LICENSE DELETED
@@ -1,28 +0,0 @@
1
- MIT License
2
-
3
- Copyright (c) 2024 Innei
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in all
13
- copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
- SOFTWARE.
22
-
23
-
24
- Additional Terms and Conditions
25
-
26
- ----------------
27
-
28
- Use of this software is governed by the terms of MIT and, in addition, by the terms and conditions described in the additional file (ADDITIONAL_TERMS.md). By using this software, you agree to abide by these additional terms and conditions.