vxe-pc-ui 4.14.29 → 4.14.30

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.
@@ -59,18 +59,6 @@ function calcContentWH(contList) {
59
59
  contentHeight
60
60
  };
61
61
  }
62
- function calcCanvasWH(contentWidth, opts) {
63
- const {
64
- gap
65
- } = opts;
66
- const [gapX = 0, gapY = 0] = gap ? _xeUtils.default.isArray(gap) ? gap : [gap, gap] : [];
67
- const canvasWidth = contentWidth + _xeUtils.default.toNumber(gapX);
68
- const canvasHeight = contentWidth + _xeUtils.default.toNumber(gapY);
69
- return {
70
- canvasWidth,
71
- canvasHeight
72
- };
73
- }
74
62
  function getFontConf(item, key, opts) {
75
63
  return (item.font ? item.font[key] : '') || (opts.font ? opts.font[key] : '');
76
64
  }
@@ -126,29 +114,41 @@ function getContentUrl(content, defaultFontSize, options) {
126
114
  const ctx = canvasEl.getContext('2d');
127
115
  if (ctx && contList.length) {
128
116
  const {
129
- contentWidth,
130
- contentHeight
131
- } = calcContentWH(contList);
117
+ gap
118
+ } = opts;
119
+ const gapList = gap ? _xeUtils.default.isArray(gap) ? gap : [gap, gap] : [];
120
+ const gapX = _xeUtils.default.toNumber(gapList[0]);
121
+ const gapY = _xeUtils.default.toNumber(gapList[1]);
132
122
  const {
133
- canvasWidth,
134
- canvasHeight
135
- } = calcCanvasWH(contentWidth, opts);
123
+ contentWidth
124
+ } = calcContentWH(contList);
125
+ const canvasWidth = contentWidth * 2 + gapX * 2 + gapX / 2;
126
+ const canvasHeight = contentWidth * 2 + gapY;
136
127
  canvasEl.width = canvasWidth;
137
128
  canvasEl.height = canvasHeight;
138
- const x = (canvasWidth - contentWidth) / 2;
139
- const y = (canvasHeight - contentHeight) / 2;
140
- const drayX = x + contentWidth / 2;
141
- const drayY = y + contentHeight / 2;
129
+ const drayX = gapX / 2;
130
+ const drayY = contentWidth + gapY / 2;
142
131
  ctx.save();
143
132
  ctx.translate(drayX, drayY);
144
133
  ctx.rotate(deg * Math.PI / 180);
145
134
  ctx.translate(-drayX, -drayY);
146
- let offsetHeight = 0;
135
+ let txtOffsetY = 0;
136
+ contList.forEach(item => {
137
+ drayFont(ctx, item, opts);
138
+ const txtX = drayX;
139
+ const txtY = drayY + txtOffsetY;
140
+ ctx.fillText(item.text, txtX, txtY, contentWidth);
141
+ txtOffsetY += item.height;
142
+ });
143
+ const offsetX = gapX;
144
+ const offsetY = gapY + contentWidth;
145
+ txtOffsetY = 0;
147
146
  contList.forEach(item => {
148
- const align = getFontConf(item, 'align', opts);
149
147
  drayFont(ctx, item, opts);
150
- ctx.fillText(item.text, x + (align === 'center' ? (contentWidth - item.width) / 2 : 0), y + (contentHeight + contentHeight) / 2 + offsetHeight, contentWidth);
151
- offsetHeight += item.height;
148
+ const txtX = drayX + offsetX;
149
+ const txtY = drayY + txtOffsetY + offsetY;
150
+ ctx.fillText(item.text, txtX, txtY, contentWidth);
151
+ txtOffsetY += item.height;
152
152
  });
153
153
  ctx.restore();
154
154
  resolve(canvasEl.toDataURL());
@@ -1 +1 @@
1
- Object.defineProperty(exports,"__esModule",{value:!0}),exports.getContentUrl=getContentUrl;var _xeUtils=_interopRequireDefault(require("xe-utils")),_dom=require("../../ui/src/dom");function _interopRequireDefault(t){return t&&t.__esModule?t:{default:t}}let canvasEl=null,fontEl=null,fontCacheMaps={};function getMarkCanvas(){return canvasEl||((canvasEl=document.createElement("canvas")).style.position="absolute",canvasEl.style.top="0",canvasEl.style.left="0"),canvasEl}function removeMarkElement(t){var e;t&&(e=t.parentNode)&&e.removeChild(t)}function calcFontWH(t,e){var n=e+"_"+t;return fontCacheMaps[n]||((fontEl=fontEl||document.createElement("span")).parentNode||document.body.append(fontEl),fontEl.textContent=t,fontEl.style.fontSize=(0,_dom.toCssUnit)(e),t=fontEl.offsetWidth,e=fontEl.offsetHeight,fontCacheMaps[n]={width:t,height:e}),fontCacheMaps[n]}function calcContentWH(t){let e=0,n=0;return t.forEach(t=>{e=Math.max(t.width,e),n=Math.max(t.height,n)}),{contentWidth:e,contentHeight:n}}function calcCanvasWH(t,e){var e=e.gap,[e=0,n=0]=e?_xeUtils.default.isArray(e)?e:[e,e]:[];return{canvasWidth:t+_xeUtils.default.toNumber(e),canvasHeight:t+_xeUtils.default.toNumber(n)}}function getFontConf(t,e,n){return(t.font?t.font[e]:"")||(n.font?n.font[e]:"")}function createMarkFont(t,e,n){var o=n.offset,a=_xeUtils.default.toValueString(t.textContent),n=_xeUtils.default.toNumber(getFontConf(t,"fontSize",n)||e)||14,[e=0,o=0]=o?_xeUtils.default.isArray(o)?o:[o,o]:[],{width:l,height:r}=calcFontWH(a,n);return{text:a,fontSize:n,font:t.font,width:l+_xeUtils.default.toNumber(e),height:r+_xeUtils.default.toNumber(o)}}function drayFont(t,e,n){var o=getFontConf(e,"fontWeight",n);t.fillStyle=""+(getFontConf(e,"color",n)||"rgba(0, 0, 0, 0.15)"),t.font=[getFontConf(e,"fontStyle",n)||"normal","bold"===o||"bolder"===o?"bold":"",(0,_dom.toCssUnit)(e.fontSize),getFontConf(e,"fontFamily",n)||"sans-serif"].join(" ")}function getContentUrl(t,e,n){let c=Object.assign({},n);n=c.rotate;let u=_xeUtils.default.toNumber(n),d=(_xeUtils.default.isArray(t)?t:[t]).map(t=>t?t.textContent?createMarkFont(t,e,c):createMarkFont({textContent:""+t},e,c):createMarkFont({textContent:""},e,c));return removeMarkElement(fontEl),new Promise(t=>{var e=getMarkCanvas();e.parentNode||document.body.append(e);let i=e.getContext("2d");if(i&&d.length){let{contentWidth:n,contentHeight:o}=calcContentWH(d);var{canvasWidth:f,canvasHeight:s}=calcCanvasWH(n,c);e.width=f,e.height=s;let a=(f-n)/2,l=(s-o)/2;f=a+n/2,s=l+o/2;i.save(),i.translate(f,s),i.rotate(u*Math.PI/180),i.translate(-f,-s);let r=0;d.forEach(t=>{var e=getFontConf(t,"align",c);drayFont(i,t,c),i.fillText(t.text,a+("center"===e?(n-t.width)/2:0),l+(o+o)/2+r,n),r+=t.height}),i.restore(),t(e.toDataURL())}else t("");removeMarkElement(e)})}
1
+ Object.defineProperty(exports,"__esModule",{value:!0}),exports.getContentUrl=getContentUrl;var _xeUtils=_interopRequireDefault(require("xe-utils")),_dom=require("../../ui/src/dom");function _interopRequireDefault(t){return t&&t.__esModule?t:{default:t}}let canvasEl=null,fontEl=null,fontCacheMaps={};function getMarkCanvas(){return canvasEl||((canvasEl=document.createElement("canvas")).style.position="absolute",canvasEl.style.top="0",canvasEl.style.left="0"),canvasEl}function removeMarkElement(t){var e;t&&(e=t.parentNode)&&e.removeChild(t)}function calcFontWH(t,e){var n=e+"_"+t;return fontCacheMaps[n]||((fontEl=fontEl||document.createElement("span")).parentNode||document.body.append(fontEl),fontEl.textContent=t,fontEl.style.fontSize=(0,_dom.toCssUnit)(e),t=fontEl.offsetWidth,e=fontEl.offsetHeight,fontCacheMaps[n]={width:t,height:e}),fontCacheMaps[n]}function calcContentWH(t){let e=0,n=0;return t.forEach(t=>{e=Math.max(t.width,e),n=Math.max(t.height,n)}),{contentWidth:e,contentHeight:n}}function getFontConf(t,e,n){return(t.font?t.font[e]:"")||(n.font?n.font[e]:"")}function createMarkFont(t,e,n){var o=n.offset,a=_xeUtils.default.toValueString(t.textContent),n=_xeUtils.default.toNumber(getFontConf(t,"fontSize",n)||e)||14,[e=0,o=0]=o?_xeUtils.default.isArray(o)?o:[o,o]:[],{width:r,height:l}=calcFontWH(a,n);return{text:a,fontSize:n,font:t.font,width:r+_xeUtils.default.toNumber(e),height:l+_xeUtils.default.toNumber(o)}}function drayFont(t,e,n){var o=getFontConf(e,"fontWeight",n);t.fillStyle=""+(getFontConf(e,"color",n)||"rgba(0, 0, 0, 0.15)"),t.font=[getFontConf(e,"fontStyle",n)||"normal","bold"===o||"bolder"===o?"bold":"",(0,_dom.toCssUnit)(e.fontSize),getFontConf(e,"fontFamily",n)||"sans-serif"].join(" ")}function getContentUrl(t,e,n){let h=Object.assign({},n);n=h.rotate;let m=_xeUtils.default.toNumber(n),g=(_xeUtils.default.isArray(t)?t:[t]).map(t=>t?t.textContent?createMarkFont(t,e,h):createMarkFont({textContent:""+t},e,h):createMarkFont({textContent:""},e,h));return removeMarkElement(fontEl),new Promise(t=>{var e=getMarkCanvas();e.parentNode||document.body.append(e);let s=e.getContext("2d");if(s&&g.length){var n=h.gap,n=n?_xeUtils.default.isArray(n)?n:[n,n]:[],u=_xeUtils.default.toNumber(n[0]),n=_xeUtils.default.toNumber(n[1]);let o=calcContentWH(g).contentWidth;var c=2*o+2*u+u/2,d=2*o+n;e.width=c,e.height=d;let a=u/2,r=o+n/2,l=(s.save(),s.translate(a,r),s.rotate(m*Math.PI/180),s.translate(-a,-r),0),f=(g.forEach(t=>{drayFont(s,t,h);var e=a,n=r+l;s.fillText(t.text,e,n,o),l+=t.height}),u),i=n+o;l=0,g.forEach(t=>{drayFont(s,t,h);var e=a+f,n=r+l+i;s.fillText(t.text,e,n,o),l+=t.height}),s.restore(),t(e.toDataURL())}else t("");removeMarkElement(e)})}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vxe-pc-ui",
3
- "version": "4.14.29",
3
+ "version": "4.14.30",
4
4
  "description": "A vue based PC component library",
5
5
  "scripts": {
6
6
  "update": "npm install --legacy-peer-deps",
@@ -71,17 +71,6 @@ function calcContentWH (contList: VxeWatermarkDefines.ContentObj[]) {
71
71
  }
72
72
  }
73
73
 
74
- function calcCanvasWH (contentWidth: number, opts: ContentMarkOptions) {
75
- const { gap } = opts
76
- const [gapX = 0, gapY = 0] = gap ? ((XEUtils.isArray(gap) ? gap : [gap, gap])) : []
77
- const canvasWidth = contentWidth + XEUtils.toNumber(gapX)
78
- const canvasHeight = contentWidth + XEUtils.toNumber(gapY)
79
- return {
80
- canvasWidth,
81
- canvasHeight
82
- }
83
- }
84
-
85
74
  function getFontConf (item: VxeWatermarkDefines.ContentObj | VxeWatermarkDefines.ContentConf, key: keyof VxeWatermarkPropTypes.Font, opts: ContentMarkOptions) {
86
75
  return (item.font ? item.font[key] : '') || (opts.font ? opts.font[key] : '')
87
76
  }
@@ -139,31 +128,46 @@ export function getContentUrl (content: VxeWatermarkPropTypes.Content, defaultFo
139
128
  }
140
129
  const ctx = canvasEl.getContext('2d')
141
130
  if (ctx && contList.length) {
142
- const { contentWidth, contentHeight } = calcContentWH(contList)
143
- const { canvasWidth, canvasHeight } = calcCanvasWH(contentWidth, opts)
131
+ const { gap } = opts
132
+ const gapList = gap ? ((XEUtils.isArray(gap) ? gap : [gap, gap])) : []
133
+ const gapX = XEUtils.toNumber(gapList[0])
134
+ const gapY = XEUtils.toNumber(gapList[1])
135
+
136
+ const { contentWidth } = calcContentWH(contList)
137
+ const canvasWidth = contentWidth * 2 + gapX * 2 + (gapX / 2)
138
+ const canvasHeight = contentWidth * 2 + gapY
144
139
 
145
140
  canvasEl.width = canvasWidth
146
141
  canvasEl.height = canvasHeight
147
142
 
148
- const x = (canvasWidth - contentWidth) / 2
149
- const y = (canvasHeight - contentHeight) / 2
150
-
151
- const drayX = x + (contentWidth / 2)
152
- const drayY = y + (contentHeight / 2)
143
+ const drayX = (gapX / 2)
144
+ const drayY = contentWidth + (gapY / 2)
153
145
 
154
146
  ctx.save()
155
147
  ctx.translate(drayX, drayY)
156
148
  ctx.rotate(deg * Math.PI / 180)
157
149
  ctx.translate(-drayX, -drayY)
158
150
 
159
- let offsetHeight = 0
151
+ let txtOffsetY = 0
160
152
  contList.forEach((item) => {
161
- const align = getFontConf(item, 'align', opts)
162
153
  drayFont(ctx, item, opts)
163
- ctx.fillText(item.text, x + (align === 'center' ? (contentWidth - item.width) / 2 : 0), y + (contentHeight + contentHeight) / 2 + offsetHeight, contentWidth)
164
- offsetHeight += item.height
154
+ const txtX = drayX
155
+ const txtY = drayY + txtOffsetY
156
+ ctx.fillText(item.text, txtX, txtY, contentWidth)
157
+ txtOffsetY += item.height
165
158
  })
166
159
 
160
+ const offsetX = gapX
161
+ const offsetY = gapY + contentWidth
162
+
163
+ txtOffsetY = 0
164
+ contList.forEach((item) => {
165
+ drayFont(ctx, item, opts)
166
+ const txtX = drayX + offsetX
167
+ const txtY = drayY + txtOffsetY + offsetY
168
+ ctx.fillText(item.text, txtX, txtY, contentWidth)
169
+ txtOffsetY += item.height
170
+ })
167
171
  ctx.restore()
168
172
 
169
173
  resolve(canvasEl.toDataURL())
@@ -4136,6 +4136,7 @@ export interface TableInternalData<D = any> {
4136
4136
  sourceDataRowIdData: Record<string, D>
4137
4137
  fullColumnIdData: Record<string, VxeTableDefines.ColumnCacheItem<D>>
4138
4138
  fullColumnFieldData: Record<string, VxeTableDefines.ColumnCacheItem<D>>
4139
+ fullCellHeightMaps: Record<string, Record<string, number>>
4139
4140
 
4140
4141
  // 当前行
4141
4142
  currentRow: D | null