@haklex/cm-editor 0.0.65 → 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 (2) hide show
  1. package/README.md +82 -0
  2. package/package.json +6 -1
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.65",
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"