fabric
Version:
Object model for HTML5 canvas, and SVG-to-canvas parser. Backed by jsdom and node-canvas.
3 lines • 1.27 kB
JavaScript
import{reNewline as e}from"../../constants.min.mjs";import{graphemeSplit as t}from"../lang_string.min.mjs";import{cloneStyles as n}from"../internals/cloneStyles.min.mjs";const r=(e,t,n=!1)=>e.fill!==t.fill||e.stroke!==t.stroke||e.strokeWidth!==t.strokeWidth||e.fontSize!==t.fontSize||e.fontFamily!==t.fontFamily||e.fontWeight!==t.fontWeight||e.fontStyle!==t.fontStyle||e.textDecorationThickness!==t.textDecorationThickness||e.textDecorationColor!==t.textDecorationColor||e.textBackgroundColor!==t.textBackgroundColor||e.deltaY!==t.deltaY||n&&(e.overline!==t.overline||e.underline!==t.underline||e.linethrough!==t.linethrough),i=(e,i)=>{let a=i.split(`
`),o=[],s=-1,c={};e=n(e);for(let n=0;n<a.length;n++){let i=t(a[n]);if(e[n])for(let t=0;t<i.length;t++){s++;let i=e[n][t];i&&Object.keys(i).length>0&&(r(c,i,!0)?o.push({start:s,end:s+1,style:i}):o[o.length-1].end++),c=i||{}}else s+=i.length,c={}}return o},a=(r,i)=>{if(!Array.isArray(r))return n(r);let a=i.split(e),o={},s=-1,c=0;for(let e=0;e<a.length;e++){let n=t(a[e]);for(let t=0;t<n.length;t++)s++,r[c]&&r[c].start<=s&&s<r[c].end&&(o[e]=o[e]||{},o[e][t]={...r[c].style},s===r[c].end-1&&c++)}return o};export{r as hasStyleChanged,a as stylesFromArray,i as stylesToArray};
//# sourceMappingURL=textStyles.min.mjs.map