diff --git a/.eslintignore b/.eslintignore index 07345cd23f..985499105e 100644 --- a/.eslintignore +++ b/.eslintignore @@ -1,5 +1,6 @@ tools/ electron/env.json +electron/about/* src/json/schema licenses.json **/*.min.js @@ -15,7 +16,6 @@ windows/ !/dist/js/export.js !/dist/index.html !/dist/index.web.html -!/dist/polyfill.js !/dist/run.js !/dist/workers/graph.js -!/dist/workers/lib/util.js +!/dist/workers/lib/util.js \ No newline at end of file diff --git a/.eslintrc.js b/.eslintrc.js index 2998ac9f82..13b131d6c5 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -22,8 +22,9 @@ module.exports = { "semi": ["warn", "always"], "quotes": "off", "no-mixed-spaces-and-tabs": "warn", + "no-multi-spaces": "warn", "no-unsafe-optional-chaining": "warn", - "no-useless-escape": "warn", + "no-useless-escape": "off", "no-empty": "off", "no-fallthrough": "off", "no-case-declarations": "off", @@ -32,7 +33,7 @@ module.exports = { // unused vars "no-unused-vars": "off", "@typescript-eslint/no-unused-vars": [ - "warn", + "off", { argsIgnorePattern: "^_", varsIgnorePattern: "^_", diff --git a/check-licenses.js b/check-licenses.js index d29dc73d8d..676ac5d91b 100644 --- a/check-licenses.js +++ b/check-licenses.js @@ -4,23 +4,23 @@ const remoteConfigUrl = 'https://raw.githubusercontent.com/anyproto/open/main/co function processLicenses(licenses, allowedLicenses) { const disallowedPackages = Object.keys(licenses).filter(pkg => { - var pkgLicenses = licenses[pkg].licenses.replace(/[()*]/g, '') + var pkgLicenses = licenses[pkg].licenses.replace(/[()*]/g, ''); // The hyphenation language patterns are licensed under the LGPL (unless otherwise noted) and copyrighted to their respective creators and maintainers. // https://github.com/bramstein/hyphenation-patterns if (pkg.startsWith("hyphenation.")) { - pkgLicenses = "LGPL" - } + pkgLicenses = "LGPL"; + }; // Solutions developed by Anytype or Any Association are allowed if (licenses[pkg].publisher == "Anytype" || licenses[pkg].publisher == "Any" || licenses[pkg].publisher == "Any Association") { return false; - } + }; if (pkgLicenses.includes(' AND ')) { - const licenseNames = pkgLicenses.split(' AND ') + const licenseNames = pkgLicenses.split(' AND '); return !licenseNames.every(name => allowedLicenses.includes(name)); - } + }; const licenseNames = pkgLicenses.split(' OR '); return !licenseNames.some(name => allowedLicenses.includes(name)); @@ -32,9 +32,9 @@ function processLicenses(licenses, allowedLicenses) { }); process.exit(1); } else { - console.info('All packages have allowed licenses.') - } -} + console.info('All packages have allowed licenses.'); + }; +}; https.get(remoteConfigUrl, (res) => { let data = ''; @@ -53,4 +53,4 @@ https.get(remoteConfigUrl, (res) => { }).on('error', (err) => { console.error(`Error retrieving remote configuration: ${err}`); process.exit(1); -}); +}); \ No newline at end of file diff --git a/dist/polyfill.js b/dist/polyfill.js index c1ee868d4d..a79fe07de6 100644 --- a/dist/polyfill.js +++ b/dist/polyfill.js @@ -1,4 +1,4 @@ -let RendererEvents = {}; +const RendererEvents = {}; window.Config = { debug: { @@ -30,7 +30,7 @@ window.Electron = { }; window.require = window.require || function (mod) { - let ret = {}; + const ret = {}; switch (mod) { case '@electron/remote': diff --git a/electron.js b/electron.js index 3244613e0d..371d54ca41 100644 --- a/electron.js +++ b/electron.js @@ -21,6 +21,18 @@ const WindowManager = require('./electron/js/window.js'); const Server = require('./electron/js/server.js'); const Util = require('./electron/js/util.js'); +const csp = [ + "default-src 'self' 'unsafe-eval' blob: http://localhost:*", + "img-src 'self' http://*:* https://*:* data: blob: file://*", + "media-src 'self' http://*:* https://*:* data: blob: file://*", + "style-src 'unsafe-inline' http://localhost:* file://*", + "font-src data: file://* http://localhost:*", + "connect-src file://* http://localhost:* http://127.0.0.1:* ws://localhost:* https://*.anytype.io https://api.amplitude.com/ devtools://devtools data:", + "script-src-elem file: http://localhost:* https://sentry.io devtools://devtools 'unsafe-inline'", + "frame-src chrome-extension://react-developer-tools", + "worker-src 'self' 'unsafe-eval' blob: http://localhost:*", +]; + app.commandLine.appendSwitch('ignore-connections-limit', 'localhost, 127.0.0.1'); app.removeAsDefaultProtocolClient(protocol); @@ -45,17 +57,6 @@ powerMonitor.on('resume', () => { let deeplinkingUrl = ''; let waitLibraryPromise = null; let mainWindow = null; -let csp = [ - "default-src 'self' 'unsafe-eval' blob: http://localhost:*", - "img-src 'self' http://*:* https://*:* data: blob: file://*", - "media-src 'self' http://*:* https://*:* data: blob: file://*", - "style-src 'unsafe-inline' http://localhost:* file://*", - "font-src data: file://* http://localhost:*", - "connect-src file://* http://localhost:* http://127.0.0.1:* ws://localhost:* https://*.anytype.io https://api.amplitude.com/ devtools://devtools data:", - "script-src-elem file: http://localhost:* https://sentry.io devtools://devtools 'unsafe-inline'", - "frame-src chrome-extension://react-developer-tools", - "worker-src 'self' 'unsafe-eval' blob: http://localhost:*", -]; if (is.development && !port) { console.error('ERROR: Please define SERVER_PORT env var'); @@ -82,7 +83,7 @@ if (process.env.ANYTYPE_USE_SIDE_SERVER) { }; function waitForLibraryAndCreateWindows () { - waitLibraryPromise.then((res) => { + waitLibraryPromise.then(() => { global.serverAddress = Server.getAddress(); createWindow(); }, (err) => { @@ -154,13 +155,13 @@ app.on('ready', () => { ...details.responseHeaders, 'Content-Security-Policy': [ csp.join('; ') ] } - }) + }); }); ConfigManager.init(waitForLibraryAndCreateWindows); }); -app.on('second-instance', (event, argv, cwd) => { +app.on('second-instance', (event, argv) => { Util.log('info', 'second-instance'); if (!is.macos) { diff --git a/electron/js/menu.js b/electron/js/menu.js index 460796ee5d..3c8ae49577 100644 --- a/electron/js/menu.js +++ b/electron/js/menu.js @@ -28,14 +28,14 @@ class MenuManager { const lang = Util.getLang(); const langMenu = []; - for (let key of Util.enabledLangs()) { + for (const key of Util.enabledLangs()) { langMenu.push({ label: Locale[key], type: 'checkbox', checked: key == lang, click: () => Api.changeInterfaceLang(this.win, key) }); }; - let menuParam = [ + const menuParam = [ { label: 'Anytype', submenu: [ @@ -197,7 +197,7 @@ class MenuManager { }; const flagMenu = []; - for (let i in flags) { + for (const i in flags) { flagMenu.push({ label: flags[i], type: 'checkbox', checked: config.debug[i], click: () => { diff --git a/electron/js/preload.js b/electron/js/preload.js index 168c2296d5..dda1c86a93 100644 --- a/electron/js/preload.js +++ b/electron/js/preload.js @@ -30,9 +30,9 @@ contextBridge.exposeInMainWorld('Electron', { showOpenDialog: dialog.showOpenDialog, fileParam: (path) => { - let stat = fs.statSync(path); - let buffer = readChunk.sync(path, 0, stat.size); - let type = fileType(buffer); + const stat = fs.statSync(path); + const buffer = readChunk.sync(path, 0, stat.size); + const type = fileType(buffer); return { buffer, type }; }, diff --git a/electron/js/server.js b/electron/js/server.js index bad9032db5..b2fff061e1 100644 --- a/electron/js/server.js +++ b/electron/js/server.js @@ -19,18 +19,18 @@ class Server { this.stop().then(() => { this.isRunning = false; - let logsDir = path.join(workingDir, 'logs'); + const logsDir = path.join(workingDir, 'logs'); try { fs.mkdirSync(logsDir); } catch (e) {}; try { - let env = process.env; + const env = process.env; if (!process.stdout.isTTY) { env['GOLOG_FILE'] = path.join(logsDir, `anytype_${Util.dateForFile()}.log`); }; - let args = [ '127.0.0.1:0', '127.0.0.1:0' ]; + const args = [ '127.0.0.1:0', '127.0.0.1:0' ]; this.cp = childProcess.spawn(binPath, args, { env: env }); } catch (err) { console.error('[Server] Process start error: ', err.toString()); @@ -44,7 +44,7 @@ class Server { }); this.cp.stdout.on('data', data => { - let str = data.toString(); + const str = data.toString(); if (!this.isRunning && str && (str.indexOf(stdoutWebProxyPrefix) >= 0)) { const regex = new RegExp(stdoutWebProxyPrefix + '([^\n^\s]+)'); @@ -57,7 +57,7 @@ class Server { }); this.cp.stderr.on('data', data => { - let chunk = data.toString(); + const chunk = data.toString(); // max chunk size is 8192 bytes // https://github.com/nodejs/node/issues/12921 @@ -85,7 +85,7 @@ class Server { this.isRunning = false; - let crashReport = path.join(logsDir, `crash_${Util.dateForFile()}.log`); + const crashReport = path.join(logsDir, `crash_${Util.dateForFile()}.log`); try { fs.writeFileSync(crashReport, this.lastErrors.join('\n'), 'utf-8'); } catch(e) { diff --git a/electron/js/update.js b/electron/js/update.js index 88e99370da..3d48fe29eb 100644 --- a/electron/js/update.js +++ b/electron/js/update.js @@ -51,7 +51,7 @@ class UpdateManager { autoUpdater.on('update-not-available', (info) => { this.isUpdating = false; - Util.log('info', 'Update not available: ' + JSON.stringify(info, null, 3)); + Util.log('info', 'Update not available: ' + JSON.stringify(info, null, 3)); Util.send(this.win, 'update-not-available', this.autoUpdate); }); @@ -65,7 +65,7 @@ class UpdateManager { autoUpdater.on('download-progress', (progress) => { this.isUpdating = true; - let msg = [ + const msg = [ `Download speed: ${progress.bytesPerSecond}`, '-', `Downloaded: ${progress.percent}%`, @@ -81,7 +81,7 @@ class UpdateManager { this.isUpdating = false; - Util.log('info', 'Update downloaded: ' + JSON.stringify(info, null, 3)); + Util.log('info', 'Update downloaded: ' + JSON.stringify(info, null, 3)); Util.send(this.win, 'update-downloaded'); if (!this.autoUpdate) { diff --git a/electron/js/util.js b/electron/js/util.js index 6016437847..372d7373be 100644 --- a/electron/js/util.js +++ b/electron/js/util.js @@ -60,7 +60,7 @@ class Util { }; getBgColor (theme) { - let bg = { + const bg = { '': '#fff', dark: '#060606', }; @@ -121,13 +121,13 @@ class Util { // Replace files loaded by url and copy them in page folder try { content = content.replace(/'(file:\/\/[^']+)'/g, function (s, p, o) { - let a = p.split('app.asar/dist/'); + const a = p.split('app.asar/dist/'); let name = a[1].split('/'); name = name[name.length - 1]; - let src = p.replace('file://', '').replace(/\?.*/, '').replace(/\/app.asar\//g, '/app.asar.unpacked/'); - let dst = path.join(filesPath, name).replace(/\?.*/, ''); + const src = p.replace('file://', '').replace(/\?.*/, '').replace(/\/app.asar\//g, '/app.asar.unpacked/'); + const dst = path.join(filesPath, name).replace(/\?.*/, ''); fs.copyFileSync(src, dst); return `'./${fn}/${name}'`; @@ -145,7 +145,7 @@ class Util { let replaceJs = ''; let replaceCss = ''; - let replaceMeta = ` + const replaceMeta = ` `; diff --git a/electron/js/window.js b/electron/js/window.js index 687820e9ae..ff4ff43e2c 100644 --- a/electron/js/window.js +++ b/electron/js/window.js @@ -111,7 +111,7 @@ class WindowManager { }); } else { const primaryDisplay = screen.getPrimaryDisplay(); - const { width, height } = primaryDisplay.workAreaSize; + const { width, height } = primaryDisplay.workAreaSize; param = Object.assign(param, this.getWindowPosition(param, width, height)); }; @@ -212,7 +212,7 @@ class WindowManager { getWindowPosition (param, displayWidth, displayHeight) { let x = Math.round(displayWidth / 2 - param.width / 2); let y = Math.round(displayHeight / 2 - param.height / 2 + 20); - let currentWindow = BrowserWindow.getFocusedWindow(); + const currentWindow = BrowserWindow.getFocusedWindow(); if (currentWindow) { const [xPos, yPos] = currentWindow.getPosition(); diff --git a/package.json b/package.json index 3f3d951d64..b46e292633 100644 --- a/package.json +++ b/package.json @@ -549,6 +549,7 @@ }, "lint-staged": { "{src,electron}/**/*.{ts,tsx}": [ + "npm run lint" ] }, "husky": { diff --git a/save-node-deps.js b/save-node-deps.js index 9db2b1e718..06fc3da2b7 100644 --- a/save-node-deps.js +++ b/save-node-deps.js @@ -2,21 +2,21 @@ const fs = require('fs'); -let stdin = process.openStdin(); +const stdin = process.openStdin(); let data = ""; stdin.on('data', function(chunk) { data +=chunk; }); -let skipIds = [ 'electron' ]; +const skipIds = [ 'electron' ]; stdin.on('end', function() { let lines = data.split('\n').sort(); - let baseDepsFile = fs.readFileSync('package.deps.json'); - let baseDepsJSON = JSON.parse(baseDepsFile); - let packageFile = fs.readFileSync('package.json'); - let packageJSON = JSON.parse(packageFile); + const baseDepsFile = fs.readFileSync('package.deps.json'); + const baseDepsJSON = JSON.parse(baseDepsFile); + const packageFile = fs.readFileSync('package.json'); + const packageJSON = JSON.parse(packageFile); lines = [ ...new Set(lines) ]; lines = lines.filter((el) => { @@ -29,6 +29,6 @@ stdin.on('end', function() { console.log(lines); packageJSON.build.files = baseDepsJSON.concat(lines); - let jsonS = JSON.stringify(packageJSON, null, '\t'); + const jsonS = JSON.stringify(packageJSON, null, '\t'); fs.writeFileSync('package.json', jsonS); }); \ No newline at end of file diff --git a/src/ts/app.tsx b/src/ts/app.tsx index 6da282f5f6..b0cdf70edd 100644 --- a/src/ts/app.tsx +++ b/src/ts/app.tsx @@ -283,8 +283,8 @@ class RoutePage extends React.Component { return ( - - + + diff --git a/src/ts/component/block/cover.tsx b/src/ts/component/block/cover.tsx index acebb14bf6..6b8d8fb8a4 100644 --- a/src/ts/component/block/cover.tsx +++ b/src/ts/component/block/cover.tsx @@ -4,7 +4,7 @@ import { observer } from 'mobx-react'; import { Icon, Drag, Cover, Loader, Label } from 'Component'; import { I, C, UtilCommon, UtilData, UtilObject, focus, translate, keyboard, Action } from 'Lib'; import { commonStore, blockStore, detailStore, menuStore } from 'Store'; -import ControlButtons from 'Component/page/head/controlButtons'; +import ControlButtons from 'Component/page/head/controlButtons'; import Constant from 'json/constant.json'; import Url from 'json/url.json'; @@ -525,13 +525,13 @@ const BlockCover = observer(class BlockCover extends React.Component { - let old = block.content.objectOrder.find(item => (view.id == item.viewId) && (item.groupId == it.groupId)); + const old = block.content.objectOrder.find(item => (view.id == item.viewId) && (item.groupId == it.groupId)); if (old) { set(old, it); } else { diff --git a/src/ts/component/block/dataview/cell/index.tsx b/src/ts/component/block/dataview/cell/index.tsx index 040c40e7a2..791f3bc79a 100644 --- a/src/ts/component/block/dataview/cell/index.tsx +++ b/src/ts/component/block/dataview/cell/index.tsx @@ -63,7 +63,7 @@ class Cell extends React.Component { Relation.className(relation.format), (canEdit ? 'canEdit' : ''), (relationKey == 'name' ? 'isName' : ''), - (!check ? 'isEmpty' : ''), + (!check ? 'isEmpty' : ''), ]; let CellComponent: any = null; @@ -172,7 +172,7 @@ class Cell extends React.Component { let closeIfOpen = true; let menuId = ''; - let setOn = () => { + const setOn = () => { cell.addClass('isEditing'); if (cellPosition) { @@ -196,7 +196,7 @@ class Cell extends React.Component { win.trigger('resize'); }; - let setOff = () => { + const setOff = () => { keyboard.disableBlur(false); if (this.ref) { @@ -342,7 +342,7 @@ class Cell extends React.Component { break; }; - let options = [ + const options = [ { id: 'go', icon: 'browse', name: translate(`menuDataviewUrlActionGo${relation.format}`) }, { id: 'copy', icon: 'copy', name: translate('menuDataviewUrlActionGoCopy') }, ]; diff --git a/src/ts/component/block/dataview/cell/item/object.tsx b/src/ts/component/block/dataview/cell/item/object.tsx index 15680e033f..b79e9b4c4a 100644 --- a/src/ts/component/block/dataview/cell/item/object.tsx +++ b/src/ts/component/block/dataview/cell/item/object.tsx @@ -22,14 +22,13 @@ const ItemObject = observer(class ItemObject extends React.Component { }; render () { - let { object, iconSize, relation, elementMapper, canEdit } = this.props; - let cn = [ 'element' ]; + const { iconSize, relation, canEdit } = this.props; + const cn = [ 'element' ]; + const object = this.getObject(); + let iconObject = null; let iconRemove = null; - if (elementMapper) { - object = elementMapper(relation, object); - }; if (object.isHidden) { cn.push('isHidden'); }; @@ -53,11 +52,8 @@ const ItemObject = observer(class ItemObject extends React.Component { }; onClick (e: any) { - let { object, relation, elementMapper, onClick, canEdit } = this.props; - - if (elementMapper) { - object = elementMapper(relation, object); - }; + const { onClick, canEdit } = this.props; + const object = this.getObject(); if (!canEdit && onClick) { onClick(e, object); @@ -74,6 +70,16 @@ const ItemObject = observer(class ItemObject extends React.Component { }; }; + getObject () { + const { relation, elementMapper } = this.props; + + let object = this.props.object || {}; + if (elementMapper) { + object = elementMapper(relation, object); + }; + return object; + }; + }); export default ItemObject; \ No newline at end of file diff --git a/src/ts/component/block/dataview/cell/object.tsx b/src/ts/component/block/dataview/cell/object.tsx index 9259cc2e54..89550f5ccb 100644 --- a/src/ts/component/block/dataview/cell/object.tsx +++ b/src/ts/component/block/dataview/cell/object.tsx @@ -47,9 +47,9 @@ const CellObject = observer(class CellObject extends React.Component ); } else if (relation.format == I.RelationType.Date) { - let mask = [ '99.99.9999' ]; - let ph = []; + const mask = [ '99.99.9999' ]; + const ph = []; if (viewRelation.dateFormat == I.DateFormat.ShortUS) { ph.push('mm.dd.yyyy'); @@ -90,7 +90,7 @@ const CellText = observer(class CellText extends React.Component ph.push('hh:mm'); }; - let maskOptions = { + const maskOptions = { mask: mask.join(' '), separator: '.', hourFormat: 12, @@ -166,7 +166,7 @@ const CellText = observer(class CellText extends React.Component if (relation.format == I.RelationType.Number) { if (value !== null) { - let mapped = Relation.mapValue(relation, value); + const mapped = Relation.mapValue(relation, value); if (mapped !== null) { value = mapped; } else { @@ -243,7 +243,7 @@ const CellText = observer(class CellText extends React.Component let value = this.value; if (relation.format == I.RelationType.Date) { - let format = [ + const format = [ (viewRelation.dateFormat == I.DateFormat.ShortUS) ? 'm.d.Y' : 'd.m.Y' ]; if (viewRelation.includeTime) { @@ -261,7 +261,7 @@ const CellText = observer(class CellText extends React.Component if (this.ref) { this.ref.setValue(value); if (this.ref.setRange) { - let length = String(value || '').length; + const length = String(value || '').length; this.ref.setRange(this.range || { from: length, to: length }); }; }; diff --git a/src/ts/component/block/dataview/controls.tsx b/src/ts/component/block/dataview/controls.tsx index 8af0f4a3e9..72eeaaba75 100644 --- a/src/ts/component/block/dataview/controls.tsx +++ b/src/ts/component/block/dataview/controls.tsx @@ -37,7 +37,7 @@ const Controls = observer(class Controls extends React.Component ) : ''} - ) : ''} + ) : ''} diff --git a/src/ts/component/block/dataview/head.tsx b/src/ts/component/block/dataview/head.tsx index ec9a219d62..2aaa22a693 100644 --- a/src/ts/component/block/dataview/head.tsx +++ b/src/ts/component/block/dataview/head.tsx @@ -155,7 +155,7 @@ const Head = observer(class Head extends React.Component }; let filters: I.Filter[] = []; - let addParam: any = {}; + const addParam: any = {}; if (isCollection) { addParam.name = translate('blockDataviewCreateNewCollection'); @@ -189,7 +189,7 @@ const Head = observer(class Head extends React.Component }; let menuId = ''; - let menuParam: any = { + const menuParam: any = { menuKey: item.id, element: `#${this.menuContext.getId()} #item-${item.id}`, offsetX: this.menuContext.getSize().width, diff --git a/src/ts/component/block/dataview/view/board.tsx b/src/ts/component/block/dataview/view/board.tsx index c383a65f01..9a1444ef76 100644 --- a/src/ts/component/block/dataview/view/board.tsx +++ b/src/ts/component/block/dataview/view/board.tsx @@ -138,7 +138,7 @@ const ViewBoard = observer(class ViewBoard extends React.Component it.viewId == view.id); + const el = block.content.groupOrder.find(it => it.viewId == view.id); if (el) { el.groups.forEach(it => groupOrder[it.groupId] = it); @@ -149,7 +149,7 @@ const ViewBoard = observer(class ViewBoard extends React.Component { + const groups = (message.groups || []).map((it: any) => { let bgColor = 'grey'; let value: any = it.value; let option: any = null; @@ -179,7 +179,7 @@ const ViewBoard = observer(class ViewBoard extends React.Component it.viewId == view.id); + const el = block.content.groupOrder.find(it => it.viewId == view.id); const groupOrder: any = {}; if (el) { diff --git a/src/ts/component/block/dataview/view/board/column.tsx b/src/ts/component/block/dataview/view/board/column.tsx index bf99a836b2..9035a3834a 100644 --- a/src/ts/component/block/dataview/view/board/column.tsx +++ b/src/ts/component/block/dataview/view/board/column.tsx @@ -156,7 +156,7 @@ const Column = observer(class Column extends React.Component { }; let value = this.props.value; - let filter: any = { operator: I.FilterOperator.And, relationKey: relation.relationKey }; + const filter: any = { operator: I.FilterOperator.And, relationKey: relation.relationKey }; switch (relation.format) { default: diff --git a/src/ts/component/block/dataview/view/gallery.tsx b/src/ts/component/block/dataview/view/gallery.tsx index ec94920b2e..d78a09a8bc 100644 --- a/src/ts/component/block/dataview/view/gallery.tsx +++ b/src/ts/component/block/dataview/view/gallery.tsx @@ -53,13 +53,13 @@ const ViewGallery = observer(class ViewGallery extends React.Component { offset += getLimit(); @@ -229,7 +229,7 @@ const ViewGallery = observer(class ViewGallery extends React.Component { const win = $(window); const menus = menuStore.list.filter(it => Constant.menuIds.cell.includes(it.id)); - for (let menu of menus) { + for (const menu of menus) { win.trigger('resize.' + UtilCommon.toCamelCase('menu-' + menu.id)); }; @@ -397,10 +397,10 @@ const ViewGrid = observer(class ViewGrid extends React.Component { }; loadMoreRows ({ startIndex, stopIndex }) { - let { rootId, block, loadData, getView, getLimit } = this.props; - let subId = dbStore.getSubId(rootId, block.id); + const { rootId, block, loadData, getView, getLimit } = this.props; + const subId = dbStore.getSubId(rootId, block.id); let { offset } = dbStore.getMeta(subId, ''); - let view = getView(); + const view = getView(); return new Promise((resolve, reject) => { offset += getLimit(); diff --git a/src/ts/component/block/dataview/view/list.tsx b/src/ts/component/block/dataview/view/list.tsx index b23e4df919..84e58de5bd 100644 --- a/src/ts/component/block/dataview/view/list.tsx +++ b/src/ts/component/block/dataview/view/list.tsx @@ -129,10 +129,10 @@ const ViewList = observer(class ViewList extends React.Component { offset += getLimit(); diff --git a/src/ts/component/block/dataview/view/list/row.tsx b/src/ts/component/block/dataview/view/list/row.tsx index 1b47cf2cf7..b196f88bf8 100644 --- a/src/ts/component/block/dataview/view/list/row.tsx +++ b/src/ts/component/block/dataview/view/list/row.tsx @@ -66,7 +66,7 @@ const Row = observer(class Row extends React.Component { > {content} - ) + ); }; if (isCollection && !isInline) { diff --git a/src/ts/component/block/div.tsx b/src/ts/component/block/div.tsx index af4b5d16d1..bb68c56449 100644 --- a/src/ts/component/block/div.tsx +++ b/src/ts/component/block/div.tsx @@ -19,7 +19,7 @@ const BlockDiv = observer(class BlockDiv extends React.Component it.name); let relations = Relation.getSetOfObjects(rootId, storeId, Constant.typeId.relation).map(it => it.name); - let setOfString = []; - let tl = types.length; - let rl = relations.length; + const setOfString = []; + const tl = types.length; + const rl = relations.length; if (tl) { const pluralType = UtilCommon.plural(tl, translate('pluralType')); @@ -351,7 +351,7 @@ const BlockFeatured = observer(class BlockFeatured extends React.Component { let canSelect = !isInsideTable && !isSelectionDisabled; let canDrop = !readonly && !isInsideTable; let canDropMiddle = false; - let cn: string[] = [ 'block', UtilData.blockClass(block), 'align' + hAlign, 'index' + index ]; - let cd: string[] = [ 'wrapContent' ]; + const cn: string[] = [ 'block', UtilData.blockClass(block), 'align' + hAlign, 'index' + index ]; + const cd: string[] = [ 'wrapContent' ]; let blockComponent = null; - let empty = null; - let setRef = ref => this.ref = ref; + const empty = null; + const setRef = ref => this.ref = ref; let additional = null; let renderChildren = !isInsideTable; @@ -664,7 +664,7 @@ const Block = observer(class Block extends React.Component { x = x / (sum * width); // Snap - for (let s of snaps) { + for (const s of snaps) { if ((x >= s - SNAP) && (x <= s + SNAP)) { x = s; }; @@ -692,7 +692,7 @@ const Block = observer(class Block extends React.Component { let c = 0; let num = 0; - for (let i in children) { + for (const i in children) { const child = children[i]; c += child.fields.width || 1 / length; @@ -726,7 +726,7 @@ const Block = observer(class Block extends React.Component { return; }; - const param = { + const param = { type: I.BlockType.Text, style: I.TextStyle.Paragraph, }; diff --git a/src/ts/component/block/media/file.tsx b/src/ts/component/block/media/file.tsx index b1b8898f82..846cca3438 100644 --- a/src/ts/component/block/media/file.tsx +++ b/src/ts/component/block/media/file.tsx @@ -30,7 +30,7 @@ const BlockFile = observer(class BlockFile extends React.Component= s - SNAP) && (width <= s + SNAP)) { width = s; }; @@ -1459,7 +1459,7 @@ const BlockTable = observer(class BlockTable extends React.Component it.id == frame.id); if (!current) { diff --git a/src/ts/component/block/table/cell.tsx b/src/ts/component/block/table/cell.tsx index ed1d5537b2..268f9db8ea 100644 --- a/src/ts/component/block/table/cell.tsx +++ b/src/ts/component/block/table/cell.tsx @@ -41,7 +41,7 @@ const BlockTableCell = observer(class BlockTableCell extends React.Component { let onDragStart = null; let onClick = null; - let cn = [ 'handle' ]; + const cn = [ 'handle' ]; let canDrag = true; switch (item.type) { @@ -49,7 +49,7 @@ const BlockTableCell = observer(class BlockTableCell extends React.Component { onDragStartColumn(e, column.id); }; - onClick = (e: any) => { onHandleColumn(e, item.type, row.id, column.id, cellId); } + onClick = (e: any) => { onHandleColumn(e, item.type, row.id, column.id, cellId); }; break; case I.BlockType.TableRow: diff --git a/src/ts/component/block/text.tsx b/src/ts/component/block/text.tsx index 570a489aca..c6327016c4 100644 --- a/src/ts/component/block/text.tsx +++ b/src/ts/component/block/text.tsx @@ -22,7 +22,7 @@ const langs = [ 'vhdl', 'visual-basic', 'wasm', 'yaml', 'javascript', 'css', 'markup', 'markup-templating', 'csharp', 'php', 'go', 'swift', 'kotlin', 'wolfram', ]; -for (let lang of langs) { +for (const lang of langs) { require(`prismjs/components/prism-${lang}.js`); }; @@ -77,7 +77,7 @@ const BlockText = observer(class BlockText extends React.Component { let marker: any = null; let placeholder = translate('placeholderBlock'); - let cv: string[] = [ 'value', 'focusable', 'c' + id ]; + const cv: string[] = [ 'value', 'focusable', 'c' + id ]; let additional = null; if (color) { @@ -88,7 +88,7 @@ const BlockText = observer(class BlockText extends React.Component { }; // Subscriptions - for (let mark of marks) { + for (const mark of marks) { if ([ I.MarkType.Mention, I.MarkType.Object ].includes(mark.type)) { const object = detailStore.get(rootId, mark.param, []); }; @@ -126,7 +126,7 @@ const BlockText = observer(class BlockText extends React.Component { case I.TextStyle.Code: { const options: I.Option[] = []; - for (let i in Constant.codeLang) { + for (const i in Constant.codeLang) { options.push({ id: i, name: Constant.codeLang[i] }); }; @@ -946,7 +946,7 @@ const BlockText = observer(class BlockText extends React.Component { // Parse markdown commands if (block.canHaveMarks() && !isInsideTable) { - for (let k in Markdown) { + for (const k in Markdown) { const reg = new RegExp(`^(${k}\\s)`); const newStyle = Markdown[k]; @@ -1073,9 +1073,9 @@ const BlockText = observer(class BlockText extends React.Component { }; onSmile () { - let { rootId, block } = this.props; - let win = $(window); - let range = this.getRange(); + const { rootId, block } = this.props; + const win = $(window); + const range = this.getRange(); let value = this.getValue(); menuStore.open('smile', { diff --git a/src/ts/component/drag/layer.tsx b/src/ts/component/drag/layer.tsx index 3e9fe77ed1..5c3400a8ca 100644 --- a/src/ts/component/drag/layer.tsx +++ b/src/ts/component/drag/layer.tsx @@ -91,7 +91,7 @@ class DragLayer extends React.Component { const inner = node.find('#inner').html(''); const container = UtilCommon.getPageContainer(keyboard.isPopup()); - let wrap = $('
'); + const wrap = $('
'); let items: any[] = []; switch (type) { diff --git a/src/ts/component/drag/provider.tsx b/src/ts/component/drag/provider.tsx index d8d612517e..742cc667fa 100644 --- a/src/ts/component/drag/provider.tsx +++ b/src/ts/component/drag/provider.tsx @@ -89,10 +89,11 @@ const DragProvider = observer(class DragProvider extends React.Component const isTargetBot = item.hasClass('targetBot'); const isTargetCol = item.hasClass('targetCol'); const isEmptyToggle = item.hasClass('emptyToggle'); + const x = offset.left; + const width = rect.width; - let x = offset.left; let y = offset.top; - let { width, height } = rect; + let height = rect.height; // Add block's paddings to height if ((data.dropType == I.DropType.Block) && (data.type != I.BlockType.Layout)) { @@ -175,8 +176,8 @@ const DragProvider = observer(class DragProvider extends React.Component }; if (isFileDrop) { - let paths: string[] = []; - for (let file of dataTransfer.files) { + const paths: string[] = []; + for (const file of dataTransfer.files) { paths.push(file.path); }; @@ -255,7 +256,7 @@ const DragProvider = observer(class DragProvider extends React.Component }; e.preventDefault(); - e.stopPropagation(); + e.stopPropagation(); const isPopup = keyboard.isPopup(); const top = UtilCommon.getScrollContainer(isPopup).scrollTop(); @@ -301,9 +302,9 @@ const DragProvider = observer(class DragProvider extends React.Component let data: any = {}; try { data = JSON.parse(e.dataTransfer.getData('text/plain')) || {}; } catch (e) { /**/ }; - let { rootId, dropType, withAlt } = data; - let ids = data.ids || []; - let contextId = rootId; + const { rootId, dropType, withAlt } = data; + const ids = data.ids || []; + const contextId = rootId; let targetContextId = keyboard.getRootId(); let isToggle = false; @@ -452,20 +453,20 @@ const DragProvider = observer(class DragProvider extends React.Component const container = UtilCommon.getScrollContainer(isPopup); const top = container.scrollTop(); - for (let [ key, value ] of this.objectData) { - let rect = value.obj.get(0).getBoundingClientRect() as DOMRect; + for (const [ key, value ] of this.objectData) { + const rect = value.obj.get(0).getBoundingClientRect() as DOMRect; this.objectData.set(key, { ...value, y: rect.y + top }); }; }; checkNodes (e: any, ex: number, ey: number) { - let dataTransfer = e.dataTransfer || e.originalEvent.dataTransfer; - let isItemDrag = UtilCommon.getDataTransferItems(dataTransfer.items).length ? true : false; - let isFileDrag = dataTransfer.types.includes('Files'); + const dataTransfer = e.dataTransfer || e.originalEvent.dataTransfer; + const isItemDrag = UtilCommon.getDataTransferItems(dataTransfer.items).length ? true : false; + const isFileDrag = dataTransfer.types.includes('Files'); let data: any = {}; try { - for (let type of dataTransfer.types) { + for (const type of dataTransfer.types) { if (type.match(/^data-/)) { data = JSON.parse(type.replace(/^data-/, '')); break; @@ -476,9 +477,10 @@ const DragProvider = observer(class DragProvider extends React.Component this.setHoverData(null); this.setPosition(I.BlockPosition.None); - for (let [ key, value ] of this.objectData) { - let { x, y, width, height, dropType } = value; + for (const [ key, value ] of this.objectData) { + const { y, height, dropType } = value; + let { x, width } = value; if (dropType == I.DropType.Block) { x -= OFFSET; width += OFFSET * 2; @@ -490,9 +492,9 @@ const DragProvider = observer(class DragProvider extends React.Component }; }; - let dropType = String(data.droptype) || ''; - let rootId = String(data.rootid) || ''; - let ids = data.ids || []; + const dropType = String(data.droptype) || ''; + const rootId = String(data.rootid) || ''; + const ids = data.ids || []; let x = 0; let y = 0; let width = 0; @@ -658,16 +660,16 @@ const DragProvider = observer(class DragProvider extends React.Component setClass (ids: string[]) { $('.block.isDragging').removeClass('isDragging'); - for (let id of ids) { + for (const id of ids) { $('#block-' + id).addClass('isDragging'); }; }; checkParentIds (ids: string[], id: string): boolean { - let parentIds: string[] = []; + const parentIds: string[] = []; this.getParentIds(id, parentIds); - for (let dropId of ids) { + for (const dropId of ids) { if ((dropId == id) || (parentIds.length && parentIds.includes(dropId))) { return false; }; @@ -707,9 +709,9 @@ const DragProvider = observer(class DragProvider extends React.Component return null; }; - let props = child.props || {}; - let children = props.children; - let dataset = props.dataset || {}; + const props = child.props || {}; + const children = props.children; + const dataset = props.dataset || {}; if (children) { child = React.cloneElement(child, { children: this.injectProps(children) }); diff --git a/src/ts/component/editor/page.tsx b/src/ts/component/editor/page.tsx index b566a01c50..e96378a98f 100644 --- a/src/ts/component/editor/page.tsx +++ b/src/ts/component/editor/page.tsx @@ -28,7 +28,7 @@ const EditorPage = observer(class EditorPage extends React.Component it.isText()) + const block = blockStore.getFirstBlock(rootId, 1, it => it.isText()); if (!block) { return; @@ -431,17 +431,17 @@ const EditorPage = observer(class EditorPage extends React.Component { type = item.type; param = item.param; @@ -815,9 +815,9 @@ const EditorPage = observer(class EditorPage extends React.Component { type = item.type; param = item.param; @@ -1008,7 +1008,7 @@ const EditorPage = observer(class EditorPage extends React.Component { let value = block.content.text; let to = 0; - let marks = UtilCommon.objectCopy(block.content.marks || []); + const marks = UtilCommon.objectCopy(block.content.marks || []); switch (item.id) { case 'link': @@ -1882,13 +1882,13 @@ const EditorPage = observer(class EditorPage extends React.Component { }; setError (v: boolean) { - this.setState({ hasError: v }) + this.setState({ hasError: v }); }; focus () { diff --git a/src/ts/component/form/pin.tsx b/src/ts/component/form/pin.tsx index ffa2fd03be..c919b32b7d 100644 --- a/src/ts/component/form/pin.tsx +++ b/src/ts/component/form/pin.tsx @@ -1,6 +1,6 @@ import * as React from 'react'; import sha1 from 'sha1'; -import { Input } from 'Component'; +import { Input } from 'Component'; import { keyboard } from 'Lib'; import Constant from 'json/constant.json'; diff --git a/src/ts/component/list/children.tsx b/src/ts/component/list/children.tsx index ad3e838b11..f3b8e17fc4 100644 --- a/src/ts/component/list/children.tsx +++ b/src/ts/component/list/children.tsx @@ -54,7 +54,7 @@ const ListChildren = observer(class ListChildren extends React.Component const cn = [ 'children', (block.isTextToggle() ? 'canToggle' : '') ]; let ColResize: any = (): any => null; - let isRow = block.isLayoutRow(); + const isRow = block.isLayoutRow(); if (isRow) { ColResize = (item: any) => ( @@ -69,8 +69,8 @@ const ListChildren = observer(class ListChildren extends React.Component return (
{children.map((item: any, i: number) => { - let css: any = {}; - let cn = []; + const css: any = {}; + const cn = []; if (isRow) { css.width = (item.fields.width || 1 / length ) * 100 + '%'; diff --git a/src/ts/component/list/widget.tsx b/src/ts/component/list/widget.tsx index 6bdb817b5c..62051740ba 100644 --- a/src/ts/component/list/widget.tsx +++ b/src/ts/component/list/widget.tsx @@ -291,7 +291,7 @@ const ListWidget = observer(class ListWidget extends React.Component { {item.name ?
{item.name}
: ''}
{item.children.map((action: any, i: number) => { - let icn: string[] = [ 'inner' ]; + const icn: string[] = [ 'inner' ]; if (action.isTextColor) { icn.push('textColor textColor-' + (action.value || 'default')); @@ -222,7 +222,7 @@ class MenuBlockAction extends React.Component { let hasBookmark = true; let hasDataview = true; - for (let id of blockIds) { + for (const id of blockIds) { const block = blockStore.getLeaf(rootId, id); if (!block) { continue; @@ -288,7 +288,7 @@ class MenuBlockAction extends React.Component { let hasColor = true; let hasBg = true; - for (let id of blockIds) { + for (const id of blockIds) { const block = blockStore.getLeaf(rootId, id); if (!block) { continue; @@ -388,7 +388,7 @@ class MenuBlockAction extends React.Component { const sections = this.getSections(); let items: any[] = []; - for (let section of sections) { + for (const section of sections) { items = items.concat(section.children); }; @@ -432,7 +432,7 @@ class MenuBlockAction extends React.Component { let ids: string[] = []; let filters = []; let menuId = ''; - let menuParam: I.MenuParam = { + const menuParam: I.MenuParam = { menuKey: item.itemId, element: `#${getId()} #item-${item.id}`, offsetX: offsetX, @@ -462,7 +462,7 @@ class MenuBlockAction extends React.Component { this.setFocus(blockIds[0]); if (item.itemId == I.TextStyle.Toggle) { - blockIds.forEach(id => blockStore.toggle(rootId, id, true)) + blockIds.forEach(id => blockStore.toggle(rootId, id, true)); }; }); }; @@ -503,7 +503,7 @@ class MenuBlockAction extends React.Component { case 'move': { menuId = 'searchObject'; - let skipIds = [ rootId ]; + const skipIds = [ rootId ]; blockIds.forEach((id: string) => { const block = blockStore.getLeaf(rootId, id); if (block && block.isLink() && block.content.targetBlockId) { @@ -595,7 +595,7 @@ class MenuBlockAction extends React.Component { const isCollection = Dataview.isCollection(rootId, blockId); const name = translate(isCollection ? 'commonLCCollection' : 'commonLCSet'); - let addParam: any = { + const addParam: any = { name: UtilCommon.sprintf(translate('menuBlockActionsCreateNew'), name), }; if (isCollection) { diff --git a/src/ts/component/menu/block/add.tsx b/src/ts/component/menu/block/add.tsx index 5c15ac82fe..bf7adcafc9 100644 --- a/src/ts/component/menu/block/add.tsx +++ b/src/ts/component/menu/block/add.tsx @@ -46,7 +46,7 @@ const MenuBlockAdd = observer(class MenuBlockAdd extends React.Component let content = null; if (item.isRelationAdd) { - content = ( + content = (
); } else { - let cn = []; - let icn: string[] = [ 'inner' ]; + const cn = []; + const icn: string[] = [ 'inner' ]; if (item.isTextColor) { icn.push('textColor textColor-' + (item.value || 'default')); @@ -340,7 +340,7 @@ const MenuBlockAdd = observer(class MenuBlockAdd extends React.Component const sections = this.getSections(); let items: any[] = []; - for (let section of sections) { + for (const section of sections) { if (withSections) { items.push({ id: section.id, name: section.name, isSection: true }); }; @@ -372,7 +372,7 @@ const MenuBlockAdd = observer(class MenuBlockAdd extends React.Component const position = length ? I.BlockPosition.Bottom : I.BlockPosition.Replace; let menuId = ''; - let menuParam: I.MenuParam = { + const menuParam: I.MenuParam = { menuKey: item.itemId, element: `#${getId()} #item-${item.id}`, offsetX: getSize().width, @@ -464,8 +464,8 @@ const MenuBlockAdd = observer(class MenuBlockAdd extends React.Component keyboard.setFocus(false); - let text = String(data.text || ''); - let length = text.length; + const text = String(data.text || ''); + const length = text.length; let marks = data.marks || []; let position = length ? I.BlockPosition.Bottom : I.BlockPosition.Replace; @@ -517,7 +517,7 @@ const MenuBlockAdd = observer(class MenuBlockAdd extends React.Component }; if (item.isBlock) { - let param: any = { + const param: any = { type: item.type, bgColor: block.bgColor, hAlign: block.hAlign, @@ -673,7 +673,7 @@ const MenuBlockAdd = observer(class MenuBlockAdd extends React.Component moveToPage (type: string) { const { param, dataset } = this.props; const { data } = param; - const { blockId, rootId, } = data; + const { blockId, rootId, } = data; const { selection } = dataset || {}; let ids = []; diff --git a/src/ts/component/menu/block/align.tsx b/src/ts/component/menu/block/align.tsx index 317a2b72f6..fb461ea5b1 100644 --- a/src/ts/component/menu/block/align.tsx +++ b/src/ts/component/menu/block/align.tsx @@ -56,8 +56,8 @@ class MenuBlockHAlign extends React.Component { const blockIds = data.blockIds || []; let hasQuote = false; - for (let id of blockIds) { - let block = blockStore.getLeaf(rootId, id); + for (const id of blockIds) { + const block = blockStore.getLeaf(rootId, id); if (block && block.isTextQuote()) { hasQuote = true; }; diff --git a/src/ts/component/menu/block/latex.tsx b/src/ts/component/menu/block/latex.tsx index c62a9865e7..3b8de435b1 100644 --- a/src/ts/component/menu/block/latex.tsx +++ b/src/ts/component/menu/block/latex.tsx @@ -288,7 +288,7 @@ const MenuBlockLatex = observer(class MenuBlockLatex extends React.Component { const sections = this.getSections(); let items: any[] = []; - for (let section of sections) { + for (const section of sections) { items = items.concat(section.children); }; @@ -137,7 +137,7 @@ class MenuBlockLayout extends React.Component { const object = detailStore.get(rootId, rootId); let menuId = ''; - let menuParam: I.MenuParam = { + const menuParam: I.MenuParam = { menuKey: item.id, element: `#${getId()} #item-${item.id}`, offsetX: getSize().width, diff --git a/src/ts/component/menu/block/link.tsx b/src/ts/component/menu/block/link.tsx index 1a9e6a29d5..ec55816ed7 100644 --- a/src/ts/component/menu/block/link.tsx +++ b/src/ts/component/menu/block/link.tsx @@ -269,7 +269,7 @@ const MenuBlockLink = observer(class MenuBlockLink extends React.Component { let setDefaultTemplate = null; let linkTo = { id: 'linkTo', icon: 'linkTo', name: translate('commonLinkTo'), arrow: true }; - let print = { id: 'print', name: translate('menuBlockMorePrint'), caption: `${cmd} + P` }; + const print = { id: 'print', name: translate('menuBlockMorePrint'), caption: `${cmd} + P` }; let search = { id: 'search', name: translate('menuBlockMoreSearchOnPage'), caption: `${cmd} + F` }; - let move = { id: 'move', name: translate('menuBlockMoreMoveTo'), arrow: true }; - let turn = { id: 'turnObject', icon: 'object', name: translate('commonTurnIntoObject'), arrow: true }; + const move = { id: 'move', name: translate('menuBlockMoreMoveTo'), arrow: true }; + const turn = { id: 'turnObject', icon: 'object', name: translate('commonTurnIntoObject'), arrow: true }; let history = { id: 'history', name: translate('menuBlockMoreVersionHistory'), caption: (UtilCommon.isPlatformMac() ? `${cmd} + Y` : `Ctrl + H`) }; - let pageExport = { id: 'pageExport', icon: 'export', name: translate('menuBlockMoreExport') }; + const pageExport = { id: 'pageExport', icon: 'export', name: translate('menuBlockMoreExport') }; let pageCopy = { id: 'pageCopy', icon: 'copy', name: translate('menuBlockMoreDuplicateObject') }; let pageLink = { id: 'pageLink', icon: 'link', name: translate('menuBlockMoreCopyLink') }; let pageReload = { id: 'pageReload', icon: 'reload', name: translate('menuBlockMoreReloadFromSource') }; - let blockRemove = { id: 'blockRemove', icon: 'remove', name: translate('commonDelete') }; + const blockRemove = { id: 'blockRemove', icon: 'remove', name: translate('commonDelete') }; if (isTemplate) { template = { id: 'pageCreate', icon: 'template', name: translate('menuBlockMoreCreateObject') }; setDefaultTemplate = { id: 'setDefault', icon: 'pin', name: translate('menuBlockMoreSetDefaultTemplate') }; - pageCopy.name = translate('menuBlockMoreDuplicateTemplate') + pageCopy.name = translate('menuBlockMoreDuplicateTemplate'); } else { template = { id: 'templateCreate', icon: 'template', name: translate('menuBlockMoreUseAsTemplate') }; }; @@ -223,7 +223,7 @@ class MenuBlockMore extends React.Component { }; sections = sections.map((it: any, i: number) => ({ ...it, id: 'page' + i })); - } else { + } else { const align = { id: 'align', name: translate('commonAlign'), icon: [ 'align', UtilData.alignIcon(block.hAlign) ].join(' '), arrow: true }; sections.push({ children: [ @@ -246,7 +246,7 @@ class MenuBlockMore extends React.Component { const sections = this.getSections(); let items: any[] = []; - for (let section of sections) { + for (const section of sections) { items = items.concat(section.children); }; @@ -276,7 +276,7 @@ class MenuBlockMore extends React.Component { }; let menuId = ''; - let menuParam: I.MenuParam = { + const menuParam: I.MenuParam = { menuKey: item.id, element: `#${getId()} #item-${item.id}`, offsetX: getSize().width, @@ -308,7 +308,7 @@ class MenuBlockMore extends React.Component { onMenuSelect(item); }; }, - }) + }); break; }; @@ -388,7 +388,7 @@ class MenuBlockMore extends React.Component { return; }; - let close = true; + const close = true; if (onSelect) { onSelect(item); diff --git a/src/ts/component/menu/block/relation/edit.tsx b/src/ts/component/menu/block/relation/edit.tsx index 9313a4b14e..0b8cec67bc 100644 --- a/src/ts/component/menu/block/relation/edit.tsx +++ b/src/ts/component/menu/block/relation/edit.tsx @@ -466,7 +466,7 @@ const MenuBlockRelationEdit = observer(class MenuBlockRelationEdit extends React const { relationId } = data; const details: any[] = []; - for (let k in item) { + for (const k in item) { details.push({ key: k, value: item[k] }); }; diff --git a/src/ts/component/menu/block/relation/view.tsx b/src/ts/component/menu/block/relation/view.tsx index 3cf9c77a3a..27b46ce550 100644 --- a/src/ts/component/menu/block/relation/view.tsx +++ b/src/ts/component/menu/block/relation/view.tsx @@ -142,7 +142,7 @@ const MenuBlockRelationView = observer(class MenuBlockRelationView extends React const win = $(window); const menus = menuStore.list.filter(it => Constant.menuIds.cell.includes(it.id)); - for (let menu of menus) { + for (const menu of menus) { win.trigger('resize.' + UtilCommon.toCamelCase('menu-' + menu.id)); }; }; @@ -194,7 +194,7 @@ const MenuBlockRelationView = observer(class MenuBlockRelationView extends React const sections = this.getSections(); let items: any[] = []; - for (let section of sections) { + for (const section of sections) { items = items.concat(section.children); }; diff --git a/src/ts/component/menu/block/style.tsx b/src/ts/component/menu/block/style.tsx index 4f1d8e3df1..889d7782a6 100644 --- a/src/ts/component/menu/block/style.tsx +++ b/src/ts/component/menu/block/style.tsx @@ -70,7 +70,7 @@ const MenuBlockStyle = observer(class MenuBlockStyle extends React.Component { let pageCopy = { id: 'copy', icon: 'copy', name: translate('commonDuplicate') }; let open = { id: 'open', icon: 'expand', name: translate('commonOpenObject') }; let linkTo = { id: 'linkTo', icon: 'linkTo', name: translate('commonLinkTo'), arrow: true }; - let changeType = { id: 'changeType', icon: 'pencil', name: translate('blockFeaturedTypeMenuChangeType'), arrow: true }; + const changeType = { id: 'changeType', icon: 'pencil', name: translate('blockFeaturedTypeMenuChangeType'), arrow: true }; let div = null; let unlink = null; let archive = null; @@ -172,7 +172,7 @@ class MenuContext extends React.Component { const sections = this.getSections(); let items: any[] = []; - for (let section of sections) { + for (const section of sections) { items = items.concat(section.children); }; @@ -193,13 +193,13 @@ class MenuContext extends React.Component { }; if (!item.arrow || !objectIds.length) { - menuStore.closeAll(Constant.menuIds.more) + menuStore.closeAll(Constant.menuIds.more); return; }; - let itemId = objectIds[0]; + const itemId = objectIds[0]; let menuId = ''; - let menuParam = { + const menuParam = { menuKey: item.id, element: `#${getId()} #item-${item.id}`, offsetX: getSize().width, diff --git a/src/ts/component/menu/dataview/date.tsx b/src/ts/component/menu/dataview/date.tsx index 5c121e44a3..2cc7f2b117 100644 --- a/src/ts/component/menu/dataview/date.tsx +++ b/src/ts/component/menu/dataview/date.tsx @@ -121,7 +121,7 @@ const MenuDataviewDate = observer(class MenuDataviewDate extends React.Component const sections = this.getSections(); let items: any[] = []; - for (let section of sections) { + for (const section of sections) { items = items.concat(section.children); }; diff --git a/src/ts/component/menu/dataview/file/list.tsx b/src/ts/component/menu/dataview/file/list.tsx index 98273dd63b..a491cbdaf7 100644 --- a/src/ts/component/menu/dataview/file/list.tsx +++ b/src/ts/component/menu/dataview/file/list.tsx @@ -57,7 +57,7 @@ const MenuDataviewFileList = observer(class MenuDataviewFileList extends React.C let content = null; if (item.id == 'add') { - content = ( + content = (
{ this.onOver(e, item); }} onClick={(e: any) => { this.onClick(e, item); }} style={param.style}>
{item.name}
diff --git a/src/ts/component/menu/dataview/file/values.tsx b/src/ts/component/menu/dataview/file/values.tsx index 2928a665b1..da3a173445 100644 --- a/src/ts/component/menu/dataview/file/values.tsx +++ b/src/ts/component/menu/dataview/file/values.tsx @@ -50,7 +50,7 @@ const MenuDataviewFileValues = observer(class MenuDataviewFileValues extends Rea const Item = SortableElement((item: any) => { let content = null; - let cn = [ 'item' ]; + const cn = [ 'item' ]; switch (item.layout) { default: diff --git a/src/ts/component/menu/dataview/filter/list.tsx b/src/ts/component/menu/dataview/filter/list.tsx index 1edccb54e0..1025eb119b 100644 --- a/src/ts/component/menu/dataview/filter/list.tsx +++ b/src/ts/component/menu/dataview/filter/list.tsx @@ -46,7 +46,7 @@ const MenuFilterList = observer(class MenuFilterList extends React.Component { this.onSwitch(e, item, v); }} /> - ) : ''} + ) : ''}
); }); @@ -198,8 +198,8 @@ const MenuGroupList = observer(class MenuGroupList extends React.Component { e.preventDefault(); diff --git a/src/ts/component/menu/dataview/object/list.tsx b/src/ts/component/menu/dataview/object/list.tsx index 92097118ff..1d05072d95 100644 --- a/src/ts/component/menu/dataview/object/list.tsx +++ b/src/ts/component/menu/dataview/object/list.tsx @@ -68,7 +68,7 @@ const MenuDataviewObjectList = observer(class MenuDataviewObjectList extends Rea
); } else if (item.id == 'add') { - content = ( + content = (
{ this.onOver(e, item); }} onClick={(e: any) => { this.onClick(e, item); }} style={param.style}>
{item.name}
@@ -354,9 +354,9 @@ const MenuDataviewObjectList = observer(class MenuDataviewObjectList extends Rea }; if (item.id == 'add') { - let details: any = { name: filter }; - let typeId = relation.objectTypes.length ? relation.objectTypes[0] : ''; - let flags: I.ObjectFlag[] = []; + const details: any = { name: filter }; + const typeId = relation.objectTypes.length ? relation.objectTypes[0] : ''; + const flags: I.ObjectFlag[] = []; if (typeId) { details.type = typeId; diff --git a/src/ts/component/menu/dataview/option/edit.tsx b/src/ts/component/menu/dataview/option/edit.tsx index 28cba79954..e5c5ffae24 100644 --- a/src/ts/component/menu/dataview/option/edit.tsx +++ b/src/ts/component/menu/dataview/option/edit.tsx @@ -114,7 +114,7 @@ const MenuOptionEdit = observer(class MenuOptionEdit extends React.Component { this.onClick(e, item); }} style={param.style} onMouseEnter={(e: any) => { this.onOver(e, item); }}>
{item.name}
@@ -199,7 +199,7 @@ const MenuOptionList = observer(class MenuOptionList extends React.Component { @@ -334,7 +334,7 @@ const MenuOptionList = observer(class MenuOptionList extends React.Component it.relationKey == relation.relationKey); - let ret = []; + const ret = []; let check = []; if (filterMapper) { diff --git a/src/ts/component/menu/dataview/relation/edit.tsx b/src/ts/component/menu/dataview/relation/edit.tsx index 5bf50f1b17..7d1e946f46 100644 --- a/src/ts/component/menu/dataview/relation/edit.tsx +++ b/src/ts/component/menu/dataview/relation/edit.tsx @@ -36,7 +36,7 @@ const MenuRelationEdit = observer(class MenuRelationEdit extends React.Component const sections = this.getSections(); let opts = null; - let ccn = [ 'item' ]; + const ccn = [ 'item' ]; if (relation) { ccn.push('disabled'); @@ -255,7 +255,7 @@ const MenuRelationEdit = observer(class MenuRelationEdit extends React.Component const sections = this.getSections(); let items: any[] = []; - for (let section of sections) { + for (const section of sections) { items = items.concat(section.children); }; @@ -623,7 +623,7 @@ const MenuRelationEdit = observer(class MenuRelationEdit extends React.Component const { relationId } = data; const details: any[] = []; - for (let k in item) { + for (const k in item) { details.push({ key: k, value: item[k] }); }; diff --git a/src/ts/component/menu/dataview/relation/list.tsx b/src/ts/component/menu/dataview/relation/list.tsx index b5ec3ba762..c119fc1f7c 100644 --- a/src/ts/component/menu/dataview/relation/list.tsx +++ b/src/ts/component/menu/dataview/relation/list.tsx @@ -75,7 +75,7 @@ const MenuRelationList = observer(class MenuRelationList extends React.Component value={item.isVisible} onChange={(e: any, v: boolean) => { this.onSwitch(e, item, v); }} /> - ) : ''} + ) : ''}
); }); @@ -206,8 +206,8 @@ const MenuRelationList = observer(class MenuRelationList extends React.Component onKeyDown (e: any) { let ret = false; - let items = this.getItems(); - let item = items[this.n]; + const items = this.getItems(); + const item = items[this.n]; keyboard.shortcut('space', e, (pressed: string) => { e.preventDefault(); diff --git a/src/ts/component/menu/dataview/sort.tsx b/src/ts/component/menu/dataview/sort.tsx index 2996609c14..34a906ae4f 100644 --- a/src/ts/component/menu/dataview/sort.tsx +++ b/src/ts/component/menu/dataview/sort.tsx @@ -334,7 +334,7 @@ const MenuSort = observer(class MenuSort extends React.Component { }; onSortEnd (result: any) { - const { oldIndex, newIndex, } = result; + const { oldIndex, newIndex, } = result; const { param } = this.props; const { data } = param; const { rootId, blockId, getView, isInline, getTarget } = data; diff --git a/src/ts/component/menu/dataview/template.tsx b/src/ts/component/menu/dataview/template.tsx index 6380825921..665d52b094 100644 --- a/src/ts/component/menu/dataview/template.tsx +++ b/src/ts/component/menu/dataview/template.tsx @@ -7,84 +7,84 @@ import Constant from 'json/constant.json'; class MenuTemplate extends React.Component { - n = -1; + n = -1; - constructor (props: I.Menu) { - super(props); + constructor (props: I.Menu) { + super(props); - this.onClick = this.onClick.bind(this); - }; + this.onClick = this.onClick.bind(this); + }; - render () { - const items = this.getItems(); + render () { + const items = this.getItems(); - return ( -
- {items.map((action: any, i: number) => ( - this.onMouseEnter(e, action)} - onClick={e => this.onClick(e, action)} - /> - ))} -
- ); - }; + return ( +
+ {items.map((action: any, i: number) => ( + this.onMouseEnter(e, action)} + onClick={e => this.onClick(e, action)} + /> + ))} +
+ ); + }; - componentDidMount () { - this.rebind(); - }; + componentDidMount () { + this.rebind(); + }; - rebind () { - this.unbind(); - $(window).on('keydown.menu', e => this.props.onKeyDown(e)); - window.setTimeout(() => this.props.setActive(), 15); - }; + rebind () { + this.unbind(); + $(window).on('keydown.menu', e => this.props.onKeyDown(e)); + window.setTimeout(() => this.props.setActive(), 15); + }; - unbind () { - $(window).off('keydown.menu'); - }; + unbind () { + $(window).off('keydown.menu'); + }; + + getItems () { + const { param } = this.props; + const { data } = param; + const { template, isView } = data; + const { isBlank, isDefault } = template; - getItems () { - const { param } = this.props; - const { data } = param; - const { template, isView } = data; - const { isBlank, isDefault } = template; - return [ !isDefault ? ({ id: 'default', name: translate(isView ? 'menuDataviewTemplateSetDefaultForView' : 'commonTemplateSetDefault') }) : null, !isBlank ? ({ id: 'edit', name: translate('menuDataviewTemplateEdit') }) : null, { id: 'duplicate', name: translate('commonDuplicate') }, !isBlank ? ({ id: 'remove', name: translate('commonDelete') }) : null, ].filter(it => it); - }; + }; - onClick (e: any, item: any) { - const { param, close } = this.props; - const { data } = param; - const { template, onSetDefault, onArchive, onDuplicate, route } = data; + onClick (e: any, item: any) { + const { param, close } = this.props; + const { data } = param; + const { template, onSetDefault, onArchive, onDuplicate, route } = data; close(); - switch (item.id) { - case 'default': { - if (onSetDefault) { - onSetDefault(); - }; + switch (item.id) { + case 'default': { + if (onSetDefault) { + onSetDefault(); + }; analytics.event('ChangeDefaultTemplate', { route }); break; - }; + }; - case 'edit': { - UtilObject.openPopup(template); + case 'edit': { + UtilObject.openPopup(template); analytics.event('EditTemplate', { route }); - break; - }; + break; + }; - case 'duplicate': { + case 'duplicate': { analytics.event('DuplicateTemplate', { route }); if (template.id == Constant.templateId.blank) { @@ -109,7 +109,7 @@ class MenuTemplate extends React.Component { break; }; - C.ObjectListDuplicate([ template.id ], (message: any) => { + C.ObjectListDuplicate([ template.id ], (message: any) => { if (!message.error.code && message.ids.length) { if (onDuplicate) { onDuplicate({ ...template, id: message.ids[0] }); @@ -117,37 +117,37 @@ class MenuTemplate extends React.Component { analytics.event('DuplicateObject', { count: 1, route: 'menuDataviewTemplate' }); }; }); - break; - }; + break; + }; - case 'remove': { + case 'remove': { Action.archive([ template.id ], () => { - if (onArchive) { + if (onArchive) { onArchive(); }; }); - break; - }; - }; - }; + break; + }; + }; + }; - onMouseEnter (e: any, item: any) { - this.onOver(e, item); - }; + onMouseEnter (e: any, item: any) { + this.onOver(e, item); + }; - onOver (e: any, item: any) { - const { param } = this.props; - const { data } = param; - const { onOver } = data; + onOver (e: any, item: any) { + const { param } = this.props; + const { data } = param; + const { onOver } = data; - if (!keyboard.isMouseDisabled) { - this.props.setActive(item, false); - }; + if (!keyboard.isMouseDisabled) { + this.props.setActive(item, false); + }; - if (onOver) { - onOver(); - }; - }; + if (onOver) { + onOver(); + }; + }; }; diff --git a/src/ts/component/menu/dataview/view/edit.tsx b/src/ts/component/menu/dataview/view/edit.tsx index a47d94690a..e65139b33e 100644 --- a/src/ts/component/menu/dataview/view/edit.tsx +++ b/src/ts/component/menu/dataview/view/edit.tsx @@ -221,8 +221,8 @@ const MenuViewEdit = observer(class MenuViewEdit extends React.Component return; }; - let current = data.view.get(); - let clearGroups = (current.type == I.ViewType.Board) && this.param.groupRelationKey && (current.groupRelationKey != this.param.groupRelationKey); + const current = data.view.get(); + const clearGroups = (current.type == I.ViewType.Board) && this.param.groupRelationKey && (current.groupRelationKey != this.param.groupRelationKey); if (withName) { this.param.name = this.getViewName(); @@ -322,7 +322,7 @@ const MenuViewEdit = observer(class MenuViewEdit extends React.Component const sections = this.getSections(); let items: any[] = []; - for (let section of sections) { + for (const section of sections) { items = items.concat(section.children); }; @@ -355,7 +355,7 @@ const MenuViewEdit = observer(class MenuViewEdit extends React.Component }; let menuId = ''; - let menuParam: I.MenuParam = { + const menuParam: I.MenuParam = { menuKey: item.id, element: `#${getId()} #item-${item.id}`, offsetX: getSize().width, diff --git a/src/ts/component/menu/dataview/view/list.tsx b/src/ts/component/menu/dataview/view/list.tsx index 7ee37d12de..3d419d65cb 100644 --- a/src/ts/component/menu/dataview/view/list.tsx +++ b/src/ts/component/menu/dataview/view/list.tsx @@ -226,7 +226,7 @@ const MenuViewList = observer(class MenuViewList extends React.Component const allowed = blockStore.checkFlags(rootId, blockId, [ I.RestrictionDataview.View ]); const object = getTarget(); - for (let relation of relations) { + for (const relation of relations) { if (relation.isHidden || !relation.isVisible) { continue; }; diff --git a/src/ts/component/menu/graph/settings.tsx b/src/ts/component/menu/graph/settings.tsx index 46e0ef087b..2788e0636e 100644 --- a/src/ts/component/menu/graph/settings.tsx +++ b/src/ts/component/menu/graph/settings.tsx @@ -120,7 +120,7 @@ const MenuGraphSettings = observer(class MenuGraphSettings extends React.Compone const sections = this.getSections(); let items = []; - for (let section of sections) { + for (const section of sections) { if (withSections) { items.push({ id: section.id, name: section.name, isSection: true }); }; diff --git a/src/ts/component/menu/index.tsx b/src/ts/component/menu/index.tsx index 2dad9dc374..2ff52ae8d8 100644 --- a/src/ts/component/menu/index.tsx +++ b/src/ts/component/menu/index.tsx @@ -197,9 +197,9 @@ const Menu = observer(class Menu extends React.Component { tab = this.state.tab || tabs[0].id; }; - let menuId = this.getId(); + const menuId = this.getId(); let Component = null; - let arrowDirection = this.getArrowDirection(); + const arrowDirection = this.getArrowDirection(); const cn = [ 'menu', @@ -260,7 +260,7 @@ const Menu = observer(class Menu extends React.Component {
) : ''} - {withArrow ? : ''} + {withArrow ? : ''}
{ let eh = 0; let ox = 0; let oy = 0; - let minY = UtilCommon.sizeHeader(); + const minY = UtilCommon.sizeHeader(); let rect = null; if (recalcRect) { diff --git a/src/ts/component/menu/item/filter.tsx b/src/ts/component/menu/item/filter.tsx index e010cac1bd..877383af83 100644 --- a/src/ts/component/menu/item/filter.tsx +++ b/src/ts/component/menu/item/filter.tsx @@ -22,12 +22,13 @@ const MenuItemFilter = observer(class MenuItemFilter extends React.Component it.id == condition) || {}; - let filterOptions = Relation.filterQuickOptions(relation.format, conditionOption.id); - let filterOption: any = filterOptions.find(it => it.id == quickOption) || {}; + const { id, index, relation, condition, quickOption, subId, readonly, style, onOver, onClick, onRemove } = this.props; + const conditionOptions = Relation.filterConditionsByType(relation.format); + const conditionOption: any = conditionOptions.find(it => it.id == condition) || {}; + const filterOptions = Relation.filterQuickOptions(relation.format, conditionOption.id); + const filterOption: any = filterOptions.find(it => it.id == quickOption) || {}; + let value = this.props.value; let v: any = null; let list = []; let Item: any = null; @@ -39,7 +40,7 @@ const MenuItemFilter = observer(class MenuItemFilter extends React.Component { @@ -359,9 +359,9 @@ const MenuRelationSuggest = observer(class MenuRelationSuggest extends React.Com const { classNameWrap, data } = param; const skipKeys = data.skipKeys || []; - let sources = this.getLibrarySources(); + const sources = this.getLibrarySources(); let menuId = ''; - let menuParam: I.MenuParam = { + const menuParam: I.MenuParam = { menuKey: item.id, element: `#${getId()} #item-${item.id}`, offsetX: getSize().width, @@ -446,7 +446,7 @@ const MenuRelationSuggest = observer(class MenuRelationSuggest extends React.Com }); } else if (addCommand) { - const cb = (item: any) => { + const cb = (item: any) => { close(); addCommand(rootId, blockId, item); }; diff --git a/src/ts/component/menu/search/object.tsx b/src/ts/component/menu/search/object.tsx index f758733245..493e8d6619 100644 --- a/src/ts/component/menu/search/object.tsx +++ b/src/ts/component/menu/search/object.tsx @@ -247,7 +247,7 @@ const MenuSearchObject = observer(class MenuSearchObject extends React.Component const { filter, label, canAdd, addParam, mapElement } = data; let items = [].concat(this.items); - let length = items.length; + const length = items.length; if (label && length) { items.unshift({ isSection: true, name: label }); diff --git a/src/ts/component/menu/select.tsx b/src/ts/component/menu/select.tsx index 5abb8359ac..7f06d4c029 100644 --- a/src/ts/component/menu/select.tsx +++ b/src/ts/component/menu/select.tsx @@ -245,7 +245,7 @@ const MenuSelect = observer(class MenuSelect extends React.Component { let items: any[] = []; if (sections && sections.length) { - for (let section of sections) { + for (const section of sections) { if (withSections) { items.push({ id: section.id, name: section.name, isSection: true }); }; diff --git a/src/ts/component/menu/smile.tsx b/src/ts/component/menu/smile.tsx index 272f4ea8b7..147fe0b37b 100644 --- a/src/ts/component/menu/smile.tsx +++ b/src/ts/component/menu/smile.tsx @@ -194,7 +194,7 @@ class MenuSmile extends React.Component { this.skin = Number(storageGet().skin) || 1; this.aliases = {}; - for (let k in EmojiData.aliases) { + for (const k in EmojiData.aliases) { this.aliases[EmojiData.aliases[k]] = k; }; @@ -299,7 +299,7 @@ class MenuSmile extends React.Component { if (c.id.match(reg)) { return true; }; - for (let w of c.keywords) { + for (const w of c.keywords) { if (w.match(reg)) { return true; }; @@ -319,8 +319,8 @@ class MenuSmile extends React.Component { getItems () { let sections = this.getSections(); let items: any[] = []; - let ret: any[] = []; - let length = sections.reduce((res: number, section: any) => { + const ret: any[] = []; + const length = sections.reduce((res: number, section: any) => { return (section.id == ID_RECENT) ? res : res + section.children.length; }, 0); @@ -335,7 +335,7 @@ class MenuSmile extends React.Component { ]; }; - for (let section of sections) { + for (const section of sections) { items.push({ id: section.id, name: section.name, isSection: true }); items = items.concat(section.children); }; @@ -603,7 +603,7 @@ class MenuSmile extends React.Component { close(); }; window.clearTimeout(this.timeoutMenu); - win.off('mouseup.smile') + win.off('mouseup.smile'); }); }; @@ -684,7 +684,7 @@ class MenuSmile extends React.Component { return this.groupCache; }; - let items = this.getItems(); + const items = this.getItems(); let t = 0; let last = null; @@ -712,7 +712,7 @@ class MenuSmile extends React.Component { onScroll ({ scrollTop }) { const cache = this.getGroupCache(); - for (let item of cache) { + for (const item of cache) { if ((scrollTop >= item.start) && (scrollTop < item.end)) { this.setActiveGroup(item.id); break; diff --git a/src/ts/component/menu/thread/status.tsx b/src/ts/component/menu/thread/status.tsx index 0b49249736..6d0f1d7eb0 100644 --- a/src/ts/component/menu/thread/status.tsx +++ b/src/ts/component/menu/thread/status.tsx @@ -45,7 +45,7 @@ class MenuThreadStatus extends React.Component { } else { cafeStatus = [ { key: translate('menuThreadStatusSomeChangesNotBackedUp'), collapse: true }, - { key: translate('menuThreadStatusUpdatesRequested'), value: cafe.lastPulled ? UtilCommon.timeAgo(cafe.lastPulled) : translate('menuThreadStatusNoInteraction') } + { key: translate('menuThreadStatusUpdatesRequested'), value: cafe.lastPulled ? UtilCommon.timeAgo(cafe.lastPulled) : translate('menuThreadStatusNoInteraction') } ]; }; diff --git a/src/ts/component/menu/type/suggest.tsx b/src/ts/component/menu/type/suggest.tsx index f41b024edf..a3df19b285 100644 --- a/src/ts/component/menu/type/suggest.tsx +++ b/src/ts/component/menu/type/suggest.tsx @@ -56,7 +56,7 @@ const MenuTypeSuggest = observer(class MenuTypeSuggest extends React.Component { @@ -371,7 +371,7 @@ const MenuTypeSuggest = observer(class MenuTypeSuggest extends React.Component { + const cb = (item: any) => { close(); if (onClick) { diff --git a/src/ts/component/menu/widget.tsx b/src/ts/component/menu/widget.tsx index b8f6bd247e..7a931f4b51 100644 --- a/src/ts/component/menu/widget.tsx +++ b/src/ts/component/menu/widget.tsx @@ -197,7 +197,7 @@ const MenuWidget = observer(class MenuWidget extends React.Component { const sections = this.getSections(); let items = []; - for (let section of sections) { + for (const section of sections) { items = items.concat(section.children); }; return items; @@ -281,7 +281,7 @@ const MenuWidget = observer(class MenuWidget extends React.Component { switch (item.itemId) { case 'source': { - let filters: I.Filter[] = [ + const filters: I.Filter[] = [ { operator: I.FilterOperator.And, relationKey: 'type', condition: I.FilterCondition.NotIn, value: UtilObject.getSystemTypes().concat(UtilObject.getFileTypes()) }, ]; @@ -448,7 +448,7 @@ const MenuWidget = observer(class MenuWidget extends React.Component { }; let prevY = 0; - for (let id of widgetIds) { + for (const id of widgetIds) { const item = $(`#widget-${id}`); if (!item || !item.length) { continue; diff --git a/src/ts/component/page/auth/onboard.tsx b/src/ts/component/page/auth/onboard.tsx index 81d22cfb75..eba88799d7 100644 --- a/src/ts/component/page/auth/onboard.tsx +++ b/src/ts/component/page/auth/onboard.tsx @@ -356,7 +356,7 @@ const PageAuthOnboard = observer(class PageAuthOnboard extends React.Component { this.onIcon = this.onIcon.bind(this); this.onCoverOpen = this.onCoverOpen.bind(this); this.onCoverClose = this.onCoverClose.bind(this); - this.onCoverSelect = this.onCoverSelect.bind(this) + this.onCoverSelect = this.onCoverSelect.bind(this); this.onLayout = this.onLayout.bind(this); this.onDragOver = this.onDragOver.bind(this); diff --git a/src/ts/component/page/head/simple.tsx b/src/ts/component/page/head/simple.tsx index a71abb22e6..d34c3dabaa 100644 --- a/src/ts/component/page/head/simple.tsx +++ b/src/ts/component/page/head/simple.tsx @@ -77,7 +77,7 @@ const HeadSimple = observer(class Controls extends React.Component { let button = null; let descr = null; let featured = null; - let cn = [ 'headSimple', check.className ]; + const cn = [ 'headSimple', check.className ]; if (!isTypeOrRelation) { if (featuredRelations.includes('description')) { @@ -113,8 +113,8 @@ const HeadSimple = observer(class Controls extends React.Component { const cn = [ 'c36' ]; const isInstalled = this.isInstalled(); - let onClick = isInstalled ? null : this.onInstall; - let color = isInstalled ? 'blank' : 'black'; + const onClick = isInstalled ? null : this.onInstall; + const color = isInstalled ? 'blank' : 'black'; if (isInstalled) { cn.push('disabled'); @@ -164,7 +164,7 @@ const HeadSimple = observer(class Controls extends React.Component { this.setValue(); - for (let item of EDITORS) { + for (const item of EDITORS) { this.placeholderCheck(item.blockId); }; diff --git a/src/ts/component/page/main/block.tsx b/src/ts/component/page/main/block.tsx index 65edee887d..6c46ca0131 100644 --- a/src/ts/component/page/main/block.tsx +++ b/src/ts/component/page/main/block.tsx @@ -61,7 +61,7 @@ const PageMainBlock = observer(class PageMainBlock extends React.Component - ) : translate('pageMainBlockEmpty')} + ) : translate('pageMainBlockEmpty')}
); diff --git a/src/ts/component/page/main/graph.tsx b/src/ts/component/page/main/graph.tsx index 0b1598a1a5..1d06134dcc 100644 --- a/src/ts/component/page/main/graph.tsx +++ b/src/ts/component/page/main/graph.tsx @@ -283,7 +283,7 @@ const PageMainGraph = observer(class PageMainGraph extends React.Component this.getNode(id), onLinkTo: (sourceId: string, targetId: string) => { - let target = this.getNode(targetId); + const target = this.getNode(targetId); if (target) { this.data.edges.push(this.refGraph?.edgeMapper({ type: I.EdgeType.Link, source: sourceId, target: targetId })); this.refGraph?.send('onSetEdges', { edges: this.data.edges }); diff --git a/src/ts/component/page/main/history.tsx b/src/ts/component/page/main/history.tsx index 819d5c09b2..5be430b693 100644 --- a/src/ts/component/page/main/history.tsx +++ b/src/ts/component/page/main/history.tsx @@ -94,7 +94,7 @@ const PageMainHistory = observer(class PageMainHistory extends React.Component {item.list.map((child: any, i: number) => { - return + return ; })} ) : ''} @@ -305,8 +305,8 @@ const PageMainHistory = observer(class PageMainHistory extends React.Component GROUP_OFFSET) || (prev.time - version.time < 0))) { groupId++; @@ -342,26 +342,26 @@ const PageMainHistory = observer(class PageMainHistory extends React.Component it.groupId == groupId); - if (!month) { month = { groupId: groupId, list: [] }; months.push(month); - }; + }; - month.list.push(group); + month.list.push(group); }; return months; @@ -369,8 +369,8 @@ const PageMainHistory = observer(class PageMainHistory extends React.Component { - let { layout, name, description, snippet } = item || {}; + const { layout, name, description, snippet } = item || {}; return (
( -
this.onClick(e, item.id)}> + const Case = (item: any) => ( +
this.onClick(e, item.id)}>
- - <Label text={translate(`usecase${item.id}Label`)} /> + <Title text={translate(`usecase${item.id}Title`)} /> + <Label text={translate(`usecase${item.id}Label`)} /> </div> - <div className="picture"> + <div className="picture"> <img src={item.img} /> </div> - </div> - ); + </div> + ); - return ( - <div> - <Frame> + return ( + <div> + <Frame> {isLoading ? <Loader /> : ''} - <Title text={translate('pageMainUsecaseTitle')} /> - <Label text={translate('pageMainUsecaseLabel')} /> + <Title text={translate('pageMainUsecaseTitle')} /> + <Label text={translate('pageMainUsecaseLabel')} /> - <div className="list"> - {items.map((item: any, i: number) => ( - <Case key={i} {...item} /> - ))} - </div> + <div className="list"> + {items.map((item: any, i: number) => ( + <Case key={i} {...item} /> + ))} + </div> - <div className="buttons"> - <Button color="blank" className="c36" text={translate('pageMainUsecaseSkip')} onClick={e => this.onClick(e, I.Usecase.None)} /> - </div> - </Frame> - </div> - ); - }; + <div className="buttons"> + <Button color="blank" className="c36" text={translate('pageMainUsecaseSkip')} onClick={e => this.onClick(e, I.Usecase.None)} /> + </div> + </Frame> + </div> + ); + }; componentDidMount (): void { this.setState({ items: this.getItems() }); }; getItems () { - return _.shuffle([ + return _.shuffle([ { id: I.Usecase.Personal, img: 'img/usecase/personal-projects.png' }, { id: I.Usecase.Notes, img: 'img/usecase/notes-or-diary.png' }, { id: I.Usecase.Knowledge, img: 'img/usecase/knowledge-base.png' }, - ]); + ]); }; - onClick (e: any, id: number) { - e.preventDefault(); + onClick (e: any, id: number) { + e.preventDefault(); const { isLoading } = this.state; - if (isLoading) { - return; - }; + if (isLoading) { + return; + }; - this.setState({ isLoading: true }); + this.setState({ isLoading: true }); - C.ObjectImportUseCase(id, (message: any) => { + C.ObjectImportUseCase(id, (message: any) => { analytics.event('SelectUsecase', { type: id, middleTime: message.middleTime }); blockStore.closeRecentWidgets(); this.setState({ isLoading: false }); UtilCommon.route('/main/graph', { animate: true }); - }); - }; + }); + }; }); diff --git a/src/ts/component/popup/help.tsx b/src/ts/component/popup/help.tsx index 1f0dd1af66..cb6dce5900 100644 --- a/src/ts/component/popup/help.tsx +++ b/src/ts/component/popup/help.tsx @@ -69,7 +69,7 @@ class PopupHelp extends React.Component<I.Popup, State> { {isWhatsNew && !showFull ? ( <div className="buttons"> - <Button text={translate('popupHelpOlderReleases')} onClick={() => { this.setState({ showFull: true }) }} /> + <Button text={translate('popupHelpOlderReleases')} onClick={() => { this.setState({ showFull: true }); }} /> </div> ) : ''} </div> diff --git a/src/ts/component/popup/index.tsx b/src/ts/component/popup/index.tsx index c116df6b31..977797ba9b 100644 --- a/src/ts/component/popup/index.tsx +++ b/src/ts/component/popup/index.tsx @@ -67,7 +67,7 @@ class Popup extends React.Component<I.Popup> { }; if (!Component) { - return <div>{UtilCommon.sprintf(translate('popupIndexComponentNotFound'), id)}</div> + return <div>{UtilCommon.sprintf(translate('popupIndexComponentNotFound'), id)}</div>; }; return ( diff --git a/src/ts/component/popup/page/settings/personal.tsx b/src/ts/component/popup/page/settings/personal.tsx index 760639d7ca..c753157858 100644 --- a/src/ts/component/popup/page/settings/personal.tsx +++ b/src/ts/component/popup/page/settings/personal.tsx @@ -100,8 +100,8 @@ const PopupSettingsPagePersonal = observer(class PopupSettingsPagePersonal exten const ret: any[] = []; const Locale = require('lib/json/locale.json'); - for (let id of Constant.enabledInterfaceLang) { - ret.push({ id, name: Locale[id] }) + for (const id of Constant.enabledInterfaceLang) { + ret.push({ id, name: Locale[id] }); }; return ret; diff --git a/src/ts/component/popup/page/settings/space/team.tsx b/src/ts/component/popup/page/settings/space/team.tsx index c73e44cb28..86be04fbbc 100644 --- a/src/ts/component/popup/page/settings/space/team.tsx +++ b/src/ts/component/popup/page/settings/space/team.tsx @@ -13,40 +13,40 @@ const FILTER_LIMIT = 20; const PopupSettingsSpaceTeam = observer(class PopupSettingsSpaceTeam extends React.Component<I.PopupSettings> { node: any = null; - team: any[] = []; - cache: any = null; - top = 0; - filter = ''; - refFilter: any = null; + team: any[] = []; + cache: any = null; + top = 0; + filter = ''; + refFilter: any = null; refList: any = null; - constructor (props: I.PopupSettings) { - super(props); + constructor (props: I.PopupSettings) { + super(props); - this.onScroll = this.onScroll.bind(this); - }; + this.onScroll = this.onScroll.bind(this); + }; - render () { + render () { if (!this.cache) { return null; }; - const { onPage } = this.props; - const space = { - name: 'Anytype Space', - }; + const { onPage } = this.props; + const space = { + name: 'Anytype Space', + }; - const memberOptions = [ + const memberOptions = [ { id: 'reader', name: translate('popupSettingsSpaceMemberTypeReader')}, { id: 'editor', name: translate('popupSettingsSpaceMemberTypeEditor')}, { id: 'admin', name: translate('popupSettingsSpaceMemberTypeAdmin')}, - { id: '', name: '', isDiv: true }, - { id: 'remove', name: translate('popupSettingsSpaceTeamRemoveMember'), icon: 'remove' } - ]; + { id: '', name: '', isDiv: true }, + { id: 'remove', name: translate('popupSettingsSpaceTeamRemoveMember'), icon: 'remove' } + ]; - const length = this.team.length; + const length = this.team.length; - const Member = (item: any) => ( + const Member = (item: any) => ( <div id={'item-' + item.id} className="row" style={item.style} > <div className="side left"> <IconObject size={32} object={item} /> @@ -66,78 +66,78 @@ const PopupSettingsSpaceTeam = observer(class PopupSettingsSpaceTeam extends Rea </div> ); - const rowRenderer = (param: any) => { - const item: any = this.team[param.index]; - return ( - <CellMeasurer - key={param.key} - parent={param.parent} - cache={this.cache} - columnIndex={0} - rowIndex={param.index} - hasFixedWidth={() => {}} - > - <Member key={item.id} {...item} index={param.index} style={param.style} /> - </CellMeasurer> - ); - }; + const rowRenderer = (param: any) => { + const item: any = this.team[param.index]; + return ( + <CellMeasurer + key={param.key} + parent={param.parent} + cache={this.cache} + columnIndex={0} + rowIndex={param.index} + hasFixedWidth={() => {}} + > + <Member key={item.id} {...item} index={param.index} style={param.style} /> + </CellMeasurer> + ); + }; - return ( - <div ref={node => this.node = node}> - <Head {...this.props} returnTo="spaceIndex" name={translate('popupSettingsSpaceIndexTitle')} /> - <Title text={UtilCommon.sprintf(translate('popupSettingsSpaceTeam'), space.name)} /> - <Label className="counter" text={UtilCommon.sprintf(translate('popupSettingsSpaceTeamMembers'), length)} /> + return ( + <div ref={node => this.node = node}> + <Head {...this.props} returnTo="spaceIndex" name={translate('popupSettingsSpaceIndexTitle')} /> + <Title text={UtilCommon.sprintf(translate('popupSettingsSpaceTeam'), space.name)} /> + <Label className="counter" text={UtilCommon.sprintf(translate('popupSettingsSpaceTeamMembers'), length)} /> - {length > FILTER_LIMIT ? ( + {length > FILTER_LIMIT ? ( <Filter - ref={ref => this.refFilter = ref} - value={this.filter} - onChange={() => { this.load(); }} - /> + ref={ref => this.refFilter = ref} + value={this.filter} + onChange={() => { this.load(); }} + /> ) : ''} - <div id="list" className="rows"> - <InfiniteLoader - isRowLoaded={({ index }) => !!this.team[index]} - loadMoreRows={() => {}} - rowCount={length} - threshold={LIMIT} - > - {({ onRowsRendered, registerChild }) => { - return ( - <AutoSizer className="scrollArea"> - {({ width, height }) => ( - <List - ref={ref => this.refList = ref} - height={Number(height) || 0} - width={Number(width) || 0} - deferredMeasurmentCache={this.cache} - rowCount={length} - rowHeight={HEIGHT} - onRowsRendered={onRowsRendered} - rowRenderer={rowRenderer} - onScroll={this.onScroll} - overscanRowCount={LIMIT} - /> - )} - </AutoSizer> - ) - }} - </InfiniteLoader> - </div> + <div id="list" className="rows"> + <InfiniteLoader + isRowLoaded={({ index }) => !!this.team[index]} + loadMoreRows={() => {}} + rowCount={length} + threshold={LIMIT} + > + {({ onRowsRendered, registerChild }) => { + return ( + <AutoSizer className="scrollArea"> + {({ width, height }) => ( + <List + ref={ref => this.refList = ref} + height={Number(height) || 0} + width={Number(width) || 0} + deferredMeasurmentCache={this.cache} + rowCount={length} + rowHeight={HEIGHT} + onRowsRendered={onRowsRendered} + rowRenderer={rowRenderer} + onScroll={this.onScroll} + overscanRowCount={LIMIT} + /> + )} + </AutoSizer> + ); + }} + </InfiniteLoader> + </div> - <div className="buttons"> - <Button className="c36" onClick={() => onPage('spaceInvite')} text={translate('popupSettingsSpaceTeamButton')} /> - </div> - </div> - ); - }; + <div className="buttons"> + <Button className="c36" onClick={() => onPage('spaceInvite')} text={translate('popupSettingsSpaceTeamButton')} /> + </div> + </div> + ); + }; - componentDidMount() { - this.load(); - }; + componentDidMount() { + this.load(); + }; - componentDidUpdate() { + componentDidUpdate() { if (!this.cache) { this.cache = new CellMeasurerCache({ fixedWidth: true, @@ -149,34 +149,34 @@ const PopupSettingsSpaceTeam = observer(class PopupSettingsSpaceTeam extends Rea this.resize(); - if (this.refList && this.top) { - this.refList.scrollToPosition(this.top); - }; - }; + if (this.refList && this.top) { + this.refList.scrollToPosition(this.top); + }; + }; - onScroll ({ scrollTop }) { - if (scrollTop) { - this.top = scrollTop; - }; - }; + onScroll ({ scrollTop }) { + if (scrollTop) { + this.top = scrollTop; + }; + }; - load () { + load () { /* const filter = this.refFilter ? this.refFilter.getValue() : ''; - const filters = [ - { operator: I.FilterOperator.And, relationKey: 'type', condition: I.FilterCondition.Equal, value: 'ot-profile' } - ]; + const filters = [ + { operator: I.FilterOperator.And, relationKey: 'type', condition: I.FilterCondition.Equal, value: 'ot-profile' } + ]; - C.ObjectSearch(filters, [], [], filter, 0, 0, (message: any) => { - if (message.error.code || !message.records.length) { - return; - }; + C.ObjectSearch(filters, [], [], filter, 0, 0, (message: any) => { + if (message.error.code || !message.records.length) { + return; + }; - this.team = message.records.map(it => detailStore.mapper(it)).filter(it => !it._empty_); - this.forceUpdate(); - }); + this.team = message.records.map(it => detailStore.mapper(it)).filter(it => !it._empty_); + this.forceUpdate(); + }); */ - }; + }; resize () { const { position } = this.props; diff --git a/src/ts/component/popup/preview.tsx b/src/ts/component/popup/preview.tsx index ea8c4928cd..6636587555 100644 --- a/src/ts/component/popup/preview.tsx +++ b/src/ts/component/popup/preview.tsx @@ -25,13 +25,13 @@ class PopupPreview extends React.Component<I.Popup> { switch (type) { case I.FileType.Image: { - content = <img className="media" src={src} onClick={() => close()} onDragStart={e => e.preventDefault()} /> + content = <img className="media" src={src} onClick={() => close()} onDragStart={e => e.preventDefault()} />; break; }; case I.FileType.Video: { content = <video src={src} controls={true} autoPlay={true} loop={true} />; - break + break; }; }; @@ -131,7 +131,7 @@ class PopupPreview extends React.Component<I.Popup> { }; const video = obj.find('video'); - const videoEl = video.get(0) + const videoEl = video.get(0); const width = WIDTH_VIDEO; const height = HEIGHT_VIDEO; diff --git a/src/ts/component/popup/search.tsx b/src/ts/component/popup/search.tsx index 7780782290..6922483db1 100644 --- a/src/ts/component/popup/search.tsx +++ b/src/ts/component/popup/search.tsx @@ -393,7 +393,7 @@ const PopupSearch = observer(class PopupSearch extends React.Component<I.Popup, ...it, caption: !type || type.isDeleted ? translate('commonDeletedType') : type.name, isObject: true, - } + }; }); items.push({ id: 'add', name: translate('popupSearchCreateObject'), icon: 'plus', shortcut: [ cmd, 'N' ] }); diff --git a/src/ts/component/popup/settings.tsx b/src/ts/component/popup/settings.tsx index 1de945cd85..371f6629aa 100644 --- a/src/ts/component/popup/settings.tsx +++ b/src/ts/component/popup/settings.tsx @@ -138,7 +138,7 @@ const PopupSettings = observer(class PopupSettings extends React.Component<I.Pop let icon = null; let name = null; - let onlineStatus = null; + const onlineStatus = null; if (action.id == 'account') { const isOnline = true; @@ -280,7 +280,7 @@ const PopupSettings = observer(class PopupSettings extends React.Component<I.Pop const sections = this.getSections(); let items: any[] = []; - for (let section of sections) { + for (const section of sections) { items = items.concat(section.children); }; diff --git a/src/ts/component/preview/object.tsx b/src/ts/component/preview/object.tsx index 7f6c2503f6..17b9e6e398 100644 --- a/src/ts/component/preview/object.tsx +++ b/src/ts/component/preview/object.tsx @@ -170,7 +170,7 @@ const PreviewObject = observer(class PreviewObject extends React.Component<Props switch (content.type) { default: case I.FileType.File: { - bullet = <div className={[ 'bullet', 'bgColor', 'bgColor-' + Colors[c] ].join(' ')} /> + bullet = <div className={[ 'bullet', 'bgColor', 'bgColor-' + Colors[c] ].join(' ')} />; inner = ( <React.Fragment> <Icon className="color" inner={bullet} /> @@ -192,7 +192,7 @@ const PreviewObject = observer(class PreviewObject extends React.Component<Props css.width = (fields.width * 100) + '%'; }; - inner = <img className="media" src={commonStore.imageUrl(content.hash, Constant.size.image)} style={css} /> + inner = <img className="media" src={commonStore.imageUrl(content.hash, Constant.size.image)} style={css} />; break; }; @@ -205,7 +205,7 @@ const PreviewObject = observer(class PreviewObject extends React.Component<Props }; case I.BlockType.Link: { - bullet = <div className={[ 'bullet', 'bgColor', 'bgColor-' + Colors[c] ].join(' ')} /> + bullet = <div className={[ 'bullet', 'bgColor', 'bgColor-' + Colors[c] ].join(' ')} />; inner = ( <React.Fragment> <Icon className="color" inner={bullet} /> @@ -225,7 +225,7 @@ const PreviewObject = observer(class PreviewObject extends React.Component<Props break; }; - bullet = <div className={[ 'bullet', 'bgColor', 'bgColor-grey' ].join(' ')} /> + bullet = <div className={[ 'bullet', 'bgColor', 'bgColor-grey' ].join(' ')} />; inner = ( <div className="bookmark"> <div className="side left"> @@ -278,7 +278,7 @@ const PreviewObject = observer(class PreviewObject extends React.Component<Props n++; n = this.checkNumber(child, n); - return <Block key={child.id} {...child} className={cn.join(' ')} css={css} /> + return <Block key={child.id} {...child} className={cn.join(' ')} css={css} />; })} </div> ) : ''} diff --git a/src/ts/component/selection/provider.tsx b/src/ts/component/selection/provider.tsx index f41a31db97..95b3132649 100644 --- a/src/ts/component/selection/provider.tsx +++ b/src/ts/component/selection/provider.tsx @@ -158,10 +158,10 @@ const SelectionProvider = observer(class SelectionProvider extends React.Compone }); if (keyboard.isShift()) { - let target = $(e.target).closest('.selectable'); - let type = target.attr('data-type') as I.SelectType; - let id = target.attr('data-id'); - let ids = this.get(type); + const target = $(e.target).closest('.selectable'); + const type = target.attr('data-type') as I.SelectType; + const id = target.attr('data-id'); + const ids = this.get(type); if (!ids.length && (id != focused)) { this.set(type, ids.concat([ focused ])); @@ -242,7 +242,7 @@ const SelectionProvider = observer(class SelectionProvider extends React.Compone } else { let needCheck = false; if (keyboard.isCtrlOrMeta()) { - for (let i in I.SelectType) { + for (const i in I.SelectType) { const idsOnStart = this.idsOnStart.get(I.SelectType[i]) || []; needCheck = needCheck || Boolean(idsOnStart.length); }; @@ -285,7 +285,7 @@ const SelectionProvider = observer(class SelectionProvider extends React.Compone }; initIds () { - for (let i in I.SelectType) { + for (const i in I.SelectType) { this.ids.set(I.SelectType[i], []); }; }; @@ -385,7 +385,7 @@ const SelectionProvider = observer(class SelectionProvider extends React.Compone checkNodes (e: any) { if (!this._isMounted) { - return + return; }; const { focused, range } = focus.state; @@ -476,7 +476,7 @@ const SelectionProvider = observer(class SelectionProvider extends React.Compone if (withChildren) { ids.forEach(id => this.getChildrenIds(id, ids)); } else { - let childrenIds = []; + const childrenIds = []; ids.forEach(id => this.getChildrenIds(id, childrenIds)); ids = ids.filter(it => !childrenIds.includes(it)); }; @@ -486,7 +486,7 @@ const SelectionProvider = observer(class SelectionProvider extends React.Compone }; checkSelected (type: I.SelectType) { - let ids = this.get(type, true); + const ids = this.get(type, true); if (!ids.length) { return; }; @@ -508,7 +508,7 @@ const SelectionProvider = observer(class SelectionProvider extends React.Compone return; }; - for (let childId of childrenIds) { + for (const childId of childrenIds) { ids.push(childId); this.getChildrenIds(childId, ids); }; @@ -527,11 +527,11 @@ const SelectionProvider = observer(class SelectionProvider extends React.Compone $('.isSelectionSelected').removeClass('isSelectionSelected'); - for (let i in I.SelectType) { + for (const i in I.SelectType) { const type = I.SelectType[i]; const ids = this.get(type, true); - for (let id of ids) { + for (const id of ids) { $(`#selectable-${id}`).addClass('isSelectionSelected'); if (type == I.SelectType.Block) { @@ -567,9 +567,9 @@ const SelectionProvider = observer(class SelectionProvider extends React.Compone return; }; - let props = child.props || {}; - let children = props.children; - let dataset = props.dataset || {}; + const props = child.props || {}; + const children = props.children; + const dataset = props.dataset || {}; if (children) { child = React.cloneElement(child, { children: this.injectProps(children) }); diff --git a/src/ts/component/util/graph.tsx b/src/ts/component/util/graph.tsx index 40cc3528ae..c9da646bb8 100644 --- a/src/ts/component/util/graph.tsx +++ b/src/ts/component/util/graph.tsx @@ -129,13 +129,13 @@ const Graph = observer(class Graph extends React.Component<Props> { }, [ transfer ]); d3.select(this.canvas) - .call(d3.drag(). + .call(d3.drag(). subject(() => this.subject). on('start', (e: any, d: any) => this.onDragStart(e)). on('drag', (e: any, d: any) => this.onDragMove(e)). on('end', (e: any, d: any) => this.onDragEnd(e)) ) - .call(this.zoom) + .call(this.zoom) .call(this.zoom.transform, d3.zoomIdentity.translate(0, 0).scale(1.5)) .on('click', (e: any) => { const [ x, y ] = d3.pointer(e); @@ -246,7 +246,7 @@ const Graph = observer(class Graph extends React.Component<Props> { onZoom ({ transform }) { this.send('onZoom', { transform }); - }; + }; onPreviewShow (data: any) { if (this.isPreviewDisabled || !this.subject) { @@ -351,8 +351,8 @@ const Graph = observer(class Graph extends React.Component<Props> { case 'onTransform': { d3.select(this.canvas) - .call(this.zoom) - .call(this.zoom.transform, d3.zoomIdentity.translate(data.x, data.y).scale(data.k)) + .call(this.zoom) + .call(this.zoom.transform, d3.zoomIdentity.translate(data.x, data.y).scale(data.k)); break; }; diff --git a/src/ts/component/util/iconEmoji.tsx b/src/ts/component/util/iconEmoji.tsx index 4436b4760f..b682dcce2f 100644 --- a/src/ts/component/util/iconEmoji.tsx +++ b/src/ts/component/util/iconEmoji.tsx @@ -75,10 +75,10 @@ const IconEmoji = observer(class IconEmoji extends React.Component<Props> { }; } else if (hash) { - element = <img src={commonStore.imageUrl(hash, Constant.size.iconPage)} className={[ 'iconImage', 'c' + size ].join(' ')} onDragStart={(e: any) => { e.preventDefault(); }} />; + element = <img src={commonStore.imageUrl(hash, Constant.size.iconPage)} className={[ 'iconImage', 'c' + size ].join(' ')} onDragStart={(e: any) => { e.preventDefault(); }} />; } else if (iconClass) { - element = <img src={IconSrc[iconClass]} className={[ 'iconCommon', iconClass, 'c' + size ].join(' ')} /> + element = <img src={IconSrc[iconClass]} className={[ 'iconCommon', iconClass, 'c' + size ].join(' ')} />; }; if (!element) { diff --git a/src/ts/component/util/iconObject.tsx b/src/ts/component/util/iconObject.tsx index 43328cf271..11cacb467e 100644 --- a/src/ts/component/util/iconObject.tsx +++ b/src/ts/component/util/iconObject.tsx @@ -195,7 +195,7 @@ const IconObject = observer(class IconObject extends React.Component<Props> { let icon = null; let icn = []; - let onLetter = () => { + const onLetter = () => { cn.push('withLetter'); icn = icn.concat([ 'iconCommon', 'c' + iconSize ]); icon = <img src={this.commonSvg()} className={icn.join(' ')} />; diff --git a/src/ts/component/util/marker.tsx b/src/ts/component/util/marker.tsx index 08b5ac6ff0..249c34b166 100644 --- a/src/ts/component/util/marker.tsx +++ b/src/ts/component/util/marker.tsx @@ -69,11 +69,11 @@ const Marker = observer(class Marker extends React.Component<Props> { switch (type) { case I.TextStyle.Bulleted: - inner = <img src={this.getBullet()} onDragStart={e => e.preventDefault()} /> + inner = <img src={this.getBullet()} onDragStart={e => e.preventDefault()} />; break; case I.TextStyle.Numbered: - inner = <span id={'marker-' + id} className={ci.join(' ')} /> + inner = <span id={'marker-' + id} className={ci.join(' ')} />; break; case I.TextStyle.Checkbox: diff --git a/src/ts/component/widget/index.tsx b/src/ts/component/widget/index.tsx index e650396d50..5af0e550dc 100644 --- a/src/ts/component/widget/index.tsx +++ b/src/ts/component/widget/index.tsx @@ -332,7 +332,12 @@ const WidgetIndex = observer(class WidgetIndex extends React.Component<Props> { getData (subId: string, callBack?: () => void) { const { block, isPreview } = this.props; const child = this.getTargetBlock(); - const { targetBlockId } = child?.content; + + if (!child) { + return; + }; + + const { targetBlockId } = child.content; const sorts = []; const filters: I.Filter[] = [ { operator: I.FilterOperator.And, relationKey: 'type', condition: I.FilterCondition.NotIn, value: UtilObject.getSystemTypes() }, @@ -420,7 +425,7 @@ const WidgetIndex = observer(class WidgetIndex extends React.Component<Props> { let blockId = ''; let event = 'ScreenHome'; - let data: any = { view: 'Widget' }; + const data: any = { view: 'Widget' }; if (!isPreview) { blockId = block.id; diff --git a/src/ts/component/widget/list/item.tsx b/src/ts/component/widget/list/item.tsx index 6d0c5d9fde..e382f2ed1f 100644 --- a/src/ts/component/widget/list/item.tsx +++ b/src/ts/component/widget/list/item.tsx @@ -125,7 +125,7 @@ const WidgetListItem = observer(class WidgetListItem extends React.Component<Pro e.preventDefault(); e.stopPropagation(); - const { subId, id, } = this.props; + const { subId, id, } = this.props; const object = detailStore.get(subId, id, Constant.sidebarRelationKeys); UtilObject.openEvent(e, object); diff --git a/src/ts/docs/help/onboarding.ts b/src/ts/docs/help/onboarding.ts index ae8ff62255..3a137f181d 100644 --- a/src/ts/docs/help/onboarding.ts +++ b/src/ts/docs/help/onboarding.ts @@ -349,4 +349,4 @@ export default { ], }), -} +}; diff --git a/src/ts/interface/block/file.ts b/src/ts/interface/block/file.ts index c9be3e4192..3db9225a95 100644 --- a/src/ts/interface/block/file.ts +++ b/src/ts/interface/block/file.ts @@ -12,7 +12,7 @@ export enum FileType { Image = 2, Video = 3, Audio = 4, - Pdf = 5, + Pdf = 5, }; export enum FileState { diff --git a/src/ts/interface/block/widget.tsx b/src/ts/interface/block/widget.tsx index 02ba424553..af6a034aa9 100644 --- a/src/ts/interface/block/widget.tsx +++ b/src/ts/interface/block/widget.tsx @@ -26,7 +26,7 @@ export interface WidgetComponent { export interface WidgetTreeItem { id: string; rootId: string; // the id of the root node (root node) - parentId: string; // the id of the parent node + parentId: string; // the id of the parent node depth: number; // the depth of the node in the tree numChildren: number; // the number of children of the node }; diff --git a/src/ts/interface/common.ts b/src/ts/interface/common.ts index c426bf9b72..c4b13ffcf4 100644 --- a/src/ts/interface/common.ts +++ b/src/ts/interface/common.ts @@ -56,7 +56,7 @@ export enum ToastAction { Link = 2, Lock = 3, Collection = 4, - StorageFull = 5, + StorageFull = 5, TemplateCreate = 6, Archive = 7, }; diff --git a/src/ts/interface/object.ts b/src/ts/interface/object.ts index ee9a985d9d..57ded67b9e 100644 --- a/src/ts/interface/object.ts +++ b/src/ts/interface/object.ts @@ -13,7 +13,7 @@ export enum ObjectLayout { Bookmark = 11, OptionList = 12, Option = 13, - Collection = 14, + Collection = 14, Audio = 15, Video = 16, Date = 17, diff --git a/src/ts/lib/action.ts b/src/ts/lib/action.ts index 4383974792..4800ed2cea 100644 --- a/src/ts/lib/action.ts +++ b/src/ts/lib/action.ts @@ -15,7 +15,7 @@ class Action { const onClose = () => { const blocks = blockStore.getBlocks(rootId, it => it.isDataview()); - for (let block of blocks) { + for (const block of blocks) { this.dbClearBlock(rootId, block.id); }; @@ -127,7 +127,7 @@ class Action { }; remove (rootId: string, blockId: string, blockIds: string[]) { - let next = blockStore.getNextBlock(rootId, blockId, -1, (it: any) => { + const next = blockStore.getNextBlock(rootId, blockId, -1, (it: any) => { return it.type == I.BlockType.Text; }); @@ -246,7 +246,7 @@ class Action { callBack(message); }; - let { details } = message; + const { details } = message; let toast = ''; let subId = ''; diff --git a/src/ts/lib/analytics.ts b/src/ts/lib/analytics.ts index dbb5d4705b..08006aa6c4 100644 --- a/src/ts/lib/analytics.ts +++ b/src/ts/lib/analytics.ts @@ -106,7 +106,7 @@ class Analytics { return; }; - let converted: any = {}; + const converted: any = {}; let param: any = {}; // Code mappers for common events @@ -330,7 +330,7 @@ class Analytics { param.context = String(Storage.get(KEY_CONTEXT) || ''); param.originalId = String(Storage.get(KEY_ORIGINAL_ID) || ''); - for (let k of KEYS) { + for (const k of KEYS) { if (undefined !== data[k]) { converted[k] = data[k]; }; diff --git a/src/ts/lib/api/command.ts b/src/ts/lib/api/command.ts index e0335c45ad..e2fcb77cf1 100644 --- a/src/ts/lib/api/command.ts +++ b/src/ts/lib/api/command.ts @@ -1469,7 +1469,7 @@ const ObjectSetLayout = (contextId: string, layout: I.ObjectLayout, callBack?: ( dispatcher.request(ObjectSetLayout.name, request, callBack); }; -const ObjectSetIsFavorite = (contextId: string, isFavorite: boolean, callBack?: (message: any) => void) => { +const ObjectSetIsFavorite = (contextId: string, isFavorite: boolean, callBack?: (message: any) => void) => { const request = new Rpc.Object.SetIsFavorite.Request(); request.setContextid(contextId); diff --git a/src/ts/lib/api/dispatcher.ts b/src/ts/lib/api/dispatcher.ts index 653e403e90..7e0319ad0d 100644 --- a/src/ts/lib/api/dispatcher.ts +++ b/src/ts/lib/api/dispatcher.ts @@ -962,7 +962,7 @@ class Dispatcher { let title = ''; let text = ''; let textConfirm = ''; - let showPopup = [ I.ProgressType.Import, I.ProgressType.Export ].includes(type) && [ I.ProgressState.Done, I.ProgressState.Error ].includes(state); + const showPopup = [ I.ProgressType.Import, I.ProgressType.Export ].includes(type) && [ I.ProgressState.Done, I.ProgressState.Error ].includes(state); switch (state) { case I.ProgressState.Error: { diff --git a/src/ts/lib/api/mapper.ts b/src/ts/lib/api/mapper.ts index 6df928d737..d4bb951601 100644 --- a/src/ts/lib/api/mapper.ts +++ b/src/ts/lib/api/mapper.ts @@ -1,6 +1,6 @@ import { Rpc } from 'protobuf/pb/protos/commands_pb'; import Model from 'protobuf/pkg/lib/pb/model/protos/models_pb'; -import { I, M, UtilCommon, Encode, Decode } from 'Lib'; +import { I, M, UtilCommon, Encode, Decode } from 'Lib'; export const Mapper = { diff --git a/src/ts/lib/history.ts b/src/ts/lib/history.ts index 3b97951fe7..3a1f526015 100644 --- a/src/ts/lib/history.ts +++ b/src/ts/lib/history.ts @@ -4,7 +4,7 @@ class History { index = 0; clear () { - this.list = [] + this.list = []; this.index = 0; }; diff --git a/src/ts/lib/keyboard.ts b/src/ts/lib/keyboard.ts index ea41e951ab..b1b7f7b797 100644 --- a/src/ts/lib/keyboard.ts +++ b/src/ts/lib/keyboard.ts @@ -292,10 +292,10 @@ class Keyboard { return; }; - let targetId = ''; - let position = I.BlockPosition.Bottom; - let rootId = ''; - let details: any = {}; + const targetId = ''; + const position = I.BlockPosition.Bottom; + const rootId = ''; + const details: any = {}; let flags: I.ObjectFlag[] = [ I.ObjectFlag.SelectType ]; if (!rootId) { @@ -402,7 +402,7 @@ class Keyboard { }; if (!isPopup) { - let prev = history.entries[history.index - 1]; + const prev = history.entries[history.index - 1]; if (account && !prev) { return false; diff --git a/src/ts/lib/mark.ts b/src/ts/lib/mark.ts index ce7ad8f020..69681d5116 100644 --- a/src/ts/lib/mark.ts +++ b/src/ts/lib/mark.ts @@ -78,7 +78,7 @@ class Mark { { key: '~~', type: I.MarkType.Strike }, ]; - for (let item of Markdown) { + for (const item of Markdown) { const non = UtilCommon.regexEscape(item.key.substring(0, 1)); const k = UtilCommon.regexEscape(item.key); this.regexpMarkdown.push({ @@ -93,8 +93,8 @@ class Mark { return marks; }; - let map = UtilCommon.mapToArray(marks, 'type'); - let type = mark.type; + const map = UtilCommon.mapToArray(marks, 'type'); + const type = mark.type; let add = true; map[type] = map[type] || []; @@ -102,8 +102,8 @@ class Mark { for (let i = 0; i < map[type].length; ++i) { let del = false; - let el = map[type][i]; - let overlap = this.overlap(mark.range, el.range); + const el = map[type][i]; + const overlap = this.overlap(mark.range, el.range); switch (overlap) { case Overlap.Equal: @@ -198,8 +198,8 @@ class Mark { marks = (marks || []).slice().sort(this.sort); for (let i = 0; i < marks.length; ++i) { - let mark = marks[i]; - let prev = marks[(i - 1)]; + const mark = marks[i]; + const prev = marks[(i - 1)]; let del = false; if (mark.range.from >= text.length) { @@ -237,7 +237,7 @@ class Mark { }; if (mark.range.from > mark.range.to) { - let t = mark.range.to; + const t = mark.range.to; mark.range.to = mark.range.from; mark.range.from = t; }; @@ -247,13 +247,13 @@ class Mark { }; getInRange (marks: I.Mark[], type: I.MarkType, range: I.TextRange): any { - let map = UtilCommon.mapToArray(marks, 'type'); + const map = UtilCommon.mapToArray(marks, 'type'); if (!map[type] || !map[type].length) { return null; }; - for (let mark of map[type]) { - let overlap = this.overlap(range, mark.range); + for (const mark of map[type]) { + const overlap = this.overlap(range, mark.range); if ([ Overlap.Inner, Overlap.InnerLeft, Overlap.InnerRight, Overlap.Equal ].indexOf(overlap) >= 0) { return mark; }; @@ -264,7 +264,7 @@ class Mark { adjust (marks: I.Mark[], from: number, length: number) { marks = marks || []; - for (let mark of marks) { + for (const mark of marks) { if ((mark.range.from <= from) && (mark.range.to > from)) { mark.range.to += length; } else @@ -281,11 +281,11 @@ class Mark { text = String(text || ''); marks = this.checkRanges(text, marks || []); - let r = text.split(''); - let parts: I.Mark[] = []; + const r = text.split(''); + const parts: I.Mark[] = []; let borders: any[] = []; - let ranges: any[] = []; - let hasParam = [ + const ranges: any[] = []; + const hasParam = [ I.MarkType.Link, I.MarkType.Object, I.MarkType.Color, @@ -294,7 +294,7 @@ class Mark { I.MarkType.Emoji, ]; - for (let mark of marks) { + for (const mark of marks) { borders.push(Number(mark.range.from)); borders.push(Number(mark.range.to)); }; @@ -313,8 +313,8 @@ class Mark { ranges.push({ from: borders[i], to: borders[i + 1] }); }; - for (let range of ranges) { - for (let mark of marks) { + for (const range of ranges) { + for (const mark of marks) { if ((mark.range.from <= range.from) && (mark.range.to >= range.to)) { parts.push({ type: mark.type, @@ -358,14 +358,14 @@ class Mark { }; // Render mentions - for (let mark of marks) { + for (const mark of marks) { if (mark.type == I.MarkType.Mention) { render(mark); }; }; // Render everything except mentions - for (let mark of parts) { + for (const mark of parts) { if (mark.type != I.MarkType.Mention) { render(mark); }; @@ -384,7 +384,7 @@ class Mark { html = html.replace(/<br\/?>/g, '\n'); // Remove inner tags from mentions and emoji - let obj = $(`<div>${html}</div>`); + const obj = $(`<div>${html}</div>`); obj.find('mention').removeAttr('class').each((i: number, item: any) => { item = $(item); @@ -418,7 +418,7 @@ class Mark { html = html.replace(/contenteditable="[^"]+"/g, ''); let text = html; - let marks: any[] = []; + const marks: any[] = []; // TODO: find classes by color or background html.replace(/<font([^>]*?)>([^<]*)<\/font>/g, (s: string, p1: string, p2: string) => { @@ -455,21 +455,21 @@ class Mark { p2 = String(p2 || '').trim(); p3 = String(p3 || '').trim(); - let end = p1 == '/'; - let offset = Number(text.indexOf(s)) || 0; - let type = Tags.indexOf(p2); + const end = p1 == '/'; + const offset = Number(text.indexOf(s)) || 0; + const type = Tags.indexOf(p2); if (end) { for (let i = 0; i < marks.length; ++i) { - let m = marks[i]; + const m = marks[i]; if ((m.type == type) && !m.range.to) { marks[i].range.to = offset; break; }; }; } else { - let pm = p3.match(rp); - let param = pm ? pm[1]: ''; + const pm = p3.match(rp); + const param = pm ? pm[1]: ''; marks.push({ type, @@ -488,8 +488,8 @@ class Mark { fromMarkdown (html: string, marks: I.Mark[], restricted: I.MarkType[]): { marks: I.Mark[], text: string, marksChanged: boolean } { let text = html; - let test = /[`\*_~\[]{1}/.test(text); - let checked = marks.filter(it => [ I.MarkType.Code ].includes(it.type)); + const test = /[`\*_~\[]{1}/.test(text); + const checked = marks.filter(it => [ I.MarkType.Code ].includes(it.type)); let marksChanged = false; if (!test) { @@ -497,7 +497,7 @@ class Mark { }; // Markdown - for (let item of this.regexpMarkdown) { + for (const item of this.regexpMarkdown) { if (restricted.includes(item.type)) { continue; }; @@ -510,9 +510,9 @@ class Mark { p4 = String(p4 || ''); p5 = String(p5 || ''); - let from = (Number(text.indexOf(s)) || 0) + p1.length; - let to = from + p3.length; - let replace = (p1 + p3 + ' ').replace(new RegExp('\\$', 'g'), '$$$'); + const from = (Number(text.indexOf(s)) || 0) + p1.length; + const to = from + p3.length; + const replace = (p1 + p3 + ' ').replace(new RegExp('\\$', 'g'), '$$$'); let check = true; for (const mark of checked) { @@ -539,13 +539,13 @@ class Mark { p2 = String(p2 || ''); p3 = String(p3 || ''); - let from = (Number(text.indexOf(s)) || 0); - let to = from + p1.length; - let innerIdx = []; + const from = (Number(text.indexOf(s)) || 0); + const to = from + p1.length; + const innerIdx = []; // Remove inner links and adjust other marks to new range for (let i = 0; i < marks.length; ++i) { - let mark = marks[i]; + const mark = marks[i]; if ((mark.range.from >= from) && (mark.range.to <= from + p1.length + p2.length + 4)) { if ([ I.MarkType.Link, I.MarkType.Object ].includes(mark.type)) { marks.splice(i, 1); @@ -558,7 +558,7 @@ class Mark { this.adjust(marks, from, -(p2.length + 4)); - for (let i of innerIdx) { + for (const i of innerIdx) { marks[i].range.from = from; marks[i].range.to = to; }; @@ -576,11 +576,11 @@ class Mark { // Unicode symbols fromUnicode (html: string, marks: I.Mark[]): string { - let checked = marks.filter(it => [ I.MarkType.Code, I.MarkType.Link ].includes(it.type)); + const checked = marks.filter(it => [ I.MarkType.Code, I.MarkType.Link ].includes(it.type)); let text = html; - let keys = Object.keys(Patterns).map(it => UtilCommon.regexEscape(it)); - let reg = new RegExp('(' + keys.join('|') + ')', 'g'); - let test = reg.test(text); + const keys = Object.keys(Patterns).map(it => UtilCommon.regexEscape(it)); + const reg = new RegExp('(' + keys.join('|') + ')', 'g'); + const test = reg.test(text); if (!test) { return text; @@ -635,7 +635,7 @@ class Mark { toggleLink (newMark: I.Mark, marks: I.Mark[]) { for (let i = 0; i < marks.length; ++i) { - let mark = marks[i]; + const mark = marks[i]; if ([ I.MarkType.Link, I.MarkType.Object ].includes(mark.type) && (mark.range.from >= newMark.range.from) && (mark.range.to <= newMark.range.to) diff --git a/src/ts/lib/scrollOnMove.ts b/src/ts/lib/scrollOnMove.ts index 2168b12834..608c51ac12 100644 --- a/src/ts/lib/scrollOnMove.ts +++ b/src/ts/lib/scrollOnMove.ts @@ -58,14 +58,14 @@ class ScrollOnMove { }; adjustWindowScroll (param: any) { - let { + const { viewportX, viewportY, isInLeftEdge, isInRightEdge, isInTopEdge, isInBottomEdge, edgeLeft, edgeRight, edgeTop, edgeBottom, } = param; - let maxScrollX = this.documentWidth - this.viewportWidth; - let maxScrollY = this.documentHeight - this.viewportHeight; + const maxScrollX = this.documentWidth - this.viewportWidth; + const maxScrollY = this.documentHeight - this.viewportHeight; let currentScrollX = 0; let currentScrollY = 0; let container; @@ -81,13 +81,13 @@ class ScrollOnMove { currentScrollY = window.pageYOffset; }; - let canScrollUp = (currentScrollY > 0); - let canScrollDown = (currentScrollY < maxScrollY); - let canScrollLeft = (currentScrollX > 0); - let canScrollRight = (currentScrollX < maxScrollX); + const canScrollUp = (currentScrollY > 0); + const canScrollDown = (currentScrollY < maxScrollY); + const canScrollLeft = (currentScrollX > 0); + const canScrollRight = (currentScrollX < maxScrollX); let nextScrollX = currentScrollX; let nextScrollY = currentScrollY; - let maxStep = 10; + const maxStep = 10; let intensity = 0; if (isInLeftEdge && canScrollLeft) { @@ -128,15 +128,15 @@ class ScrollOnMove { }; onMouseMove (x: number, y: number) { - let edgeTop = BORDER; - let edgeLeft = BORDER; - let edgeBottom = this.viewportHeight - BORDER; - let edgeRight = this.viewportWidth - BORDER; + const edgeTop = BORDER; + const edgeLeft = BORDER; + const edgeBottom = this.viewportHeight - BORDER; + const edgeRight = this.viewportWidth - BORDER; - let isInLeftEdge = x < edgeLeft; - let isInRightEdge = x > edgeRight; - let isInTopEdge = y < edgeTop; - let isInBottomEdge = y > edgeBottom; + const isInLeftEdge = x < edgeLeft; + const isInRightEdge = x > edgeRight; + const isInTopEdge = y < edgeTop; + const isInBottomEdge = y > edgeBottom; if (!(isInLeftEdge || isInRightEdge || isInTopEdge || isInBottomEdge)) { this.clear(); diff --git a/src/ts/lib/storage.ts b/src/ts/lib/storage.ts index 989cce962c..03c5d1305a 100644 --- a/src/ts/lib/storage.ts +++ b/src/ts/lib/storage.ts @@ -27,7 +27,7 @@ class Storage { }; get (key: string): any { - let o = String(this.storage[key] || ''); + const o = String(this.storage[key] || ''); if (this.isSpaceKey(key)) { if (o) { @@ -53,7 +53,7 @@ class Storage { let o = this.get(key); if (typeof o === 'object') { - for (let i in obj) { + for (const i in obj) { o[i] = obj[i]; }; } else { diff --git a/src/ts/lib/survey.ts b/src/ts/lib/survey.ts index 130c77d58f..9f7dcd17d4 100644 --- a/src/ts/lib/survey.ts +++ b/src/ts/lib/survey.ts @@ -4,16 +4,16 @@ import Surveys from 'json/survey.json'; class Survey { - check (type: I.SurveyType) { + check (type: I.SurveyType) { const fn = `check${I.SurveyType[type]}`; if (this[fn]) { this[fn](); }; - }; + }; - show (type: I.SurveyType) { - const prefix = `survey${type}`; + show (type: I.SurveyType) { + const prefix = `survey${type}`; popupStore.open('confirm', { data: { @@ -29,49 +29,49 @@ class Survey { }); analytics.event('SurveyShow', { type }); - }; + }; - onConfirm (type: I.SurveyType) { - const { account } = authStore; - const survey = Surveys[type]; + onConfirm (type: I.SurveyType) { + const { account } = authStore; + const survey = Surveys[type]; const param: any = {}; param[type] = param[type] || {}; - switch (type) { + switch (type) { default: param[type].complete = true; break; - case I.SurveyType.Pmf: - param[type].time = UtilCommon.time(); - break; - }; + case I.SurveyType.Pmf: + param[type].time = UtilCommon.time(); + break; + }; Storage.set('survey', param); Renderer.send('urlOpen', UtilCommon.sprintf(survey.url, account.id)); - analytics.event('SurveyOpen', { type }); - }; + analytics.event('SurveyOpen', { type }); + }; - onSkip (type: I.SurveyType) { + onSkip (type: I.SurveyType) { const param: any = {}; param[type] = param[type] || {}; - switch (type) { + switch (type) { default: param[type].complete = true; break; - case I.SurveyType.Pmf: - param[type].cancel = true; - param[type].time = UtilCommon.time(); - break; - }; + case I.SurveyType.Pmf: + param[type].cancel = true; + param[type].time = UtilCommon.time(); + break; + }; Storage.set('survey', param); analytics.event('SurveySkip', { type }); - }; + }; getStorage (type: I.SurveyType) { const obj = Storage.get('survey') || {}; @@ -82,14 +82,14 @@ class Survey { return this.getStorage(type).complete; }; - checkPmf () { + checkPmf () { const time = UtilCommon.time(); const timeRegister = Number(Storage.get('timeRegister')) || 0; const storage = Storage.get('survey') || {}; - const obj = storage[I.SurveyType.Pmf] || {}; - const lastTime = Number(Storage.get('lastSurveyTime')) || Number(obj.time) || 0; - const lastCanceled = Number(Storage.get('lastSurveyCanceled')) || obj.cancel || false; - const surveyTime = (timeRegister <= time - 86400 * 7) && (lastTime <= time - 86400 * 30); + const obj = storage[I.SurveyType.Pmf] || {}; + const lastTime = Number(Storage.get('lastSurveyTime')) || Number(obj.time) || 0; + const lastCanceled = Number(Storage.get('lastSurveyCanceled')) || obj.cancel || false; + const surveyTime = (timeRegister <= time - 86400 * 7) && (lastTime <= time - 86400 * 30); const randSeed = 10000000; const rand = UtilCommon.rand(0, randSeed); @@ -99,50 +99,50 @@ class Survey { return; }; - if (!popupStore.isOpen() && !lastCanceled && surveyTime) { - this.show(I.SurveyType.Pmf); - }; - }; + if (!popupStore.isOpen() && !lastCanceled && surveyTime) { + this.show(I.SurveyType.Pmf); + }; + }; - checkRegister () { - const timeRegister = Number(Storage.get('timeRegister')) || 0; + checkRegister () { + const timeRegister = Number(Storage.get('timeRegister')) || 0; const isComplete = this.isComplete(I.SurveyType.Register); - const surveyTime = timeRegister && ((UtilCommon.time() - 86400 * 7 - timeRegister) > 0); + const surveyTime = timeRegister && ((UtilCommon.time() - 86400 * 7 - timeRegister) > 0); - if (!isComplete && surveyTime && !popupStore.isOpen()) { - this.show(I.SurveyType.Register); - }; - }; + if (!isComplete && surveyTime && !popupStore.isOpen()) { + this.show(I.SurveyType.Register); + }; + }; - checkDelete () { - const isComplete = this.isComplete(I.SurveyType.Delete); + checkDelete () { + const isComplete = this.isComplete(I.SurveyType.Delete); - if (!isComplete) { - this.show(I.SurveyType.Delete); - }; - }; + if (!isComplete) { + this.show(I.SurveyType.Delete); + }; + }; - checkObject () { - const timeRegister = Number(Storage.get('timeRegister')) || 0; + checkObject () { + const timeRegister = Number(Storage.get('timeRegister')) || 0; const isComplete = this.isComplete(I.SurveyType.Object); - if (isComplete || !timeRegister) { - return; - }; + if (isComplete || !timeRegister) { + return; + }; UtilData.search({ filters: [ { operator: I.FilterOperator.And, relationKey: 'layout', condition: I.FilterCondition.In, value: UtilObject.getPageLayouts() }, { operator: I.FilterOperator.And, relationKey: 'type', condition: I.FilterCondition.NotIn, value: UtilObject.getSystemTypes() }, - { operator: I.FilterOperator.And, relationKey: 'createdDate', condition: I.FilterCondition.Greater, value: timeRegister + 30 } + { operator: I.FilterOperator.And, relationKey: 'createdDate', condition: I.FilterCondition.Greater, value: timeRegister + 30 } ], limit: 50, }, (message: any) => { - if (!message.error.code && (message.records.length >= 50)) { - this.show(I.SurveyType.Object); - }; - }); - }; + if (!message.error.code && (message.records.length >= 50)) { + this.show(I.SurveyType.Object); + }; + }); + }; } diff --git a/src/ts/lib/util/common.ts b/src/ts/lib/util/common.ts index 5bc8889008..5e144dd6cd 100644 --- a/src/ts/lib/util/common.ts +++ b/src/ts/lib/util/common.ts @@ -14,15 +14,19 @@ class UtilCommon { }; sprintf (...args: any[]) { - let regex = /%%|%(\d+\$)?([-+#0 ]*)(\*\d+\$|\*|\d+)?(\.(\*\d+\$|\*|\d+))?([scboxXuidfegEG])/g; - let a = args, i = 0, format = a[i++]; - let pad = function (str, len, chr, leftJustify) { - let padding = (str.length >= len) ? '' : Array(1 + len - str.length >>> 0).join(chr); + const regex = /%%|%(\d+\$)?([-+#0 ]*)(\*\d+\$|\*|\d+)?(\.(\*\d+\$|\*|\d+))?([scboxXuidfegEG])/g; + const a = args; + + let i = 0; + + const format = a[i++]; + const pad = function (str, len, chr, leftJustify) { + const padding = (str.length >= len) ? '' : Array(1 + len - str.length >>> 0).join(chr); return leftJustify ? str + padding : padding + str; }; - let justify = function (value, prefix, leftJustify, minWidth, zeroPad) { - let diff = minWidth - value.length; + const justify = function (value, prefix, leftJustify, minWidth, zeroPad) { + const diff = minWidth - value.length; if (diff > 0) { if (leftJustify || !zeroPad) { value = pad(value, minWidth, ' ', leftJustify); @@ -33,21 +37,21 @@ class UtilCommon { return value; }; - let formatBaseX = function (value, base, prefix, leftJustify, minWidth, precision, zeroPad) { - let number = value >>> 0; + const formatBaseX = function (value, base, prefix, leftJustify, minWidth, precision, zeroPad) { + const number = value >>> 0; prefix = prefix && number && {'2': '0b', '8': '0', '16': '0x'}[base] || ''; value = prefix + pad(number.toString(base), precision || 0, '0', false); return justify(value, prefix, leftJustify, minWidth, zeroPad); }; - let formatString = function (value, leftJustify, minWidth, precision, zeroPad) { + const formatString = function (value, leftJustify, minWidth, precision, zeroPad) { if (precision != null) { value = value.slice(0, precision); }; return justify(value, '', leftJustify, minWidth, zeroPad); }; - let doFormat = function (substring, valueIndex, flags, minWidth, _, precision, type) { + const doFormat = function (substring, valueIndex, flags, minWidth, _, precision, type) { if (substring == '%%') return '%'; let leftJustify = false, positivePrefix = '', zeroPad = false, prefixBaseX = false; for (let j = 0; flags && j < flags.length; j++) switch (flags.charAt(j)) { @@ -103,7 +107,7 @@ class UtilCommon { case 'd': { let number = +value; number = parseInt(String(number)); - let prefix = number < 0 ? '-' : positivePrefix; + const prefix = number < 0 ? '-' : positivePrefix; value = prefix + pad(String(Math.abs(number)), precision, '0', false); return justify(value, prefix, leftJustify, minWidth, zeroPad); }; @@ -113,10 +117,10 @@ class UtilCommon { case 'F': case 'g': case 'G': { - let number = +value; - let prefix = number < 0 ? '-' : positivePrefix; - let method = ['toExponential', 'toFixed', 'toPrecision']['efg'.indexOf(type.toLowerCase())]; - let textTransform = ['toString', 'toUpperCase']['eEfFgG'.indexOf(type) % 2]; + const number = +value; + const prefix = number < 0 ? '-' : positivePrefix; + const method = ['toExponential', 'toFixed', 'toPrecision']['efg'.indexOf(type.toLowerCase())]; + const textTransform = ['toString', 'toUpperCase']['eEfFgG'.indexOf(type) % 2]; value = prefix + Math.abs(number)[method](precision); return justify(value, prefix, leftJustify, minWidth, zeroPad)[textTransform](); @@ -170,7 +174,7 @@ class UtilCommon { // Clear object for smaller console output objectClear (o: any) { - for (let k in o) { + for (const k in o) { if (typeof o[k] === 'object') { o[k] = this.objectClear(o[k]); if (!this.objectLength(o[k])) { @@ -188,13 +192,13 @@ class UtilCommon { }; fieldsMap (a: any[]) { - let o = {}; + const o = {}; for (let i = 0; i < a.length; ++i) { if ((a[i].constructor === Array) && (a[i].length == 2)) { - let value = a[i][1]; + const value = a[i][1]; let v = ''; - for (let k in value) { + for (const k in value) { if (value[k]) { v = value[k]; break; @@ -211,11 +215,11 @@ class UtilCommon { o1 = o1 || {}; o2 = o2 || {}; - let k1 = Object.keys(o1); - let k2 = Object.keys(o2); - let v1 = Object.values(o1); - let v2 = Object.values(o2); - let sort = (c1: any, c2: any) => { + const k1 = Object.keys(o1); + const k2 = Object.keys(o2); + const v1 = Object.values(o1); + const v2 = Object.values(o2); + const sort = (c1: any, c2: any) => { if (c1 > c2) return 1; if (c1 < c2) return -1; return 0; @@ -303,7 +307,7 @@ class UtilCommon { cacheImages (images: string[], callBack?: () => void) { let loaded = 0; - let cb = () => { + const cb = () => { loaded++; if ((loaded == images.length) && callBack) { callBack(); @@ -356,7 +360,7 @@ class UtilCommon { }; parseDate (value: string, format?: I.DateFormat): number { - let [ date, time ] = String(value || '').split(' '); + const [ date, time ] = String(value || '').split(' '); let d: any = 0; let m: any = 0; let y: any = 0; @@ -401,7 +405,7 @@ class UtilCommon { let s = String(n); if ((s = s + '').length < c ) { ++c; - let m = c - s.length; + const m = c - s.length; return new Array(m).join('0') + s; } else { return s; @@ -411,10 +415,10 @@ class UtilCommon { const f: any = { // Day d: () => { - return pad(f.j(), 2); + return pad(f.j(), 2); }, D: () => { - let t = f.l(); + const t = f.l(); return t.substring(0,3); }, j: () => { @@ -506,16 +510,16 @@ class UtilCommon { }; let delta = this.time() - t; - let d = Math.floor(delta / 86400); + const d = Math.floor(delta / 86400); delta -= d * 86400; - let h = Math.floor(delta / 3600); + const h = Math.floor(delta / 3600); delta -= h * 3600; - let m = Math.floor(delta / 60); + const m = Math.floor(delta / 60); delta -= m * 60; - let s = delta; + const s = delta; if (d > 0) { return this.sprintf('%d days ago', d); @@ -550,16 +554,16 @@ class UtilCommon { return ''; }; - let d = Math.floor(t / 86400); + const d = Math.floor(t / 86400); t -= d * 86400; - let h = Math.floor(t / 3600); + const h = Math.floor(t / 3600); t -= h * 3600; - let m = Math.floor(t / 60); + const m = Math.floor(t / 60); t -= m * 60; - let s = t; + const s = t; if (d > 0) { return this.sprintf('%dd', d); @@ -577,7 +581,7 @@ class UtilCommon { }; round (v: number, l: number) { - let d = Math.pow(10, l); + const d = Math.pow(10, l); return d > 0 ? Math.round(v * d) / d : Math.round(v); }; @@ -621,8 +625,8 @@ class UtilCommon { mapToArray (list: any[], field: string): any { list = list|| [] as any[]; - let map = {} as any; - for (let item of list) { + const map = {} as any; + for (const item of list) { map[item[field]] = map[item[field]] || []; map[item[field]].push(item); }; @@ -639,7 +643,7 @@ class UtilCommon { unmap (map: any) { let ret: any[] = [] as any[]; - for (let field in map) { + for (const field in map) { ret = ret.concat(map[field]); }; return ret; @@ -689,7 +693,7 @@ class UtilCommon { }; getSelectionRange (): Range { - let sel: Selection = window.getSelection(); + const sel: Selection = window.getSelection(); let range: Range = null; if (sel && (sel.rangeCount > 0)) { @@ -701,7 +705,7 @@ class UtilCommon { getSelectionRect () { let rect: any = { x: 0, y: 0, width: 0, height: 0 }; - let range = this.getSelectionRange(); + const range = this.getSelectionRange(); if (range) { rect = range.getBoundingClientRect() as DOMRect; }; @@ -788,7 +792,7 @@ class UtilCommon { }; getRoute (path: string): { page: string, action: string, id: string } { - let route = path.split('/'); + const route = path.split('/'); route.shift(); const page = String(route[0] || 'index'); @@ -928,7 +932,7 @@ class UtilCommon { }; const files: any[] = []; - for (let item of items) { + for (const item of items) { if (item.kind != 'file') { continue; }; @@ -946,8 +950,8 @@ class UtilCommon { return []; }; - let ret = []; - for (let item of items) { + const ret = []; + for (const item of items) { if ((item.kind == 'string') && (item.type == 'text/html')) { ret.push(item); }; @@ -970,7 +974,7 @@ class UtilCommon { }; }; - for (let item of items) { + for (const item of items) { item.getAsString(cb); }; }; @@ -980,16 +984,16 @@ class UtilCommon { return; }; - let ret: any[] = []; + const ret: any[] = []; let n = 0; - let cb = () => { + const cb = () => { n++; if (n == items.length) { callBack({ ...data, files: ret }); }; }; - for (let item of items) { + for (const item of items) { if (item.path) { ret.push({ name: item.name, path: item.path }); cb(); diff --git a/src/ts/lib/util/data.ts b/src/ts/lib/util/data.ts index 84f8955aca..a4e48f8e09 100644 --- a/src/ts/lib/util/data.ts +++ b/src/ts/lib/util/data.ts @@ -682,9 +682,8 @@ class UtilData { noDeps: false, }, param); - let { subId, ids, keys, noDeps } = param; - - ids = UtilCommon.arrayUnique(ids.filter(it => it)); + const { subId, keys, noDeps } = param; + const ids = UtilCommon.arrayUnique(param.ids.filter(it => it)); if (!subId) { console.error('[UtilData].subscribeIds: subId is empty'); diff --git a/src/ts/lib/util/file.ts b/src/ts/lib/util/file.ts index 36a19520f2..17d1a2ac67 100644 --- a/src/ts/lib/util/file.ts +++ b/src/ts/lib/util/file.ts @@ -22,10 +22,10 @@ class UtilFile { return Number.isInteger(n) ? 0 : afterComma; }; - let unit = 1024; - let g = v / (unit * unit * unit); - let m = v / (unit * unit); - let k = v / unit; + const unit = 1024; + const g = v / (unit * unit * unit); + const m = v / (unit * unit); + const k = v / unit; if (g >= 1) { v = UtilCommon.sprintf(`%0.${trimmer(g, 2)}fGB`, UtilCommon.round(g, trimmer(g, 2))); } else if (m > 1) { @@ -47,7 +47,7 @@ class UtilFile { let icon = 'other'; if (mime) { - let a: string[] = mime.split(';'); + const a: string[] = mime.split(';'); if (a.length) { t = a[0].split('/'); }; @@ -98,7 +98,7 @@ class UtilFile { icon = 'presentation'; }; - for (let k in Constant.extension) { + for (const k in Constant.extension) { if (Constant.extension[k].indexOf(e) >= 0) { icon = k; break; @@ -132,7 +132,7 @@ class UtilFile { loadPreviewBase64 (file: any, param: any, success?: (image: string, param: any) => void, error?: (error: string) => void) { this.loadPreviewCanvas(file, param, (canvas: any) => { - let image = canvas.toDataURL(param.type, param.quality); + const image = canvas.toDataURL(param.type, param.quality); if (image && success) { success(image, { width: canvas.width, height: canvas.height }); diff --git a/src/ts/lib/util/menu.ts b/src/ts/lib/util/menu.ts index f267ffcecd..0248129280 100644 --- a/src/ts/lib/util/menu.ts +++ b/src/ts/lib/util/menu.ts @@ -53,13 +53,13 @@ class UtilMenu { }; getBlockObject () { - let ret: any[] = [ + const ret: any[] = [ { type: I.BlockType.Page, id: 'existing', icon: 'existing', lang: 'Existing', arrow: true }, ]; let i = 0; - let items = UtilData.getObjectTypesForNewObject({ withSet: true, withCollection: true }); + const items = UtilData.getObjectTypesForNewObject({ withSet: true, withCollection: true }); - for (let type of items) { + for (const type of items) { ret.push({ id: 'object' + i++, type: I.BlockType.Page, @@ -97,7 +97,7 @@ class UtilMenu { types.sort(UtilData.sortByName); let i = 0; - for (let type of types) { + for (const type of types) { ret.push({ type: I.BlockType.Page, id: 'object' + i++, @@ -182,10 +182,10 @@ class UtilMenu { }; getBgColors () { - let items: any[] = [ + const items: any[] = [ { id: 'bgColor-default', name: translate('commonDefault'), value: '', className: 'default', isBgColor: true } ]; - for (let color of Constant.textColor) { + for (const color of Constant.textColor) { items.push({ id: 'bgColor-' + color, name: translate('textColor-' + color), value: color, className: color, isBgColor: true }); }; return items; @@ -327,7 +327,7 @@ class UtilMenu { c._sortWeight_ = getWeight(c.description); } else if (c.aliases && c.aliases.length) { - for (let alias of c.aliases) { + for (const alias of c.aliases) { if (alias.match(regC)) { ret = true; break; diff --git a/src/ts/lib/util/smile.ts b/src/ts/lib/util/smile.ts index 53032733bc..7113c99a8a 100644 --- a/src/ts/lib/util/smile.ts +++ b/src/ts/lib/util/smile.ts @@ -46,11 +46,11 @@ class UtilSmile { return ''; }; - let codeUnits = []; + const codeUnits = []; let highSurrogate; let lowSurrogate; let index = -1; - let length = points.length; + const length = points.length; let result = ''; while (++index < length) { @@ -61,7 +61,7 @@ class UtilSmile { point > 0x10ffff || // not a valid Unicode code point Math.floor(point) != point // not an integer ) { - throw RangeError('Invalid code point: ' + point) + throw RangeError('Invalid code point: ' + point); }; if (point <= 0xffff) { @@ -78,7 +78,7 @@ class UtilSmile { }; if ((index + 1 === length) || (codeUnits.length > MAX_SIZE)) { - result += String.fromCharCode.apply(null, codeUnits) + result += String.fromCharCode.apply(null, codeUnits); codeUnits.length = 0; }; }; @@ -98,8 +98,8 @@ class UtilSmile { let uni = item.unified; if (item.skin_variations && (skin > 1)) { - let skinCode = SKINS[(skin - 1)]; - let skinItem = item.skin_variations[skinCode]; + const skinCode = SKINS[(skin - 1)]; + const skinItem = item.skin_variations[skinCode]; if (skinItem && skinItem.unified) { uni = skinItem.unified; }; @@ -108,7 +108,7 @@ class UtilSmile { }; uncompress (item: any) { - for (let key in item) { + for (const key in item) { if (!Mapping[key]) { continue; }; @@ -166,7 +166,7 @@ class UtilSmile { return this.cache[icon]; }; - let cp = []; + const cp = []; for (let i = 0; i < icon.length; ++i) { cp.push(icon.charCodeAt(i)); }; @@ -199,7 +199,7 @@ class UtilSmile { strip (t: string) { const r = /(?:[\u2700-\u27bf]|(?:\ud83c[\udde6-\uddff]){2}|[\ud800-\udbff][\udc00-\udfff]|[\u0023-\u0039]\ufe0f?\u20e3|\u3299|\u3297|\u303d|\u3030|\u24c2|\ud83c[\udd70-\udd71]|\ud83c[\udd7e-\udd7f]|\ud83c\udd8e|\ud83c[\udd91-\udd9a]|\ud83c[\udde6-\uddff]|\ud83c[\ude01-\ude02]|\ud83c\ude1a|\ud83c\ude2f|\ud83c[\ude32-\ude3a]|\ud83c[\ude50-\ude51]|\u203c|\u2049|[\u25aa-\u25ab]|\u25b6|\u25c0|[\u25fb-\u25fe]|\u00a9|\u00ae|\u2122|\u2139|\ud83c\udc04|[\u2600-\u26FF]|\u2b05|\u2b06|\u2b07|\u2b1b|\u2b1c|\u2b50|\u2b55|\u231a|\u231b|\u2328|\u23cf|[\u23e9-\u23f3]|[\u23f8-\u23fa]|\ud83c\udccf|\u2934|\u2935|[\u2190-\u21ff])/g; - return t.replace(r, ''); + return t.replace(r, ''); }; }; diff --git a/src/ts/model/content/table.ts b/src/ts/model/content/table.ts index 272983e0f6..f026080942 100644 --- a/src/ts/model/content/table.ts +++ b/src/ts/model/content/table.ts @@ -19,4 +19,4 @@ class BlockContentTableRow implements I.ContentTableRow { export { BlockContentTableRow, -} \ No newline at end of file +}; \ No newline at end of file diff --git a/src/ts/store/block.ts b/src/ts/store/block.ts index 191b9148e5..2e839f91b7 100644 --- a/src/ts/store/block.ts +++ b/src/ts/store/block.ts @@ -268,7 +268,7 @@ class BlockStore { let ret = false; - for (let childId of element.childrenIds) { + for (const childId of element.childrenIds) { ret = this.checkIsChild(rootId, childId, blockId); if (ret) { break; diff --git a/src/ts/store/common.ts b/src/ts/store/common.ts index f1291b9936..b5b95eeb8c 100644 --- a/src/ts/store/common.ts +++ b/src/ts/store/common.ts @@ -164,7 +164,7 @@ class CommonStore { }; get isSidebarFixed(): boolean { - return Boolean(this.isSidebarFixedValue) || Storage.get('isSidebarFixed'); + return Boolean(this.isSidebarFixedValue) || Storage.get('isSidebarFixed'); }; get theme(): string { diff --git a/src/ts/store/db.ts b/src/ts/store/db.ts index e02deb24ab..5bafe96d07 100644 --- a/src/ts/store/db.ts +++ b/src/ts/store/db.ts @@ -6,44 +6,44 @@ import Constant from 'json/constant.json'; class DbStore { - public relationMap: Map<string, any[]> = observable(new Map()); + public relationMap: Map<string, any[]> = observable(new Map()); public relationKeyMap: any = {}; - public viewMap: Map<string, I.View[]> = observable.map(new Map()); - public recordMap: Map<string, string[]> = observable.map(new Map()); - public metaMap: Map<string, any> = observable.map(new Map()); + public viewMap: Map<string, I.View[]> = observable.map(new Map()); + public recordMap: Map<string, string[]> = observable.map(new Map()); + public metaMap: Map<string, any> = observable.map(new Map()); public groupMap: Map<string, any> = observable.map(new Map()); - constructor() { - makeObservable(this, { + constructor() { + makeObservable(this, { clearAll: action, relationsSet: action, - viewsSet: action, + viewsSet: action, viewsSort: action, - viewsClear: action, - viewAdd: action, - viewUpdate: action, - viewDelete: action, - metaSet: action, - metaClear: action, - recordsSet: action, - recordsClear: action, - recordAdd: action, - recordDelete: action, + viewsClear: action, + viewAdd: action, + viewUpdate: action, + viewDelete: action, + metaSet: action, + metaClear: action, + recordsSet: action, + recordsClear: action, + recordAdd: action, + recordDelete: action, groupsSet: action, groupsAdd: action, groupsRemove: action, groupsClear: action, - }); - } + }); + } clearAll () { - this.relationMap.clear(); - this.viewMap.clear(); - this.recordMap.clear(); - this.metaMap.clear(); + this.relationMap.clear(); + this.viewMap.clear(); + this.recordMap.clear(); + this.metaMap.clear(); }; - relationsSet (rootId: string, blockId: string, list: any[]) { + relationsSet (rootId: string, blockId: string, list: any[]) { const key = this.getId(rootId, blockId); const relations = (this.relationMap.get(this.getId(rootId, blockId)) || []). concat(list.map(it => ({ relationKey: it.relationKey, format: it.format }))); @@ -58,7 +58,7 @@ class DbStore { this.relationMap.set(key, relations.map(it => ({ relationKey: it.relationKey, format: it.format }))); }; - viewsSet (rootId: string, blockId: string, list: I.View[]) { + viewsSet (rootId: string, blockId: string, list: I.View[]) { const key = this.getId(rootId, blockId); const views = this.getViews(rootId, blockId); @@ -94,11 +94,11 @@ class DbStore { this.viewsSet(rootId, blockId, views); }; - viewsClear (rootId: string, blockId: string) { + viewsClear (rootId: string, blockId: string) { this.viewMap.delete(this.getId(rootId, blockId)); }; - viewAdd (rootId: string, blockId: string, item: any) { + viewAdd (rootId: string, blockId: string, item: any) { const views = this.getViews(rootId, blockId); const view = this.getView(rootId, blockId, item.id); @@ -109,7 +109,7 @@ class DbStore { }; }; - viewUpdate (rootId: string, blockId: string, item: any) { + viewUpdate (rootId: string, blockId: string, item: any) { const views = this.getViews(rootId, blockId); const idx = views.findIndex(it => it.id == item.id); @@ -123,11 +123,11 @@ class DbStore { set(views[idx], item); }; - viewDelete (rootId: string, blockId: string, id: string) { + viewDelete (rootId: string, blockId: string, id: string) { this.viewMap.set(this.getId(rootId, blockId), this.getViews(rootId, blockId).filter(it => it.id != id)); }; - metaSet (rootId: string, blockId: string, meta: any) { + metaSet (rootId: string, blockId: string, meta: any) { const data = this.metaMap.get(this.getId(rootId, blockId)); if (data) { @@ -150,26 +150,26 @@ class DbStore { }; }; - metaClear (rootId: string, blockId: string) { + metaClear (rootId: string, blockId: string) { this.metaMap.delete(this.getId(rootId, blockId)); }; - recordsSet (rootId: string, blockId: string, list: string[]) { + recordsSet (rootId: string, blockId: string, list: string[]) { this.recordMap.set(this.getId(rootId, blockId), observable.array(list)); }; - recordsClear (rootId: string, blockId: string) { + recordsClear (rootId: string, blockId: string) { this.recordMap.delete(this.getId(rootId, blockId)); }; - recordAdd (rootId: string, blockId: string, id: string, index: number) { + recordAdd (rootId: string, blockId: string, id: string, index: number) { const records = this.getRecords(rootId, blockId); records.splice(index, 0, id); this.recordsSet(rootId, blockId, records); }; - recordDelete (rootId: string, blockId: string, id: string) { + recordDelete (rootId: string, blockId: string, id: string) { this.recordMap.set(this.getId(rootId, blockId), this.getRecords(rootId, blockId).filter(it => it != id)); }; @@ -224,11 +224,11 @@ class DbStore { return (this.relationMap.get(this.getId(rootId, blockId)) || []).map(it => it.relationKey); }; - getObjectRelations (rootId: string, blockId: string): any[] { + getObjectRelations (rootId: string, blockId: string): any[] { return this.getObjectRelationKeys(rootId, blockId).map(it => this.getRelationByKey(it)).filter(it => it); }; - getRelationByKey (relationKey: string): any { + getRelationByKey (relationKey: string): any { const id = relationKey ? this.relationKeyMap[relationKey] : ''; return id ? this.getRelationById(id) : null; }; @@ -247,15 +247,15 @@ class DbStore { return object._empty_ ? null : object; }; - getViews (rootId: string, blockId: string): I.View[] { + getViews (rootId: string, blockId: string): I.View[] { return this.viewMap.get(this.getId(rootId, blockId)) || []; }; - getView (rootId: string, blockId: string, id: string): I.View { + getView (rootId: string, blockId: string, id: string): I.View { return this.getViews(rootId, blockId).find(it => it.id == id); }; - getMeta (rootId: string, blockId: string) { + getMeta (rootId: string, blockId: string) { const map = this.metaMap.get(this.getId(rootId, blockId)) || {}; return { @@ -266,7 +266,7 @@ class DbStore { }; }; - getRecords (rootId: string, blockId: string) { + getRecords (rootId: string, blockId: string) { return this.recordMap.get(this.getId(rootId, blockId)) || []; }; diff --git a/src/ts/store/detail.ts b/src/ts/store/detail.ts index 01f95cb939..c91a5e83f3 100644 --- a/src/ts/store/detail.ts +++ b/src/ts/store/detail.ts @@ -103,12 +103,12 @@ class DetailStore { }; /** Idempotent. Clears any data stored with rootId, if there happens to be any. */ - public clear (rootId: string): void { + public clear (rootId: string): void { this.map.delete(rootId); }; /** Idempotent. Clears all of the data stored in DetailStore, if there happens to be any */ - public clearAll (): void { + public clearAll (): void { this.map.clear(); }; diff --git a/src/ts/store/menu.ts b/src/ts/store/menu.ts index bba394125b..b703be2068 100644 --- a/src/ts/store/menu.ts +++ b/src/ts/store/menu.ts @@ -169,7 +169,7 @@ class MenuStore { getTimeout (items: I.Menu[]): number { let t = 0; - for (let item of items) { + for (const item of items) { if (!item.param.noAnimation) { t = Constant.delay.menu; }; diff --git a/webpack.config.js b/webpack.config.js index 82ec0c61ba..19b2f3b40e 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -12,8 +12,8 @@ module.exports = (env, argv) => { optimization: { minimize: false, removeAvailableModules: true, - removeEmptyChunks: true, - splitChunks: false, + removeEmptyChunks: true, + splitChunks: false, }, entry: './src/ts/entry.tsx', @@ -22,14 +22,14 @@ module.exports = (env, argv) => { extensions: [ '.ts', '.tsx', '.js', '.jsx' ], alias: { protobuf: path.resolve(__dirname, 'dist/lib'), - json: path.resolve(__dirname, 'src/json'), - Lib: path.resolve(__dirname, 'src/ts/lib'), + json: path.resolve(__dirname, 'src/json'), + Lib: path.resolve(__dirname, 'src/ts/lib'), Store: path.resolve(__dirname, 'src/ts/store'), Component: path.resolve(__dirname, 'src/ts/component'), Interface: path.resolve(__dirname, 'src/ts/interface'), Model: path.resolve(__dirname, 'src/ts/model'), Docs: path.resolve(__dirname, 'src/ts/docs'), - }, + }, modules: [ path.resolve('./src/'), path.resolve('./electron/'), @@ -55,7 +55,7 @@ module.exports = (env, argv) => { port, client: { progress: false, - }, + }, }, module: { diff --git a/webpack.node.config.js b/webpack.node.config.js index d69bed22db..0984baad63 100644 --- a/webpack.node.config.js +++ b/webpack.node.config.js @@ -5,8 +5,8 @@ module.exports = (env) => { optimization: { minimize: false, removeAvailableModules: false, - removeEmptyChunks: false, - splitChunks: false, + removeEmptyChunks: false, + splitChunks: false, }, entry: './electron.js', @@ -21,4 +21,4 @@ module.exports = (env) => { } }; -}; +}; \ No newline at end of file