From e61534f1281ecdd7163a8fb51afa0fa6d0c95456 Mon Sep 17 00:00:00 2001 From: Luzefiru Date: Fri, 22 Mar 2024 00:35:56 +0800 Subject: [PATCH] fix(transformer): stop unnecessary calls to list recursor on empty nested items array --- build/edjsHTML.browser.js | 2 +- build/edjsHTML.js | 2 +- build/edjsHTML.node.js | 2 +- src/transforms.ts | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/build/edjsHTML.browser.js b/build/edjsHTML.browser.js index 1bccd1a..fede1f8 100644 --- a/build/edjsHTML.browser.js +++ b/build/edjsHTML.browser.js @@ -1 +1 @@ -var edjsHTML=function(){"use strict";var e=["left","right","center","justify"],t={delimiter:function(){return"
"},header:function(e){var t=e.data;return""+t.text+""},paragraph:function(t){var r=t.data,n=r.alignment||r.align;return void 0!==n&&e.includes(n)?'

'+r.text+"

":"

"+r.text+"

"},list:function(e){var t=e.data,r="unordered"===t.style?"ul":"ol",n=function(e,t){var r=e.map((function(e){if(!e.content&&!e.items)return"
  • "+e+"
  • ";var r="";return e.items&&(r=n(e.items,t)),e.content?"
  • "+e.content+"
  • "+r:void 0}));return"<"+t+">"+r.join("")+""};return n(t.items,r)},image:function(e){var t=e.data,r=t.caption?t.caption:"Image";return''+r+''},quote:function(e){var t=e.data;return"
    "+t.text+"
    - "+t.caption},code:function(e){return"
    "+e.data.code+"
    "},embed:function(e){var t=e.data;switch(t.service){case"vimeo":return'';case"youtube":return'';default:throw new Error("Only Youtube and Vime Embeds are supported right now.")}}};function r(e){return new Error(' The Parser function of type "'+e+'" is not defined. \n\n Define your custom parser functions as: https://github.com/pavittarx/editorjs-html#extend-for-custom-blocks ')}var n=function(e){void 0===e&&(e={});var i=Object.assign({},t,e);return{parse:function(e){return e.blocks.map((function(e){return i[e.type]?i[e.type](e):r(e.type)}))},parseBlock:function(e){return i[e.type]?i[e.type](e):r(e.type)},parseStrict:function(e){var t=e.blocks,o=n(i).validate({blocks:t});if(o.length)throw new Error("Parser Functions missing for blocks: "+o.toString());for(var a=[],u=0;u"},header:function(e){var t=e.data;return""+t.text+""},paragraph:function(t){var r=t.data,n=r.alignment||r.align;return void 0!==n&&e.includes(n)?'

    '+r.text+"

    ":"

    "+r.text+"

    "},list:function(e){var t=e.data,r="unordered"===t.style?"ul":"ol",n=function(e,t){var r=e.map((function(e){if(!e.content&&!e.items)return"
  • "+e+"
  • ";var r="";return e.items.length&&(r=n(e.items,t)),e.content?"
  • "+e.content+" "+r+"
  • ":void 0}));return"<"+t+">"+r.join("")+""};return n(t.items,r)},image:function(e){var t=e.data,r=t.caption?t.caption:"Image";return''+r+''},quote:function(e){var t=e.data;return"
    "+t.text+"
    - "+t.caption},code:function(e){return"
    "+e.data.code+"
    "},embed:function(e){var t=e.data;switch(t.service){case"vimeo":return'';case"youtube":return'';default:throw new Error("Only Youtube and Vime Embeds are supported right now.")}}};function r(e){return new Error(' The Parser function of type "'+e+'" is not defined. \n\n Define your custom parser functions as: https://github.com/pavittarx/editorjs-html#extend-for-custom-blocks ')}var n=function(e){void 0===e&&(e={});var i=Object.assign({},t,e);return{parse:function(e){return e.blocks.map((function(e){return i[e.type]?i[e.type](e):r(e.type)}))},parseBlock:function(e){return i[e.type]?i[e.type](e):r(e.type)},parseStrict:function(e){var t=e.blocks,o=n(i).validate({blocks:t});if(o.length)throw new Error("Parser Functions missing for blocks: "+o.toString());for(var a=[],u=0;u"},header:function(e){var t=e.data;return""+t.text+""},paragraph:function(t){var r=t.data,n=r.alignment||r.align;return void 0!==n&&e.includes(n)?'

    '+r.text+"

    ":"

    "+r.text+"

    "},list:function(e){var t=e.data,r="unordered"===t.style?"ul":"ol",n=function(e,t){var r=e.map((function(e){if(!e.content&&!e.items)return"
  • "+e+"
  • ";var r="";return e.items&&(r=n(e.items,t)),e.content?"
  • "+e.content+"
  • "+r:void 0}));return"<"+t+">"+r.join("")+""};return n(t.items,r)},image:function(e){var t=e.data,r=t.caption?t.caption:"Image";return''+r+''},quote:function(e){var t=e.data;return"
    "+t.text+"
    - "+t.caption},code:function(e){return"
    "+e.data.code+"
    "},embed:function(e){var t=e.data;switch(t.service){case"vimeo":return'';case"youtube":return'';default:throw new Error("Only Youtube and Vime Embeds are supported right now.")}}};function r(e){return new Error(' The Parser function of type "'+e+'" is not defined. \n\n Define your custom parser functions as: https://github.com/pavittarx/editorjs-html#extend-for-custom-blocks ')}var n=function(e){void 0===e&&(e={});var i=Object.assign({},t,e);return{parse:function(e){return e.blocks.map((function(e){return i[e.type]?i[e.type](e):r(e.type)}))},parseBlock:function(e){return i[e.type]?i[e.type](e):r(e.type)},parseStrict:function(e){var t=e.blocks,o=n(i).validate({blocks:t});if(o.length)throw new Error("Parser Functions missing for blocks: "+o.toString());for(var u=[],a=0;a"},header:function(e){var t=e.data;return""+t.text+""},paragraph:function(t){var r=t.data,n=r.alignment||r.align;return void 0!==n&&e.includes(n)?'

    '+r.text+"

    ":"

    "+r.text+"

    "},list:function(e){var t=e.data,r="unordered"===t.style?"ul":"ol",n=function(e,t){var r=e.map((function(e){if(!e.content&&!e.items)return"
  • "+e+"
  • ";var r="";return e.items.length&&(r=n(e.items,t)),e.content?"
  • "+e.content+" "+r+"
  • ":void 0}));return"<"+t+">"+r.join("")+""};return n(t.items,r)},image:function(e){var t=e.data,r=t.caption?t.caption:"Image";return''+r+''},quote:function(e){var t=e.data;return"
    "+t.text+"
    - "+t.caption},code:function(e){return"
    "+e.data.code+"
    "},embed:function(e){var t=e.data;switch(t.service){case"vimeo":return'';case"youtube":return'';default:throw new Error("Only Youtube and Vime Embeds are supported right now.")}}};function r(e){return new Error(' The Parser function of type "'+e+'" is not defined. \n\n Define your custom parser functions as: https://github.com/pavittarx/editorjs-html#extend-for-custom-blocks ')}var n=function(e){void 0===e&&(e={});var i=Object.assign({},t,e);return{parse:function(e){return e.blocks.map((function(e){return i[e.type]?i[e.type](e):r(e.type)}))},parseBlock:function(e){return i[e.type]?i[e.type](e):r(e.type)},parseStrict:function(e){var t=e.blocks,o=n(i).validate({blocks:t});if(o.length)throw new Error("Parser Functions missing for blocks: "+o.toString());for(var u=[],a=0;a"},header:function(e){var t=e.data;return""+t.text+""},paragraph:function(t){var r=t.data,n=r.alignment||r.align;return void 0!==n&&e.includes(n)?'

    '+r.text+"

    ":"

    "+r.text+"

    "},list:function(e){var t=e.data,r="unordered"===t.style?"ul":"ol",n=function(e,t){var r=e.map((function(e){if(!e.content&&!e.items)return"
  • "+e+"
  • ";var r="";return e.items&&(r=n(e.items,t)),e.content?"
  • "+e.content+"
  • "+r:void 0}));return"<"+t+">"+r.join("")+""};return n(t.items,r)},image:function(e){var t=e.data,r=t.caption?t.caption:"Image";return''+r+''},quote:function(e){var t=e.data;return"
    "+t.text+"
    - "+t.caption},code:function(e){return"
    "+e.data.code+"
    "},embed:function(e){var t=e.data;switch(t.service){case"vimeo":return'';case"youtube":return'';default:throw new Error("Only Youtube and Vime Embeds are supported right now.")}}};function r(e){return new Error(' The Parser function of type "'+e+'" is not defined. \n\n Define your custom parser functions as: https://github.com/pavittarx/editorjs-html#extend-for-custom-blocks ')}var n=function(e){void 0===e&&(e={});var i=Object.assign({},t,e);return{parse:function(e){return e.blocks.map((function(e){return i[e.type]?i[e.type](e):r(e.type)}))},parseBlock:function(e){return i[e.type]?i[e.type](e):r(e.type)},parseStrict:function(e){var t=e.blocks,o=n(i).validate({blocks:t});if(o.length)throw new Error("Parser Functions missing for blocks: "+o.toString());for(var a=[],u=0;u"},header:function(e){var t=e.data;return""+t.text+""},paragraph:function(t){var r=t.data,n=r.alignment||r.align;return void 0!==n&&e.includes(n)?'

    '+r.text+"

    ":"

    "+r.text+"

    "},list:function(e){var t=e.data,r="unordered"===t.style?"ul":"ol",n=function(e,t){var r=e.map((function(e){if(!e.content&&!e.items)return"
  • "+e+"
  • ";var r="";return e.items.length&&(r=n(e.items,t)),e.content?"
  • "+e.content+" "+r+"
  • ":void 0}));return"<"+t+">"+r.join("")+""};return n(t.items,r)},image:function(e){var t=e.data,r=t.caption?t.caption:"Image";return''+r+''},quote:function(e){var t=e.data;return"
    "+t.text+"
    - "+t.caption},code:function(e){return"
    "+e.data.code+"
    "},embed:function(e){var t=e.data;switch(t.service){case"vimeo":return'';case"youtube":return'';default:throw new Error("Only Youtube and Vime Embeds are supported right now.")}}};function r(e){return new Error(' The Parser function of type "'+e+'" is not defined. \n\n Define your custom parser functions as: https://github.com/pavittarx/editorjs-html#extend-for-custom-blocks ')}var n=function(e){void 0===e&&(e={});var i=Object.assign({},t,e);return{parse:function(e){return e.blocks.map((function(e){return i[e.type]?i[e.type](e):r(e.type)}))},parseBlock:function(e){return i[e.type]?i[e.type](e):r(e.type)},parseStrict:function(e){var t=e.blocks,o=n(i).validate({blocks:t});if(o.length)throw new Error("Parser Functions missing for blocks: "+o.toString());for(var a=[],u=0;u${item}`; let list = ""; - if (item.items) list = recursor(item.items, listStyle); + if (item.items.length) list = recursor(item.items, listStyle); if (item.content) return `
  • ${item.content} ${list}
  • `; });