fix(table): fix table too wide

fix #9
This commit is contained in:
Julien Calixte
2023-12-18 16:00:48 +01:00
parent cf14f9fddd
commit 69fd413224
2 changed files with 14 additions and 2 deletions

View File

@@ -1,5 +1,6 @@
import markdownItClass from '@toycode/markdown-it-class' import markdownItClass from '@toycode/markdown-it-class'
import MarkdownIt from 'markdown-it' import MarkdownIt from 'markdown-it'
import Renderer from 'markdown-it/lib/renderer'
import blockEmbedPlugin from 'markdown-it-block-embed' import blockEmbedPlugin from 'markdown-it-block-embed'
import markdownItCheckbox from 'markdown-it-checkbox' import markdownItCheckbox from 'markdown-it-checkbox'
import markdownItFootnote from 'markdown-it-footnote' import markdownItFootnote from 'markdown-it-footnote'
@@ -21,8 +22,7 @@ const md = new MarkdownIt({
h3: ['title', 'is-4'], h3: ['title', 'is-4'],
h4: ['title', 'is-5'], h4: ['title', 'is-5'],
h5: ['title', 'is-6'], h5: ['title', 'is-6'],
h6: ['title', 'is-6'], h6: ['title', 'is-6']
table: ['table', 'is-fullwidth']
}) })
.use(html5Media) .use(html5Media)
.use(blockEmbedPlugin, { .use(blockEmbedPlugin, {
@@ -40,6 +40,14 @@ const md = new MarkdownIt({
height: 400 height: 400
}) })
const rules: Renderer.RenderRuleRecord = {
table_close: () => '</table>\n</div>',
table_open: () =>
'<div class="table-wrapper table is-fullwidth is striped">\n<table>\n'
}
md.renderer.rules = { ...md.renderer.rules, ...rules }
export const useMarkdown = (defaultPrefix?: Ref<string> | string) => { export const useMarkdown = (defaultPrefix?: Ref<string> | string) => {
const getRawContent = (content: string) => decodeBase64ToUTF8(content) const getRawContent = (content: string) => decodeBase64ToUTF8(content)
const renderFromUTF8 = (content: string, prefix?: string) => const renderFromUTF8 = (content: string, prefix?: string) =>

View File

@@ -93,6 +93,10 @@ a {
transition: cubic-bezier(0.39, 0.575, 0.565, 1) 0.2s; transition: cubic-bezier(0.39, 0.575, 0.565, 1) 0.2s;
} }
.table-wrapper {
overflow-x: auto;
}
@media print { @media print {
html, html,