![Deno 2.2 Improves Dependency Management and Expands Node.js Compatibility](https://cdn.sanity.io/images/cgdhsj6q/production/97774ea8c88cc8f4bed2766c31994ebc38116948-1664x1366.png?w=400&fit=max&auto=format)
Security News
Deno 2.2 Improves Dependency Management and Expands Node.js Compatibility
Deno 2.2 enhances Node.js compatibility, improves dependency management, adds OpenTelemetry support, and expands linting and task automation for developers.
ByteMD is a Markdown editor component built with Svelte. It could also be used in other libraries/frameworks such as React, Vue and Angular.
<script>
and <img onerror>
have been correctly handled by ByteMD. No need to introduce extra DOM sanitize steps.Package | Status | Description |
---|---|---|
bytemd | Svelte/Vanilla JS component | |
@bytemd/react | React component | |
@bytemd/vue | Vue component |
The default entry of NPM package only supports modern browsers. There are two ways to make legacy browsers (IE9+) work:
dist/index.es5.js
)Notice that polyfills are not included, and should be imported manually, see the legacy browser example.
There are two components: Editor
and Viewer
. Editor
is the Markdown editor, as the name suggests; Viewer
is commonly used to display rendered Markdown results without editing.
Before using the component, remember to import CSS file to make styles correct:
import 'bytemd/dist/index.min.css';
<script>
import { Editor, Viewer } from 'bytemd';
import gfm from '@bytemd/plugin-gfm';
let value;
const plugins = [
gfm(),
// Add more plugins here
];
function handleChange(e) {
value = e.detail.value;
}
</script>
<template>
<Editor {value} {plugins} on:change={handleChange} />
</template>
import { Editor, Viewer } from '@bytemd/react';
import gfm from '@bytemd/plugin-gfm';
const plugins = [
gfm(),
// Add more plugins here
];
const App = () => {
const [value, setValue] = useState('');
return (
<Editor
value={value}
plugins={plugins}
onChange={(v) => {
setValue(v);
}}
/>
);
};
<template>
<Editor :value="value" :plugins="plugins" @change="handleChange" />
</template>
<script>
import { Editor, Viewer } from '@bytemd/vue';
import gfm from '@bytemd/plugin-gfm';
const plugins = [
gfm(),
// Add more plugins here
];
export default {
components: { Editor },
data() {
return { value: '', plugins };
},
methods: {
handleChange(v) {
value = v;
},
},
};
</script>
import { Editor, Viewer } from 'bytemd';
import gfm from '@bytemd/plugin-gfm';
const plugins = [
gfm(),
// Add more plugins here
];
const editor = new Editor({
target: document.body, // DOM to render
props: {
value: '',
plugins,
},
});
editor.on('change', (e) => {
editor.$set({ value: e.detail.value });
});
Key | Type | Description |
---|---|---|
value | string (required) | Markdown text |
plugins | BytemdPlugin[] | ByteMD plugin list |
sanitize | (schema: Schema) => Schema | Sanitize strategy |
Editor
component also accepts the options of Viewer
for preview. Besides that, there are some other options:
Key | Type | Description |
---|---|---|
mode | split , tab , auto | Editor display mode |
previewDebounce | number | Debounce time (ms) for preview, default: 300 |
placeholder | string | Editor placeholder |
editorConfig | documentation | CodeMirror editor config |
locale | i18n locale. Available locales could be found at bytemd/lib/locales | |
uploadImages | function | Specify how to upload images |
The default height of ByteMD Editor is 300px
. It could be overrided by CSS:
.bytemd {
height: calc(100vh - 200px);
}
The other styles could also be overrided, see the default style.
There is no built-in styles for the Viewer. You could use third-party markdown themes, for example juejin-markdown-themes and github-markdown-css.
ByteMD uses remark and rehype ecosystem to process Markdown. The complete process is as follows:
It could also be described as a flowchart:
The 2,5,7 steps are designed for user customization via ByteMD plugin API.
Package | Status | Description |
---|---|---|
@bytemd/plugin-breaks | Support breaks | |
@bytemd/plugin-footnotes | Support footnotes | |
@bytemd/plugin-frontmatter | Parse frontmatter | |
@bytemd/plugin-gemoji | Support Gemoji shortcodes | |
@bytemd/plugin-gfm | Support GFM (autolink literals, strikethrough, tables, tasklists) | |
@bytemd/plugin-highlight | Highlight code blocks | |
@bytemd/plugin-highlight-ssr | Highlight code blocks (SSR compatible) | |
@bytemd/plugin-math | Support math formula | |
@bytemd/plugin-math-ssr | Support math formula (SSR compatible) | |
@bytemd/plugin-medium-zoom | Zoom images like Medium | |
@bytemd/plugin-mermaid | Support Mermaid diagram |
TODO
MIT
FAQs
Hackable Markdown Editor and Viewer
The npm package bytemd receives a total of 3,849 weekly downloads. As such, bytemd popularity was classified as popular.
We found that bytemd demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Deno 2.2 enhances Node.js compatibility, improves dependency management, adds OpenTelemetry support, and expands linting and task automation for developers.
Security News
React's CRA deprecation announcement sparked community criticism over framework recommendations, leading to quick updates acknowledging build tools like Vite as valid alternatives.
Security News
Ransomware payment rates hit an all-time low in 2024 as law enforcement crackdowns, stronger defenses, and shifting policies make attacks riskier and less profitable.