@univerjs/docs-drawing 0.25.1 → 1.0.0-alpha.1
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/lib/cjs/index.js +27 -12
- package/lib/es/index.js +27 -13
- package/lib/index.js +27 -13
- package/lib/types/controllers/doc-drawing.controller.d.ts +1 -0
- package/lib/types/index.d.ts +4 -2
- package/lib/umd/index.js +1 -1
- package/package.json +5 -5
package/lib/cjs/index.js
CHANGED
|
@@ -7,7 +7,7 @@ var DocDrawingService = class extends _univerjs_drawing.UnitDrawingService {};
|
|
|
7
7
|
const IDocDrawingService = (0, _univerjs_core.createIdentifier)("univer.doc.plugin.doc-drawing.service");
|
|
8
8
|
|
|
9
9
|
//#endregion
|
|
10
|
-
//#region \0@oxc-project+runtime@0.
|
|
10
|
+
//#region \0@oxc-project+runtime@0.137.0/helpers/esm/decorateParam.js
|
|
11
11
|
function __decorateParam(paramIndex, decorator) {
|
|
12
12
|
return function(target, key) {
|
|
13
13
|
decorator(target, key, paramIndex);
|
|
@@ -15,7 +15,7 @@ function __decorateParam(paramIndex, decorator) {
|
|
|
15
15
|
}
|
|
16
16
|
|
|
17
17
|
//#endregion
|
|
18
|
-
//#region \0@oxc-project+runtime@0.
|
|
18
|
+
//#region \0@oxc-project+runtime@0.137.0/helpers/esm/decorate.js
|
|
19
19
|
function __decorate(decorators, target, key, desc) {
|
|
20
20
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
21
21
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -26,6 +26,19 @@ function __decorate(decorators, target, key, desc) {
|
|
|
26
26
|
//#endregion
|
|
27
27
|
//#region src/controllers/doc-drawing.controller.ts
|
|
28
28
|
const DOCS_DRAWING_PLUGIN = "DOC_DRAWING_PLUGIN";
|
|
29
|
+
function getDocDrawingRenderOrder(order, drawings = {}) {
|
|
30
|
+
return order.map((drawingId, index) => ({
|
|
31
|
+
drawingId,
|
|
32
|
+
index
|
|
33
|
+
})).sort((a, b) => {
|
|
34
|
+
const aBehind = isDocDrawingBehindText(drawings[a.drawingId]);
|
|
35
|
+
if (aBehind !== isDocDrawingBehindText(drawings[b.drawingId])) return aBehind ? -1 : 1;
|
|
36
|
+
return a.index - b.index;
|
|
37
|
+
}).map(({ drawingId }) => drawingId);
|
|
38
|
+
}
|
|
39
|
+
function isDocDrawingBehindText(drawing) {
|
|
40
|
+
return (drawing === null || drawing === void 0 ? void 0 : drawing.layoutType) === _univerjs_core.PositionedObjectLayoutType.WRAP_NONE && drawing.behindDoc === _univerjs_core.BooleanNumber.TRUE;
|
|
41
|
+
}
|
|
29
42
|
let DocDrawingController = class DocDrawingController extends _univerjs_core.Disposable {
|
|
30
43
|
constructor(_docDrawingService, _drawingManagerService, _resourceManagerService, _univerInstanceService) {
|
|
31
44
|
super();
|
|
@@ -98,17 +111,18 @@ let DocDrawingController = class DocDrawingController extends _univerjs_core.Dis
|
|
|
98
111
|
const drawingDataModels = dataModel.getDrawings();
|
|
99
112
|
const drawingOrderModel = dataModel.getDrawingsOrder();
|
|
100
113
|
if (!drawingDataModels || !drawingOrderModel) return false;
|
|
101
|
-
Object.keys(drawingDataModels).forEach((drawingId) => {
|
|
102
|
-
drawingDataModels[drawingId] = { ...drawingDataModels[drawingId] };
|
|
103
|
-
});
|
|
104
114
|
const subDrawings = { [subUnitId]: {
|
|
105
115
|
unitId,
|
|
106
116
|
subUnitId,
|
|
107
117
|
data: drawingDataModels,
|
|
108
118
|
order: drawingOrderModel
|
|
109
119
|
} };
|
|
120
|
+
const renderSubDrawings = { [subUnitId]: {
|
|
121
|
+
...subDrawings[subUnitId],
|
|
122
|
+
order: getDocDrawingRenderOrder(drawingOrderModel, drawingDataModels)
|
|
123
|
+
} };
|
|
110
124
|
this._docDrawingService.registerDrawingData(unitId, subDrawings);
|
|
111
|
-
this._drawingManagerService.registerDrawingData(unitId,
|
|
125
|
+
this._drawingManagerService.registerDrawingData(unitId, renderSubDrawings);
|
|
112
126
|
return true;
|
|
113
127
|
}
|
|
114
128
|
};
|
|
@@ -122,7 +136,7 @@ DocDrawingController = __decorate([
|
|
|
122
136
|
//#endregion
|
|
123
137
|
//#region package.json
|
|
124
138
|
var name = "@univerjs/docs-drawing";
|
|
125
|
-
var version = "0.
|
|
139
|
+
var version = "1.0.0-alpha.1";
|
|
126
140
|
|
|
127
141
|
//#endregion
|
|
128
142
|
//#region src/config/config.ts
|
|
@@ -146,7 +160,7 @@ const configSymbol = Symbol(DOCS_DRAWING_PLUGIN_CONFIG_KEY);
|
|
|
146
160
|
const defaultPluginConfig = {};
|
|
147
161
|
|
|
148
162
|
//#endregion
|
|
149
|
-
//#region \0@oxc-project+runtime@0.
|
|
163
|
+
//#region \0@oxc-project+runtime@0.137.0/helpers/esm/typeof.js
|
|
150
164
|
function _typeof(o) {
|
|
151
165
|
"@babel/helpers - typeof";
|
|
152
166
|
return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o) {
|
|
@@ -157,7 +171,7 @@ function _typeof(o) {
|
|
|
157
171
|
}
|
|
158
172
|
|
|
159
173
|
//#endregion
|
|
160
|
-
//#region \0@oxc-project+runtime@0.
|
|
174
|
+
//#region \0@oxc-project+runtime@0.137.0/helpers/esm/toPrimitive.js
|
|
161
175
|
function toPrimitive(t, r) {
|
|
162
176
|
if ("object" != _typeof(t) || !t) return t;
|
|
163
177
|
var e = t[Symbol.toPrimitive];
|
|
@@ -170,14 +184,14 @@ function toPrimitive(t, r) {
|
|
|
170
184
|
}
|
|
171
185
|
|
|
172
186
|
//#endregion
|
|
173
|
-
//#region \0@oxc-project+runtime@0.
|
|
187
|
+
//#region \0@oxc-project+runtime@0.137.0/helpers/esm/toPropertyKey.js
|
|
174
188
|
function toPropertyKey(t) {
|
|
175
189
|
var i = toPrimitive(t, "string");
|
|
176
190
|
return "symbol" == _typeof(i) ? i : i + "";
|
|
177
191
|
}
|
|
178
192
|
|
|
179
193
|
//#endregion
|
|
180
|
-
//#region \0@oxc-project+runtime@0.
|
|
194
|
+
//#region \0@oxc-project+runtime@0.137.0/helpers/esm/defineProperty.js
|
|
181
195
|
function _defineProperty(e, r, t) {
|
|
182
196
|
return (r = toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
|
|
183
197
|
value: t,
|
|
@@ -228,4 +242,5 @@ Object.defineProperty(exports, 'UniverDocsDrawingPlugin', {
|
|
|
228
242
|
get: function () {
|
|
229
243
|
return UniverDocsDrawingPlugin;
|
|
230
244
|
}
|
|
231
|
-
});
|
|
245
|
+
});
|
|
246
|
+
exports.getDocDrawingRenderOrder = getDocDrawingRenderOrder;
|
package/lib/es/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Disposable, IConfigService, IResourceManagerService, IUniverInstanceService, Inject, Injector, Plugin, UniverInstanceType, createIdentifier, merge, touchDependencies } from "@univerjs/core";
|
|
1
|
+
import { BooleanNumber, Disposable, IConfigService, IResourceManagerService, IUniverInstanceService, Inject, Injector, Plugin, PositionedObjectLayoutType, UniverInstanceType, createIdentifier, merge, touchDependencies } from "@univerjs/core";
|
|
2
2
|
import { IDrawingManagerService, UnitDrawingService } from "@univerjs/drawing";
|
|
3
3
|
|
|
4
4
|
//#region src/services/doc-drawing.service.ts
|
|
@@ -6,7 +6,7 @@ var DocDrawingService = class extends UnitDrawingService {};
|
|
|
6
6
|
const IDocDrawingService = createIdentifier("univer.doc.plugin.doc-drawing.service");
|
|
7
7
|
|
|
8
8
|
//#endregion
|
|
9
|
-
//#region \0@oxc-project+runtime@0.
|
|
9
|
+
//#region \0@oxc-project+runtime@0.137.0/helpers/esm/decorateParam.js
|
|
10
10
|
function __decorateParam(paramIndex, decorator) {
|
|
11
11
|
return function(target, key) {
|
|
12
12
|
decorator(target, key, paramIndex);
|
|
@@ -14,7 +14,7 @@ function __decorateParam(paramIndex, decorator) {
|
|
|
14
14
|
}
|
|
15
15
|
|
|
16
16
|
//#endregion
|
|
17
|
-
//#region \0@oxc-project+runtime@0.
|
|
17
|
+
//#region \0@oxc-project+runtime@0.137.0/helpers/esm/decorate.js
|
|
18
18
|
function __decorate(decorators, target, key, desc) {
|
|
19
19
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
20
20
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -25,6 +25,19 @@ function __decorate(decorators, target, key, desc) {
|
|
|
25
25
|
//#endregion
|
|
26
26
|
//#region src/controllers/doc-drawing.controller.ts
|
|
27
27
|
const DOCS_DRAWING_PLUGIN = "DOC_DRAWING_PLUGIN";
|
|
28
|
+
function getDocDrawingRenderOrder(order, drawings = {}) {
|
|
29
|
+
return order.map((drawingId, index) => ({
|
|
30
|
+
drawingId,
|
|
31
|
+
index
|
|
32
|
+
})).sort((a, b) => {
|
|
33
|
+
const aBehind = isDocDrawingBehindText(drawings[a.drawingId]);
|
|
34
|
+
if (aBehind !== isDocDrawingBehindText(drawings[b.drawingId])) return aBehind ? -1 : 1;
|
|
35
|
+
return a.index - b.index;
|
|
36
|
+
}).map(({ drawingId }) => drawingId);
|
|
37
|
+
}
|
|
38
|
+
function isDocDrawingBehindText(drawing) {
|
|
39
|
+
return (drawing === null || drawing === void 0 ? void 0 : drawing.layoutType) === PositionedObjectLayoutType.WRAP_NONE && drawing.behindDoc === BooleanNumber.TRUE;
|
|
40
|
+
}
|
|
28
41
|
let DocDrawingController = class DocDrawingController extends Disposable {
|
|
29
42
|
constructor(_docDrawingService, _drawingManagerService, _resourceManagerService, _univerInstanceService) {
|
|
30
43
|
super();
|
|
@@ -97,17 +110,18 @@ let DocDrawingController = class DocDrawingController extends Disposable {
|
|
|
97
110
|
const drawingDataModels = dataModel.getDrawings();
|
|
98
111
|
const drawingOrderModel = dataModel.getDrawingsOrder();
|
|
99
112
|
if (!drawingDataModels || !drawingOrderModel) return false;
|
|
100
|
-
Object.keys(drawingDataModels).forEach((drawingId) => {
|
|
101
|
-
drawingDataModels[drawingId] = { ...drawingDataModels[drawingId] };
|
|
102
|
-
});
|
|
103
113
|
const subDrawings = { [subUnitId]: {
|
|
104
114
|
unitId,
|
|
105
115
|
subUnitId,
|
|
106
116
|
data: drawingDataModels,
|
|
107
117
|
order: drawingOrderModel
|
|
108
118
|
} };
|
|
119
|
+
const renderSubDrawings = { [subUnitId]: {
|
|
120
|
+
...subDrawings[subUnitId],
|
|
121
|
+
order: getDocDrawingRenderOrder(drawingOrderModel, drawingDataModels)
|
|
122
|
+
} };
|
|
109
123
|
this._docDrawingService.registerDrawingData(unitId, subDrawings);
|
|
110
|
-
this._drawingManagerService.registerDrawingData(unitId,
|
|
124
|
+
this._drawingManagerService.registerDrawingData(unitId, renderSubDrawings);
|
|
111
125
|
return true;
|
|
112
126
|
}
|
|
113
127
|
};
|
|
@@ -121,7 +135,7 @@ DocDrawingController = __decorate([
|
|
|
121
135
|
//#endregion
|
|
122
136
|
//#region package.json
|
|
123
137
|
var name = "@univerjs/docs-drawing";
|
|
124
|
-
var version = "0.
|
|
138
|
+
var version = "1.0.0-alpha.1";
|
|
125
139
|
|
|
126
140
|
//#endregion
|
|
127
141
|
//#region src/config/config.ts
|
|
@@ -145,7 +159,7 @@ const configSymbol = Symbol(DOCS_DRAWING_PLUGIN_CONFIG_KEY);
|
|
|
145
159
|
const defaultPluginConfig = {};
|
|
146
160
|
|
|
147
161
|
//#endregion
|
|
148
|
-
//#region \0@oxc-project+runtime@0.
|
|
162
|
+
//#region \0@oxc-project+runtime@0.137.0/helpers/esm/typeof.js
|
|
149
163
|
function _typeof(o) {
|
|
150
164
|
"@babel/helpers - typeof";
|
|
151
165
|
return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o) {
|
|
@@ -156,7 +170,7 @@ function _typeof(o) {
|
|
|
156
170
|
}
|
|
157
171
|
|
|
158
172
|
//#endregion
|
|
159
|
-
//#region \0@oxc-project+runtime@0.
|
|
173
|
+
//#region \0@oxc-project+runtime@0.137.0/helpers/esm/toPrimitive.js
|
|
160
174
|
function toPrimitive(t, r) {
|
|
161
175
|
if ("object" != _typeof(t) || !t) return t;
|
|
162
176
|
var e = t[Symbol.toPrimitive];
|
|
@@ -169,14 +183,14 @@ function toPrimitive(t, r) {
|
|
|
169
183
|
}
|
|
170
184
|
|
|
171
185
|
//#endregion
|
|
172
|
-
//#region \0@oxc-project+runtime@0.
|
|
186
|
+
//#region \0@oxc-project+runtime@0.137.0/helpers/esm/toPropertyKey.js
|
|
173
187
|
function toPropertyKey(t) {
|
|
174
188
|
var i = toPrimitive(t, "string");
|
|
175
189
|
return "symbol" == _typeof(i) ? i : i + "";
|
|
176
190
|
}
|
|
177
191
|
|
|
178
192
|
//#endregion
|
|
179
|
-
//#region \0@oxc-project+runtime@0.
|
|
193
|
+
//#region \0@oxc-project+runtime@0.137.0/helpers/esm/defineProperty.js
|
|
180
194
|
function _defineProperty(e, r, t) {
|
|
181
195
|
return (r = toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
|
|
182
196
|
value: t,
|
|
@@ -213,4 +227,4 @@ _defineProperty(UniverDocsDrawingPlugin, "type", UniverInstanceType.UNIVER_DOC);
|
|
|
213
227
|
UniverDocsDrawingPlugin = __decorate([__decorateParam(1, Inject(Injector)), __decorateParam(2, IConfigService)], UniverDocsDrawingPlugin);
|
|
214
228
|
|
|
215
229
|
//#endregion
|
|
216
|
-
export { DOCS_DRAWING_PLUGIN, DocDrawingController, DocDrawingService, IDocDrawingService, UniverDocsDrawingPlugin };
|
|
230
|
+
export { DOCS_DRAWING_PLUGIN, DocDrawingController, DocDrawingService, IDocDrawingService, UniverDocsDrawingPlugin, getDocDrawingRenderOrder };
|
package/lib/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Disposable, IConfigService, IResourceManagerService, IUniverInstanceService, Inject, Injector, Plugin, UniverInstanceType, createIdentifier, merge, touchDependencies } from "@univerjs/core";
|
|
1
|
+
import { BooleanNumber, Disposable, IConfigService, IResourceManagerService, IUniverInstanceService, Inject, Injector, Plugin, PositionedObjectLayoutType, UniverInstanceType, createIdentifier, merge, touchDependencies } from "@univerjs/core";
|
|
2
2
|
import { IDrawingManagerService, UnitDrawingService } from "@univerjs/drawing";
|
|
3
3
|
|
|
4
4
|
//#region src/services/doc-drawing.service.ts
|
|
@@ -6,7 +6,7 @@ var DocDrawingService = class extends UnitDrawingService {};
|
|
|
6
6
|
const IDocDrawingService = createIdentifier("univer.doc.plugin.doc-drawing.service");
|
|
7
7
|
|
|
8
8
|
//#endregion
|
|
9
|
-
//#region \0@oxc-project+runtime@0.
|
|
9
|
+
//#region \0@oxc-project+runtime@0.137.0/helpers/esm/decorateParam.js
|
|
10
10
|
function __decorateParam(paramIndex, decorator) {
|
|
11
11
|
return function(target, key) {
|
|
12
12
|
decorator(target, key, paramIndex);
|
|
@@ -14,7 +14,7 @@ function __decorateParam(paramIndex, decorator) {
|
|
|
14
14
|
}
|
|
15
15
|
|
|
16
16
|
//#endregion
|
|
17
|
-
//#region \0@oxc-project+runtime@0.
|
|
17
|
+
//#region \0@oxc-project+runtime@0.137.0/helpers/esm/decorate.js
|
|
18
18
|
function __decorate(decorators, target, key, desc) {
|
|
19
19
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
20
20
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -25,6 +25,19 @@ function __decorate(decorators, target, key, desc) {
|
|
|
25
25
|
//#endregion
|
|
26
26
|
//#region src/controllers/doc-drawing.controller.ts
|
|
27
27
|
const DOCS_DRAWING_PLUGIN = "DOC_DRAWING_PLUGIN";
|
|
28
|
+
function getDocDrawingRenderOrder(order, drawings = {}) {
|
|
29
|
+
return order.map((drawingId, index) => ({
|
|
30
|
+
drawingId,
|
|
31
|
+
index
|
|
32
|
+
})).sort((a, b) => {
|
|
33
|
+
const aBehind = isDocDrawingBehindText(drawings[a.drawingId]);
|
|
34
|
+
if (aBehind !== isDocDrawingBehindText(drawings[b.drawingId])) return aBehind ? -1 : 1;
|
|
35
|
+
return a.index - b.index;
|
|
36
|
+
}).map(({ drawingId }) => drawingId);
|
|
37
|
+
}
|
|
38
|
+
function isDocDrawingBehindText(drawing) {
|
|
39
|
+
return (drawing === null || drawing === void 0 ? void 0 : drawing.layoutType) === PositionedObjectLayoutType.WRAP_NONE && drawing.behindDoc === BooleanNumber.TRUE;
|
|
40
|
+
}
|
|
28
41
|
let DocDrawingController = class DocDrawingController extends Disposable {
|
|
29
42
|
constructor(_docDrawingService, _drawingManagerService, _resourceManagerService, _univerInstanceService) {
|
|
30
43
|
super();
|
|
@@ -97,17 +110,18 @@ let DocDrawingController = class DocDrawingController extends Disposable {
|
|
|
97
110
|
const drawingDataModels = dataModel.getDrawings();
|
|
98
111
|
const drawingOrderModel = dataModel.getDrawingsOrder();
|
|
99
112
|
if (!drawingDataModels || !drawingOrderModel) return false;
|
|
100
|
-
Object.keys(drawingDataModels).forEach((drawingId) => {
|
|
101
|
-
drawingDataModels[drawingId] = { ...drawingDataModels[drawingId] };
|
|
102
|
-
});
|
|
103
113
|
const subDrawings = { [subUnitId]: {
|
|
104
114
|
unitId,
|
|
105
115
|
subUnitId,
|
|
106
116
|
data: drawingDataModels,
|
|
107
117
|
order: drawingOrderModel
|
|
108
118
|
} };
|
|
119
|
+
const renderSubDrawings = { [subUnitId]: {
|
|
120
|
+
...subDrawings[subUnitId],
|
|
121
|
+
order: getDocDrawingRenderOrder(drawingOrderModel, drawingDataModels)
|
|
122
|
+
} };
|
|
109
123
|
this._docDrawingService.registerDrawingData(unitId, subDrawings);
|
|
110
|
-
this._drawingManagerService.registerDrawingData(unitId,
|
|
124
|
+
this._drawingManagerService.registerDrawingData(unitId, renderSubDrawings);
|
|
111
125
|
return true;
|
|
112
126
|
}
|
|
113
127
|
};
|
|
@@ -121,7 +135,7 @@ DocDrawingController = __decorate([
|
|
|
121
135
|
//#endregion
|
|
122
136
|
//#region package.json
|
|
123
137
|
var name = "@univerjs/docs-drawing";
|
|
124
|
-
var version = "0.
|
|
138
|
+
var version = "1.0.0-alpha.1";
|
|
125
139
|
|
|
126
140
|
//#endregion
|
|
127
141
|
//#region src/config/config.ts
|
|
@@ -145,7 +159,7 @@ const configSymbol = Symbol(DOCS_DRAWING_PLUGIN_CONFIG_KEY);
|
|
|
145
159
|
const defaultPluginConfig = {};
|
|
146
160
|
|
|
147
161
|
//#endregion
|
|
148
|
-
//#region \0@oxc-project+runtime@0.
|
|
162
|
+
//#region \0@oxc-project+runtime@0.137.0/helpers/esm/typeof.js
|
|
149
163
|
function _typeof(o) {
|
|
150
164
|
"@babel/helpers - typeof";
|
|
151
165
|
return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o) {
|
|
@@ -156,7 +170,7 @@ function _typeof(o) {
|
|
|
156
170
|
}
|
|
157
171
|
|
|
158
172
|
//#endregion
|
|
159
|
-
//#region \0@oxc-project+runtime@0.
|
|
173
|
+
//#region \0@oxc-project+runtime@0.137.0/helpers/esm/toPrimitive.js
|
|
160
174
|
function toPrimitive(t, r) {
|
|
161
175
|
if ("object" != _typeof(t) || !t) return t;
|
|
162
176
|
var e = t[Symbol.toPrimitive];
|
|
@@ -169,14 +183,14 @@ function toPrimitive(t, r) {
|
|
|
169
183
|
}
|
|
170
184
|
|
|
171
185
|
//#endregion
|
|
172
|
-
//#region \0@oxc-project+runtime@0.
|
|
186
|
+
//#region \0@oxc-project+runtime@0.137.0/helpers/esm/toPropertyKey.js
|
|
173
187
|
function toPropertyKey(t) {
|
|
174
188
|
var i = toPrimitive(t, "string");
|
|
175
189
|
return "symbol" == _typeof(i) ? i : i + "";
|
|
176
190
|
}
|
|
177
191
|
|
|
178
192
|
//#endregion
|
|
179
|
-
//#region \0@oxc-project+runtime@0.
|
|
193
|
+
//#region \0@oxc-project+runtime@0.137.0/helpers/esm/defineProperty.js
|
|
180
194
|
function _defineProperty(e, r, t) {
|
|
181
195
|
return (r = toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
|
|
182
196
|
value: t,
|
|
@@ -213,4 +227,4 @@ _defineProperty(UniverDocsDrawingPlugin, "type", UniverInstanceType.UNIVER_DOC);
|
|
|
213
227
|
UniverDocsDrawingPlugin = __decorate([__decorateParam(1, Inject(Injector)), __decorateParam(2, IConfigService)], UniverDocsDrawingPlugin);
|
|
214
228
|
|
|
215
229
|
//#endregion
|
|
216
|
-
export { DOCS_DRAWING_PLUGIN, DocDrawingController, DocDrawingService, IDocDrawingService, UniverDocsDrawingPlugin };
|
|
230
|
+
export { DOCS_DRAWING_PLUGIN, DocDrawingController, DocDrawingService, IDocDrawingService, UniverDocsDrawingPlugin, getDocDrawingRenderOrder };
|
|
@@ -22,6 +22,7 @@ export interface IDocDrawingModel {
|
|
|
22
22
|
drawings?: IDocumentData['drawings'];
|
|
23
23
|
drawingsOrder?: IDocumentData['drawingsOrder'];
|
|
24
24
|
}
|
|
25
|
+
export declare function getDocDrawingRenderOrder(order: string[], drawings?: IDocumentData['drawings']): string[];
|
|
25
26
|
export declare class DocDrawingController extends Disposable {
|
|
26
27
|
private readonly _docDrawingService;
|
|
27
28
|
private readonly _drawingManagerService;
|
package/lib/types/index.d.ts
CHANGED
|
@@ -14,8 +14,10 @@
|
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
16
|
export type { IUniverDocsDrawingConfig } from './config/config';
|
|
17
|
-
export { DOCS_DRAWING_PLUGIN,
|
|
17
|
+
export { DOCS_DRAWING_PLUGIN, getDocDrawingRenderOrder } from './controllers/doc-drawing.controller';
|
|
18
|
+
export type { IDocDrawingModel } from './controllers/doc-drawing.controller';
|
|
18
19
|
export { DocDrawingController } from './controllers/doc-drawing.controller';
|
|
19
20
|
export { UniverDocsDrawingPlugin } from './plugin';
|
|
20
|
-
export { DocDrawingService,
|
|
21
|
+
export { DocDrawingService, IDocDrawingService } from './services/doc-drawing.service';
|
|
22
|
+
export type { IDocDrawing, IDocImage } from './services/doc-drawing.service';
|
|
21
23
|
export { type IDocFloatDom } from './services/doc-drawing.service';
|
package/lib/umd/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(e,t){typeof exports==`object`&&typeof module<`u`?t(exports,require("@univerjs/core"),require("@univerjs/drawing")):typeof define==`function`&&define.amd?define([`exports`,`@univerjs/core`,`@univerjs/drawing`],t):(e=typeof globalThis<`u`?globalThis:e||self,t(e.UniverDocsDrawing={},e.UniverCore,e.UniverDrawing))})(this,function(e,t,n){Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});var r=class extends n.UnitDrawingService{};let i=(0,t.createIdentifier)(`univer.doc.plugin.doc-drawing.service`);function a(e,t){return function(n,r){t(n,r,e)}}function o(e,t,n,r){var i=arguments.length,a=i<3?t:r===null?r=Object.getOwnPropertyDescriptor(t,n):r,o;if(typeof Reflect==`object`&&typeof Reflect.decorate==`function`)a=Reflect.decorate(e,t,n,r);else for(var s=e.length-1;s>=0;s--)(o=e[s])&&(a=(i<3?o(a):i>3?o(t,n,a):o(t,n))||a);return i>3&&a&&Object.defineProperty(t,n,a),a}let s=`DOC_DRAWING_PLUGIN
|
|
1
|
+
(function(e,t){typeof exports==`object`&&typeof module<`u`?t(exports,require("@univerjs/core"),require("@univerjs/drawing")):typeof define==`function`&&define.amd?define([`exports`,`@univerjs/core`,`@univerjs/drawing`],t):(e=typeof globalThis<`u`?globalThis:e||self,t(e.UniverDocsDrawing={},e.UniverCore,e.UniverDrawing))})(this,function(e,t,n){Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});var r=class extends n.UnitDrawingService{};let i=(0,t.createIdentifier)(`univer.doc.plugin.doc-drawing.service`);function a(e,t){return function(n,r){t(n,r,e)}}function o(e,t,n,r){var i=arguments.length,a=i<3?t:r===null?r=Object.getOwnPropertyDescriptor(t,n):r,o;if(typeof Reflect==`object`&&typeof Reflect.decorate==`function`)a=Reflect.decorate(e,t,n,r);else for(var s=e.length-1;s>=0;s--)(o=e[s])&&(a=(i<3?o(a):i>3?o(t,n,a):o(t,n))||a);return i>3&&a&&Object.defineProperty(t,n,a),a}let s=`DOC_DRAWING_PLUGIN`;function c(e,t={}){return e.map((e,t)=>({drawingId:e,index:t})).sort((e,n)=>{let r=l(t[e.drawingId]);return r===l(t[n.drawingId])?e.index-n.index:r?-1:1}).map(({drawingId:e})=>e)}function l(e){return(e==null?void 0:e.layoutType)===t.PositionedObjectLayoutType.WRAP_NONE&&e.behindDoc===t.BooleanNumber.TRUE}let u=class extends t.Disposable{constructor(e,t,n,r){super(),this._docDrawingService=e,this._drawingManagerService=t,this._resourceManagerService=n,this._univerInstanceService=r,this._init()}_init(){this._initSnapshot()}_initSnapshot(){let e=e=>{let n=this._univerInstanceService.getUnit(e,t.UniverInstanceType.UNIVER_DOC);if(n){let e=n.getSnapshot().drawings,t=n.getSnapshot().drawingsOrder;return JSON.stringify({data:e==null?{}:e,order:t==null?[]:t})}return``},n=e=>{if(!e)return{data:{},order:[]};try{return JSON.parse(e)}catch{return{data:{},order:[]}}};this.disposeWithMe(this._resourceManagerService.registerPluginResource({pluginName:s,businesses:[t.UniverInstanceType.UNIVER_DOC],toJson:t=>e(t),parseJson:e=>n(e),onUnLoad:e=>{this._setDrawingDataForUnit(e,{data:{},order:[]})},onLoad:(e,t)=>{var n,r;this._setDrawingDataForUnit(e,{data:(n=t.data)==null?{}:n,order:(r=t.order)==null?[]:r})}}))}_setDrawingDataForUnit(e,t){let n=this._univerInstanceService.getUnit(e);n!=null&&(n.resetDrawing(t.data,t.order),this.loadDrawingDataForUnit(e))}loadDrawingDataForUnit(e){let n=this._univerInstanceService.getUnit(e,t.UniverInstanceType.UNIVER_DOC);if(!n)return!1;let r=e,i=n.getDrawings(),a=n.getDrawingsOrder();if(!i||!a)return!1;let o={[r]:{unitId:e,subUnitId:r,data:i,order:a}},s={[r]:{...o[r],order:c(a,i)}};return this._docDrawingService.registerDrawingData(e,o),this._drawingManagerService.registerDrawingData(e,s),!0}};u=o([a(0,i),a(1,n.IDrawingManagerService),a(2,t.IResourceManagerService),a(3,t.IUniverInstanceService)],u);var d=`@univerjs/docs-drawing`,f=`1.0.0-alpha.1`;let p={};function m(e){"@babel/helpers - typeof";return m=typeof Symbol==`function`&&typeof Symbol.iterator==`symbol`?function(e){return typeof e}:function(e){return e&&typeof Symbol==`function`&&e.constructor===Symbol&&e!==Symbol.prototype?`symbol`:typeof e},m(e)}function h(e,t){if(m(e)!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(m(r)!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function g(e){var t=h(e,`string`);return m(t)==`symbol`?t:t+``}function _(e,t,n){return(t=g(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}let v=class extends t.Plugin{constructor(e=p,n,r){super(),this._config=e,this._injector=n,this._configService=r;let{...i}=(0,t.merge)({},p,this._config);this._configService.setConfig(`docs-drawing.config`,i)}onStarting(){[[u],[r],[i,{useClass:r}]].forEach(e=>this._injector.add(e)),(0,t.touchDependencies)(this._injector,[[u]])}};_(v,`pluginName`,s),_(v,`packageName`,d),_(v,`version`,f),_(v,`type`,t.UniverInstanceType.UNIVER_DOC),v=o([a(1,(0,t.Inject)(t.Injector)),a(2,t.IConfigService)],v),e.DOCS_DRAWING_PLUGIN=s,Object.defineProperty(e,"DocDrawingController",{enumerable:!0,get:function(){return u}}),e.DocDrawingService=r,e.IDocDrawingService=i,Object.defineProperty(e,"UniverDocsDrawingPlugin",{enumerable:!0,get:function(){return v}}),e.getDocDrawingRenderOrder=c});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@univerjs/docs-drawing",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "1.0.0-alpha.1",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "Drawing model integration for Univer Docs.",
|
|
6
6
|
"author": "DreamNum Co., Ltd. <developer@univer.ai>",
|
|
@@ -49,13 +49,13 @@
|
|
|
49
49
|
"lib"
|
|
50
50
|
],
|
|
51
51
|
"dependencies": {
|
|
52
|
-
"@univerjs/core": "0.
|
|
53
|
-
"@univerjs/drawing": "0.
|
|
52
|
+
"@univerjs/core": "1.0.0-alpha.1",
|
|
53
|
+
"@univerjs/drawing": "1.0.0-alpha.1"
|
|
54
54
|
},
|
|
55
55
|
"devDependencies": {
|
|
56
56
|
"typescript": "^6.0.3",
|
|
57
|
-
"vitest": "^4.1.
|
|
58
|
-
"@univerjs-infra/shared": "0.
|
|
57
|
+
"vitest": "^4.1.9",
|
|
58
|
+
"@univerjs-infra/shared": "1.0.0-alpha.1"
|
|
59
59
|
},
|
|
60
60
|
"scripts": {
|
|
61
61
|
"test": "vitest run",
|