UNPKG

@leafer-in/editor

Version:
1 lines 174 kB
{"version":3,"file":"editor.min.cjs","sources":["../../../../../node_modules/.pnpm/@rollup+plugin-typescript@11.1.6_rollup@4.34.6_tslib@2.8.1_typescript@5.7.3/node_modules/tslib/tslib.es6.js","../../../../../../src/in/packages/editor/src/event/EditorEvent.ts","../../../../../../src/in/packages/editor/src/event/EditorMoveEvent.ts","../../../../../../src/in/packages/editor/src/event/EditorScaleEvent.ts","../../../../../../src/in/packages/editor/src/event/EditorRotateEvent.ts","../../../../../../src/in/packages/editor/src/event/EditorSkewEvent.ts","../../../../../../src/in/packages/editor/src/decorator/data.ts","../../../../../../src/in/packages/editor/src/display/Stroker.ts","../../../../../../src/in/packages/editor/src/display/SelectArea.ts","../../../../../../src/in/packages/editor/src/helper/EditSelectHelper.ts","../../../../../../src/in/packages/editor/src/display/EditSelect.ts","../../../../../../src/in/packages/editor/src/helper/EditDataHelper.ts","../../../../../../src/in/packages/editor/src/editor/cursor.ts","../../../../../../src/in/packages/editor/src/display/EditPoint.ts","../../../../../../src/in/packages/editor/src/display/EditBox.ts","../../../../../../src/in/packages/editor/src/display/EditMask.ts","../../../../../../src/in/packages/editor/src/svg.ts","../../../../../../src/in/packages/editor/src/config.ts","../../../../../../src/in/packages/editor/src/editor/simulate.ts","../../../../../../src/in/packages/editor/src/helper/EditorHelper.ts","../../../../../../src/in/packages/editor/src/tool/EditToolCreator.ts","../../../../../../src/in/packages/editor/src/event/InnerEditorEvent.ts","../../../../../../src/in/packages/editor/src/event/EditorGroupEvent.ts","../../../../../../src/in/packages/editor/src/display/SimulateElement.ts","../../../../../../src/in/packages/editor/src/Editor.ts","../../../../../../src/in/packages/editor/src/editor/target.ts","../../../../../../src/in/packages/editor/src/tool/InnerEditor.ts","../../../../../../src/in/packages/editor/src/tool/EditTool.ts","../../../../../../src/in/packages/editor/src/tool/LineEditTool.ts","../../../../../../src/in/packages/editor/src/index.ts"],"sourcesContent":["/******************************************************************************\r\nCopyright (c) Microsoft Corporation.\r\n\r\nPermission to use, copy, modify, and/or distribute this software for any\r\npurpose with or without fee is hereby granted.\r\n\r\nTHE SOFTWARE IS PROVIDED \"AS IS\" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH\r\nREGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY\r\nAND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,\r\nINDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM\r\nLOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR\r\nOTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR\r\nPERFORMANCE OF THIS SOFTWARE.\r\n***************************************************************************** */\r\n/* global Reflect, Promise, SuppressedError, Symbol, Iterator */\r\n\r\nvar extendStatics = function(d, b) {\r\n extendStatics = Object.setPrototypeOf ||\r\n ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||\r\n function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };\r\n return extendStatics(d, b);\r\n};\r\n\r\nexport function __extends(d, b) {\r\n if (typeof b !== \"function\" && b !== null)\r\n throw new TypeError(\"Class extends value \" + String(b) + \" is not a constructor or null\");\r\n extendStatics(d, b);\r\n function __() { this.constructor = d; }\r\n d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());\r\n}\r\n\r\nexport var __assign = function() {\r\n __assign = Object.assign || function __assign(t) {\r\n for (var s, i = 1, n = arguments.length; i < n; i++) {\r\n s = arguments[i];\r\n for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];\r\n }\r\n return t;\r\n }\r\n return __assign.apply(this, arguments);\r\n}\r\n\r\nexport function __rest(s, e) {\r\n var t = {};\r\n for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)\r\n t[p] = s[p];\r\n if (s != null && typeof Object.getOwnPropertySymbols === \"function\")\r\n for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {\r\n if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))\r\n t[p[i]] = s[p[i]];\r\n }\r\n return t;\r\n}\r\n\r\nexport function __decorate(decorators, target, key, desc) {\r\n var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;\r\n if (typeof Reflect === \"object\" && typeof Reflect.decorate === \"function\") r = Reflect.decorate(decorators, target, key, desc);\r\n else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;\r\n return c > 3 && r && Object.defineProperty(target, key, r), r;\r\n}\r\n\r\nexport function __param(paramIndex, decorator) {\r\n return function (target, key) { decorator(target, key, paramIndex); }\r\n}\r\n\r\nexport function __esDecorate(ctor, descriptorIn, decorators, contextIn, initializers, extraInitializers) {\r\n function accept(f) { if (f !== void 0 && typeof f !== \"function\") throw new TypeError(\"Function expected\"); return f; }\r\n var kind = contextIn.kind, key = kind === \"getter\" ? \"get\" : kind === \"setter\" ? \"set\" : \"value\";\r\n var target = !descriptorIn && ctor ? contextIn[\"static\"] ? ctor : ctor.prototype : null;\r\n var descriptor = descriptorIn || (target ? Object.getOwnPropertyDescriptor(target, contextIn.name) : {});\r\n var _, done = false;\r\n for (var i = decorators.length - 1; i >= 0; i--) {\r\n var context = {};\r\n for (var p in contextIn) context[p] = p === \"access\" ? {} : contextIn[p];\r\n for (var p in contextIn.access) context.access[p] = contextIn.access[p];\r\n context.addInitializer = function (f) { if (done) throw new TypeError(\"Cannot add initializers after decoration has completed\"); extraInitializers.push(accept(f || null)); };\r\n var result = (0, decorators[i])(kind === \"accessor\" ? { get: descriptor.get, set: descriptor.set } : descriptor[key], context);\r\n if (kind === \"accessor\") {\r\n if (result === void 0) continue;\r\n if (result === null || typeof result !== \"object\") throw new TypeError(\"Object expected\");\r\n if (_ = accept(result.get)) descriptor.get = _;\r\n if (_ = accept(result.set)) descriptor.set = _;\r\n if (_ = accept(result.init)) initializers.unshift(_);\r\n }\r\n else if (_ = accept(result)) {\r\n if (kind === \"field\") initializers.unshift(_);\r\n else descriptor[key] = _;\r\n }\r\n }\r\n if (target) Object.defineProperty(target, contextIn.name, descriptor);\r\n done = true;\r\n};\r\n\r\nexport function __runInitializers(thisArg, initializers, value) {\r\n var useValue = arguments.length > 2;\r\n for (var i = 0; i < initializers.length; i++) {\r\n value = useValue ? initializers[i].call(thisArg, value) : initializers[i].call(thisArg);\r\n }\r\n return useValue ? value : void 0;\r\n};\r\n\r\nexport function __propKey(x) {\r\n return typeof x === \"symbol\" ? x : \"\".concat(x);\r\n};\r\n\r\nexport function __setFunctionName(f, name, prefix) {\r\n if (typeof name === \"symbol\") name = name.description ? \"[\".concat(name.description, \"]\") : \"\";\r\n return Object.defineProperty(f, \"name\", { configurable: true, value: prefix ? \"\".concat(prefix, \" \", name) : name });\r\n};\r\n\r\nexport function __metadata(metadataKey, metadataValue) {\r\n if (typeof Reflect === \"object\" && typeof Reflect.metadata === \"function\") return Reflect.metadata(metadataKey, metadataValue);\r\n}\r\n\r\nexport function __awaiter(thisArg, _arguments, P, generator) {\r\n function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }\r\n return new (P || (P = Promise))(function (resolve, reject) {\r\n function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }\r\n function rejected(value) { try { step(generator[\"throw\"](value)); } catch (e) { reject(e); } }\r\n function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }\r\n step((generator = generator.apply(thisArg, _arguments || [])).next());\r\n });\r\n}\r\n\r\nexport function __generator(thisArg, body) {\r\n var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === \"function\" ? Iterator : Object).prototype);\r\n return g.next = verb(0), g[\"throw\"] = verb(1), g[\"return\"] = verb(2), typeof Symbol === \"function\" && (g[Symbol.iterator] = function() { return this; }), g;\r\n function verb(n) { return function (v) { return step([n, v]); }; }\r\n function step(op) {\r\n if (f) throw new TypeError(\"Generator is already executing.\");\r\n while (g && (g = 0, op[0] && (_ = 0)), _) try {\r\n if (f = 1, y && (t = op[0] & 2 ? y[\"return\"] : op[0] ? y[\"throw\"] || ((t = y[\"return\"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;\r\n if (y = 0, t) op = [op[0] & 2, t.value];\r\n switch (op[0]) {\r\n case 0: case 1: t = op; break;\r\n case 4: _.label++; return { value: op[1], done: false };\r\n case 5: _.label++; y = op[1]; op = [0]; continue;\r\n case 7: op = _.ops.pop(); _.trys.pop(); continue;\r\n default:\r\n if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }\r\n if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }\r\n if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }\r\n if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }\r\n if (t[2]) _.ops.pop();\r\n _.trys.pop(); continue;\r\n }\r\n op = body.call(thisArg, _);\r\n } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }\r\n if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };\r\n }\r\n}\r\n\r\nexport var __createBinding = Object.create ? (function(o, m, k, k2) {\r\n if (k2 === undefined) k2 = k;\r\n var desc = Object.getOwnPropertyDescriptor(m, k);\r\n if (!desc || (\"get\" in desc ? !m.__esModule : desc.writable || desc.configurable)) {\r\n desc = { enumerable: true, get: function() { return m[k]; } };\r\n }\r\n Object.defineProperty(o, k2, desc);\r\n}) : (function(o, m, k, k2) {\r\n if (k2 === undefined) k2 = k;\r\n o[k2] = m[k];\r\n});\r\n\r\nexport function __exportStar(m, o) {\r\n for (var p in m) if (p !== \"default\" && !Object.prototype.hasOwnProperty.call(o, p)) __createBinding(o, m, p);\r\n}\r\n\r\nexport function __values(o) {\r\n var s = typeof Symbol === \"function\" && Symbol.iterator, m = s && o[s], i = 0;\r\n if (m) return m.call(o);\r\n if (o && typeof o.length === \"number\") return {\r\n next: function () {\r\n if (o && i >= o.length) o = void 0;\r\n return { value: o && o[i++], done: !o };\r\n }\r\n };\r\n throw new TypeError(s ? \"Object is not iterable.\" : \"Symbol.iterator is not defined.\");\r\n}\r\n\r\nexport function __read(o, n) {\r\n var m = typeof Symbol === \"function\" && o[Symbol.iterator];\r\n if (!m) return o;\r\n var i = m.call(o), r, ar = [], e;\r\n try {\r\n while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);\r\n }\r\n catch (error) { e = { error: error }; }\r\n finally {\r\n try {\r\n if (r && !r.done && (m = i[\"return\"])) m.call(i);\r\n }\r\n finally { if (e) throw e.error; }\r\n }\r\n return ar;\r\n}\r\n\r\n/** @deprecated */\r\nexport function __spread() {\r\n for (var ar = [], i = 0; i < arguments.length; i++)\r\n ar = ar.concat(__read(arguments[i]));\r\n return ar;\r\n}\r\n\r\n/** @deprecated */\r\nexport function __spreadArrays() {\r\n for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;\r\n for (var r = Array(s), k = 0, i = 0; i < il; i++)\r\n for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)\r\n r[k] = a[j];\r\n return r;\r\n}\r\n\r\nexport function __spreadArray(to, from, pack) {\r\n if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {\r\n if (ar || !(i in from)) {\r\n if (!ar) ar = Array.prototype.slice.call(from, 0, i);\r\n ar[i] = from[i];\r\n }\r\n }\r\n return to.concat(ar || Array.prototype.slice.call(from));\r\n}\r\n\r\nexport function __await(v) {\r\n return this instanceof __await ? (this.v = v, this) : new __await(v);\r\n}\r\n\r\nexport function __asyncGenerator(thisArg, _arguments, generator) {\r\n if (!Symbol.asyncIterator) throw new TypeError(\"Symbol.asyncIterator is not defined.\");\r\n var g = generator.apply(thisArg, _arguments || []), i, q = [];\r\n return i = Object.create((typeof AsyncIterator === \"function\" ? AsyncIterator : Object).prototype), verb(\"next\"), verb(\"throw\"), verb(\"return\", awaitReturn), i[Symbol.asyncIterator] = function () { return this; }, i;\r\n function awaitReturn(f) { return function (v) { return Promise.resolve(v).then(f, reject); }; }\r\n function verb(n, f) { if (g[n]) { i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; if (f) i[n] = f(i[n]); } }\r\n function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } }\r\n function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); }\r\n function fulfill(value) { resume(\"next\", value); }\r\n function reject(value) { resume(\"throw\", value); }\r\n function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); }\r\n}\r\n\r\nexport function __asyncDelegator(o) {\r\n var i, p;\r\n return i = {}, verb(\"next\"), verb(\"throw\", function (e) { throw e; }), verb(\"return\"), i[Symbol.iterator] = function () { return this; }, i;\r\n function verb(n, f) { i[n] = o[n] ? function (v) { return (p = !p) ? { value: __await(o[n](v)), done: false } : f ? f(v) : v; } : f; }\r\n}\r\n\r\nexport function __asyncValues(o) {\r\n if (!Symbol.asyncIterator) throw new TypeError(\"Symbol.asyncIterator is not defined.\");\r\n var m = o[Symbol.asyncIterator], i;\r\n return m ? m.call(o) : (o = typeof __values === \"function\" ? __values(o) : o[Symbol.iterator](), i = {}, verb(\"next\"), verb(\"throw\"), verb(\"return\"), i[Symbol.asyncIterator] = function () { return this; }, i);\r\n function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }\r\n function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); }\r\n}\r\n\r\nexport function __makeTemplateObject(cooked, raw) {\r\n if (Object.defineProperty) { Object.defineProperty(cooked, \"raw\", { value: raw }); } else { cooked.raw = raw; }\r\n return cooked;\r\n};\r\n\r\nvar __setModuleDefault = Object.create ? (function(o, v) {\r\n Object.defineProperty(o, \"default\", { enumerable: true, value: v });\r\n}) : function(o, v) {\r\n o[\"default\"] = v;\r\n};\r\n\r\nvar ownKeys = function(o) {\r\n ownKeys = Object.getOwnPropertyNames || function (o) {\r\n var ar = [];\r\n for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;\r\n return ar;\r\n };\r\n return ownKeys(o);\r\n};\r\n\r\nexport function __importStar(mod) {\r\n if (mod && mod.__esModule) return mod;\r\n var result = {};\r\n if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== \"default\") __createBinding(result, mod, k[i]);\r\n __setModuleDefault(result, mod);\r\n return result;\r\n}\r\n\r\nexport function __importDefault(mod) {\r\n return (mod && mod.__esModule) ? mod : { default: mod };\r\n}\r\n\r\nexport function __classPrivateFieldGet(receiver, state, kind, f) {\r\n if (kind === \"a\" && !f) throw new TypeError(\"Private accessor was defined without a getter\");\r\n if (typeof state === \"function\" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError(\"Cannot read private member from an object whose class did not declare it\");\r\n return kind === \"m\" ? f : kind === \"a\" ? f.call(receiver) : f ? f.value : state.get(receiver);\r\n}\r\n\r\nexport function __classPrivateFieldSet(receiver, state, value, kind, f) {\r\n if (kind === \"m\") throw new TypeError(\"Private method is not writable\");\r\n if (kind === \"a\" && !f) throw new TypeError(\"Private accessor was defined without a setter\");\r\n if (typeof state === \"function\" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError(\"Cannot write private member to an object whose class did not declare it\");\r\n return (kind === \"a\" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;\r\n}\r\n\r\nexport function __classPrivateFieldIn(state, receiver) {\r\n if (receiver === null || (typeof receiver !== \"object\" && typeof receiver !== \"function\")) throw new TypeError(\"Cannot use 'in' operator on non-object\");\r\n return typeof state === \"function\" ? receiver === state : state.has(receiver);\r\n}\r\n\r\nexport function __addDisposableResource(env, value, async) {\r\n if (value !== null && value !== void 0) {\r\n if (typeof value !== \"object\" && typeof value !== \"function\") throw new TypeError(\"Object expected.\");\r\n var dispose, inner;\r\n if (async) {\r\n if (!Symbol.asyncDispose) throw new TypeError(\"Symbol.asyncDispose is not defined.\");\r\n dispose = value[Symbol.asyncDispose];\r\n }\r\n if (dispose === void 0) {\r\n if (!Symbol.dispose) throw new TypeError(\"Symbol.dispose is not defined.\");\r\n dispose = value[Symbol.dispose];\r\n if (async) inner = dispose;\r\n }\r\n if (typeof dispose !== \"function\") throw new TypeError(\"Object not disposable.\");\r\n if (inner) dispose = function() { try { inner.call(this); } catch (e) { return Promise.reject(e); } };\r\n env.stack.push({ value: value, dispose: dispose, async: async });\r\n }\r\n else if (async) {\r\n env.stack.push({ async: true });\r\n }\r\n return value;\r\n\r\n}\r\n\r\nvar _SuppressedError = typeof SuppressedError === \"function\" ? SuppressedError : function (error, suppressed, message) {\r\n var e = new Error(message);\r\n return e.name = \"SuppressedError\", e.error = error, e.suppressed = suppressed, e;\r\n};\r\n\r\nexport function __disposeResources(env) {\r\n function fail(e) {\r\n env.error = env.hasError ? new _SuppressedError(e, env.error, \"An error was suppressed during disposal.\") : e;\r\n env.hasError = true;\r\n }\r\n var r, s = 0;\r\n function next() {\r\n while (r = env.stack.pop()) {\r\n try {\r\n if (!r.async && s === 1) return s = 0, env.stack.push(r), Promise.resolve().then(next);\r\n if (r.dispose) {\r\n var result = r.dispose.call(r.value);\r\n if (r.async) return s |= 2, Promise.resolve(result).then(next, function(e) { fail(e); return next(); });\r\n }\r\n else s |= 1;\r\n }\r\n catch (e) {\r\n fail(e);\r\n }\r\n }\r\n if (s === 1) return env.hasError ? Promise.reject(env.error) : Promise.resolve();\r\n if (env.hasError) throw env.error;\r\n }\r\n return next();\r\n}\r\n\r\nexport function __rewriteRelativeImportExtension(path, preserveJsx) {\r\n if (typeof path === \"string\" && /^\\.\\.?\\//.test(path)) {\r\n return path.replace(/\\.(tsx)$|((?:\\.d)?)((?:\\.[^./]+?)?)\\.([cm]?)ts$/i, function (m, tsx, d, ext, cm) {\r\n return tsx ? preserveJsx ? \".jsx\" : \".js\" : d && (!ext || !cm) ? m : (d + ext + \".\" + cm.toLowerCase() + \"js\");\r\n });\r\n }\r\n return path;\r\n}\r\n\r\nexport default {\r\n __extends: __extends,\r\n __assign: __assign,\r\n __rest: __rest,\r\n __decorate: __decorate,\r\n __param: __param,\r\n __esDecorate: __esDecorate,\r\n __runInitializers: __runInitializers,\r\n __propKey: __propKey,\r\n __setFunctionName: __setFunctionName,\r\n __metadata: __metadata,\r\n __awaiter: __awaiter,\r\n __generator: __generator,\r\n __createBinding: __createBinding,\r\n __exportStar: __exportStar,\r\n __values: __values,\r\n __read: __read,\r\n __spread: __spread,\r\n __spreadArrays: __spreadArrays,\r\n __spreadArray: __spreadArray,\r\n __await: __await,\r\n __asyncGenerator: __asyncGenerator,\r\n __asyncDelegator: __asyncDelegator,\r\n __asyncValues: __asyncValues,\r\n __makeTemplateObject: __makeTemplateObject,\r\n __importStar: __importStar,\r\n __importDefault: __importDefault,\r\n __classPrivateFieldGet: __classPrivateFieldGet,\r\n __classPrivateFieldSet: __classPrivateFieldSet,\r\n __classPrivateFieldIn: __classPrivateFieldIn,\r\n __addDisposableResource: __addDisposableResource,\r\n __disposeResources: __disposeResources,\r\n __rewriteRelativeImportExtension: __rewriteRelativeImportExtension,\r\n};\r\n","import { IUI, IPointData } from '@leafer-ui/interface'\nimport { Event } from '@leafer-ui/draw'\n\nimport { IEditor, IEditorEvent } from '@leafer-in/interface'\n\n\nfunction toList(value: IUI | IUI[]): IUI[] {\n return value ? (value instanceof Array ? value : [value]) : []\n}\n\nexport class EditorEvent extends Event implements IEditorEvent {\n\n static BEFORE_SELECT = 'editor.before_select'\n static SELECT = 'editor.select'\n\n static BEFORE_HOVER = 'editor.before_hover'\n static HOVER = 'editor.hover'\n\n declare readonly target: IUI\n readonly editor: IEditor\n\n readonly value: IUI | IUI[]\n readonly oldValue: IUI | IUI[]\n\n get list() { return toList(this.value) }\n get oldList() { return toList(this.oldValue) }\n\n readonly worldOrigin: IPointData\n declare readonly origin: IPointData\n\n constructor(type: string, data?: IEditorEvent) {\n super(type)\n if (data) Object.assign(this, data)\n }\n\n}","import { IEditorMoveEvent } from '@leafer-in/interface'\n\nimport { EditorEvent } from './EditorEvent'\n\n\nexport class EditorMoveEvent extends EditorEvent implements IEditorMoveEvent {\n\n static BEFORE_MOVE = 'editor.before_move'\n static MOVE = 'editor.move'\n\n readonly moveX: number\n readonly moveY: number\n\n constructor(type: string, data?: IEditorMoveEvent) {\n super(type, data)\n }\n\n}","import { IAround, IDragEvent, IMatrixData } from '@leafer-ui/interface'\n\nimport { IEditorScaleEvent } from '@leafer-in/interface'\nimport { Direction9 } from '@leafer-ui/draw'\n\nimport { EditorEvent } from './EditorEvent'\n\n\nexport class EditorScaleEvent extends EditorEvent implements IEditorScaleEvent {\n\n static BEFORE_SCALE = 'editor.before_scale'\n static SCALE = 'editor.scale'\n\n // scaleOf(origin, scaleX, scaleY, resize)\n readonly scaleX: number\n readonly scaleY: number\n readonly transform?: IMatrixData\n\n readonly drag: IDragEvent\n\n readonly direction: Direction9\n readonly lockRatio: boolean\n readonly around: IAround\n\n constructor(type: string, data?: IEditorScaleEvent) {\n super(type, data)\n }\n\n}","import { IEditorRotateEvent } from '@leafer-in/interface'\n\nimport { EditorEvent } from './EditorEvent'\n\n\nexport class EditorRotateEvent extends EditorEvent implements IEditorRotateEvent {\n\n static BEFORE_ROTATE = 'editor.before_rotate'\n static ROTATE = 'editor.rotate'\n\n // rotateOf(origin, rotation)\n readonly rotation: number\n\n constructor(type: string, data?: IEditorRotateEvent) {\n super(type, data)\n }\n\n}","import { IEditorSkewEvent } from '@leafer-in/interface'\n\nimport { EditorEvent } from './EditorEvent'\n\n\nexport class EditorSkewEvent extends EditorEvent implements IEditorSkewEvent {\n\n static BEFORE_SKEW = 'editor.before_skew'\n static SKEW = 'editor.skew'\n\n // skewOf(origin, skewX, skewY)\n readonly skewX: number\n readonly skewY: number\n\n constructor(type: string, data?: IEditorSkewEvent) {\n super(type, data)\n }\n\n}","import { IFunction, ILeaf, IObject, IUI, } from '@leafer-ui/interface'\nimport { IEditor } from '@leafer-in/interface'\nimport { defineKey, isNull } from '@leafer-ui/draw'\n\nimport { EditorEvent } from '../event/EditorEvent'\n\n\nexport function targetAttr(fn: IFunction) {\n return (target: ILeaf, key: string) => {\n const privateKey = '_' + key\n defineKey(target, key, {\n get() { return (this as IObject)[privateKey] },\n set(value: IUI | IUI[]) {\n const old = (this as IObject)[privateKey]\n if (old !== value) {\n\n if ((this as IEditor).config) { // Editor\n\n const isSelect = key === 'target'\n if (isSelect) {\n if (value instanceof Array && value.length > 1 && value[0].locked) value.splice(0, 1) // fix: 单个锁定 + shift多选\n\n const { beforeSelect } = (this as IEditor).config\n if (beforeSelect) {\n const check = beforeSelect({ target: value })\n if (typeof check === 'object') value = check\n else if (check === false) return\n }\n }\n\n const type = isSelect ? EditorEvent.BEFORE_SELECT : EditorEvent.BEFORE_HOVER\n if (this.hasEvent(type)) this.emitEvent(new EditorEvent(type, { editor: this as IEditor, value: value as IUI, oldValue: old }))\n }\n\n (this as IObject)[privateKey] = value, fn(this, old)\n }\n }\n } as ThisType<ILeaf>)\n }\n}\n\n\nexport function mergeConfigAttr() {\n return (target: IEditor, key: string) => {\n defineKey(target, key, {\n get() {\n const { config, element, dragPoint } = this, mergeConfig = { ...config } // 实时合并,后期可优化\n if (element && element.editConfig) Object.assign(mergeConfig, element.editConfig)\n if (dragPoint) {\n if (dragPoint.editConfig) Object.assign(mergeConfig, dragPoint.editConfig)\n if (mergeConfig.editSize === 'font-size') mergeConfig.lockRatio = true // 强制锁定比例\n if (dragPoint.pointType === 'resize-rotate') {\n mergeConfig.around || (mergeConfig.around = 'center')\n isNull(mergeConfig.lockRatio) && (mergeConfig.lockRatio = true)\n }\n }\n return (this as IObject).mergedConfig = mergeConfig\n }\n } as ThisType<IEditor>)\n }\n}\n\n\n","import { IUI, ILeaferCanvas, IRenderOptions, IRectInputData, IMatrixWithOptionHalfData } from '@leafer-ui/interface'\nimport { Paint, UI, MatrixHelper, getBoundsData, getMatrixData, BoundsHelper, LeafBoundsHelper } from '@leafer-ui/draw'\n\nimport { IStroker } from '@leafer-in/interface'\n\nimport { targetAttr } from '../decorator/data'\n\n\nconst { abs } = Math\nconst { copy, scale } = MatrixHelper\nconst { setListWithFn } = BoundsHelper\nconst { worldBounds } = LeafBoundsHelper\nconst matrix = getMatrixData() as IMatrixWithOptionHalfData\nconst bounds = getBoundsData()\n\nexport class Stroker extends UI implements IStroker {\n\n @targetAttr(onTarget)\n public target: IUI | IUI[]\n\n public list: IUI[] = []\n\n constructor() {\n super()\n this.visible = 0\n this.hittable = false\n this.strokeAlign = 'center'\n }\n\n public setTarget(target: IUI | IUI[], style: IRectInputData): void {\n this.set(style)\n this.target = target\n this.update()\n }\n\n public update(): void {\n const { list } = this\n if (list.length) {\n setListWithFn(bounds, list, worldBounds)\n this.set(bounds)\n this.visible = true\n } else this.visible = 0\n }\n\n public __draw(canvas: ILeaferCanvas, options: IRenderOptions): void {\n const { list } = this\n\n if (list.length) {\n\n let leaf: IUI\n const data = this.__, { stroke, strokeWidth, fill } = data, { bounds } = options\n\n for (let i = 0; i < list.length; i++) {\n leaf = list[i]\n const { worldTransform, worldRenderBounds } = leaf\n\n if (worldRenderBounds.width && worldRenderBounds.height && (!bounds || bounds.hit(worldRenderBounds, options.matrix))) {\n\n const aScaleX = abs(worldTransform.scaleX), aScaleY = abs(worldTransform.scaleY)\n\n copy(matrix, worldTransform)\n matrix.half = strokeWidth % 2\n\n if (aScaleX !== aScaleY) { // need no scale stroke, use rect path\n\n scale(matrix, 1 / aScaleX, 1 / aScaleY)\n canvas.setWorld(matrix, options.matrix)\n canvas.beginPath()\n data.strokeWidth = strokeWidth\n\n const { x, y, width, height } = leaf.__layout.boxBounds\n canvas.rect(x * aScaleX, y * aScaleY, width * aScaleX, height * aScaleY)\n\n } else {\n\n canvas.setWorld(matrix, options.matrix)\n canvas.beginPath()\n\n if (leaf.__.__useArrow) leaf.__drawPath(canvas)\n else leaf.__.__pathForRender ? leaf.__drawRenderPath(canvas) : leaf.__drawPathByBox(canvas)\n\n data.strokeWidth = strokeWidth / abs(worldTransform.scaleX)\n\n }\n\n if (stroke) typeof stroke === 'string' ? Paint.stroke(stroke, this, canvas) : Paint.strokes(stroke, this, canvas)\n if (fill) typeof fill === 'string' ? Paint.fill(fill, this, canvas) : Paint.fills(fill, this, canvas)\n }\n }\n\n data.strokeWidth = strokeWidth\n }\n }\n\n public destroy(): void {\n this.target = null\n super.destroy()\n }\n\n}\n\nfunction onTarget(stroker: Stroker): void {\n const value = stroker.target\n stroker.list = value ? (value instanceof Array ? value : [value]) : []\n}\n","import { IBoundsData, IGroupInputData, IRect, IRectInputData } from '@leafer-ui/interface'\nimport { Group, Rect } from '@leafer-ui/draw'\n\nimport { ISelectArea } from '@leafer-in/interface'\n\n\nexport class SelectArea extends Group implements ISelectArea {\n\n protected strokeArea: IRect = new Rect({ strokeAlign: 'center' })\n protected fillArea: IRect = new Rect()\n\n constructor(data?: IGroupInputData) {\n super(data)\n this.visible = 0\n this.hittable = false\n this.addMany(this.fillArea, this.strokeArea)\n }\n\n public setStyle(style: IRectInputData, userStyle?: IRectInputData): void {\n const { visible, stroke, strokeWidth } = style\n this.visible = visible\n this.strokeArea.reset({ stroke, strokeWidth, ...(userStyle || {}) })\n this.fillArea.reset({ visible: userStyle ? false : true, fill: stroke, opacity: 0.2 })\n }\n\n public setBounds(bounds: IBoundsData): void {\n this.strokeArea.set(bounds)\n this.fillArea.set(bounds)\n }\n\n}","import { IBounds, ILeafList, IUI, IUIData } from '@leafer-ui/interface'\n\n\nexport const EditSelectHelper = {\n\n findOne(path: ILeafList): IUI {\n return path.list.find((leaf) => leaf.editable) as IUI\n },\n\n findByBounds(branch: IUI, bounds: IBounds): IUI[] {\n const list: IUI[] = []\n eachFind([branch], list, bounds)\n return list\n }\n\n}\n\n\nfunction eachFind(children: IUI[], list: IUI[], bounds: IBounds): void {\n let child: IUI, data: IUIData\n for (let i = 0, len = children.length; i < len; i++) {\n child = children[i], data = child.__\n if (data.hittable && data.visible && !data.locked && bounds.hit(child.__world)) {\n\n if (data.editable) {\n if (child.isBranch && !data.hitChildren) {\n if (data.hitSelf) list.push(child)\n continue\n } else if (child.isFrame) {\n if (bounds.includes(child.__layout.boxBounds, child.__world)) {\n list.push(child)\n continue\n }\n } else if (bounds.hit(child.__layout.boxBounds, child.__world) && data.hitSelf) list.push(child)\n }\n\n if (child.isBranch) eachFind(child.children, list, bounds)\n\n }\n }\n}","import { IBounds, ILeaf, ILeafList, IUI, IEventListenerId, IPointerEvent, IFunction } from '@leafer-ui/interface'\nimport { Bounds, LeafList, Group } from '@leafer-ui/draw'\nimport { PointerEvent, DragEvent, MoveEvent, ZoomEvent } from '@leafer-ui/core'\n\nimport { IEditSelect, IEditor, ISelectArea, IStroker } from '@leafer-in/interface'\n\nimport { Stroker } from './Stroker'\nimport { SelectArea } from './SelectArea'\nimport { EditSelectHelper } from '../helper/EditSelectHelper'\nimport { EditorEvent } from '../event/EditorEvent'\n\n\nconst { findOne, findByBounds } = EditSelectHelper\n\nexport class EditSelect extends Group implements IEditSelect {\n\n public editor: IEditor\n\n public get dragging(): boolean { return !!this.originList }\n public get running(): boolean { const { editor } = this; return this.hittable && editor.visible && editor.hittable && editor.mergeConfig.selector }\n public get isMoveMode(): boolean { return this.app && this.app.interaction.moveMode }\n\n public hoverStroker: IStroker = new Stroker()\n public targetStroker: IStroker = new Stroker()\n\n public bounds: IBounds = new Bounds()\n public selectArea: ISelectArea = new SelectArea()\n\n protected originList: ILeafList\n protected needRemoveItem: IUI\n\n protected waitSelect: IFunction // 手机端延迟选中,防止多点触屏误选元素\n\n protected __eventIds: IEventListenerId[] = []\n\n constructor(editor: IEditor) {\n super()\n this.editor = editor\n this.addMany(this.targetStroker, this.hoverStroker, this.selectArea)\n this.__listenEvents()\n }\n\n // hover / select\n\n protected onHover(): void {\n const { editor } = this\n if (this.running && !this.dragging && !editor.dragging) {\n const { stroke, strokeWidth, hover, hoverStyle } = editor.mergeConfig\n this.hoverStroker.setTarget(hover ? this.editor.hoverTarget : null, { stroke, strokeWidth, ...(hoverStyle || {}) })\n } else {\n this.hoverStroker.target = null\n }\n }\n\n protected onSelect(): void {\n if (this.running) {\n const { mergeConfig, list } = this.editor\n const { stroke, strokeWidth, selectedStyle } = mergeConfig\n this.targetStroker.setTarget(list, { stroke, strokeWidth: Math.max(1, strokeWidth / 2), ...(selectedStyle || {}) })\n this.hoverStroker.target = null\n }\n }\n\n public update(): void {\n this.hoverStroker.update()\n this.targetStroker.update()\n }\n\n // move / down\n\n protected onPointerMove(e: PointerEvent): void {\n const { app, editor } = this\n if (this.running && !this.isMoveMode && app.interaction.canHover && !app.interaction.dragging) {\n const find = this.findUI(e)\n editor.hoverTarget = editor.hasItem(find) ? null : find\n } if (this.isMoveMode) {\n editor.hoverTarget = null // move.dragEmpty\n }\n }\n\n protected onBeforeDown(e: PointerEvent): void {\n if (e.multiTouch) return\n\n const { select } = this.editor.mergeConfig\n if (select === 'press') {\n if (this.app.config.mobile) {\n this.waitSelect = () => this.checkAndSelect(e)\n } else {\n this.checkAndSelect(e)\n }\n }\n }\n\n protected onTap(e: PointerEvent): void {\n if (e.multiTouch) return\n\n const { editor } = this\n const { select } = editor.mergeConfig\n\n if (select === 'tap') this.checkAndSelect(e)\n else if (this.waitSelect) this.waitSelect()\n\n if (this.needRemoveItem) {\n editor.removeItem(this.needRemoveItem)\n } else if (this.isMoveMode) {\n editor.target = null // move.dragEmpty\n }\n\n }\n\n protected checkAndSelect(e: PointerEvent): void { // pointer.down or tap\n this.needRemoveItem = null\n\n if (this.allowSelect(e)) {\n const { editor } = this\n const find = this.findUI(e)\n\n if (find) {\n if (this.isMultipleSelect(e)) {\n if (editor.hasItem(find)) this.needRemoveItem = find // 等待tap事件再实际移除\n else editor.addItem(find)\n } else {\n editor.target = find\n }\n\n } else if (this.allow(e.target)) {\n\n if (!e.shiftKey) editor.target = null\n\n }\n }\n }\n\n // drag\n\n protected onDragStart(e: DragEvent): void {\n if (e.multiTouch) return\n if (this.waitSelect) this.waitSelect()\n\n if (this.allowDrag(e)) {\n const { editor } = this\n const { stroke, area } = editor.mergeConfig\n const { x, y } = e.getInnerPoint(this)\n\n this.bounds.set(x, y)\n\n this.selectArea.setStyle({ visible: true, stroke, x, y }, area)\n this.selectArea.setBounds(this.bounds.get())\n\n this.originList = editor.leafList.clone()\n }\n }\n\n protected onDrag(e: DragEvent): void {\n if (e.multiTouch) return\n if (this.editor.dragging) return this.onDragEnd(e)\n\n if (this.dragging) {\n const { editor } = this\n const total = e.getInnerTotal(this)\n\n const dragBounds = this.bounds.clone().unsign()\n const list = new LeafList(findByBounds(editor.app, dragBounds))\n\n this.bounds.width = total.x\n this.bounds.height = total.y\n\n this.selectArea.setBounds(dragBounds.get())\n\n if (list.length) {\n\n const selectList: ILeaf[] = []\n\n this.originList.forEach(item => { if (!list.has(item)) selectList.push(item) })\n list.forEach(item => { if (!this.originList.has(item)) selectList.push(item) })\n\n if (selectList.length !== editor.list.length || editor.list.some((child, index) => child !== selectList[index])) {\n editor.target = selectList as IUI[]\n }\n\n } else {\n\n editor.target = this.originList.list as IUI[]\n\n }\n }\n }\n\n protected onDragEnd(e: DragEvent): void {\n if (e.multiTouch) return\n\n if (this.dragging) this.originList = null, this.selectArea.visible = 0\n }\n\n protected onAutoMove(e: MoveEvent): void {\n if (this.dragging) {\n const { x, y } = e.getLocalMove(this)\n this.bounds.x += x\n this.bounds.y += y\n }\n }\n\n // helper\n\n protected allow(target: ILeaf): boolean {\n return target.leafer !== this.editor.leafer\n }\n\n protected allowDrag(e: DragEvent) {\n const { boxSelect, multipleSelect } = this.editor.mergeConfig\n if (this.running && (multipleSelect && boxSelect) && !e.target.draggable) {\n return (!this.editor.editing && this.allow(e.target)) || (e.shiftKey && !findOne(e.path))\n } else {\n return false\n }\n }\n\n protected allowSelect(e: IPointerEvent): boolean {\n return this.running && !this.isMoveMode && !e.middle\n }\n\n public findDeepOne(e: PointerEvent): IUI {\n const options = { exclude: new LeafList(this.editor.editBox.rect) }\n return findOne(e.target.leafer.interaction.findPath(e, options)) as IUI\n }\n\n public findUI(e: PointerEvent): IUI {\n return this.isMultipleSelect(e) ? this.findDeepOne(e) : findOne(e.path)\n }\n\n public isMultipleSelect(e: IPointerEvent): boolean {\n const { multipleSelect, continuousSelect } = this.editor.mergeConfig\n return multipleSelect && (e.shiftKey || continuousSelect)\n }\n\n protected __listenEvents(): void {\n const { editor } = this\n editor.waitLeafer(() => {\n\n const { app } = editor\n app.selector.proxy = editor\n\n this.__eventIds = [\n editor.on_(EditorEvent.HOVER, this.onHover, this),\n editor.on_(EditorEvent.SELECT, this.onSelect, this),\n\n app.on_(PointerEvent.MOVE, this.onPointerMove, this),\n app.on_(PointerEvent.BEFORE_DOWN, this.onBeforeDown, this),\n app.on_(PointerEvent.TAP, this.onTap, this),\n\n app.on_(DragEvent.START, this.onDragStart, this, true), // 采用捕获事件,需要比EditBox中的dragStart早触发\n app.on_(DragEvent.DRAG, this.onDrag, this),\n app.on_(DragEvent.END, this.onDragEnd, this),\n\n app.on_(MoveEvent.MOVE, this.onAutoMove, this),\n app.on_([ZoomEvent.ZOOM, MoveEvent.MOVE], () => { this.editor.hoverTarget = null }),\n ]\n\n })\n }\n\n protected __removeListenEvents(): void {\n if (this.__eventIds) {\n this.off_(this.__eventIds)\n this.__eventIds.length = 0\n }\n }\n\n public destroy(): void {\n this.editor = this.originList = this.needRemoveItem = null\n this.__removeListenEvents()\n super.destroy()\n }\n}","import { IBoundsData, IPointData, IAround, IAlign, IUI, ILayoutBoundsData } from '@leafer-ui/interface'\nimport { AroundHelper, MathHelper, PointHelper, BoundsHelper, Bounds, Direction9 } from '@leafer-ui/draw'\n\nimport { IEditorScaleEvent, IEditorSkewEvent, IEditorRotateEvent } from '@leafer-in/interface'\n\n\nconst { topLeft, top, topRight, right, bottomRight, bottom, bottomLeft, left } = Direction9\nconst { toPoint } = AroundHelper\nconst { within } = MathHelper\n\nexport const EditDataHelper = {\n\n getScaleData(element: IUI, startBounds: ILayoutBoundsData, direction: Direction9, totalMove: IPointData, lockRatio: boolean | 'corner', around: IAround, flipable: boolean, scaleMode: boolean): IEditorScaleEvent {\n let align: IAlign, origin = {} as IPointData, scaleX: number = 1, scaleY: number = 1\n\n const { boxBounds, widthRange, heightRange, dragBounds, worldBoxBounds } = element\n const { width, height } = startBounds\n\n if (around) {\n totalMove.x *= 2\n totalMove.y *= 2\n }\n\n\n // 获取已经改变的比例\n const originChangedScaleX = element.scaleX / startBounds.scaleX\n const originChangedScaleY = element.scaleY / startBounds.scaleY\n const signX = originChangedScaleX < 0 ? -1 : 1\n const signY = originChangedScaleY < 0 ? -1 : 1\n\n const changedScaleX = scaleMode ? originChangedScaleX : signX * boxBounds.width / width\n const changedScaleY = scaleMode ? originChangedScaleY : signY * boxBounds.height / height\n\n totalMove.x *= scaleMode ? originChangedScaleX : signX\n totalMove.y *= scaleMode ? originChangedScaleY : signY\n\n const topScale = (-totalMove.y + height) / height\n const rightScale = (totalMove.x + width) / width\n const bottomScale = (totalMove.y + height) / height\n const leftScale = (-totalMove.x + width) / width\n\n switch (direction) {\n case top:\n scaleY = topScale\n align = 'bottom'\n break\n case right:\n scaleX = rightScale\n align = 'left'\n break\n case bottom:\n scaleY = bottomScale\n align = 'top'\n break\n case left:\n scaleX = leftScale\n align = 'right'\n break\n case topLeft:\n scaleY = topScale\n scaleX = leftScale\n align = 'bottom-right'\n break\n case topRight:\n scaleY = topScale\n scaleX = rightScale\n align = 'bottom-left'\n break\n case bottomRight:\n scaleY = bottomScale\n scaleX = rightScale\n align = 'top-left'\n break\n case bottomLeft:\n scaleY = bottomScale\n scaleX = leftScale\n align = 'top-right'\n }\n\n if (lockRatio) {\n if (lockRatio === 'corner' && direction % 2) {\n lockRatio = false\n } else {\n let scale: number\n switch (direction) {\n case top:\n case bottom:\n scale = scaleY\n break\n case left:\n case right:\n scale = scaleX\n break\n default:\n scale = Math.sqrt(Math.abs(scaleX * scaleY))\n }\n scaleX = scaleX < 0 ? -scale : scale\n scaleY = scaleY < 0 ? -scale : scale\n }\n }\n\n const useScaleX = scaleX !== 1, useScaleY = scaleY !== 1\n\n if (useScaleX) scaleX /= changedScaleX\n if (useScaleY) scaleY /= changedScaleY\n\n if (!flipable) {\n const { worldTransform } = element\n if (scaleX < 0) scaleX = 1 / boxBounds.width / worldTransform.scaleX\n if (scaleY < 0) scaleY = 1 / boxBounds.height / worldTransform.scaleY\n }\n\n // 检查限制\n\n toPoint(around || align, boxBounds, origin, true)\n\n if (dragBounds) {\n const allowBounds = dragBounds === 'parent' ? element.parent.boxBounds : dragBounds\n const localBounds = new Bounds(element.__localBoxBounds)\n localBounds.scaleOf(element.getLocalPointByInner(origin), scaleX, scaleY)\n\n if (!BoundsHelper.includes(allowBounds, localBounds)) {\n const realBounds = localBounds.getIntersect(allowBounds)\n const fitScaleX = realBounds.width / localBounds.width, fitScaleY = realBounds.height / localBounds.height\n if (useScaleX) scaleX *= fitScaleX\n if (useScaleY) scaleY *= fitScaleY // 后续需优化带旋转的场景\n }\n }\n\n if (useScaleX && widthRange) {\n const nowWidth = boxBounds.width * element.scaleX\n scaleX = within(nowWidth * scaleX, widthRange) / nowWidth\n }\n\n if (useScaleY && heightRange) {\n const nowHeight = boxBounds.height * element.scaleY\n scaleY = within(nowHeight * scaleY, heightRange) / nowHeight\n }\n\n // 防止小于1px\n if (useScaleX && Math.abs(scaleX * worldBoxBounds.width) < 1) scaleX = (scaleX < 0 ? -1 : 1) / worldBoxBounds.width\n if (useScaleY && Math.abs(scaleY * worldBoxBounds.height) < 1) scaleY = (scaleY < 0 ? -1 : 1) / worldBoxBounds.height\n\n if (lockRatio && scaleX !== scaleY) scaleY = scaleX = Math.min(scaleX, scaleY)\n\n return { origin, scaleX, scaleY, direction, lockRatio, around }\n },\n\n getRotateData(bounds: IBoundsData, direction: Direction9, current: IPointData, last: IPointData, around: IAround): IEditorRotateEvent {\n let align: IAlign, origin = {} as IPointData\n\n switch (direction) {\n case topLeft:\n align = 'bottom-right'\n break\n case topRight:\n align = 'bottom-left'\n break\n case bottomRight:\n align = 'top-left'\n break\n case bottomLeft:\n align = 'top-right'\n break\n default:\n align = 'center'\n }\n\n toPoint(around || align, bounds, origin, true)\n\n return { origin, rotation: PointHelper.getRotation(last, origin, c