editorjs html
Nested List Support
用來解析Editorjs將數據清潔到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 ) ; 請添加問題,或為任何錯誤,審查或建議打開PR。
parsers/block-name中。檢查現有功能以獲取建議。pnpm test && pnpm build ,每個測試都可以正常工作。tests目錄中添加測試。確保您的測試通過適當的覆蓋範圍。 我很想有您的反饋和任何建議。您還可以讓我知道,如果您需要更多的Editorjs塊。
如果您覺得這有用,請考慮將此存儲庫成為一顆星。你也可以在這裡給我買咖啡
麻省理工學院公共許可證
@pavittarx