editorjs html
Nested List Support
Утилита для анализа Editorjs Clean Data в HTML.
parseStrict() и validate() удаляются.Браузер - get /.build/edjshtml.browser.js
Nodejs - get /.build/edjshtml.node.js
Как для браузера, так и для узла - get /.build/edjshtml.js
npm install editorjs-html const edjsParser = edjsHTML ( ) ;
let html = edjsParser . parse ( editorjs_clean_data ) ;
console . log ( html ) ; const edjsHTML = require ( "editorjs-html" ) ;
const edjsParser = edjsHTML ( ) ;
const html = edjsParser . parse ( editorjs_clean_data ) ;
console . log ( html ) ; Смотрите релизы
const edjsParser = edjsHTML ( ) ;
const HTML = edjsParser . parse ( editorjs_data ) ;
// returns array of html strings per block
console . log ( HTML ) ; const edjsParser = edjsHTML ( ) ;
const HTML = edjsParser . parse ( editorjs_data ) ;
// returns an error
if ( HTML instanceof Error ) throw HTML ;
// in case of success, returns an array of strings
console . log ( HTML ) ; const edjsParser = edjsHTML ( ) ;
const blockHTML = edjsParser . parseBlock ( editorjs_data_block ) ;
// returns string of html for this block
console . log ( blockHTML ) ; const edjsParser = edjsHTML ( { } , { strict : true } ) ;
// returns the list of missing parser functions
const blockHTML = edjsParser . parse ( editorjs_data ) ;
console . log ( blockHTML ) ; editorjs-html поддерживает расширение и переопределение функций анализатора для блоков.
// Example Custom or Unrecognised Block
{
type : "custom" ,
data : {
text : "Hello World"
}
} // Parse this block in editorjs-html
function customParser ( block ) {
return `<custom-tag> ${ block . data . text } </custom-tag>` ;
}
const plugins = {
// The keyname must match with the type of block you want to parse with this funcion
custom : customParser
// ... add more or overwrite
}
const edjsParser = edjsHTML ( plugins ) ; Пожалуйста, добавьте проблему или откройте пиар для любых ошибок, просмотра или предложений.
parsers/block-name . Проверьте существующие функции на предложения.pnpm test && pnpm build .tests . Убедитесь, что ваши тесты проходят с соответствующим покрытием. Я хотел бы получить ваши отзывы и любые предложения. Вы также можете сообщить мне, если вам нужна поддержка для дополнительных блоков редактора.
Если вы найдете это полезным, подумайте о том, чтобы дать этому репозиторию звезду. Вы также можете купить мне кофе здесь
MIT Public License
@pavittarx