problem with preview and @diplodoc/transform
Los mantenedores suelen responder en 1 día
Nadie ha tomado este issue todavía.
Evaluación
- Dificultad
- 3/5
- Tiempo estimado
- 1-2 días
- Aptitud para principiantes
- 42/100
- Tipo de issue
- Error
- Claridad
- Bastante claro
- Estado de actividad
- Estancado
- Stack tecnológico
- javascript, markdown, react, typescript
- Área
- developer-experience, frontend
Línea de trabajo
Start with src/editor.tsx and src/SplitModePreview.tsx, then compare docs/how-to-add-preview.md with the @diplodoc/transform full-preset configuration. Reproduce the missing emoji, marked, and text-color output in both the editor preview and standalone browser/server usage. Done means the full preset transforms those features to HTML without requiring unsupported props or an incorrect plugin setup.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
question 1
i want to add preview to the editor and i follow the how-to-add-preview structure :
src/SplitModePreview.tsx
// src/SplitModePreview.tsx
import {useEffect, useMemo, useRef, useState} from 'react';
import debounce from 'lodash/debounce';
import {useThemeValue} from '@gravity-ui/uikit';
import {YfmStaticView} from '@gravity-ui/markdown-editor'; // Adjust path if needed
import transform from '@diplodoc/transform'; // Adjust path if needed
interface SplitModePreviewProps {
plugins?: any[];
getValue: () => string;
allowHTML?: boolean;
breaks?: boolean;
linkify?: boolean;
linkifyTlds?: string[];
needToSanitizeHtml?: boolean;
}
export function SplitModePreview(props: SplitModePreviewProps) {
const {plugins, getValue, allowHTML, breaks, linkify, linkifyTlds, needToSanitizeHtml} = props;
const [html, setHtml] = useState('');
const divRef = useRef<HTMLDivElement>(null);
const theme = useThemeValue();
const render = useMemo(
() =>
debounce(() => {
const res = transform(getValue(), {
allowHTML,
breaks,
plugins,
linkify,
linkifyTlds,
needToSanitizeHtml,
}).result;
console.log(res);
setHtml(res.html);
}, 200),
[getValue, allowHTML, breaks, plugins, linkify, linkifyTlds, needToSanitizeHtml, theme],
);
useEffect(() => {
render();
}, [props, render]);
return <YfmStaticView ref={divRef} html={html} noListReset className="demo-preview" />;
}
and this is my editor :
src/editor.tsx
import React, {useCallback} from 'react'; // ✅ Fix: import useCallback
import {
MarkdownEditorView,
MarkupString,
RenderPreview,
useMarkdownEditor, // ✅ Fix: import props type for renderPreview
} from '@gravity-ui/markdown-editor';
import {SplitModePreview} from './SplitModePreview'; // Adjust the path if needed
export interface EditorProps {
onSubmit: (value: MarkupString) => void;
}
export const Editor: React.FC<EditorProps> = ({onSubmit}) => {
const renderPreview = useCallback<RenderPreview>(
(props) => <SplitModePreview {...props} />,
[],
);
const editor = useMarkdownEditor({
markupConfig: {
renderPreview,
splitMode: 'horizontal',
},
md: {
html: false,
},
experimental:{
directiveSyntax:'enabled'
},
initial: {
splitModeEnabled: true,
toolbarVisible: true,
},
});
React.useEffect(() => {
const submitHandler = () => {
const value = editor.getValue();
onSubmit(value);
};
editor.on('submit', submitHandler);
return () => {
editor.off('submit', submitHandler);
};
}, [editor, onSubmit]);
return <MarkdownEditorView stickyToolbar autofocus editor={editor} />;
};
the preview is working for the YFM preset but not for full preset .
i mean the emoji and marked and text color and ... are not tranfoming to html ,
i think the problem is for props .
marked preview
underline preview
question 2
im trying to transform the YFM without the editor just transform as plugin or module on browser or nodejs server but it has the same problem with @diplodoc/transform its not support the "full" preset options ( emoji and marked and text color and ... ). what the way to do that ?
- Lenguaje dominante
- TypeScript
- Estrellas
- 428
- Forks
- 48
- Merge medio
- 5 d 15 h
- PR fusionados (30 d)
- 47
Preparar el entorno
Este proyecto no incluye contenedor de desarrollo, Dockerfile ni guía de contribución, así que la configuración corre por tu cuenta: empieza por su README y consulta nuestra guía para la primera contribución para los pasos generales.
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de gravity-ui/markdown-editor
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 74/100
gravity-ui/markdown-editor#1452 ·
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
gravity-ui/markdown-editor#1293 ·
Los mantenedores suelen responder en 1 día
-
Markup mode: `colorify` does not detect existing `{color}(...)` wrapper when switching colorsAbierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 75/100
gravity-ui/markdown-editor#1129 ·
Los mantenedores suelen responder en 1 día
-
Dificultad 3/5 1-2 días Aptitud para principiantes 72/100
gravity-ui/markdown-editor#1450 ·
Los mantenedores suelen responder en 1 día
-
enhancement
Dificultad 5/5 Más de una semana Aptitud para principiantes 25/100
gravity-ui/markdown-editor#1331 ·
Los mantenedores suelen responder en 1 día
Todos los issues de gravity-ui/markdown-editor
Issues similares
-
clawsweeper:fix-shape-clear clawsweeper:queueable-fix clawsweeper:source-repro impact:ux-friction issue-rating: 🦞 diamond lobster no-stale P2
Dificultad 2/5 1-3 horas Aptitud para principiantes 68/100
openclaw/openclaw#199885 · 2 comentarios · 1 reacción ·
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 88/100
-
feature needs-triage
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
BoardGamesEmpire/board-games-empire-backend#1306 ·
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 80/100
sequant-io/sequant#1689 ·
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 80/100