mirror of
https://github.com/anyproto/anytype-ts.git
synced 2025-06-08 05:57:02 +09:00
linter fixes
This commit is contained in:
parent
c1b1f26035
commit
0b6ed5bf4c
139 changed files with 917 additions and 898 deletions
|
@ -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
|
|
@ -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: "^_",
|
||||
|
|
|
@ -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);
|
||||
});
|
||||
});
|
4
dist/polyfill.js
vendored
4
dist/polyfill.js
vendored
|
@ -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':
|
||||
|
|
29
electron.js
29
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) {
|
||||
|
|
|
@ -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: () => {
|
||||
|
|
|
@ -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 };
|
||||
},
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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 = `
|
||||
<meta name='viewport' content='width=device-width, initial-scale=1.0' />
|
||||
`;
|
||||
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -549,6 +549,7 @@
|
|||
},
|
||||
"lint-staged": {
|
||||
"{src,electron}/**/*.{ts,tsx}": [
|
||||
"npm run lint"
|
||||
]
|
||||
},
|
||||
"husky": {
|
||||
|
|
|
@ -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);
|
||||
});
|
|
@ -283,8 +283,8 @@ class RoutePage extends React.Component<RouteComponentProps> {
|
|||
return (
|
||||
<SelectionProvider>
|
||||
<DragProvider>
|
||||
<ListPopup key='listPopup' {...this.props} />
|
||||
<ListMenu key='listMenu' {...this.props} />
|
||||
<ListPopup key="listPopup" {...this.props} />
|
||||
<ListMenu key="listMenu" {...this.props} />
|
||||
|
||||
<Page {...this.props} />
|
||||
</DragProvider>
|
||||
|
|
|
@ -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<I.BlockComp
|
|||
};
|
||||
|
||||
setTransform (x: number, y: number) {
|
||||
let mx = this.rect.cw - this.rect.width;
|
||||
let my = this.rect.ch - this.rect.height;
|
||||
const mx = this.rect.cw - this.rect.width;
|
||||
const my = this.rect.ch - this.rect.height;
|
||||
|
||||
x = Math.max(-mx, Math.min(0, x));
|
||||
y = Math.max(-my, Math.min(0, y));
|
||||
|
||||
let css: any = { transform: `translate3d(${x}px,${y}px,0px)` };
|
||||
const css: any = { transform: `translate3d(${x}px,${y}px,0px)` };
|
||||
|
||||
if (this.rect.ch < this.rect.height) {
|
||||
css.transform = 'translate3d(0px,0px,0px)';
|
||||
|
|
|
@ -100,10 +100,10 @@ const BlockDataview = observer(class BlockDataview extends React.Component<Props
|
|||
const isCollection = this.isCollection();
|
||||
const cn = [ 'focusable', 'c' + block.id ];
|
||||
|
||||
let { groupRelationKey, pageLimit, defaultTemplateId } = view;
|
||||
const { groupRelationKey, pageLimit, defaultTemplateId } = view;
|
||||
let ViewComponent: any = null;
|
||||
let className = [ UtilCommon.toCamelCase('view-' + I.ViewType[view.type]) ];
|
||||
let head = null;
|
||||
const className = [ UtilCommon.toCamelCase('view-' + I.ViewType[view.type]) ];
|
||||
const head = null;
|
||||
let body = null;
|
||||
|
||||
if (isCollection) {
|
||||
|
@ -379,7 +379,7 @@ const BlockDataview = observer(class BlockDataview extends React.Component<Props
|
|||
};
|
||||
|
||||
getKeys (id: string): string[] {
|
||||
let view = this.getView(id);
|
||||
const view = this.getView(id);
|
||||
let keys = Constant.defaultRelationKeys.concat(Constant.coverRelationKeys);
|
||||
|
||||
if (view) {
|
||||
|
@ -441,17 +441,16 @@ const BlockDataview = observer(class BlockDataview extends React.Component<Props
|
|||
return {};
|
||||
};
|
||||
|
||||
let { name, layout, isReadonly, isDeleted, snippet } = item;
|
||||
if (name == UtilObject.defaultName('Page')) {
|
||||
name = '';
|
||||
const { layout, isReadonly, isDeleted, snippet } = item;
|
||||
|
||||
if (item.name == UtilObject.defaultName('Page')) {
|
||||
item.name = '';
|
||||
};
|
||||
if (layout == I.ObjectLayout.Note) {
|
||||
name = snippet;
|
||||
item.name = snippet;
|
||||
};
|
||||
|
||||
item.name = name;
|
||||
item.isReadonly = isDeleted || isReadonly;
|
||||
|
||||
return item;
|
||||
};
|
||||
|
||||
|
@ -540,7 +539,7 @@ const BlockDataview = observer(class BlockDataview extends React.Component<Props
|
|||
});
|
||||
};
|
||||
|
||||
for (let filter of view.filters) {
|
||||
for (const filter of view.filters) {
|
||||
if (!conditions.includes(filter.condition)) {
|
||||
continue;
|
||||
};
|
||||
|
@ -893,7 +892,7 @@ const BlockDataview = observer(class BlockDataview extends React.Component<Props
|
|||
|
||||
value = Relation.formatValue(relation, value, true);
|
||||
|
||||
let details: any = {};
|
||||
const details: any = {};
|
||||
details[relationKey] = value;
|
||||
detailStore.update(subId, { id, details }, false);
|
||||
|
||||
|
@ -938,7 +937,7 @@ const BlockDataview = observer(class BlockDataview extends React.Component<Props
|
|||
const isCollection = this.isCollection();
|
||||
|
||||
let filters: I.Filter[] = [];
|
||||
let addParam: any = {};
|
||||
const addParam: any = {};
|
||||
|
||||
if (isCollection) {
|
||||
addParam.name = translate('blockDataviewCreateNewCollection');
|
||||
|
@ -1196,7 +1195,7 @@ const BlockDataview = observer(class BlockDataview extends React.Component<Props
|
|||
};
|
||||
|
||||
orders.forEach((it: any) => {
|
||||
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 {
|
||||
|
|
|
@ -63,7 +63,7 @@ class Cell extends React.Component<Props> {
|
|||
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<Props> {
|
|||
|
||||
let closeIfOpen = true;
|
||||
let menuId = '';
|
||||
let setOn = () => {
|
||||
const setOn = () => {
|
||||
cell.addClass('isEditing');
|
||||
|
||||
if (cellPosition) {
|
||||
|
@ -196,7 +196,7 @@ class Cell extends React.Component<Props> {
|
|||
win.trigger('resize');
|
||||
};
|
||||
|
||||
let setOff = () => {
|
||||
const setOff = () => {
|
||||
keyboard.disableBlur(false);
|
||||
|
||||
if (this.ref) {
|
||||
|
@ -342,7 +342,7 @@ class Cell extends React.Component<Props> {
|
|||
break;
|
||||
};
|
||||
|
||||
let options = [
|
||||
const options = [
|
||||
{ id: 'go', icon: 'browse', name: translate(`menuDataviewUrlActionGo${relation.format}`) },
|
||||
{ id: 'copy', icon: 'copy', name: translate('menuDataviewUrlActionGoCopy') },
|
||||
];
|
||||
|
|
|
@ -22,14 +22,13 @@ const ItemObject = observer(class ItemObject extends React.Component<Props> {
|
|||
};
|
||||
|
||||
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<Props> {
|
|||
};
|
||||
|
||||
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<Props> {
|
|||
};
|
||||
};
|
||||
|
||||
getObject () {
|
||||
const { relation, elementMapper } = this.props;
|
||||
|
||||
let object = this.props.object || {};
|
||||
if (elementMapper) {
|
||||
object = elementMapper(relation, object);
|
||||
};
|
||||
return object;
|
||||
};
|
||||
|
||||
});
|
||||
|
||||
export default ItemObject;
|
|
@ -47,9 +47,9 @@ const CellObject = observer(class CellObject extends React.Component<I.Cell, Sta
|
|||
return null;
|
||||
};
|
||||
|
||||
let placeholder = this.props.placeholder || translate(`placeholderCell${relation.format}`)
|
||||
const placeholder = this.props.placeholder || translate(`placeholderCell${relation.format}`);
|
||||
let value = this.getItems();
|
||||
let length = value.length;
|
||||
const length = value.length;
|
||||
|
||||
if (arrayLimit) {
|
||||
value = value.slice(0, arrayLimit);
|
||||
|
|
|
@ -46,9 +46,9 @@ const CellSelect = observer(class CellSelect extends React.Component<I.Cell, Sta
|
|||
return null;
|
||||
};
|
||||
|
||||
let placeholder = this.props.placeholder || translate(`placeholderCell${relation.format}`);
|
||||
const placeholder = this.props.placeholder || translate(`placeholderCell${relation.format}`);
|
||||
let value = this.getItems();
|
||||
let length = value.length;
|
||||
const length = value.length;
|
||||
let content = null;
|
||||
|
||||
if (elementMapper) {
|
||||
|
|
|
@ -76,8 +76,8 @@ const CellText = observer(class CellText extends React.Component<I.Cell, State>
|
|||
);
|
||||
} 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<I.Cell, State>
|
|||
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<I.Cell, State>
|
|||
|
||||
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<I.Cell, State>
|
|||
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<I.Cell, State>
|
|||
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 });
|
||||
};
|
||||
};
|
||||
|
|
|
@ -37,7 +37,7 @@ const Controls = observer(class Controls extends React.Component<I.ViewComponent
|
|||
const isAllowedTemplate = this.props.isAllowedTemplate();
|
||||
|
||||
if (isAllowedTemplate) {
|
||||
buttonWrapperCn.push('withSelect')
|
||||
buttonWrapperCn.push('withSelect');
|
||||
};
|
||||
|
||||
if (className) {
|
||||
|
@ -152,7 +152,7 @@ const Controls = observer(class Controls extends React.Component<I.ViewComponent
|
|||
/>
|
||||
) : ''}
|
||||
</div>
|
||||
) : ''}
|
||||
) : ''}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
@ -155,7 +155,7 @@ const Head = observer(class Head extends React.Component<I.ViewComponent, State>
|
|||
};
|
||||
|
||||
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<I.ViewComponent, State>
|
|||
};
|
||||
|
||||
let menuId = '';
|
||||
let menuParam: any = {
|
||||
const menuParam: any = {
|
||||
menuKey: item.id,
|
||||
element: `#${this.menuContext.getId()} #item-${item.id}`,
|
||||
offsetX: this.menuContext.getSize().width,
|
||||
|
|
|
@ -138,7 +138,7 @@ const ViewBoard = observer(class ViewBoard extends React.Component<I.ViewCompone
|
|||
};
|
||||
|
||||
const groupOrder: any = {};
|
||||
const el = block.content.groupOrder.find(it => 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<I.ViewCompone
|
|||
return;
|
||||
};
|
||||
|
||||
let groups = (message.groups || []).map((it: any) => {
|
||||
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<I.ViewCompone
|
|||
};
|
||||
|
||||
getGroups (withHidden: boolean) {
|
||||
let { rootId, block } = this.props;
|
||||
const { rootId, block } = this.props;
|
||||
let groups = this.applyGroupOrder(UtilCommon.objectCopy(dbStore.getGroups(rootId, block.id)));
|
||||
|
||||
if (!withHidden) {
|
||||
|
@ -263,7 +263,7 @@ const ViewBoard = observer(class ViewBoard extends React.Component<I.ViewCompone
|
|||
const view = node.find('.viewContent');
|
||||
const clone = target.clone();
|
||||
|
||||
this.ox = node.find('#columns').offset().left;
|
||||
this.ox = node.find('#columns').offset().left;
|
||||
|
||||
target.addClass('isDragging');
|
||||
clone.attr({ id: '' }).addClass('isClone').css({ zIndex: 10000, position: 'fixed', left: -10000, top: -10000 });
|
||||
|
@ -328,7 +328,7 @@ const ViewBoard = observer(class ViewBoard extends React.Component<I.ViewCompone
|
|||
let isLeft = false;
|
||||
let hoverId = '';
|
||||
|
||||
for (let group of groups) {
|
||||
for (const group of groups) {
|
||||
const rect = this.cache[group.id];
|
||||
if (!rect || (group.id == groupId)) {
|
||||
continue;
|
||||
|
@ -409,7 +409,7 @@ const ViewBoard = observer(class ViewBoard extends React.Component<I.ViewCompone
|
|||
let isTop = false;
|
||||
let hoverId = '';
|
||||
|
||||
for (let i in this.cache) {
|
||||
for (const i in this.cache) {
|
||||
const rect = this.cache[i];
|
||||
if (!rect || (rect.id == record.id)) {
|
||||
continue;
|
||||
|
@ -500,7 +500,7 @@ const ViewBoard = observer(class ViewBoard extends React.Component<I.ViewCompone
|
|||
return [];
|
||||
};
|
||||
|
||||
const el = block.content.groupOrder.find(it => it.viewId == view.id);
|
||||
const el = block.content.groupOrder.find(it => it.viewId == view.id);
|
||||
const groupOrder: any = {};
|
||||
|
||||
if (el) {
|
||||
|
|
|
@ -156,7 +156,7 @@ const Column = observer(class Column extends React.Component<Props> {
|
|||
};
|
||||
|
||||
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:
|
||||
|
|
|
@ -53,13 +53,13 @@ const ViewGallery = observer(class ViewGallery extends React.Component<I.ViewCom
|
|||
const items = this.getItems();
|
||||
|
||||
// Subscriptions on dependent objects
|
||||
for (let id of records) {
|
||||
for (const id of records) {
|
||||
const item = detailStore.get(subId, id, getKeys(view.id));
|
||||
if (item._empty_) {
|
||||
continue;
|
||||
};
|
||||
|
||||
for (let k in item) {
|
||||
for (const k in item) {
|
||||
const relation = dbStore.getRelationByKey(k);
|
||||
if (!relation || ![ I.RelationType.Object, I.RelationType.File ].includes(relation.format)) {
|
||||
continue;
|
||||
|
@ -199,10 +199,10 @@ const ViewGallery = observer(class ViewGallery extends React.Component<I.ViewCom
|
|||
};
|
||||
|
||||
loadMoreCards ({ 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();
|
||||
|
@ -229,7 +229,7 @@ const ViewGallery = observer(class ViewGallery extends React.Component<I.ViewCom
|
|||
let n = 0;
|
||||
let row = { children: [] };
|
||||
|
||||
for (let item of records) {
|
||||
for (const item of records) {
|
||||
row.children.push(item);
|
||||
|
||||
n++;
|
||||
|
|
|
@ -185,7 +185,7 @@ const ViewGrid = observer(class ViewGrid extends React.Component<Props> {
|
|||
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<Props> {
|
|||
};
|
||||
|
||||
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();
|
||||
|
|
|
@ -129,10 +129,10 @@ const ViewList = observer(class ViewList extends React.Component<I.ViewComponent
|
|||
};
|
||||
|
||||
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();
|
||||
|
|
|
@ -66,7 +66,7 @@ const Row = observer(class Row extends React.Component<Props> {
|
|||
>
|
||||
{content}
|
||||
</div>
|
||||
)
|
||||
);
|
||||
};
|
||||
|
||||
if (isCollection && !isInline) {
|
||||
|
|
|
@ -19,7 +19,7 @@ const BlockDiv = observer(class BlockDiv extends React.Component<I.BlockComponen
|
|||
const { id, content } = block;
|
||||
const { style } = content;
|
||||
|
||||
let cn = [ 'wrap', 'focusable', 'c' + id ];
|
||||
const cn = [ 'wrap', 'focusable', 'c' + id ];
|
||||
let inner: any = null;
|
||||
|
||||
switch (content.style) {
|
||||
|
|
|
@ -91,9 +91,9 @@ const BlockFeatured = observer(class BlockFeatured extends React.Component<Props
|
|||
|
||||
let types = Relation.getSetOfObjects(rootId, storeId, Constant.typeId.type).map(it => 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<Props
|
|||
const object = detailStore.get(rootId, rootId, [ 'setOf' ]);
|
||||
const type = detailStore.get(rootId, object.type, []);
|
||||
const allowed = blockStore.checkFlags(rootId, rootId, [ I.RestrictionObject.Type ]);
|
||||
const typeIsDeleted = type._empty_ || type.isDeleted
|
||||
const typeIsDeleted = type._empty_ || type.isDeleted;
|
||||
const options: any[] = [];
|
||||
|
||||
if (readonly) {
|
||||
|
@ -420,7 +420,7 @@ const BlockFeatured = observer(class BlockFeatured extends React.Component<Props
|
|||
const object = detailStore.get(rootId, rootId, [ 'setOf' ]);
|
||||
|
||||
let menuId = '';
|
||||
let menuParam = {
|
||||
const menuParam = {
|
||||
element: `#${this.menuContext.getId()} #item-${item.id}`,
|
||||
offsetX: this.menuContext.getSize().width,
|
||||
className: 'big single',
|
||||
|
|
|
@ -79,11 +79,11 @@ const Block = observer(class Block extends React.Component<Props> {
|
|||
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<Props> {
|
|||
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<Props> {
|
|||
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<Props> {
|
|||
return;
|
||||
};
|
||||
|
||||
const param = {
|
||||
const param = {
|
||||
type: I.BlockType.Text,
|
||||
style: I.TextStyle.Paragraph,
|
||||
};
|
||||
|
|
|
@ -30,7 +30,7 @@ const BlockFile = observer(class BlockFile extends React.Component<I.BlockCompon
|
|||
object.sizeInBytes = object.size;
|
||||
};
|
||||
|
||||
let { name, sizeInBytes } = object;
|
||||
const { name, sizeInBytes } = object;
|
||||
let element = null;
|
||||
|
||||
switch (state) {
|
||||
|
|
|
@ -34,7 +34,7 @@ const BlockImage = observer(class BlockImage extends React.Component<I.BlockComp
|
|||
const { state, hash } = block.content;
|
||||
|
||||
let element = null;
|
||||
let css: any = {};
|
||||
const css: any = {};
|
||||
|
||||
if (width) {
|
||||
css.width = (width * 100) + '%';
|
||||
|
|
|
@ -49,12 +49,12 @@ const BlockPdf = observer(class BlockPdf extends React.Component<I.BlockComponen
|
|||
object.sizeInBytes = object.size;
|
||||
};
|
||||
|
||||
let { name, sizeInBytes } = object;
|
||||
const { name, sizeInBytes } = object;
|
||||
|
||||
let { width } = fields;
|
||||
const { width } = fields;
|
||||
let element = null;
|
||||
let pager = null;
|
||||
let css: any = {};
|
||||
const css: any = {};
|
||||
|
||||
if (width) {
|
||||
css.width = (width * 100) + '%';
|
||||
|
|
|
@ -34,9 +34,9 @@ const BlockVideo = observer(class BlockVideo extends React.Component<I.BlockComp
|
|||
const { id, fields, content } = block;
|
||||
const { state, hash, type, mime } = content;
|
||||
|
||||
let { width } = fields;
|
||||
const { width } = fields;
|
||||
let element = null;
|
||||
let css: any = {};
|
||||
const css: any = {};
|
||||
|
||||
if (width) {
|
||||
css.width = (width * 100) + '%';
|
||||
|
|
|
@ -352,7 +352,7 @@ const BlockTable = observer(class BlockTable extends React.Component<I.BlockComp
|
|||
|
||||
let menuSubContext = null;
|
||||
let menuId = '';
|
||||
let menuParam: any = {
|
||||
const menuParam: any = {
|
||||
element: `#${menuContext.getId()} #item-${item.id}`,
|
||||
offsetX: menuContext.getSize().width,
|
||||
vertical: I.MenuDirection.Center,
|
||||
|
@ -1206,7 +1206,7 @@ const BlockTable = observer(class BlockTable extends React.Component<I.BlockComp
|
|||
|
||||
let width = Math.max(min, Math.min(max, w));
|
||||
for (let x = 1; x <= steps; ++x) {
|
||||
let s = max / steps * x;
|
||||
const s = max / steps * x;
|
||||
if ((width >= s - SNAP) && (width <= s + SNAP)) {
|
||||
width = s;
|
||||
};
|
||||
|
@ -1459,7 +1459,7 @@ const BlockTable = observer(class BlockTable extends React.Component<I.BlockComp
|
|||
w += 2;
|
||||
h += 2;
|
||||
|
||||
let frame = { id, x, y, w, h, type, rowId, columnId, cellId, position };
|
||||
const frame = { id, x, y, w, h, type, rowId, columnId, cellId, position };
|
||||
let current = this.frames.find(it => it.id == frame.id);
|
||||
|
||||
if (!current) {
|
||||
|
|
|
@ -41,7 +41,7 @@ const BlockTableCell = observer(class BlockTableCell extends React.Component<Pro
|
|||
const Handle = (item: any) => {
|
||||
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<Pro
|
|||
cn.push('handleColumn canDrag');
|
||||
|
||||
onDragStart = (e: any) => { 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:
|
||||
|
|
|
@ -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<Props> {
|
|||
|
||||
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<Props> {
|
|||
};
|
||||
|
||||
// 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<Props> {
|
|||
|
||||
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<Props> {
|
|||
|
||||
// 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<Props> {
|
|||
};
|
||||
|
||||
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', {
|
||||
|
|
|
@ -91,7 +91,7 @@ class DragLayer extends React.Component<object, State> {
|
|||
const inner = node.find('#inner').html('');
|
||||
const container = UtilCommon.getPageContainer(keyboard.isPopup());
|
||||
|
||||
let wrap = $('<div></div>');
|
||||
const wrap = $('<div></div>');
|
||||
let items: any[] = [];
|
||||
|
||||
switch (type) {
|
||||
|
|
|
@ -89,10 +89,11 @@ const DragProvider = observer(class DragProvider extends React.Component<Props>
|
|||
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<Props>
|
|||
};
|
||||
|
||||
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<Props>
|
|||
};
|
||||
|
||||
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<Props>
|
|||
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<Props>
|
|||
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<Props>
|
|||
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<Props>
|
|||
};
|
||||
};
|
||||
|
||||
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<Props>
|
|||
|
||||
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<Props>
|
|||
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) });
|
||||
|
|
|
@ -28,7 +28,7 @@ const EditorPage = observer(class EditorPage extends React.Component<Props, Stat
|
|||
_isMounted = false;
|
||||
node: any = null;
|
||||
id = '';
|
||||
hoverId = '';
|
||||
hoverId = '';
|
||||
hoverPosition: I.BlockPosition = I.BlockPosition.None;
|
||||
scrollTop = 0;
|
||||
uiHidden = false;
|
||||
|
@ -306,7 +306,7 @@ const EditorPage = observer(class EditorPage extends React.Component<Props, Stat
|
|||
|
||||
focusTitle () {
|
||||
const { rootId } = this.props;
|
||||
const block = blockStore.getFirstBlock(rootId, 1, it => 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<Props, Stat
|
|||
offset = featured.offset().top + featured.outerHeight() - BUTTON_OFFSET;
|
||||
};
|
||||
|
||||
for (let block of blocks) {
|
||||
for (const block of blocks) {
|
||||
if (!block.canCreateBlock()) {
|
||||
continue;
|
||||
};
|
||||
|
||||
let obj = $(`#block-${block.id}`);
|
||||
const obj = $(`#block-${block.id}`);
|
||||
if (!obj.length || obj.hasClass('noPlus')) {
|
||||
continue;
|
||||
};
|
||||
|
||||
let rect = obj.get(0).getBoundingClientRect() as DOMRect;
|
||||
const rect = obj.get(0).getBoundingClientRect() as DOMRect;
|
||||
|
||||
rect.y += st;
|
||||
|
||||
|
@ -487,8 +487,8 @@ const EditorPage = observer(class EditorPage extends React.Component<Props, Stat
|
|||
return;
|
||||
};
|
||||
|
||||
let buttonX = hoveredRect.x - (rectContainer.x - Constant.size.blockMenu) + 2;
|
||||
let buttonY = pageY - rectContainer.y - BUTTON_OFFSET - st;
|
||||
const buttonX = hoveredRect.x - (rectContainer.x - Constant.size.blockMenu) + 2;
|
||||
const buttonY = pageY - rectContainer.y - BUTTON_OFFSET - st;
|
||||
|
||||
clear();
|
||||
button.addClass('show').css({ transform: `translate3d(${buttonX}px,${buttonY}px,0px)` });
|
||||
|
@ -577,9 +577,9 @@ const EditorPage = observer(class EditorPage extends React.Component<Props, Stat
|
|||
|
||||
let type = null;
|
||||
let param = '';
|
||||
let markParam = this.getMarkParam();
|
||||
const markParam = this.getMarkParam();
|
||||
|
||||
for (let item of markParam) {
|
||||
for (const item of markParam) {
|
||||
keyboard.shortcut(item.key, e, (pressed: string) => {
|
||||
type = item.type;
|
||||
param = item.param;
|
||||
|
@ -815,9 +815,9 @@ const EditorPage = observer(class EditorPage extends React.Component<Props, Stat
|
|||
if (block.canHaveMarks() && range.to && (range.from != range.to)) {
|
||||
let type = null;
|
||||
let param = '';
|
||||
let markParam = this.getMarkParam();
|
||||
const markParam = this.getMarkParam();
|
||||
|
||||
for (let item of markParam) {
|
||||
for (const item of markParam) {
|
||||
keyboard.shortcut(item.key, e, (pressed: string) => {
|
||||
type = item.type;
|
||||
param = item.param;
|
||||
|
@ -1008,7 +1008,7 @@ const EditorPage = observer(class EditorPage extends React.Component<Props, Stat
|
|||
|
||||
const element = blockStore.getMapElement(rootId, block.id);
|
||||
const parentElement = blockStore.getMapElement(rootId, block.parentId);
|
||||
const nextElement = blockStore.getMapElement(rootId, next.id)
|
||||
const nextElement = blockStore.getMapElement(rootId, next.id);
|
||||
const nextParent = blockStore.getLeaf(rootId, next.parentId);
|
||||
const nextParentElement = blockStore.getMapElement(rootId, next.parentId);
|
||||
|
||||
|
@ -1075,7 +1075,7 @@ const EditorPage = observer(class EditorPage extends React.Component<Props, Stat
|
|||
|
||||
const element = blockStore.getMapElement(rootId, block.id);
|
||||
const parentElement = blockStore.getMapElement(rootId, block.parentId);
|
||||
const nextElement = blockStore.getMapElement(rootId, next.id)
|
||||
const nextElement = blockStore.getMapElement(rootId, next.id);
|
||||
const nextParent = blockStore.getLeaf(rootId, next.parentId);
|
||||
const nextParentElement = blockStore.getMapElement(rootId, next.parentId);
|
||||
|
||||
|
@ -1176,7 +1176,7 @@ const EditorPage = observer(class EditorPage extends React.Component<Props, Stat
|
|||
vRect = value.get(0).getBoundingClientRect();
|
||||
} else
|
||||
if (element && element.length) {
|
||||
vRect = element.get(0).getBoundingClientRect()
|
||||
vRect = element.get(0).getBoundingClientRect();
|
||||
};
|
||||
|
||||
if (!sRect) {
|
||||
|
@ -1789,7 +1789,7 @@ const EditorPage = observer(class EditorPage extends React.Component<Props, Stat
|
|||
onSelect: (event: any, item: any) => {
|
||||
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<Props, Stat
|
|||
const { rootId } = this.props;
|
||||
|
||||
let ret: any[] = [];
|
||||
for (let id of ids) {
|
||||
let element = blockStore.getMapElement(rootId, id);
|
||||
for (const id of ids) {
|
||||
const element = blockStore.getMapElement(rootId, id);
|
||||
if (!element) {
|
||||
continue;
|
||||
};
|
||||
|
||||
let parent = blockStore.getLeaf(rootId, element.parentId);
|
||||
const parent = blockStore.getLeaf(rootId, element.parentId);
|
||||
if (!parent || !parent.isLayout() || parent.isLayoutDiv() || parent.isLayoutHeader()) {
|
||||
continue;
|
||||
};
|
||||
|
@ -1915,7 +1915,7 @@ const EditorPage = observer(class EditorPage extends React.Component<Props, Stat
|
|||
callBack(message.blockId);
|
||||
};
|
||||
|
||||
const event: any = {
|
||||
const event: any = {
|
||||
middleTime: message.middleTime,
|
||||
type: param.type,
|
||||
style: param.content?.style,
|
||||
|
@ -2046,7 +2046,7 @@ const EditorPage = observer(class EditorPage extends React.Component<Props, Stat
|
|||
menuStore.closeAll();
|
||||
popupStore.closeAll([ 'preview' ]);
|
||||
|
||||
let ids = selection.get(I.SelectType.Block);
|
||||
const ids = selection.get(I.SelectType.Block);
|
||||
let blockIds = [];
|
||||
|
||||
if (ids.length) {
|
||||
|
@ -2101,8 +2101,8 @@ const EditorPage = observer(class EditorPage extends React.Component<Props, Stat
|
|||
let length = 0;
|
||||
|
||||
if (last) {
|
||||
let element = blockStore.getMapElement(rootId, last.id)
|
||||
let parent = blockStore.getLeaf(rootId, element.parentId);
|
||||
const element = blockStore.getMapElement(rootId, last.id);
|
||||
const parent = blockStore.getLeaf(rootId, element.parentId);
|
||||
|
||||
if (!parent.isLayoutDiv() && !parent.isPage()) {
|
||||
last = null;
|
||||
|
|
|
@ -247,7 +247,7 @@ class Phrase extends React.Component<Props, State> {
|
|||
};
|
||||
|
||||
setError (v: boolean) {
|
||||
this.setState({ hasError: v })
|
||||
this.setState({ hasError: v });
|
||||
};
|
||||
|
||||
focus () {
|
||||
|
|
|
@ -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';
|
||||
|
||||
|
|
|
@ -54,7 +54,7 @@ const ListChildren = observer(class ListChildren extends React.Component<Props>
|
|||
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<Props>
|
|||
return (
|
||||
<div id={'block-children-' + block.id} className={cn.join(' ')} onMouseMove={onMouseMove} onMouseLeave={onMouseLeave}>
|
||||
{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 + '%';
|
||||
|
|
|
@ -291,7 +291,7 @@ const ListWidget = observer(class ListWidget extends React.Component<Props, Stat
|
|||
const { isEditing } = this.state;
|
||||
|
||||
if (!isEditing && !e.button) {
|
||||
UtilObject.openEvent(e, { layout: I.ObjectLayout.Store })
|
||||
UtilObject.openEvent(e, { layout: I.ObjectLayout.Store });
|
||||
};
|
||||
};
|
||||
|
||||
|
@ -299,7 +299,7 @@ const ListWidget = observer(class ListWidget extends React.Component<Props, Stat
|
|||
const { isEditing } = this.state;
|
||||
|
||||
if (!isEditing && !e.button) {
|
||||
UtilObject.openEvent(e, { layout: I.ObjectLayout.Archive })
|
||||
UtilObject.openEvent(e, { layout: I.ObjectLayout.Archive });
|
||||
};
|
||||
};
|
||||
|
||||
|
|
|
@ -38,7 +38,7 @@ class MenuBlockAction extends React.Component<I.Menu, State> {
|
|||
{item.name ? <div className="name">{item.name}</div> : ''}
|
||||
<div className="items">
|
||||
{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<I.Menu, State> {
|
|||
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<I.Menu, State> {
|
|||
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<I.Menu, State> {
|
|||
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<I.Menu, State> {
|
|||
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<I.Menu, State> {
|
|||
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<I.Menu, State> {
|
|||
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<I.Menu, State> {
|
|||
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) {
|
||||
|
|
|
@ -46,7 +46,7 @@ const MenuBlockAdd = observer(class MenuBlockAdd extends React.Component<I.Menu>
|
|||
|
||||
let content = null;
|
||||
if (item.isRelationAdd) {
|
||||
content = (
|
||||
content = (
|
||||
<div
|
||||
id="item-relation-add"
|
||||
className="item add"
|
||||
|
@ -98,8 +98,8 @@ const MenuBlockAdd = observer(class MenuBlockAdd extends React.Component<I.Menu>
|
|||
</div>
|
||||
);
|
||||
} 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<I.Menu>
|
|||
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<I.Menu>
|
|||
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<I.Menu>
|
|||
|
||||
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<I.Menu>
|
|||
};
|
||||
|
||||
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<I.Menu>
|
|||
moveToPage (type: string) {
|
||||
const { param, dataset } = this.props;
|
||||
const { data } = param;
|
||||
const { blockId, rootId, } = data;
|
||||
const { blockId, rootId, } = data;
|
||||
const { selection } = dataset || {};
|
||||
|
||||
let ids = [];
|
||||
|
|
|
@ -56,8 +56,8 @@ class MenuBlockHAlign extends React.Component<I.Menu> {
|
|||
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;
|
||||
};
|
||||
|
|
|
@ -288,7 +288,7 @@ const MenuBlockLatex = observer(class MenuBlockLatex extends React.Component<I.M
|
|||
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 });
|
||||
};
|
||||
|
@ -328,7 +328,7 @@ const MenuBlockLatex = observer(class MenuBlockLatex extends React.Component<I.M
|
|||
|
||||
let height = offset;
|
||||
|
||||
for (let item of items) {
|
||||
for (const item of items) {
|
||||
height += this.getRowHeight(item);
|
||||
};
|
||||
|
||||
|
|
|
@ -111,7 +111,7 @@ class MenuBlockLayout extends React.Component<I.Menu> {
|
|||
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<I.Menu> {
|
|||
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,
|
||||
|
|
|
@ -269,7 +269,7 @@ const MenuBlockLink = observer(class MenuBlockLink extends React.Component<I.Men
|
|||
const sections = this.getSections();
|
||||
|
||||
let items: any[] = [];
|
||||
for (let section of sections) {
|
||||
for (const section of sections) {
|
||||
if (withSections && section.name) {
|
||||
items.push({ id: section.id, name: section.name, isSection: true });
|
||||
};
|
||||
|
|
|
@ -265,7 +265,7 @@ const MenuBlockLinkSettings = observer(class MenuBlockLinkSettings extends React
|
|||
const sections = this.getSections();
|
||||
|
||||
let items: any[] = [];
|
||||
for (let section of sections) {
|
||||
for (const section of sections) {
|
||||
items = items.concat(section.children);
|
||||
};
|
||||
|
||||
|
|
|
@ -197,7 +197,7 @@ const MenuBlockMention = observer(class MenuBlockMention 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);
|
||||
};
|
||||
return items;
|
||||
|
|
|
@ -113,21 +113,21 @@ class MenuBlockMore extends React.Component<I.Menu> {
|
|||
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<I.Menu> {
|
|||
};
|
||||
|
||||
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<I.Menu> {
|
|||
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<I.Menu> {
|
|||
};
|
||||
|
||||
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<I.Menu> {
|
|||
onMenuSelect(item);
|
||||
};
|
||||
},
|
||||
})
|
||||
});
|
||||
break;
|
||||
};
|
||||
|
||||
|
@ -388,7 +388,7 @@ class MenuBlockMore extends React.Component<I.Menu> {
|
|||
return;
|
||||
};
|
||||
|
||||
let close = true;
|
||||
const close = true;
|
||||
|
||||
if (onSelect) {
|
||||
onSelect(item);
|
||||
|
|
|
@ -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] });
|
||||
};
|
||||
|
||||
|
|
|
@ -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);
|
||||
};
|
||||
|
||||
|
|
|
@ -70,7 +70,7 @@ const MenuBlockStyle = observer(class MenuBlockStyle extends React.Component<I.M
|
|||
return 0;
|
||||
};
|
||||
|
||||
let style = block.content.style;
|
||||
const style = block.content.style;
|
||||
|
||||
if (block.isFile()) {
|
||||
return style != I.FileStyle.Link ? I.FileStyle.Embed : I.FileStyle.Link;
|
||||
|
@ -93,9 +93,9 @@ const MenuBlockStyle = observer(class MenuBlockStyle extends React.Component<I.M
|
|||
let hasTurnList = true;
|
||||
let hasTurnDiv = true;
|
||||
let hasTurnFile = true;
|
||||
let sections: any[] = [];
|
||||
const sections: any[] = [];
|
||||
|
||||
for (let id of blockIds) {
|
||||
for (const id of blockIds) {
|
||||
const block = blockStore.getLeaf(rootId, id);
|
||||
if (!block) {
|
||||
continue;
|
||||
|
@ -109,7 +109,7 @@ const MenuBlockStyle = observer(class MenuBlockStyle extends React.Component<I.M
|
|||
if (hasTurnText) sections.push(turnText);
|
||||
if (hasTurnList) sections.push(turnList);
|
||||
if (hasTurnDiv) sections.push(turnDiv);
|
||||
if (hasTurnFile) sections.push(turnFile);
|
||||
if (hasTurnFile) sections.push(turnFile);
|
||||
|
||||
return UtilMenu.sectionsMap(sections);
|
||||
};
|
||||
|
@ -118,7 +118,7 @@ const MenuBlockStyle = observer(class MenuBlockStyle extends React.Component<I.M
|
|||
const sections = this.getSections();
|
||||
|
||||
let items: any[] = [];
|
||||
for (let section of sections) {
|
||||
for (const section of sections) {
|
||||
items = items.concat(section.children);
|
||||
};
|
||||
return items;
|
||||
|
|
|
@ -88,7 +88,7 @@ class MenuContext extends React.Component<I.Menu> {
|
|||
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<I.Menu> {
|
|||
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<I.Menu> {
|
|||
};
|
||||
|
||||
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,
|
||||
|
|
|
@ -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);
|
||||
};
|
||||
|
||||
|
|
|
@ -57,7 +57,7 @@ const MenuDataviewFileList = observer(class MenuDataviewFileList extends React.C
|
|||
|
||||
let content = null;
|
||||
if (item.id == 'add') {
|
||||
content = (
|
||||
content = (
|
||||
<div id="item-add" className="item add" onMouseEnter={(e: any) => { this.onOver(e, item); }} onClick={(e: any) => { this.onClick(e, item); }} style={param.style}>
|
||||
<Icon className="plus" />
|
||||
<div className="name">{item.name}</div>
|
||||
|
|
|
@ -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:
|
||||
|
|
|
@ -46,7 +46,7 @@ const MenuFilterList = observer(class MenuFilterList extends React.Component<I.M
|
|||
const filterCnt = view.filters.length;
|
||||
const items = this.getItems();
|
||||
|
||||
for (let filter of items) {
|
||||
for (const filter of items) {
|
||||
const { relationKey, condition, value } = filter;
|
||||
};
|
||||
|
||||
|
|
|
@ -476,7 +476,7 @@ const MenuDataviewFilterValues = observer(class MenuDataviewFilterValues extends
|
|||
const { getView, itemId } = data;
|
||||
const view = getView();
|
||||
|
||||
let item = view.getFilter(itemId);
|
||||
const item = view.getFilter(itemId);
|
||||
if (!item) {
|
||||
return;
|
||||
};
|
||||
|
|
|
@ -98,7 +98,7 @@ const MenuGroupEdit = observer(class MenuGroupEdit extends React.Component<I.Men
|
|||
const sections = this.getSections();
|
||||
|
||||
let items: any[] = [];
|
||||
for (let section of sections) {
|
||||
for (const section of sections) {
|
||||
items = items.concat(section.children);
|
||||
};
|
||||
|
||||
|
|
|
@ -86,7 +86,7 @@ const MenuGroupList = observer(class MenuGroupList extends React.Component<I.Men
|
|||
value={!item.isHidden}
|
||||
onChange={(e: any, v: boolean) => { this.onSwitch(e, item, v); }}
|
||||
/>
|
||||
) : ''}
|
||||
) : ''}
|
||||
</div>
|
||||
);
|
||||
});
|
||||
|
@ -198,8 +198,8 @@ const MenuGroupList = observer(class MenuGroupList extends React.Component<I.Men
|
|||
|
||||
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();
|
||||
|
|
|
@ -68,7 +68,7 @@ const MenuDataviewObjectList = observer(class MenuDataviewObjectList extends Rea
|
|||
</div>
|
||||
);
|
||||
} else if (item.id == 'add') {
|
||||
content = (
|
||||
content = (
|
||||
<div id="item-add" className="item add" onMouseEnter={(e: any) => { this.onOver(e, item); }} onClick={(e: any) => { this.onClick(e, item); }} style={param.style}>
|
||||
<Icon className="plus" />
|
||||
<div className="name">{item.name}</div>
|
||||
|
@ -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;
|
||||
|
|
|
@ -114,7 +114,7 @@ const MenuOptionEdit = observer(class MenuOptionEdit extends React.Component<I.M
|
|||
const sections = this.getSections();
|
||||
|
||||
let items: any[] = [];
|
||||
for (let section of sections) {
|
||||
for (const section of sections) {
|
||||
items = items.concat(section.children);
|
||||
};
|
||||
|
||||
|
|
|
@ -39,11 +39,11 @@ const MenuOptionList = observer(class MenuOptionList extends React.Component<I.M
|
|||
|
||||
if (canAdd) {
|
||||
placeholder = translate('menuDataviewOptionListFilterOrCreateOptions');
|
||||
empty = translate('menuDataviewOptionListTypeToCreate')
|
||||
empty = translate('menuDataviewOptionListTypeToCreate');
|
||||
}
|
||||
else {
|
||||
placeholder = translate('menuDataviewOptionListFilterOptions');
|
||||
empty = translate('menuDataviewOptionListTypeToSearch')
|
||||
empty = translate('menuDataviewOptionListTypeToSearch');
|
||||
};
|
||||
|
||||
if (!this.cache) {
|
||||
|
@ -56,7 +56,7 @@ const MenuOptionList = observer(class MenuOptionList extends React.Component<I.M
|
|||
|
||||
let content = null;
|
||||
if (item.id == 'add') {
|
||||
content = (
|
||||
content = (
|
||||
<div id="item-add" className="item add" onClick={(e: any) => { this.onClick(e, item); }} style={param.style} onMouseEnter={(e: any) => { this.onOver(e, item); }}>
|
||||
<Icon className="plus" />
|
||||
<div className="name">{item.name}</div>
|
||||
|
@ -199,7 +199,7 @@ const MenuOptionList = observer(class MenuOptionList extends React.Component<I.M
|
|||
};
|
||||
|
||||
onKeyDown (e: any) {
|
||||
let item = this.getItems()[this.n];
|
||||
const item = this.getItems()[this.n];
|
||||
let ret = false;
|
||||
|
||||
keyboard.shortcut('arrowright', e, () => {
|
||||
|
@ -334,7 +334,7 @@ const MenuOptionList = observer(class MenuOptionList extends React.Component<I.M
|
|||
const value = Relation.getArrayValue(data.value);
|
||||
|
||||
let items = Relation.getOptions(dbStore.getRecords(Constant.subId.option, '')).filter(it => it.relationKey == relation.relationKey);
|
||||
let ret = [];
|
||||
const ret = [];
|
||||
let check = [];
|
||||
|
||||
if (filterMapper) {
|
||||
|
|
|
@ -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] });
|
||||
};
|
||||
|
||||
|
|
|
@ -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); }}
|
||||
/>
|
||||
) : ''}
|
||||
) : ''}
|
||||
</div>
|
||||
);
|
||||
});
|
||||
|
@ -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();
|
||||
|
|
|
@ -334,7 +334,7 @@ const MenuSort = observer(class MenuSort extends React.Component<I.Menu> {
|
|||
};
|
||||
|
||||
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;
|
||||
|
|
|
@ -7,84 +7,84 @@ import Constant from 'json/constant.json';
|
|||
|
||||
class MenuTemplate extends React.Component<I.Menu> {
|
||||
|
||||
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 (
|
||||
<div>
|
||||
{items.map((action: any, i: number) => (
|
||||
<MenuItemVertical
|
||||
key={i}
|
||||
{...action}
|
||||
onMouseEnter={e => this.onMouseEnter(e, action)}
|
||||
onClick={e => this.onClick(e, action)}
|
||||
/>
|
||||
))}
|
||||
</div>
|
||||
);
|
||||
};
|
||||
return (
|
||||
<div>
|
||||
{items.map((action: any, i: number) => (
|
||||
<MenuItemVertical
|
||||
key={i}
|
||||
{...action}
|
||||
onMouseEnter={e => this.onMouseEnter(e, action)}
|
||||
onClick={e => this.onClick(e, action)}
|
||||
/>
|
||||
))}
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
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<I.Menu> {
|
|||
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<I.Menu> {
|
|||
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();
|
||||
};
|
||||
};
|
||||
|
||||
};
|
||||
|
||||
|
|
|
@ -221,8 +221,8 @@ const MenuViewEdit = observer(class MenuViewEdit extends React.Component<I.Menu>
|
|||
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<I.Menu>
|
|||
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<I.Menu>
|
|||
};
|
||||
|
||||
let menuId = '';
|
||||
let menuParam: I.MenuParam = {
|
||||
const menuParam: I.MenuParam = {
|
||||
menuKey: item.id,
|
||||
element: `#${getId()} #item-${item.id}`,
|
||||
offsetX: getSize().width,
|
||||
|
|
|
@ -226,7 +226,7 @@ const MenuViewList = observer(class MenuViewList extends React.Component<I.Menu>
|
|||
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;
|
||||
};
|
||||
|
|
|
@ -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 });
|
||||
};
|
||||
|
|
|
@ -197,9 +197,9 @@ const Menu = observer(class Menu extends React.Component<I.Menu, State> {
|
|||
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<I.Menu, State> {
|
|||
</div>
|
||||
) : ''}
|
||||
|
||||
{withArrow ? <Icon id="arrowDirection" className={[ 'arrowDirection', 'c' + arrowDirection ].join(' ')} /> : ''}
|
||||
{withArrow ? <Icon id="arrowDirection" className={[ 'arrowDirection', 'c' + arrowDirection ].join(' ')} /> : ''}
|
||||
|
||||
<div className="content">
|
||||
<Component
|
||||
|
@ -448,7 +448,7 @@ const Menu = observer(class Menu extends React.Component<I.Menu, State> {
|
|||
let eh = 0;
|
||||
let ox = 0;
|
||||
let oy = 0;
|
||||
let minY = UtilCommon.sizeHeader();
|
||||
const minY = UtilCommon.sizeHeader();
|
||||
let rect = null;
|
||||
|
||||
if (recalcRect) {
|
||||
|
|
|
@ -22,12 +22,13 @@ const MenuItemFilter = observer(class MenuItemFilter extends React.Component<Pro
|
|||
_isMounted = false;
|
||||
|
||||
render () {
|
||||
let { id, index, relation, condition, quickOption, value, subId, readonly, style, onOver, onClick, onRemove } = this.props;
|
||||
let conditionOptions = Relation.filterConditionsByType(relation.format);
|
||||
let conditionOption: any = conditionOptions.find(it => 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<Pro
|
|||
switch (relation.format) {
|
||||
|
||||
default: {
|
||||
v = `“${value}”`
|
||||
v = `“${value}”`;
|
||||
break;
|
||||
};
|
||||
|
||||
|
|
|
@ -56,7 +56,7 @@ const MenuRelationSuggest = observer(class MenuRelationSuggest extends React.Com
|
|||
|
||||
let content = null;
|
||||
if (item.id == 'add') {
|
||||
content = (
|
||||
content = (
|
||||
<div
|
||||
id="item-add"
|
||||
className="item add"
|
||||
|
@ -311,7 +311,7 @@ const MenuRelationSuggest = observer(class MenuRelationSuggest extends React.Com
|
|||
};
|
||||
|
||||
getItems () {
|
||||
let sections = this.getSections();
|
||||
const sections = this.getSections();
|
||||
let items: any[] = [];
|
||||
|
||||
sections.forEach((section: any, i: number) => {
|
||||
|
@ -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);
|
||||
};
|
||||
|
|
|
@ -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 });
|
||||
|
|
|
@ -245,7 +245,7 @@ const MenuSelect = observer(class MenuSelect extends React.Component<I.Menu> {
|
|||
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 });
|
||||
};
|
||||
|
|
|
@ -194,7 +194,7 @@ class MenuSmile extends React.Component<I.Menu, State> {
|
|||
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<I.Menu, State> {
|
|||
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<I.Menu, State> {
|
|||
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<I.Menu, State> {
|
|||
];
|
||||
};
|
||||
|
||||
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<I.Menu, State> {
|
|||
close();
|
||||
};
|
||||
window.clearTimeout(this.timeoutMenu);
|
||||
win.off('mouseup.smile')
|
||||
win.off('mouseup.smile');
|
||||
});
|
||||
};
|
||||
|
||||
|
@ -684,7 +684,7 @@ class MenuSmile extends React.Component<I.Menu, State> {
|
|||
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<I.Menu, State> {
|
|||
|
||||
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;
|
||||
|
|
|
@ -45,7 +45,7 @@ class MenuThreadStatus extends React.Component<I.Menu> {
|
|||
} 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') }
|
||||
];
|
||||
};
|
||||
|
||||
|
|
|
@ -56,7 +56,7 @@ const MenuTypeSuggest = observer(class MenuTypeSuggest extends React.Component<I
|
|||
|
||||
let content = null;
|
||||
if (item.id == 'add') {
|
||||
content = (
|
||||
content = (
|
||||
<div
|
||||
id="item-add"
|
||||
className="item add"
|
||||
|
@ -321,7 +321,7 @@ const MenuTypeSuggest = observer(class MenuTypeSuggest extends React.Component<I
|
|||
};
|
||||
|
||||
getItems () {
|
||||
let sections = this.getSections();
|
||||
const sections = this.getSections();
|
||||
let items: any[] = [];
|
||||
|
||||
sections.forEach((section: any, i: number) => {
|
||||
|
@ -371,7 +371,7 @@ const MenuTypeSuggest = observer(class MenuTypeSuggest extends React.Component<I
|
|||
const className = [];
|
||||
|
||||
let menuId = '';
|
||||
let menuParam: I.MenuParam = {
|
||||
const menuParam: I.MenuParam = {
|
||||
menuKey: item.id,
|
||||
element: `#${getId()} #item-${item.id}`,
|
||||
offsetX: getSize().width,
|
||||
|
@ -437,7 +437,7 @@ const MenuTypeSuggest = observer(class MenuTypeSuggest extends React.Component<I
|
|||
e.preventDefault();
|
||||
e.stopPropagation();
|
||||
|
||||
const cb = (item: any) => {
|
||||
const cb = (item: any) => {
|
||||
close();
|
||||
|
||||
if (onClick) {
|
||||
|
|
|
@ -197,7 +197,7 @@ const MenuWidget = observer(class MenuWidget extends React.Component<I.Menu> {
|
|||
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<I.Menu> {
|
|||
|
||||
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<I.Menu> {
|
|||
};
|
||||
|
||||
let prevY = 0;
|
||||
for (let id of widgetIds) {
|
||||
for (const id of widgetIds) {
|
||||
const item = $(`#widget-${id}`);
|
||||
if (!item || !item.length) {
|
||||
continue;
|
||||
|
|
|
@ -356,7 +356,7 @@ const PageAuthOnboard = observer(class PageAuthOnboard extends React.Component<I
|
|||
return;
|
||||
};
|
||||
|
||||
let nextStage = stage - 1;
|
||||
const nextStage = stage - 1;
|
||||
let nextAnimation = animationStage - 1;
|
||||
|
||||
if (animationStage == Stage.SoulCreating) {
|
||||
|
|
|
@ -40,8 +40,8 @@ const ControlButtons = observer(class ControlButtons extends React.Component<Pro
|
|||
return null;
|
||||
};
|
||||
|
||||
let checkType = blockStore.checkBlockTypeExists(rootId);
|
||||
let allowedDetails = blockStore.checkFlags(rootId, rootId, [ I.RestrictionObject.Details ]);
|
||||
const checkType = blockStore.checkBlockTypeExists(rootId);
|
||||
const allowedDetails = blockStore.checkFlags(rootId, rootId, [ I.RestrictionObject.Details ]);
|
||||
let allowedLayout = !checkType && allowedDetails && !root.isObjectSet() && !root.isObjectCollection();
|
||||
let allowedIcon = !checkType && allowedDetails && !root.isObjectTask() && !root.isObjectNote() && !root.isObjectBookmark();
|
||||
let allowedCover = !checkType && allowedDetails && !root.isObjectNote();
|
||||
|
|
|
@ -4,7 +4,7 @@ import { observer } from 'mobx-react';
|
|||
import { Loader } from 'Component';
|
||||
import { I, C, focus, UtilObject, Action } from 'Lib';
|
||||
import { menuStore, blockStore, detailStore } from 'Store';
|
||||
import ControlButtons from './controlButtons';
|
||||
import ControlButtons from './controlButtons';
|
||||
import Constant from 'json/constant.json';
|
||||
|
||||
interface Props extends I.PageComponent {
|
||||
|
@ -31,7 +31,7 @@ const Controls = observer(class Controls extends React.Component<Props, State> {
|
|||
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);
|
||||
|
|
|
@ -77,7 +77,7 @@ const HeadSimple = observer(class Controls extends React.Component<Props> {
|
|||
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<Props> {
|
|||
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<Props> {
|
|||
|
||||
this.setValue();
|
||||
|
||||
for (let item of EDITORS) {
|
||||
for (const item of EDITORS) {
|
||||
this.placeholderCheck(item.blockId);
|
||||
};
|
||||
|
||||
|
|
|
@ -61,7 +61,7 @@ const PageMainBlock = observer(class PageMainBlock extends React.Component<I.Pag
|
|||
block={block}
|
||||
className="noPlus"
|
||||
/>
|
||||
) : translate('pageMainBlockEmpty')}
|
||||
) : translate('pageMainBlockEmpty')}
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
|
|
|
@ -283,7 +283,7 @@ const PageMainGraph = observer(class PageMainGraph extends React.Component<I.Pag
|
|||
objectIds: ids,
|
||||
getObject: id => 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 });
|
||||
|
|
|
@ -94,7 +94,7 @@ const PageMainHistory = observer(class PageMainHistory extends React.Component<I
|
|||
{withChildren ? (
|
||||
<div id={'children-' + item.id} className="children">
|
||||
{item.list.map((child: any, i: number) => {
|
||||
return <Version key={i} {...child} />
|
||||
return <Version key={i} {...child} />;
|
||||
})}
|
||||
</div>
|
||||
) : ''}
|
||||
|
@ -305,8 +305,8 @@ const PageMainHistory = observer(class PageMainHistory extends React.Component<I
|
|||
this.loadVersion(list[0].id);
|
||||
};
|
||||
});
|
||||
};
|
||||
|
||||
};
|
||||
|
||||
loadVersion (id: string) {
|
||||
const rootId = this.getRootId();
|
||||
|
||||
|
@ -326,13 +326,13 @@ const PageMainHistory = observer(class PageMainHistory extends React.Component<I
|
|||
};
|
||||
|
||||
groupData (versions: I.HistoryVersion[]) {
|
||||
let months: any[] = [];
|
||||
let groups: any[] = [];
|
||||
let groupId = 0;
|
||||
const months: any[] = [];
|
||||
const groups: any[] = [];
|
||||
|
||||
let groupId = 0;
|
||||
for (let i = 0; i < versions.length; ++i) {
|
||||
let version = versions[i];
|
||||
let prev = versions[i - 1];
|
||||
const version = versions[i];
|
||||
const prev = versions[i - 1];
|
||||
|
||||
if (prev && ((prev.time - version.time > GROUP_OFFSET) || (prev.time - version.time < 0))) {
|
||||
groupId++;
|
||||
|
@ -342,26 +342,26 @@ const PageMainHistory = observer(class PageMainHistory extends React.Component<I
|
|||
if (!group) {
|
||||
group = { ...version, groupId: groupId, list: [] };
|
||||
groups.push(group);
|
||||
} else {
|
||||
} else {
|
||||
version.groupId = groupId;
|
||||
group.list.push(version);
|
||||
};
|
||||
};
|
||||
|
||||
for (let group of groups) {
|
||||
for (const group of groups) {
|
||||
if ((group.list.length == 1) && (group.time == group.list[0].time)) {
|
||||
group.list = [];
|
||||
};
|
||||
|
||||
let groupId = this.monthId(group.time);
|
||||
const groupId = this.monthId(group.time);
|
||||
|
||||
let month = months.find(it => 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<I
|
|||
|
||||
ungroupData (groups: any[]): I.HistoryVersion[] {
|
||||
let ret: I.HistoryVersion[] = [] as I.HistoryVersion[];
|
||||
for (let month of groups) {
|
||||
for (let group of month.list) {
|
||||
for (const month of groups) {
|
||||
for (const group of month.list) {
|
||||
ret.push(group);
|
||||
ret = ret.concat(group.list);
|
||||
};
|
||||
|
|
|
@ -64,7 +64,7 @@ const PageMainNavigation = observer(class PageMainNavigation extends React.Compo
|
|||
);
|
||||
|
||||
const Item = (item: any) => {
|
||||
let { layout, name, description, snippet } = item || {};
|
||||
const { layout, name, description, snippet } = item || {};
|
||||
|
||||
return (
|
||||
<div
|
||||
|
|
|
@ -538,7 +538,7 @@ const PageMainStore = observer(class PageMainStore extends React.Component<I.Pag
|
|||
ret.push({ id: 'empty', className: 'block', children: [ { id: 'empty' } ] },);
|
||||
};
|
||||
|
||||
for (let item of records) {
|
||||
for (const item of records) {
|
||||
row.children.push(item);
|
||||
|
||||
n++;
|
||||
|
@ -575,7 +575,7 @@ const PageMainStore = observer(class PageMainStore extends React.Component<I.Pag
|
|||
};
|
||||
|
||||
getSources (): string[] {
|
||||
let sources: any[] = []
|
||||
let sources: any[] = [];
|
||||
|
||||
switch (this.tab) {
|
||||
case I.StoreTab.Type:
|
||||
|
@ -618,7 +618,7 @@ const PageMainStore = observer(class PageMainStore extends React.Component<I.Pag
|
|||
this.refFilter.forceUpdate();
|
||||
};
|
||||
|
||||
for (let menu of menus) {
|
||||
for (const menu of menus) {
|
||||
win.trigger('resize.' + UtilCommon.toCamelCase(`menu-${menu.id}`));
|
||||
};
|
||||
};
|
||||
|
|
|
@ -18,80 +18,80 @@ const PageMainUsecase = observer(class PageMainUsecase extends React.Component<I
|
|||
items: [],
|
||||
};
|
||||
|
||||
constructor (props: I.PageComponent) {
|
||||
super(props);
|
||||
constructor (props: I.PageComponent) {
|
||||
super(props);
|
||||
|
||||
this.onClick = this.onClick.bind(this);
|
||||
};
|
||||
this.onClick = this.onClick.bind(this);
|
||||
};
|
||||
|
||||
render () {
|
||||
render () {
|
||||
const { isLoading, items } = this.state;
|
||||
|
||||
const Case = (item: any) => (
|
||||
<div className="item" onClick={e => this.onClick(e, item.id)}>
|
||||
const Case = (item: any) => (
|
||||
<div className="item" onClick={e => this.onClick(e, item.id)}>
|
||||
<div className="head">
|
||||
<Title text={translate(`usecase${item.id}Title`)} />
|
||||
<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 });
|
||||
});
|
||||
};
|
||||
});
|
||||
};
|
||||
|
||||
});
|
||||
|
||||
|
|
|
@ -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>
|
||||
|
|
|
@ -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 (
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Add a link
Reference in a new issue