@pfmcodes/caret 0.2.7 → 0.2.9

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/README.md CHANGED
@@ -1,5 +1,5 @@
1
+ ![LOGO](https://github.com/PFMCODES/Caret/raw/main/logo.svg)
1
2
  # Caret
2
-
3
3
  [![License: MIT](https://img.shields.io/badge/License-MIT-4000ff.svg)](https://opensource.org/licenses/MIT)
4
4
  [![JavaScript](https://img.shields.io/badge/JavaScript-63.7%25-f6fa03)](https://github.com/PFMCODES/lexius-edior)
5
5
  [![JavaScript](https://img.shields.io/badge/TypeScript-32.3%25-0244f7)](https://github.com/PFMCODES/lexius-edior)
@@ -33,6 +33,9 @@ A lightweight, feature-rich code editor with real-time syntax highlighting and c
33
33
 
34
34
  ## What's-New?
35
35
 
36
+ ### v0.2.8
37
+ - just mistake i made has been fixed
38
+
36
39
  ### v0.2.7
37
40
  - another cleanup but this time, with file optimizations and updated comments at the end of each containing short summaries of each function and variables(only some important variables)
38
41
 
package/editor.js CHANGED
@@ -71,8 +71,10 @@ async function createEditor(editor, data) {
71
71
  editor.style = "position: relative; width: 600px; height: 300px; overflow: hidden; /* 👈 CRITICAL */ font-size: 14px;"
72
72
  if (code && editor && editor1 && language && highlighted) {
73
73
  editor1.style.paddingTop = "-9px";
74
- editor1.value = data.value;
75
- highlighted.innerHTML = await _render(data.value, language, editor1);
74
+ editor1.value = code;
75
+ let h = await _render(code, language, editor1);
76
+ highlighted.innerHTML = h;
77
+ console.log({h: h, code: code})
76
78
  }
77
79
  const keyDown = async (e) => {
78
80
  if (e.key !== "Tab") return;
@@ -396,13 +398,6 @@ function getWrapMap(code, wrapAt = 71) {
396
398
  return wrapMap;
397
399
  }
398
400
 
399
- function escapeHtml(str) {
400
- return str
401
- .replace(/&/g, "&")
402
- .replace(/</g, "&lt;")
403
- .replace(/>/g, "&gt;");
404
- }
405
-
406
401
  async function _render(code, language, editor) {
407
402
  // If no editor context provided, just highlight everything (initial load)
408
403
  if (!editor) {
@@ -440,7 +435,7 @@ async function _render(code, language, editor) {
440
435
  const highlightedVisible = hljs.highlight(wrappedCode, { language }).value;
441
436
  // Plain text for non-visible areas (no highlighting = faster)
442
437
  if (highlightedVisible.trim() === "") {
443
- return hljs.highlight(escapeHtml(code), { language }).value;
438
+ return hljs.highlight(code, { language }).value;
444
439
  }
445
440
  const beforeHTML = "\n".repeat(beforeLines.length);
446
441
  const afterHTML = "\n".repeat(afterLines.length);
@@ -467,7 +462,6 @@ Internal functions:
467
462
  _render(code, language, editor) -> virtual renderer, only highlights visible lines for performance
468
463
  wrapCode(code, wrapAt) -> wraps long lines at word boundaries
469
464
  getWrapMap(code, wrapAt) -> returns an array mapping each line to its visual line count
470
- escapeHtml(str) -> escapes HTML special characters
471
465
  updateCaret() -> updates the caret position using canvas font metrics
472
466
  updateLineNumbers() -> re-renders line numbers, accounting for wrapped lines
473
467
  updateFontMetrics() -> updates the canvas font to match the textarea's computed style
package/langauges.js CHANGED
@@ -69,6 +69,10 @@ function init() {
69
69
  );
70
70
  }
71
71
 
72
+ export function registerAliases(a, b) {
73
+ hljs.registerAliases(a, b)
74
+ }
75
+
72
76
  function registerLanguage(name, definition) {
73
77
  if (!registeredLanguages.includes(name)) {
74
78
  hljs.registerLanguage(name, definition);
@@ -84,6 +88,7 @@ const languages = {
84
88
  init,
85
89
  registeredLanguages,
86
90
  registerLanguage,
91
+ registerAliases,
87
92
  hljs
88
93
  }
89
94
 
@@ -93,4 +98,5 @@ export default languages;
93
98
  registeredLannguage: added for the editor.js can check if the langauge provided already is regsitered or not
94
99
  init: just registers some languages and updates the registeredLangauges variable
95
100
  registerLanguage: just registers a language
101
+ registerAliases: basically registers a nickname or second name for an language
96
102
  */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pfmcodes/caret",
3
- "version": "0.2.7",
3
+ "version": "0.2.9",
4
4
  "description": "The official code editor engine for lexius",
5
5
  "type": "module",
6
6
  "main": "./index.js",
@@ -37,8 +37,7 @@ import plaintext from "https://esm.sh/@pfmcodes/highlight.js@1.0.0/es/languages/
37
37
  // @ts-ignore
38
38
  import hljs from "https://esm.sh/@pfmcodes/highlight.js@1.0.0/es/core.js";
39
39
 
40
- let registeredLanguages: Array<T> = [];
41
- type T = any
40
+ let registeredLanguages: Array<any> = [];
42
41
 
43
42
  function init() {
44
43
  // Register all languages
@@ -89,6 +88,10 @@ function init() {
89
88
  ]
90
89
  }
91
90
 
91
+ export function registerAliases(a: any, b: any) {
92
+ hljs.registerAliases(a, b)
93
+ }
94
+
92
95
  function registerLanguage(name: string, definition: any) {
93
96
  hljs.registerLanguage(name, definition);
94
97
  if (!registeredLanguages.includes(name)) {
@@ -106,12 +109,8 @@ const languages = {
106
109
  export default languages;
107
110
 
108
111
  /*
109
-
110
112
  registeredLannguage: added for the editor.js can check if the langauge provided already is regsitered or not
111
-
112
-
113
113
  init: just registers some languages and updates the registeredLangauges variable
114
-
115
114
  registerLanguage: just registers a language
116
-
115
+ registerAliases: basically registers a nickname or second name for an language
117
116
  */