Skip to content

Commit

Permalink
ESLint
Browse files Browse the repository at this point in the history
  • Loading branch information
Flyer3d committed Mar 11, 2024
1 parent 90f35df commit fbc7c77
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 44 deletions.
4 changes: 2 additions & 2 deletions packages/drawing/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion packages/drawing/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@ulms/ui-drawing",
"version": "3.3.19",
"version": "3.3.19-dev.0",
"description": "Whiteboard for uLMS",
"keywords": [
"lerna"
Expand All @@ -22,6 +22,7 @@
"src"
],
"scripts": {
"lint": "eslint --fix --ext js,jsx ./src",
"build": "rm -rf ./es/* && BABEL_ENV=es rollup --config ./rollup.config.js index.js"
},
"dependencies": {
Expand Down
77 changes: 38 additions & 39 deletions packages/drawing/src/drawing.jsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* eslint-disable react/prop-types, max-classes-per-file */
/* eslint-disable react/prop-types, max-classes-per-file, promise/catch-or-return */
import React from 'react'
import { fabric } from 'fabric/dist/fabric.min'
import Hammer from 'hammerjs'
Expand Down Expand Up @@ -62,7 +62,7 @@ function clearExternalSelection () {
}

let abortController = null
let signal = null;
let signal = null

export class Drawing extends React.Component {
constructor (props) {
Expand Down Expand Up @@ -1085,51 +1085,53 @@ export class Drawing extends React.Component {
}
}

_abortableCreateObjectsPromise = (pageObjects) => {
return new Promise((resolve, reject) => {
let shouldAbort = false
signal.addEventListener('abort', () => {
shouldAbort = true
_abortableCreateObjectsPromise = pageObjects => new Promise((resolve) => {
let shouldAbort = false

signal.addEventListener('abort', () => {
shouldAbort = true
resolve()
})

const normalizedObjects = pageObjects.map(_ => normalizeFields({ ..._, remote: true })).filter(_ => !_._removed)

if (shouldAbort) return
fabric.util.enlivenObjects(normalizedObjects, (enlivenedObjects) => {
// Есть ситуации, когда во время выполнения enlivenObjects this.canvas уже нет
if (shouldAbort) return

if (!this.canvas) {
resolve()
});

const normalizedObjects = pageObjects.map(_ => normalizeFields({..._, remote: true})).filter(_ => !_._removed)
return
}

if(shouldAbort) return
fabric.util.enlivenObjects(normalizedObjects, (enlivenedObjects) => {
enlivenedObjects.forEach((object) => {
// Есть ситуации, когда во время выполнения enlivenObjects this.canvas уже нет
if(shouldAbort) return

if (!this.canvas) {
resolve()

return
}

enlivenedObjects.forEach((object) => {
// Есть ситуации, когда во время выполнения enlivenObjects this.canvas уже нет
if (!this.canvas) {
resolve()
return
}
this._fixObjectInteractivity(object)

this._fixObjectInteractivity(object)
this.canvas._objectsMap.set(object._id, object)
})
if (shouldAbort) return
this.canvas.renderOnAddRemove = false
this.canvas.add(...enlivenedObjects)
this.canvas.renderOnAddRemove = true

this.canvas._objectsMap.set(object._id, object)
})
if(shouldAbort) return
this.canvas.renderOnAddRemove = false
this.canvas.add(...enlivenedObjects)
this.canvas.renderOnAddRemove = true
if (shouldAbort) { // Если дошли до этого места и прервали загрузку объектов - надо удалить добавленные объекты
this.canvas.remove(...enlivenedObjects)

if(shouldAbort) { // Если дошли до этого места и прервали загрузку объектов - надо удалить добавленные объекты
this.canvas.remove(...enlivenedObjects)
return
}
return
}

resolve()
})
resolve()
})
}
})

createCanvasObjects = (pageObjects) => {
if (abortController) {
Expand All @@ -1138,16 +1140,13 @@ export class Drawing extends React.Component {
abortController = null
}

abortController = new window.AbortController();
signal = abortController.signal;
abortController = new window.AbortController()
signal = abortController.signal

this.clearCanvasObjects()
if (pageObjects.length) {
this._abortableCreateObjectsPromise(pageObjects)
.then(() => {
this.canvas.requestRenderAll()
}
)
.then(() => this.canvas.requestRenderAll())
.finally(() => {
signal = null
abortController = null
Expand Down
4 changes: 2 additions & 2 deletions packages/drawing/src/util/fabric-presets.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ fabric.Line.prototype.calcLineEndpointCoords = function calcLineEndpointCoords (
const textBoxOnInput = fabric.Textbox.prototype.onInput
const textBoxFromObject = fabric.Textbox.fromObject

fabric.Textbox.prototype.onInput = function (e) {
fabric.Textbox.prototype.onInput = function onInput (e) {
textBoxOnInput.call(this, e)

if (this.canvas) {
Expand All @@ -93,7 +93,7 @@ fabric.Textbox.prototype.onInput = function (e) {
}
}

fabric.Textbox.fromObject = function (object, callback) {
fabric.Textbox.fromObject = function fromObject (object, callback) {
if (object.fontFamily.includes('BlinkMacSystemFont')) {
// eslint-disable-next-line no-param-reassign
object.fontFamily = object.fontFamily.split(', ').filter(item => item !== 'BlinkMacSystemFont').join(', ')
Expand Down

0 comments on commit fbc7c77

Please sign in to comment.