我没有和古腾堡玩太多,但我很可能需要在将来解决类似的问题,
我要做的就是直接编辑函数,以便快速调试。
const rawTransforms = getRawTransformations();
const phrasingContentSchema = getPhrasingContentSchema( \'paste\' );
const blockContentSchema = getBlockContentSchema( rawTransforms, phrasingContentSchema, true );
const blocks = compact( flatMap( pieces, ( piece ) => {
...
// console.log( "Piece - deepFilterHTML" )
// console.log( piece );
piece = deepFilterHTML( piece, filters, blockContentSchema );
// console.log( "Piece - removeInvalidHTML" )
// console.log( piece );
piece = removeInvalidHTML( piece, schema );
// console.log( "Piece - normaliseBlocks" )
// console.log( piece );
piece = normaliseBlocks( piece );
// console.log( "Piece - deepFilterHTML" )
// console.log( piece );
piece = deepFilterHTML( piece, [
htmlFormattingRemover,
brRemover,
emptyParagraphRemover,
], blockContentSchema );
...
return htmlToBlocks( { html: piece, rawTransforms } );
} ) );
我敢肯定,doc粘贴与HTML的不同之处在于“cleanNodeList”函数,它有4个参数:nodeList、doc、schema、inline
这个schema 参数是“可以随提供的节点变化的函数数组”
我想知道当你的html/doc被过滤时,与未过滤时相比,这会产生什么结果
然后我想知道如何更改该参数,因为我认为当它被“过滤”时,它将处于默认状态。
这就是默认情况下运行的代码的长度:
cleanNodeList(node.childNodes, doc, schema, inline); // For inline mode, insert a line break when unwrapping nodes that
// are not phrasing content.
if (inline && !isPhrasingContent(node) && node.nextElementSibling) {
Object(external_this_wp_dom_["insertAfter"])(doc.createElement(\'br\'), node);
}
Object(external_this_wp_dom_["unwrap"])(node);
external_this_wp_dom_["unwrap"] 运行默认筛选时,从外观来看,最有可能依赖于phrasing\\u content\\u phrasingContentSchema
<span>
标记根本没有定义。
var phrasing_content_phrasingContentSchema = {
strong: {},
em: {},
s: {},
del: {},
ins: {},
a: {
attributes: [\'href\', \'target\', \'rel\']
},
code: {},
abbr: {
attributes: [\'title\']
},
sub: {},
sup: {},
br: {},
\'#text\': {}
}
希望这会有所帮助。