Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/develop' into staging
Browse files Browse the repository at this point in the history
Signed-off-by: Andrey Sobolev <[email protected]>
  • Loading branch information
haiodo committed Jan 9, 2025
2 parents cc2c0c3 + 12e0aaa commit 5bf3fc0
Show file tree
Hide file tree
Showing 48 changed files with 872 additions and 391 deletions.
3 changes: 2 additions & 1 deletion .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -584,7 +584,8 @@
"PASSWORD": "password",
"AVATAR_PATH": "./assets/avatar.png",
"AVATAR_CONTENT_TYPE": ".png",
"LOVE_ENDPOINT": "http://localhost:8096"
"STORAGE_CONFIG": "minio|localhost?accessKey=minioadmin&secretKey=minioadmin",
"LOVE_ENDPOINT": "http://localhost:8096",
},
"runtimeArgs": ["--nolazy", "-r", "ts-node/register"],
"sourceMaps": true,
Expand Down
4 changes: 2 additions & 2 deletions common/config/rush/command-line.json
Original file line number Diff line number Diff line change
Expand Up @@ -238,8 +238,8 @@
"summary": "Build docker with platform",
"description": "use to build all docker containers required for platform",
"safeForSimultaneousRushProcesses": true,
"shellCommand": "rush docker:build -p 20 --to @hcengineering/pod-server --to @hcengineering/pod-front --to @hcengineering/prod --to @hcengineering/pod-account --to @hcengineering/pod-workspace --to @hcengineering/pod-collaborator --to @hcengineering/tool --to @hcengineering/pod-print --to @hcengineering/pod-sign --to @hcengineering/pod-analytics-collector --to @hcengineering/rekoni-service --to @hcengineering/pod-ai-bot --to @hcengineering/import-tool --to @hcengineering/pod-stats --to @hcengineering/pod-fulltext"
},
"shellCommand": "rush docker:build -p 20 --to @hcengineering/pod-server --to @hcengineering/pod-front --to @hcengineering/prod --to @hcengineering/pod-account --to @hcengineering/pod-workspace --to @hcengineering/pod-collaborator --to @hcengineering/tool --to @hcengineering/pod-print --to @hcengineering/pod-sign --to @hcengineering/pod-analytics-collector --to @hcengineering/rekoni-service --to @hcengineering/pod-ai-bot --to @hcengineering/import-tool --to @hcengineering/pod-stats --to @hcengineering/pod-fulltext --to @hcengineering/pod-love"
},
{
"commandKind": "global",
"name": "docker:up",
Expand Down
32 changes: 22 additions & 10 deletions common/config/rush/pnpm-lock.yaml

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

1 change: 1 addition & 0 deletions dev/tool/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
"bundle": "node ../../common/scripts/esbuild.js --entry=src/__start.ts --keep-names=true --sourcemap=external --define:MODEL_VERSION --define:GIT_REVISION",
"docker:build": "../../common/scripts/docker_build.sh hardcoreeng/tool",
"docker:tbuild": "docker build -t hardcoreeng/tool . --platform=linux/amd64 && ../../common/scripts/docker_tag_push.sh hardcoreeng/tool",
"docker:abuild": "docker build -t hardcoreeng/tool . --platform=linux/arm64 && ../../common/scripts/docker_tag_push.sh hardcoreeng/tool",
"docker:staging": "../../common/scripts/docker_tag.sh hardcoreeng/tool staging",
"docker:push": "../../common/scripts/docker_tag.sh hardcoreeng/tool",
"run-local": "rush bundle --to @hcengineering/tool >/dev/null && cross-env SERVER_SECRET=secret ACCOUNTS_URL=http://localhost:3000 TRANSACTOR_URL=ws://localhost:3333 MINIO_ACCESS_KEY=minioadmin MINIO_SECRET_KEY=minioadmin MINIO_ENDPOINT=localhost ACCOUNT_DB_URL=mongodb://localhost:27017 DB_URL=mongodb://localhost:27017 TELEGRAM_DATABASE=telegram-service REKONI_URL=http://localhost:4004 MODEL_VERSION=$(node ../../common/scripts/show_version.js) GIT_REVISION=$(git describe --all --long) node --expose-gc --max-old-space-size=18000 ./bundle/bundle.js",
Expand Down
2 changes: 1 addition & 1 deletion dev/tool/src/db.ts
Original file line number Diff line number Diff line change
Expand Up @@ -347,7 +347,7 @@ export async function updateDataWorkspaceIdToUuid (
throw new Error('workspace uuid is required but not defined')
}

await client`UPDATE ${client(table)} SET "workspaceId" = ${uuid} WHERE "workspaceIdOld" = ${ws.workspace}`
await client`UPDATE ${client(table)} SET "workspaceId" = ${uuid} WHERE "workspaceIdOld" = ${ws.workspace} OR "workspaceIdOld" = ${uuid}`
}
})

Expand Down
5 changes: 0 additions & 5 deletions models/contact/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -518,11 +518,6 @@ export function createModel (builder: Builder): void {
grouppingManager: contact.aggregation.GrouppingPersonManager
})

builder.mixin(contact.mixin.Employee, core.class.Class, view.mixin.ObjectEditor, {
editor: contact.component.EditEmployee,
pinned: true
})

builder.mixin(contact.class.Organization, core.class.Class, view.mixin.ObjectEditor, {
editor: contact.component.EditOrganization,
pinned: true
Expand Down
1 change: 0 additions & 1 deletion models/contact/src/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ export default mergeIds(contactId, contact, {
ContactRefPresenter: '' as AnyComponent,
ContactPresenter: '' as AnyComponent,
EditPerson: '' as AnyComponent,
EditEmployee: '' as AnyComponent,
EditOrganization: '' as AnyComponent,
OrganizationPresenter: '' as AnyComponent,
Contacts: '' as AnyComponent,
Expand Down
41 changes: 41 additions & 0 deletions models/text-editor/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,42 @@ function createImageAlignmentAction (builder: Builder, align: 'center' | 'left'
})
}

function createTextAlignmentAction (builder: Builder, align: 'center' | 'left' | 'right'): void {
let icon: Asset
let label: IntlString
let index: number
switch (align) {
case 'left':
icon = textEditor.icon.AlignLeft
label = textEditor.string.AlignLeft
index = 5
break
case 'center':
icon = textEditor.icon.AlignCenter
label = textEditor.string.AlignCenter
index = 10
break
case 'right':
icon = textEditor.icon.AlignRight
label = textEditor.string.AlignRight
index = 15
break
}

builder.createDoc(textEditor.class.TextEditorAction, core.space.Model, {
kind: 'text',
action: {
command: 'setTextAlign',
params: align
},
visibilityTester: textEditor.function.IsEditable,
icon,
label,
category: 45,
index
})
}

export function createModel (builder: Builder): void {
builder.createModel(TRefInputActionItem, TTextEditorExtensionFactory, TTextEditorAction)

Expand Down Expand Up @@ -253,6 +289,11 @@ export function createModel (builder: Builder): void {
index: 10
})

// Text align category
createTextAlignmentAction(builder, 'left')
createTextAlignmentAction(builder, 'center')
createTextAlignmentAction(builder, 'right')

// Quote category
builder.createDoc(textEditor.class.TextEditorAction, core.space.Model, {
action: {
Expand Down
1 change: 1 addition & 0 deletions packages/core/src/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -329,6 +329,7 @@ async function tryLoadModel (

if (conn.getLastHash !== undefined && (await conn.getLastHash(ctx)) === current.hash) {
// We have same model hash.
current.full = false // Since we load, no need to send full
return current
}
const lastTxTime = getLastTxTime(current.transactions)
Expand Down
3 changes: 2 additions & 1 deletion packages/text/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,8 @@
"@tiptap/suggestion": "^2.6.6",
"prosemirror-codemark": "^0.4.2",
"markdown-it": "^14.0.0",
"fast-equals": "^5.0.1"
"fast-equals": "^5.0.1",
"@tiptap/extension-text-align": "~2.11.0"
},
"repository": "https://github.com/hcengineering/platform",
"publishConfig": {
Expand Down
6 changes: 6 additions & 0 deletions packages/text/src/kits/server-kit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ import { DefaultKit, DefaultKitOptions } from './default-kit'
import { CodeExtension, codeOptions } from '../marks/code'
import { NoteBaseExtension } from '../marks/noteBase'
import { CommentNode } from '../nodes/comment'
import TextAlign from '@tiptap/extension-text-align'

const headingLevels: Level[] = [1, 2, 3, 4, 5, 6]

Expand Down Expand Up @@ -86,6 +87,11 @@ export const ServerKit = Extension.create<ServerKitOptions>({
...taskListExtensions,
...fileExtensions,
...imageExtensions,
TextAlign.configure({
types: ['heading', 'paragraph'],
alignments: ['left', 'center', 'right'],
defaultAlignment: null
}),
TodoItemNode,
TodoListNode,
ReferenceNode,
Expand Down
20 changes: 14 additions & 6 deletions packages/text/src/markup/__tests__/utils.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,17 +61,19 @@ describe('EmptyMarkup', () => {
describe('getMarkup', () => {
it('with empty content', async () => {
const editor = new Editor({ extensions })
expect(getMarkup(editor)).toEqual('{"type":"doc","content":[{"type":"paragraph"}]}')
expect(getMarkup(editor)).toEqual('{"type":"doc","content":[{"type":"paragraph","attrs":{"textAlign":null}}]}')
})
it('with some content', async () => {
const editor = new Editor({ extensions, content: '<p>hello</p>' })
expect(getMarkup(editor)).toEqual(
'{"type":"doc","content":[{"type":"paragraph","content":[{"type":"text","text":"hello"}]}]}'
'{"type":"doc","content":[{"type":"paragraph","attrs":{"textAlign":null},"content":[{"type":"text","text":"hello"}]}]}'
)
})
it('with empty paragraphs as content', async () => {
const editor = new Editor({ extensions, content: '<p></p><p></p>' })
expect(getMarkup(editor)).toEqual('{"type":"doc","content":[{"type":"paragraph"},{"type":"paragraph"}]}')
expect(getMarkup(editor)).toEqual(
'{"type":"doc","content":[{"type":"paragraph","attrs":{"textAlign":null}},{"type":"paragraph","attrs":{"textAlign":null}}]}'
)
})
})

Expand Down Expand Up @@ -250,13 +252,15 @@ describe('pmNodeToMarkup', () => {
const schema = getSchema(extensions)
const node = schema.node('paragraph', {}, [schema.text('Hello, world!')])

expect(pmNodeToMarkup(node)).toEqual('{"type":"paragraph","content":[{"type":"text","text":"Hello, world!"}]}')
expect(pmNodeToMarkup(node)).toEqual(
'{"type":"paragraph","attrs":{"textAlign":null},"content":[{"type":"text","text":"Hello, world!"}]}'
)
})
})

describe('markupToPmNode', () => {
it('converts markup to ProseMirrorNode', () => {
const markup = '{"type":"paragraph","content":[{"type":"text","text":"Hello, world!"}]}'
const markup = '{"type":"paragraph","attrs":{"textAlign":null},"content":[{"type":"text","text":"Hello, world!"}]}'
const node = markupToPmNode(markup)

expect(node.type.name).toEqual('paragraph')
Expand Down Expand Up @@ -306,7 +310,11 @@ describe('pmNodeToJSON', () => {
const schema = getSchema(extensions)
const node = schema.node('paragraph', {}, [schema.text('Hello, world!')])

const json = nodeParagraph(nodeText('Hello, world!'))
const json: MarkupNode = {
type: MarkupNodeType.paragraph,
attrs: { textAlign: null as any },
content: [nodeText('Hello, world!')]
}
expect(pmNodeToJSON(node)).toEqual(json)
})
})
Expand Down
12 changes: 9 additions & 3 deletions plugins/client-resources/src/connection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ import core, {
TxApplyIf,
TxHandler,
TxResult,
clone,
generateId,
toFindResult,
type MeasureContext
Expand Down Expand Up @@ -108,6 +109,8 @@ class Connection implements ClientConnection {

private helloRecieved: boolean = false

private account: Account | undefined

onConnect?: (event: ClientConnectEvent, lastTx: string | undefined, data: any) => Promise<void>

rpcHandler = new RPCHandler()
Expand Down Expand Up @@ -303,7 +306,7 @@ class Connection implements ClientConnection {
this.websocket?.close()
return
}

this.account = helloResp.account
this.helloRecieved = true
if (this.upgrading) {
// We need to call upgrade since connection is upgraded
Expand All @@ -322,8 +325,8 @@ class Connection implements ClientConnection {
}

void this.onConnect?.(
(resp as HelloResponse).reconnect === true ? ClientConnectEvent.Reconnected : ClientConnectEvent.Connected,
(resp as HelloResponse).lastTx,
helloResp.reconnect === true ? ClientConnectEvent.Reconnected : ClientConnectEvent.Connected,
helloResp.lastTx,
this.sessionId
)
this.schedulePing(socketId)
Expand Down Expand Up @@ -635,6 +638,9 @@ class Connection implements ClientConnection {
}

getAccount (): Promise<Account> {
if (this.account !== undefined) {
return clone(this.account)
}
return this.sendRequest({ method: 'getAccount', params: [] })
}

Expand Down
Loading

0 comments on commit 5bf3fc0

Please sign in to comment.