Comparing version 2.8.0 to 3.0.0
declare module '*.css'; |
@@ -160,6 +160,4 @@ import { Marked, type MarkedExtension } from 'marked'; | ||
readonly markedSync: Marked; | ||
private _element; | ||
private _input; | ||
private _renderer; | ||
get element(): HTMLDivElement | undefined; | ||
get input(): CartaInput | undefined; | ||
@@ -182,7 +180,2 @@ get renderer(): CartaRenderer | undefined; | ||
/** | ||
* **Internal**: set the editor element. | ||
* @param element The editor element. | ||
*/ | ||
$setElement(element: HTMLDivElement): void; | ||
/** | ||
* **Internal**: set the input element. | ||
@@ -189,0 +182,0 @@ * @param textarea The input textarea element. |
@@ -7,3 +7,3 @@ import { Marked } from 'marked'; | ||
import { CartaRenderer } from './renderer'; | ||
import { loadCustomLanguage, highlight, highlightAutodetect, loadCustomMarkdown } from './highlight.js'; | ||
import { loadCustomLanguage, highlight, highlightAutodetect } from './highlight.js'; | ||
import { mangle } from 'marked-mangle'; | ||
@@ -33,8 +33,4 @@ import { gfmHeadingId } from 'marked-gfm-heading-id'; | ||
markedSync = new Marked(); | ||
_element; | ||
_input; | ||
_renderer; | ||
get element() { | ||
return this._element; | ||
} | ||
get input() { | ||
@@ -76,3 +72,3 @@ return this._input; | ||
// Load default icons | ||
this.icons.unshift(...defaultIcons.filter((icon) => options?.disableIcons === true ? false : !options?.disableIcons?.includes(icon.id))); | ||
this.icons.push(...defaultIcons.filter((icon) => options?.disableIcons === true ? false : !options?.disableIcons?.includes(icon.id))); | ||
// Load default prefixes | ||
@@ -102,3 +98,8 @@ this.prefixes.push(...defaultPrefixes.filter((prefix) => options?.disablePrefixes === true ? false : !options?.disablePrefixes?.includes(prefix.id))); | ||
// Load highlight custom language | ||
loadCustomMarkdown(this.options?.extensions ?? []) | ||
import('./shj.js') | ||
.then((module) => { | ||
// inject custom rules | ||
module.default.unshift(...this.highlightRules); | ||
return loadCustomLanguage('cartamd', module); | ||
}) | ||
// trigger re-render | ||
@@ -157,9 +158,2 @@ .then(() => this.input?.update()); | ||
/** | ||
* **Internal**: set the editor element. | ||
* @param element The editor element. | ||
*/ | ||
$setElement(element) { | ||
this._element = element; | ||
} | ||
/** | ||
* **Internal**: set the input element. | ||
@@ -166,0 +160,0 @@ * @param textarea The input textarea element. |
@@ -1,7 +0,2 @@ | ||
import { type ShjLanguage, type ShjLanguageDefinition } from '@speed-highlight/core'; | ||
import type { CartaExtension } from './carta'; | ||
interface Nothing { | ||
} | ||
type Union<T, U> = T | (U & Nothing); | ||
type Lang = Union<ShjLanguage, string>; | ||
import { type ShjLanguageDefinition } from '@speed-highlight/core'; | ||
/** | ||
@@ -15,3 +10,3 @@ * Highlight text using Speed-Highlight. May return null on error(usually if requested | ||
*/ | ||
export declare function highlight(text: string, lang: Lang, hideLineNumbers?: boolean): Promise<string | null>; | ||
export declare function highlight(text: string, lang: string, hideLineNumbers?: boolean): Promise<string | null>; | ||
/** | ||
@@ -54,8 +49,1 @@ * Highlight text using Speed-Highlight with detected language. | ||
} | ||
/** | ||
* Load custom markdown syntax highlighting rules. | ||
* Automatically called when a Carta instance is created. | ||
* @param extensions Additional extensions used in Carta. | ||
*/ | ||
export declare function loadCustomMarkdown(extensions?: CartaExtension[]): Promise<void>; | ||
export {}; |
import { detectLanguage } from '@speed-highlight/core/detect.js'; | ||
import { highlightText, loadLanguage } from '@speed-highlight/core'; | ||
import cartaMarkdown from './shj'; | ||
/** | ||
@@ -55,11 +54,1 @@ * Highlight text using Speed-Highlight. May return null on error(usually if requested | ||
} | ||
/** | ||
* Load custom markdown syntax highlighting rules. | ||
* Automatically called when a Carta instance is created. | ||
* @param extensions Additional extensions used in Carta. | ||
*/ | ||
export async function loadCustomMarkdown(extensions = []) { | ||
const highlightRules = extensions.map((ext) => ext.highlightRules ?? []).flat(); | ||
const lang = Array.prototype.concat(cartaMarkdown, highlightRules); | ||
loadCustomLanguage('cartamd', { default: lang }); | ||
} |
@@ -7,5 +7,12 @@ { | ||
"license": "MIT", | ||
"repository": { "type": "git", "url": "https://github.com/BearToCode/carta-md.git" }, | ||
"repository": { | ||
"type": "git", | ||
"url": "https://github.com/BearToCode/carta-md.git" | ||
}, | ||
"exports": { | ||
".": { "types": "./dist/index.d.ts", "svelte": "./dist/index.js", "import": "./dist/index.js" }, | ||
".": { | ||
"types": "./dist/index.d.ts", | ||
"svelte": "./dist/index.js", | ||
"import": "./dist/index.js" | ||
}, | ||
"./default-theme.css": "./dist/default-theme.css", | ||
@@ -15,3 +22,3 @@ "./light.css": "./dist/light.css", | ||
}, | ||
"version": "2.8.0", | ||
"version": "3.0.0", | ||
"scripts": { | ||
@@ -35,7 +42,7 @@ "dev": "vite dev", | ||
"@speed-highlight/core": "1.2.2", | ||
"marked": "^9.1.5", | ||
"marked-gfm-heading-id": "^3.0.5", | ||
"marked-mangle": "^1.1.1" | ||
"marked": "^9.1.5" | ||
}, | ||
"peerDependencies": { "svelte": "^3.54.0 || ^4.0.0" }, | ||
"peerDependencies": { | ||
"svelte": "^3.54.0 || ^4.0.0" | ||
}, | ||
"keywords": [ | ||
@@ -53,3 +60,5 @@ "carta", | ||
], | ||
"files": ["dist"] | ||
"files": [ | ||
"dist" | ||
] | ||
} |
@@ -131,4 +131,2 @@ <div align="center"> | ||
| `sanitizer` | `(html: string) => string` | HTML sanitizer | | ||
| `mangle` | `false` | Allows disabling of marked-mangle | | ||
| `gfmHeadingId` | `GfmHeadingIdOptions \| false` | marked-gfm-heading-id options, or disabling | | ||
@@ -135,0 +133,0 @@ You can easily extend Carta by creating custom plugins. Here are all the `CartaExtension` properties: |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
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
3
92287
2097
162
- Removedmarked-gfm-heading-id@^3.0.5
- Removedmarked-mangle@^1.1.1
- Removedgithub-slugger@2.0.0(transitive)
- Removedmarked-gfm-heading-id@3.2.0(transitive)
- Removedmarked-mangle@1.1.10(transitive)