1
0
Fork 0
mirror of https://github.com/anyproto/anytype-ts.git synced 2025-06-08 05:57:02 +09:00
This commit is contained in:
Andrew Simachev 2025-02-03 02:19:52 +01:00
commit db96671f58
No known key found for this signature in database
GPG key ID: 1DFE44B21443F0EF
15 changed files with 97 additions and 93 deletions

View file

@ -62,14 +62,16 @@ class Util {
};
arrowHead (x, y, angle, width, height, color) {
const halfWidth = width / 2;
this.ctx.save();
this.ctx.translate(x, y);
this.ctx.rotate(angle);
this.ctx.beginPath();
this.ctx.moveTo(0, 0);
this.ctx.lineTo(height, -width / 2);
this.ctx.lineTo(height, width / 2);
this.ctx.lineTo(height, -halfWidth);
this.ctx.lineTo(height, halfWidth);
this.ctx.lineTo(0, 0);
this.ctx.closePath();

View file

@ -66,8 +66,6 @@ const Index = observer(class Index extends React.Component<I.PageComponent, Stat
login () {
const appKey = Storage.get('appKey');
console.log('appKey', appKey);
if (appKey) {
Util.authorize(appKey, () => {
const { serverPort, gatewayPort } = S.Extension;

View file

@ -1 +1 @@
0.39.2
0.39.4

4
package-lock.json generated
View file

@ -1,12 +1,12 @@
{
"name": "anytype",
"version": "0.44.15-beta",
"version": "0.44.17-alpha",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "anytype",
"version": "0.44.15-beta",
"version": "0.44.17-alpha",
"hasInstallScript": true,
"license": "SEE LICENSE IN LICENSE.md",
"dependencies": {

View file

@ -1,6 +1,6 @@
{
"name": "anytype",
"version": "0.44.15-beta",
"version": "0.44.17-alpha",
"description": "Anytype",
"main": "electron.js",
"scripts": {

View file

@ -161,7 +161,7 @@
.cellContent { height: 100% !important; min-width: 300px; padding: 14px; border-radius: 4px; }
.cellContent.isName { padding: 0px 14px !important; }
.cellContent.isName {
.iconObject { margin: 14px 8px 14px 0px; }
.iconObject { margin: 14px 0px; }
.input-text { height: 48px; width: calc(100% - 30px) !important; }
.name { width: 100%; }
}
@ -189,6 +189,10 @@
.viewContent.viewGrid.isCollection {
.cellHead:first-child .flex, .cell:first-child { padding-left: 20px; }
.cell.isEditing.isName {
.cellContent { padding-left: 20px !important; }
}
.row:hover {
.icon.drag { opacity: 1; }
}

View file

@ -17,7 +17,7 @@
.sidebar { position: fixed; z-index: 21; user-select: none; transition: none; top: 0px; height: 100%; background-color: var(--color-shape-tertiary); }
.sidebar.anim { transition-duration: $transitionSidebarTime; transition-timing-function: linear; }
.sidebar.isClosed { left: 0px !important; }
.sidebar.isClosed { left: 0px !important; overflow: hidden; }
.sidebar.left { left: 0px; }
.sidebar.left.withVault { left: $vaultWidthCollapsed; }

View file

@ -3,7 +3,7 @@
.menus {
.menu.menuBlockAdd { width: var(--menu-width-add) !important; }
.menu.menuBlockAdd {
.content { padding: 0px; }
.content { padding: 0px; max-height: unset; }
.wrap { height: 100%; }
.items { height: 100%; }

View file

@ -14,9 +14,6 @@ for (const lang of U.Prism.components) {
require(`prismjs/components/prism-${lang}.js`);
};
const katex = require('katex');
require('katex/dist/contrib/mhchem');
const BlockText = observer(class BlockText extends React.Component<Props> {
public static defaultProps = {
@ -309,59 +306,8 @@ const BlockText = observer(class BlockText extends React.Component<Props> {
return;
};
const tag = Mark.getTag(I.MarkType.Latex);
const code = Mark.getTag(I.MarkType.Code);
const value = this.refEditable.getHtmlValue();
const reg = /(^|[^\d<\$]+)?\$((?:[^$<]|\.)*?)\$([^\d>\$]+|$)/gi;
const regCode = new RegExp(`^${code}|${code}$`, 'i');
if (!/\$[^\$]+\$/.test(value)) {
return;
};
const match = value.matchAll(reg);
const render = (s: string) => {
s = U.Common.fromHtmlSpecialChars(s);
let ret = s;
try {
ret = katex.renderToString(s, {
displayMode: false,
throwOnError: false,
output: 'html',
trust: ctx => [ '\\url', '\\href', '\\includegraphics' ].includes(ctx.command),
});
ret = ret ? ret : s;
} catch (e) {};
return ret;
};
let html = value;
match.forEach((m: any) => {
const m0 = String(m[0] || '');
const m1 = String(m[1] || '');
const m2 = String(m[2] || '');
const m3 = String(m[3] || '');
// Skip inline code marks
if (regCode.test(m1) || regCode.test(m3)) {
return;
};
// Skip Brazilian Real
if (/R$/.test(m1) || /R$/.test(m2)) {
return;
};
// Escaped $ sign
if (/\\$/.test(m1) || /\\$/.test(m2)) {
return;
};
html = html.replace(m0, `${m1}<${tag}>${render(m2)}</${tag}>${m3}`);
});
const html = U.Common.getLatex(value);
if (html !== value) {
ref.setValue(html);

View file

@ -9,7 +9,7 @@ const HEIGHT_ITEM = 32;
const HEIGHT_SECTION = 42;
const HEIGHT_DESCRIPTION = 56;
const HEIGHT_RELATION = 32;
const LIMIT = 40;
const LIMIT = 10;
const MenuBlockAdd = observer(class MenuBlockAdd extends React.Component<I.Menu> {
@ -34,7 +34,7 @@ const MenuBlockAdd = observer(class MenuBlockAdd extends React.Component<I.Menu>
const { data } = param;
const { rootId, blockId } = data;
const { filter } = S.Common;
const items = this.getItems(true);
const items = this.getItems();
const block = S.Block.getLeaf(rootId, blockId);
const idPrefix = 'menuBlockAdd';
@ -160,7 +160,6 @@ const MenuBlockAdd = observer(class MenuBlockAdd extends React.Component<I.Menu>
rowCount={items.length}
loadMoreRows={() => {}}
isRowLoaded={() => true}
threshold={LIMIT}
>
{({ onRowsRendered }) => (
<AutoSizer className="scrollArea">
@ -174,8 +173,8 @@ const MenuBlockAdd = observer(class MenuBlockAdd extends React.Component<I.Menu>
rowHeight={({ index }) => this.getRowHeight(items[index], index)}
rowRenderer={rowRenderer}
onRowsRendered={onRowsRendered}
overscanRowCount={20}
scrollToAlignment="start"
overscanRowCount={LIMIT}
scrollToAlignment="center"
/>
)}
</AutoSizer>
@ -189,7 +188,7 @@ const MenuBlockAdd = observer(class MenuBlockAdd extends React.Component<I.Menu>
componentDidMount () {
const { getId } = this.props;
const items = this.getItems(true);
const items = this.getItems();
this._isMounted = true;
this.rebind();
@ -198,7 +197,7 @@ const MenuBlockAdd = observer(class MenuBlockAdd extends React.Component<I.Menu>
this.cache = new CellMeasurerCache({
fixedWidth: true,
defaultHeight: HEIGHT_ITEM,
defaultHeight: i => this.getRowHeight(items[i], i),
keyMapper: i => (items[i] || {}).id,
});
@ -207,8 +206,8 @@ const MenuBlockAdd = observer(class MenuBlockAdd extends React.Component<I.Menu>
componentDidUpdate () {
const { filter } = S.Common;
const items = this.getItems(true);
const itemsWithoutSections = this.getItems(false);
const items = this.getItems();
const itemsWithoutSections = items.filter(it => !it.isSection);
if (!itemsWithoutSections.length && !this.emptyLength) {
this.emptyLength = filter.text.length;
@ -221,7 +220,7 @@ const MenuBlockAdd = observer(class MenuBlockAdd extends React.Component<I.Menu>
this.cache = new CellMeasurerCache({
fixedWidth: true,
defaultHeight: HEIGHT_ITEM,
defaultHeight: i => this.getRowHeight(items[i], i),
keyMapper: i => (items[i] || {}).id,
});
@ -234,7 +233,6 @@ const MenuBlockAdd = observer(class MenuBlockAdd extends React.Component<I.Menu>
this.checkFilter();
this.resize();
this.props.setActive();
};
@ -343,12 +341,12 @@ const MenuBlockAdd = observer(class MenuBlockAdd extends React.Component<I.Menu>
return U.Menu.sectionsMap(sections);
};
getItems (withSections: boolean) {
getItems () {
const sections = this.getSections();
let items: any[] = [];
for (const section of sections) {
if (withSections) {
if (section.name) {
items.push({ id: section.id, name: section.name, isSection: true });
};
items = items.concat(section.children);
@ -716,21 +714,21 @@ const MenuBlockAdd = observer(class MenuBlockAdd extends React.Component<I.Menu>
resize () {
const { getId, position } = this.props;
const items = this.getItems(true);
const items = this.getItems().slice(0, LIMIT);
const obj = $(`#${getId()} .content`);
let height = 16;
for (let i = 0; i < items.length; ++i) {
height += this.getRowHeight(items[i], i);
};
height = Math.max(HEIGHT_ITEM + 18, Math.min(360, height));
height = Math.max(HEIGHT_ITEM + 18, height);
obj.css({ height: height });
obj.css({ height });
position();
};
getRowHeight (item: any, index: number) {
let h = HEIGHT_ITEM
let h = HEIGHT_ITEM;
if (item.isRelation || item.isRelationAdd) h = HEIGHT_RELATION;
else if (item.isSection && (index > 0)) h = HEIGHT_SECTION;
else if (item.isBlock) h = HEIGHT_DESCRIPTION;

View file

@ -104,7 +104,7 @@ const MenuPublish = observer(forwardRef<I.MenuRef, I.Menu>((props, ref) => {
const loadStatus = () => {
setIsStatusLoading(true);
C.PublishingGetStatus(space.targetSpaceId, rootId, message => {
C.PublishingGetStatus(S.Common.space, rootId, message => {
setIsStatusLoading(false);
if (message.error.code) {

View file

@ -46,7 +46,7 @@ const PopupSettingsPageDataPublish = observer(class PopupSettingsPageDataPublish
<div className="items">
<div className="row isHead">
<div className="col colSpace">{translate('commonObject')}</div>
<div className="col">{translate('popupSettingsDataManagementDataPublishTitle')}</div>
<div className="col">{translate('popupSettingsDataManagementDataPublishDate')}</div>
<div className="col">{translate('commonSize')}</div>
<div className="col colMore" />
</div>
@ -127,7 +127,7 @@ const PopupSettingsPageDataPublish = observer(class PopupSettingsPageDataPublish
onUnpublish (item: any) {
const object = S.Detail.mapper(item.details);
C.PublishingRemove(S.Common.space, item.objectId, (message: any) => {
C.PublishingRemove(item.spaceId, item.objectId, (message: any) => {
if (!message.error.code) {
this.load();

View file

@ -23,7 +23,7 @@ const WidgetGalleryItem = observer(forwardRef<{}, Props>(({
const nodeRef = useRef(null);
const view = getView();
const rootId = keyboard.getRootId();
const object = S.Detail.get(subId, id, J.Relation.sidebar);
const object = S.Detail.get(subId, id, J.Relation.sidebar.concat(J.Relation.cover));
const { isReadonly, isArchived, restrictions } = object;
const allowedDetails = S.Block.isAllowed(restrictions, [ I.RestrictionObject.Details ]);
const iconKey = `widget-icon-${block.id}-${id}`;

View file

@ -2,6 +2,9 @@ import $ from 'jquery';
import DOMPurify from 'dompurify';
import { I, C, S, J, U, Preview, Renderer, translate, Mark, Action } from 'Lib';
const katex = require('katex');
require('katex/dist/contrib/mhchem');
const TEST_HTML = /<[^>]*>/;
class UtilCommon {
@ -1049,6 +1052,62 @@ class UtilCommon {
.replace(/-+/g, '-');
};
getLatex (html: string): string {
if (!/\$[^\$]+\$/.test(html)) {
return html;
};
const reg = /(^|[^\d<\$]+)?\$((?:[^$<]|\.)*?)\$([^\d>\$]+|$)/gi;
const tag = Mark.getTag(I.MarkType.Latex);
const code = Mark.getTag(I.MarkType.Code);
const regCode = new RegExp(`^${code}|${code}$`, 'i');
const match = html.matchAll(reg);
const render = (s: string) => {
s = U.Common.fromHtmlSpecialChars(s);
let ret = s;
try {
ret = katex.renderToString(s, {
displayMode: false,
throwOnError: false,
output: 'html',
trust: ctx => [ '\\url', '\\href', '\\includegraphics' ].includes(ctx.command),
});
ret = ret ? ret : s;
} catch (e) {};
return ret;
};
let text = html;
match.forEach((m: any) => {
const m0 = String(m[0] || '');
const m1 = String(m[1] || '');
const m2 = String(m[2] || '');
const m3 = String(m[3] || '');
// Skip inline code marks
if (regCode.test(m1) || regCode.test(m3)) {
return;
};
// Skip Brazilian Real
if (/R$/.test(m1) || /R$/.test(m2)) {
return;
};
// Escaped $ sign
if (/\\$/.test(m1) || /\\$/.test(m2)) {
return;
};
text = text.replace(m0, `${m1}<${tag}>${render(m2)}</${tag}>${m3}`);
});
return text;
};
};
export default new UtilCommon();

View file

@ -186,12 +186,8 @@ class MenuStore {
return;
};
if (timeout) {
this.clearTimeout();
this.timeout = window.setTimeout(() => callBack(), timeout);
} else {
callBack();
};
this.clearTimeout();
this.timeout = window.setTimeout(() => callBack(), timeout);
};
getTimeout (ids?: string[]): number {
@ -201,6 +197,7 @@ class MenuStore {
for (const item of items) {
if (!item.param.noAnimation) {
t = J.Constant.delay.menu;
break;
};
};
return t;