@pixldocs/canvas-renderer 0.5.38 → 0.5.39
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +62 -11
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +62 -11
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -12072,7 +12072,7 @@ function PixldocsPreview(props) {
|
|
|
12072
12072
|
!canvasSettled && /* @__PURE__ */ jsxRuntime.jsx("div", { style: { position: "absolute", inset: 0, display: "flex", alignItems: "center", justifyContent: "center", minHeight: 200 }, children: /* @__PURE__ */ jsxRuntime.jsx("div", { style: { color: "#888", fontSize: 14 }, children: "Loading preview..." }) })
|
|
12073
12073
|
] });
|
|
12074
12074
|
}
|
|
12075
|
-
const PACKAGE_VERSION = "0.5.
|
|
12075
|
+
const PACKAGE_VERSION = "0.5.39";
|
|
12076
12076
|
let __underlineFixInstalled = false;
|
|
12077
12077
|
function installUnderlineFix(fab) {
|
|
12078
12078
|
var _a;
|
|
@@ -12084,22 +12084,73 @@ function installUnderlineFix(fab) {
|
|
|
12084
12084
|
try {
|
|
12085
12085
|
const hasOwn = !!this[type];
|
|
12086
12086
|
const hasStyled = typeof this.styleHas === "function" && this.styleHas(type);
|
|
12087
|
-
if (!hasOwn && !hasStyled)
|
|
12087
|
+
if (!hasOwn && !hasStyled) return;
|
|
12088
|
+
const lines = this._textLines;
|
|
12089
|
+
const offsets = this.offsets;
|
|
12090
|
+
if (!Array.isArray(lines) || !offsets) {
|
|
12088
12091
|
return original.call(this, ctx, type);
|
|
12089
12092
|
}
|
|
12090
|
-
const
|
|
12091
|
-
|
|
12092
|
-
|
|
12093
|
-
|
|
12094
|
-
|
|
12095
|
-
|
|
12096
|
-
|
|
12097
|
-
|
|
12093
|
+
const offsetY = offsets[type];
|
|
12094
|
+
const offsetAligner = type === "linethrough" ? 0.5 : type === "overline" ? 1 : 0;
|
|
12095
|
+
const leftOffset = this._getLeftOffset();
|
|
12096
|
+
let topOffset = this._getTopOffset();
|
|
12097
|
+
for (let i = 0, len = lines.length; i < len; i++) {
|
|
12098
|
+
const heightOfLine = this.getHeightOfLine(i);
|
|
12099
|
+
const lineHas = !!this[type] || typeof this.styleHas === "function" && this.styleHas(type, i);
|
|
12100
|
+
if (!lineHas) {
|
|
12101
|
+
topOffset += heightOfLine;
|
|
12102
|
+
continue;
|
|
12103
|
+
}
|
|
12104
|
+
const fillStyle = this.getValueOfPropertyAt(i, 0, "fill");
|
|
12105
|
+
const thickness = this.getValueOfPropertyAt(i, 0, "textDecorationThickness");
|
|
12106
|
+
const charSize = this.getHeightOfChar(i, 0);
|
|
12107
|
+
const dy = this.getValueOfPropertyAt(i, 0, "deltaY") || 0;
|
|
12108
|
+
const finalThickness = this.fontSize * (thickness || 0) / 1e3;
|
|
12109
|
+
if (!fillStyle || !finalThickness) {
|
|
12110
|
+
topOffset += heightOfLine;
|
|
12111
|
+
continue;
|
|
12112
|
+
}
|
|
12113
|
+
if (Array.isArray(this.__lineWidths)) {
|
|
12114
|
+
this.__lineWidths[i] = void 0;
|
|
12115
|
+
}
|
|
12116
|
+
let lineWidth = 0;
|
|
12117
|
+
try {
|
|
12118
|
+
lineWidth = this.getLineWidth(i);
|
|
12119
|
+
} catch {
|
|
12120
|
+
lineWidth = 0;
|
|
12121
|
+
}
|
|
12122
|
+
if (!lineWidth) {
|
|
12123
|
+
topOffset += heightOfLine;
|
|
12124
|
+
continue;
|
|
12125
|
+
}
|
|
12126
|
+
const lineLeftOffset = this._getLineLeftOffset(i);
|
|
12127
|
+
let drawStart = leftOffset + lineLeftOffset;
|
|
12128
|
+
if (this.direction === "rtl") {
|
|
12129
|
+
drawStart = this.width - drawStart - lineWidth;
|
|
12130
|
+
}
|
|
12131
|
+
const maxHeight = heightOfLine / this.lineHeight;
|
|
12132
|
+
const top = topOffset + maxHeight * (1 - this._fontSizeFraction);
|
|
12133
|
+
ctx.fillStyle = fillStyle;
|
|
12134
|
+
ctx.fillRect(
|
|
12135
|
+
drawStart,
|
|
12136
|
+
top + offsetY * charSize + dy - offsetAligner * finalThickness,
|
|
12137
|
+
lineWidth,
|
|
12138
|
+
finalThickness
|
|
12139
|
+
);
|
|
12140
|
+
topOffset += heightOfLine;
|
|
12141
|
+
}
|
|
12142
|
+
if (typeof this._removeShadow === "function") {
|
|
12143
|
+
try {
|
|
12144
|
+
this._removeShadow(ctx);
|
|
12145
|
+
} catch {
|
|
12098
12146
|
}
|
|
12099
12147
|
}
|
|
12100
12148
|
} catch {
|
|
12149
|
+
try {
|
|
12150
|
+
return original.call(this, ctx, type);
|
|
12151
|
+
} catch {
|
|
12152
|
+
}
|
|
12101
12153
|
}
|
|
12102
|
-
return original.call(this, ctx, type);
|
|
12103
12154
|
};
|
|
12104
12155
|
__underlineFixInstalled = true;
|
|
12105
12156
|
console.log(`[canvas-renderer] underline-fix monkey patch installed (v${PACKAGE_VERSION})`);
|