diff --git a/.vscode/settings.json b/.vscode/settings.json index 85e3f0d..7fd34f4 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -5,15 +5,11 @@ "coldark", "dompurify", "flexsearch", - "Gemoji", "gruvbox", - "iconify", "Katex", "mdsvex", "oldschool", "rehype", - "shiki", - "shikijs", "tikz", "tikzjax", "typeof" @@ -21,6 +17,5 @@ "typescript.tsdk": "node_modules\\typescript\\lib", "[svelte]": { "editor.defaultFormatter": "svelte.svelte-vscode" - }, - "css.customData": [".vscode/tailwind.json"] + } } diff --git a/.vscode/tailwind.json b/.vscode/tailwind.json deleted file mode 100644 index a45bccc..0000000 --- a/.vscode/tailwind.json +++ /dev/null @@ -1,55 +0,0 @@ -{ - "version": 1.1, - "atDirectives": [ - { - "name": "@tailwind", - "description": "Use the `@tailwind` directive to insert Tailwind's `base`, `components`, `utilities` and `screens` styles into your CSS.", - "references": [ - { - "name": "Tailwind Documentation", - "url": "https://tailwindcss.com/docs/functions-and-directives#tailwind" - } - ] - }, - { - "name": "@apply", - "description": "Use the `@apply` directive to inline any existing utility classes into your own custom CSS. This is useful when you find a common utility pattern in your HTML that youโ€™d like to extract to a new component.", - "references": [ - { - "name": "Tailwind Documentation", - "url": "https://tailwindcss.com/docs/functions-and-directives#apply" - } - ] - }, - { - "name": "@responsive", - "description": "You can generate responsive variants of your own classes by wrapping their definitions in the `@responsive` directive:\n```css\n@responsive {\n .alert {\n background-color: #E53E3E;\n }\n}\n```\n", - "references": [ - { - "name": "Tailwind Documentation", - "url": "https://tailwindcss.com/docs/functions-and-directives#responsive" - } - ] - }, - { - "name": "@screen", - "description": "The `@screen` directive allows you to create media queries that reference your breakpoints by **name** instead of duplicating their values in your own CSS:\n```css\n@screen sm {\n /* ... */\n}\n```\nโ€ฆgets transformed into this:\n```css\n@media (min-width: 640px) {\n /* ... */\n}\n```\n", - "references": [ - { - "name": "Tailwind Documentation", - "url": "https://tailwindcss.com/docs/functions-and-directives#screen" - } - ] - }, - { - "name": "@variants", - "description": "Generate `hover`, `focus`, `active` and other **variants** of your own utilities by wrapping their definitions in the `@variants` directive:\n```css\n@variants hover, focus {\n .btn-brand {\n background-color: #3182CE;\n }\n}\n```\n", - "references": [ - { - "name": "Tailwind Documentation", - "url": "https://tailwindcss.com/docs/functions-and-directives#variants" - } - ] - } - ] -} diff --git a/README.md b/README.md index 38235d5..4508e54 100644 --- a/README.md +++ b/README.md @@ -1,25 +1,31 @@
- npm + npm - bundle + bundle - license + license - docs + docs
-[![Carta.png](https://i.postimg.cc/nV6DMXKM/Carta.png)](https://beartocode.github.io/carta/) +
+ + banner + +
-

Carta

-
Modern, lightweight, powerful Markdown Editor.
+
+ +
Carta
+
Swiftly edit and render Markdown, with no overhead.

-๐Ÿ“š Documentation +Documentation ยท GitHub
@@ -28,30 +34,24 @@ # Introduction -> [!NOTE] -> Carta has recently been updated to `v4`, which features numerous major changes. -> -> Follow the [Migration Guide](http://beartocode.github.io/carta/migration) to update your project. - -Carta is a **lightweight**, **fast** and **extensible** Svelte Markdown editor and viewer. It is powered by [unified](https://github.com/unifiedjs/unified), [remark](https://github.com/remarkjs/remark) and [rehype](https://github.com/rehypejs/rehype). Check out the [examples](http://beartocode.github.io/carta/examples) to see it in action. -Differently from most editors, Carta does not include a code editor, but it is _just_ a textarea with syntax highlighting, shortcuts and more. +Carta is a **lightweight**, **fast** and **extensible** Svelte Markdown editor and viewer, based on [Marked](https://github.com/markedjs/marked). Check out the [examples](http://beartocode.github.io/carta/examples) to see it in action. +Differently from most editors, Carta includes neither ProseMirror nor CodeMirror, allowing for an extremely small bundle size and fast loading time. ## Features -- ๐ŸŒˆ Markdown syntax highlighting ([Shiki](https://shiki.style/)); -- ๐Ÿ› ๏ธ Toolbar (extensible); -- โŒจ๏ธ Keyboard **shortcuts** (extensible); -- ๐Ÿ“ฆ Supports **[150+ plugins](https://github.com/remarkjs/remark/blob/main/doc/plugins.md#list-of-plugins)** thanks to remark; -- ๐Ÿ”€ Scroll sync; -- โœ… Accessibility friendly; -- ๐Ÿ–ฅ๏ธ **SSR** compatible; -- โš—๏ธ **KaTeX** support (plugin); -- ๐Ÿ”จ **Slash** commands (plugin); -- ๐Ÿ˜„ **Emojis**, with included search (plugin); -- โœ๏ธ **TikZ** support (plugin); -- ๐Ÿ“‚ **Attachment** support (plugin); -- โš“ **Anchor** links in headings (plugin); -- ๐ŸŒˆ Code blocks **syntax highlighting** (plugin). +- Keyboard **shortcuts** (extensible); +- Toolbar (extensible); +- Markdown syntax highlighting; +- Scroll sync; +- Accessibility friendly; +- **SSR** compatible; +- **Katex** support (plugin); +- **Slash** commands (plugin); +- **Emojis**, with included search (plugin); +- **Tikz** support (plugin); +- **Attachment** support (plugin); +- **Anchor** links in headings; +- Code blocks **syntax highlighting** (plugin). ## Packages @@ -80,7 +80,6 @@ Differently from most editors, Carta does not include a code editor, but it is _ > [!WARNING] > Sanitization is not dealt with by Carta. You need to provide a `sanitizer` in the options. > Common sanitizers are [isomorphic-dompurify](https://www.npmjs.com/package/isomorphic-dompurify) (suggested) and [sanitize-html](https://www.npmjs.com/package/sanitize-html). -> Checkout the documentation for an example. ## Installation @@ -100,9 +99,11 @@ npm i @cartamd/plugin-name ```svelte - + ``` diff --git a/docs/package.json b/docs/package.json index 7a24ff5..c19d1a2 100644 --- a/docs/package.json +++ b/docs/package.json @@ -47,8 +47,8 @@ "clsx": "^2.0.0", "cmdk-sv": "^0.0.6", "flexsearch": "0.7.21", - "iconify-icon": "^2.0.0", - "katex": "^0.16.10", + "katex": "^0.16.7", + "radix-icons-svelte": "^1.2.1", "tailwind-merge": "^2.0.0" } } diff --git a/docs/src/lib/components/code/Code.svelte b/docs/src/lib/components/code/Code.svelte index 8be7d1f..f0b289b 100644 --- a/docs/src/lib/components/code/Code.svelte +++ b/docs/src/lib/components/code/Code.svelte @@ -1,4 +1,6 @@ @@ -11,10 +13,10 @@ navigator.clipboard.writeText(elem.innerText); }} class=" - absolute right-4 top-[min(50%_,_32px)] aspect-square -translate-y-1/2 transform - rounded hover:bg-neutral-800 hover:text-neutral-300 active:text-sky-300 + absolute right-4 top-[min(50%_,_32px)] -translate-y-1/2 transform + rounded p-2 hover:bg-neutral-800 hover:text-neutral-300 active:text-sky-300 " > - + diff --git a/docs/src/lib/components/header-tracker/HeaderTracker.svelte b/docs/src/lib/components/header-tracker/HeaderTracker.svelte index d584c97..f5a6b1d 100644 --- a/docs/src/lib/components/header-tracker/HeaderTracker.svelte +++ b/docs/src/lib/components/header-tracker/HeaderTracker.svelte @@ -1,7 +1,5 @@ - { - throttledHighlightHeader(); - debouncedHighlightHeader(); // So it is called at the end of the scroll event - }} -/> +
{#each headers as header, i} {@const margin = Number(header.tagName.split('')[1]) - 1} - {#key selectedHeaderIndex} - {#if header.children[0] instanceof HTMLAnchorElement && header.children[0].href} + {@const nextHeader = headers[i + 1]} + {#if header.children[0] instanceof HTMLAnchorElement && header.children[0].href} + {#key scrollY} {header.innerText} - {/if} - {/key} + {/key} + {/if} {/each}
diff --git a/docs/src/lib/components/link/PluginLink.svelte b/docs/src/lib/components/link/PluginLink.svelte index 8318e91..90a884b 100644 --- a/docs/src/lib/components/link/PluginLink.svelte +++ b/docs/src/lib/components/link/PluginLink.svelte @@ -1,16 +1,18 @@ - diff --git a/docs/src/routes/+layout.ts b/docs/src/routes/+layout.ts index a4c5a95..189f71e 100644 --- a/docs/src/routes/+layout.ts +++ b/docs/src/routes/+layout.ts @@ -1,3 +1 @@ -import 'iconify-icon'; // Register iconify web components - export const prerender = true; diff --git a/docs/src/routes/[...slug]/+page.svelte b/docs/src/routes/[...slug]/+page.svelte index 449ea7b..a0df694 100644 --- a/docs/src/routes/[...slug]/+page.svelte +++ b/docs/src/routes/[...slug]/+page.svelte @@ -2,10 +2,10 @@ import type { PageData } from './$types'; import { onMount, type SvelteComponent } from 'svelte'; import { page } from '$app/stores'; - import { base } from '$app/paths'; import '$lib/styles/markdown.scss'; import '$lib/styles/coldark.scss'; + import { base } from '$app/paths'; export let data: PageData; diff --git a/packages/carta-md/README.md b/packages/carta-md/README.md index 2b4495b..aadc55b 100644 --- a/packages/carta-md/README.md +++ b/packages/carta-md/README.md @@ -1,25 +1,31 @@ -[![Carta.png](https://i.postimg.cc/nV6DMXKM/Carta.png)](https://beartocode.github.io/carta/) + -

Carta

-
Modern, lightweight, powerful Markdown Editor.
+
+ +
Carta
+
Swiftly edit and render Markdown, with no overhead.

@@ -28,81 +34,38 @@ # Introduction -> **NOTE**: -> Carta has recently been updated to `v4`, which features numerous major changes. -> -> Follow the [Migration Guide](http://beartocode.github.io/carta/migration) to update your project. - -Carta is a **lightweight**, **fast** and **extensible** Svelte Markdown editor and viewer. It is powered by [unified](https://github.com/unifiedjs/unified), [remark](https://github.com/remarkjs/remark) and [rehype](https://github.com/rehypejs/rehype). Check out the [examples](http://beartocode.github.io/carta/examples) to see it in action. -Differently from most editors, Carta does not include a code editor, but it is _just_ a textarea with syntax highlighting, shortcuts and more. +Carta is a **lightweight**, **fast** and **extensible** Svelte Markdown editor and viewer, based on [Marked](https://github.com/markedjs/marked). Check out the [examples](http://beartocode.github.io/carta/examples) to see it in action. +Differently from most editors, Carta includes neither ProseMirror nor CodeMirror, allowing for an extremely small bundle size and fast loading time. ## Features -- ๐ŸŒˆ Markdown syntax highlighting ([Shiki](https://shiki.style/)); -- ๐Ÿ› ๏ธ Toolbar (extensible); -- โŒจ๏ธ Keyboard **shortcuts** (extensible); -- ๐Ÿ“ฆ Supports **[150+ plugins](https://github.com/remarkjs/remark/blob/main/doc/plugins.md#list-of-plugins)** thanks to remark; -- ๐Ÿ”€ Scroll sync; -- โœ… Accessibility friendly; -- ๐Ÿ–ฅ๏ธ **SSR** compatible; -- โš—๏ธ **KaTeX** support (plugin); -- ๐Ÿ”จ **Slash** commands (plugin); -- ๐Ÿ˜„ **Emojis**, with included search (plugin); -- โœ๏ธ **TikZ** support (plugin); -- ๐Ÿ“‚ **Attachment** support (plugin); -- โš“ **Anchor** links in headings (plugin); -- ๐ŸŒˆ Code blocks **syntax highlighting** (plugin). - -## Packages - -| Package | Status | Docs | -| ----------------------------------------------------------------------------- | ----------------------------------------------------------------------------- | ---------------------------------------------------------------------------- | -| [carta-md](https://www.npmjs.com/package/carta-md) | ![carta-md](https://img.shields.io/npm/v/carta-md) | [/](https://beartocode.github.io/carta/introduction) | -| [plugin-math](https://www.npmjs.com/package/@cartamd/plugin-math) | ![plugin-math](https://img.shields.io/npm/v/@cartamd/plugin-math) | [/plugins/math](https://beartocode.github.io/carta/plugins/math) | -| [plugin-code](https://www.npmjs.com/package/@cartamd/plugin-code) | ![plugin-code](https://img.shields.io/npm/v/@cartamd/plugin-code) | [/plugins/code](https://beartocode.github.io/carta/plugins/code) | -| [plugin-emoji](https://www.npmjs.com/package/@cartamd/plugin-emoji) | ![plugin-emoji](https://img.shields.io/npm/v/@cartamd/plugin-emoji) | [/plugins/emoji](https://beartocode.github.io/carta/plugins/emoji) | -| [plugin-slash](https://www.npmjs.com/package/@cartamd/plugin-slash) | ![plugin-slash](https://img.shields.io/npm/v/@cartamd/plugin-slash) | [/plugins/slash](https://beartocode.github.io/carta/plugins/slash) | -| [plugin-tikz](https://www.npmjs.com/package/@cartamd/plugin-tikz) | ![plugin-tikz](https://img.shields.io/npm/v/@cartamd/plugin-tikz) | [/plugins/tikz](https://beartocode.github.io/carta/plugins/tikz) | -| [plugin-attachment](https://www.npmjs.com/package/@cartamd/plugin-attachment) | ![plugin-attachment](https://img.shields.io/npm/v/@cartamd/plugin-attachment) | [/plugins/attachment](https://beartocode.github.io/carta/plugins/attachment) | -| [plugin-anchor](https://www.npmjs.com/package/@cartamd/plugin-anchor) | ![plugin-anchor](https://img.shields.io/npm/v/@cartamd/plugin-anchor) | [/plugins/anchor](https://beartocode.github.io/carta/plugins/anchor) | - -## Community plugins - -| Plugin | Description | -| ----------------------------------------------------------------------------- | ---------------------------------- | -| [carta-plugin-video](https://github.com/maisonsmd/carta-plugin-video) | Render online videos | -| [carta-plugin-imsize](https://github.com/maisonsmd/carta-plugin-imsize) | Render images in specific sizes | -| [carta-plugin-subscript](https://github.com/maisonsmd/carta-plugin-subscript) | Render subscripts and superscripts | -| [carta-plugin-ins-del](https://github.com/maisonsmd/carta-plugin-ins-del) | `` and `` tags support | +- Keyboard **shortcuts** (extensible); +- Toolbar (extensible); +- Markdown syntax highlighting; +- Scroll sync; +- **SSR** compatible; +- **Katex** support (plugin); +- **Slash** commands (plugin); +- **Emojis**, with included search (plugin); +- **Tikz** support(plugin); +- **Attachment** support(plugin); +- Code blocks **syntax highlighting** (plugin). # Getting started -> **WARNING** +> **Warning** > Sanitization is not dealt with by Carta. You need to provide a `sanitizer` in the options. > Common sanitizers are [isomorphic-dompurify](https://www.npmjs.com/package/isomorphic-dompurify) (suggested) and [sanitize-html](https://www.npmjs.com/package/sanitize-html). -> Checkout the documentation for an example. - -## Installation - -Core package: - -``` -npm i carta-md -``` - -Plugins: - -``` -npm i @cartamd/plugin-name -``` ## Basic configuration ```svelte - + ``` @@ -137,33 +99,7 @@ For the full documentation, examples, guides and more checkout the [website](htt - [Slash](https://beartocode.github.io/carta/plugins/slash) - [TikZ](https://beartocode.github.io/carta/plugins/tikz) - [Attachment](https://beartocode.github.io/carta/plugins/attachment) - - [Anchor](https://beartocode.github.io/carta/plugins/anchor) - API: - [Utilities](https://beartocode.github.io/carta/api/utilities) - [Core](https://beartocode.github.io/carta/api/core) - [Extension](https://beartocode.github.io/carta/api/extension) - -# Contributing & Development - -Every contribution is well accepted. If you have a feature request you can open a new issue. - -This package uses a [pnpm workspace](https://pnpm.io/workspaces), so pnpm is required to download and put everything together properly. - -### Committing - -This repository is [commitizen](https://github.com/commitizen/cz-cli) friendly. To commit use: - -``` -npm run commit -# or, if you have commitizen installed globally -git cz -``` - -### Running docs - -If you want to preview the docs: - -``` -cd docs -npm run dev -``` diff --git a/packages/carta-md/package.json b/packages/carta-md/package.json index bc074ef..b24e85d 100644 --- a/packages/carta-md/package.json +++ b/packages/carta-md/package.json @@ -14,7 +14,10 @@ "svelte": "./dist/index.js", "import": "./dist/index.js" }, - "./default.css": "./dist/default.css" + "./default.css": "./dist/default.css", + "./default-theme.css": "./dist/default.css", + "./light.css": "./dist/light.css", + "./dark.css": "./dist/dark.css" }, "version": "3.0.0", "scripts": { @@ -35,12 +38,8 @@ }, "type": "module", "dependencies": { - "rehype-stringify": "^10.0.0", - "remark-gfm": "^4.0.0", - "remark-parse": "^11.0.0", - "remark-rehype": "^11.1.0", - "shiki": "^1.4.0", - "unified": "^11.0.4" + "@speed-highlight/core": "1.2.2", + "marked": "^9.1.5" }, "peerDependencies": { "svelte": "^3.54.0 || ^4.0.0" diff --git a/packages/carta-md/src/lib/MarkdownEditor.svelte b/packages/carta-md/src/lib/CartaEditor.svelte similarity index 90% rename from packages/carta-md/src/lib/MarkdownEditor.svelte rename to packages/carta-md/src/lib/CartaEditor.svelte index 8e8cb33..9dc20e8 100644 --- a/packages/carta-md/src/lib/MarkdownEditor.svelte +++ b/packages/carta-md/src/lib/CartaEditor.svelte @@ -1,11 +1,11 @@ @@ -92,14 +56,11 @@ bind:this={elem} >
- + tabindex="-1" + aria-hidden="true">{@html highlighted}