@pixldocs/canvas-renderer 0.5.37 → 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 CHANGED
@@ -12072,11 +12072,94 @@ 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.37";
12075
+ const PACKAGE_VERSION = "0.5.39";
12076
+ let __underlineFixInstalled = false;
12077
+ function installUnderlineFix(fab) {
12078
+ var _a;
12079
+ if (__underlineFixInstalled) return;
12080
+ const TextProto = (_a = fab.Text) == null ? void 0 : _a.prototype;
12081
+ if (!TextProto || typeof TextProto._renderTextDecoration !== "function") return;
12082
+ const original = TextProto._renderTextDecoration;
12083
+ TextProto._renderTextDecoration = function patchedRenderTextDecoration(ctx, type) {
12084
+ try {
12085
+ const hasOwn = !!this[type];
12086
+ const hasStyled = typeof this.styleHas === "function" && this.styleHas(type);
12087
+ if (!hasOwn && !hasStyled) return;
12088
+ const lines = this._textLines;
12089
+ const offsets = this.offsets;
12090
+ if (!Array.isArray(lines) || !offsets) {
12091
+ return original.call(this, ctx, type);
12092
+ }
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 {
12146
+ }
12147
+ }
12148
+ } catch {
12149
+ try {
12150
+ return original.call(this, ctx, type);
12151
+ } catch {
12152
+ }
12153
+ }
12154
+ };
12155
+ __underlineFixInstalled = true;
12156
+ console.log(`[canvas-renderer] underline-fix monkey patch installed (v${PACKAGE_VERSION})`);
12157
+ }
12076
12158
  class PixldocsRenderer {
12077
12159
  constructor(config) {
12078
12160
  __publicField(this, "config");
12079
12161
  this.config = config;
12162
+ installUnderlineFix(fabric__namespace);
12080
12163
  try {
12081
12164
  console.log(`[canvas-renderer] PixldocsRenderer v${PACKAGE_VERSION} initialized`);
12082
12165
  } catch {