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ブロックのサポートが必要な場合は、お知らせください。
これが役立つ場合は、このリポジトリを星にすることを検討してください。ここでコーヒーを買うこともできます
MITパブリックライセンス
@pavittarx