@neocodemirror/svelte
Advanced tools
Comparing version 0.0.1 to 0.0.2
@@ -20,2 +20,3 @@ import { defaultKeymap, indentWithTab } from '@codemirror/commands'; | ||
lang, | ||
langMap, | ||
instanceStore, | ||
@@ -45,2 +46,3 @@ useTabs = false, | ||
lang, | ||
langMap, | ||
setup, | ||
@@ -82,2 +84,3 @@ useTabs, | ||
lang, | ||
langMap, | ||
setup, | ||
@@ -116,3 +119,3 @@ useTabs, | ||
}; | ||
async function make_extensions(lang, setup, useTabs = false, tabSize = 2, theme, styles, extensions) { | ||
async function make_extensions(lang, langMap, setup, useTabs = false, tabSize = 2, theme, styles, extensions) { | ||
const internal_extensions = [ | ||
@@ -125,3 +128,12 @@ keymap.of([...defaultKeymap, ...useTabs ? [indentWithTab] : []]), | ||
if (lang) { | ||
internal_extensions.push(lang); | ||
if (typeof lang === "string") { | ||
if (!langMap) | ||
throw new Error("`langMap` is required when `lang` is a string."); | ||
if (!(lang in langMap)) | ||
throw new Error(`Language "${lang}" is not defined in \`langMap\`.`); | ||
const lang_support = await langMap[lang](); | ||
internal_extensions.push(lang_support); | ||
} else { | ||
internal_extensions.push(lang); | ||
} | ||
} | ||
@@ -128,0 +140,0 @@ if (theme) |
@@ -63,2 +63,3 @@ import { LanguageSupport } from '@codemirror/language'; | ||
type MaybePromise<T> = T | Promise<T>; | ||
type Styles = { | ||
@@ -70,3 +71,4 @@ [val: string]: Properties | Styles; | ||
setup?: 'basic' | 'minimal'; | ||
lang?: LanguageSupport; | ||
lang?: LanguageSupport | string; | ||
langMap?: Record<string, () => MaybePromise<LanguageSupport>>; | ||
useTabs?: boolean; | ||
@@ -73,0 +75,0 @@ styles?: Styles; |
@@ -20,2 +20,3 @@ import { defaultKeymap, indentWithTab } from '@codemirror/commands'; | ||
lang, | ||
langMap, | ||
instanceStore, | ||
@@ -45,2 +46,3 @@ useTabs = false, | ||
lang, | ||
langMap, | ||
setup, | ||
@@ -82,2 +84,3 @@ useTabs, | ||
lang, | ||
langMap, | ||
setup, | ||
@@ -116,3 +119,3 @@ useTabs, | ||
}; | ||
async function make_extensions(lang, setup, useTabs = false, tabSize = 2, theme, styles, extensions) { | ||
async function make_extensions(lang, langMap, setup, useTabs = false, tabSize = 2, theme, styles, extensions) { | ||
const internal_extensions = [ | ||
@@ -125,3 +128,12 @@ keymap.of([...defaultKeymap, ...useTabs ? [indentWithTab] : []]), | ||
if (lang) { | ||
internal_extensions.push(lang); | ||
if (typeof lang === "string") { | ||
if (!langMap) | ||
throw new Error("`langMap` is required when `lang` is a string."); | ||
if (!(lang in langMap)) | ||
throw new Error(`Language "${lang}" is not defined in \`langMap\`.`); | ||
const lang_support = await langMap[lang](); | ||
internal_extensions.push(lang_support); | ||
} else { | ||
internal_extensions.push(lang); | ||
} | ||
} | ||
@@ -128,0 +140,0 @@ if (theme) |
{ | ||
"name": "@neocodemirror/svelte", | ||
"version": "0.0.1", | ||
"version": "0.0.2", | ||
"description": "Svelte Action to add codemirro to your apps 😉", | ||
@@ -5,0 +5,0 @@ "main": "./dist/index.js", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
15200
426