mirror of
https://github.com/hcengineering/platform.git
synced 2026-10-01 14:05:05 +02:00
Merge branch 'staging' into develop
Signed-off-by: Andrey Sobolev <haiodo@gmail.com>
This commit is contained in:
@@ -1,3 +1,18 @@
|
||||
//
|
||||
// Copyright © 2025 Hardcore Engineering Inc.
|
||||
//
|
||||
// Licensed under the Eclipse Public License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License. You may
|
||||
// obtain a copy of the License at https://www.eclipse.org/legal/epl-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
//
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
|
||||
import { mergeAttributes, type Editor } from '@tiptap/core'
|
||||
import { Plugin, PluginKey } from '@tiptap/pm/state'
|
||||
import MentionList from '../MentionList.svelte'
|
||||
@@ -9,8 +24,9 @@ import Suggestion, { type SuggestionKeyDownProps, type SuggestionOptions, type S
|
||||
import { type Class, type Doc, type Ref } from '@hcengineering/core'
|
||||
import { getMetadata, getResource } from '@hcengineering/platform'
|
||||
import presentation, { createQuery, getClient } from '@hcengineering/presentation'
|
||||
import { parseLocation } from '@hcengineering/ui'
|
||||
import view from '@hcengineering/view'
|
||||
|
||||
import { parseLocation, type Location } from '@hcengineering/ui'
|
||||
import workbench, { type Application } from '@hcengineering/workbench'
|
||||
|
||||
export interface ReferenceExtensionOptions extends ReferenceOptions {
|
||||
@@ -104,7 +120,7 @@ export const ReferenceExtension = ReferenceNode.extend<ReferenceExtensionOptions
|
||||
|
||||
const renderLabel = (props: ReferenceNodeProps): void => {
|
||||
span.setAttribute('data-label', props.label)
|
||||
span.innerText = options.renderLabel({ options, props: props ?? node.attrs })
|
||||
span.innerText = options.renderLabel({ options, props: props ?? (node.attrs as ReferenceNodeProps) })
|
||||
}
|
||||
|
||||
const id = node.attrs.id
|
||||
@@ -328,16 +344,37 @@ export async function getReferenceLabel<T extends Doc> (
|
||||
return label
|
||||
}
|
||||
|
||||
export async function getReferenceFromUrl (text: string): Promise<ReferenceNodeProps | undefined> {
|
||||
export async function getReferenceFromUrl (urlString: string): Promise<ReferenceNodeProps | undefined> {
|
||||
const target = await getTargetObjectFromUrl(urlString)
|
||||
if (target === undefined) return
|
||||
|
||||
const label = await getReferenceLabel(target._class, target._id)
|
||||
if (label === '') return
|
||||
|
||||
return {
|
||||
id: target._id,
|
||||
objectclass: target._class,
|
||||
label
|
||||
}
|
||||
}
|
||||
|
||||
export async function getTargetObjectFromUrl (
|
||||
urlOrLocation: string | Location
|
||||
): Promise<{ _id: Ref<Doc>, _class: Ref<Class<Doc>> } | undefined> {
|
||||
const client = getClient()
|
||||
const hierarchy = client.getHierarchy()
|
||||
|
||||
const url = new URL(text)
|
||||
let location: Location
|
||||
if (typeof urlOrLocation === 'string') {
|
||||
const url = new URL(urlOrLocation)
|
||||
|
||||
const frontUrl = getMetadata(presentation.metadata.FrontUrl) ?? window.location.origin
|
||||
if (url.origin !== frontUrl) return
|
||||
const frontUrl = getMetadata(presentation.metadata.FrontUrl) ?? window.location.origin
|
||||
if (url.origin !== frontUrl) return
|
||||
|
||||
const location = parseLocation(url)
|
||||
location = parseLocation(url)
|
||||
} else {
|
||||
location = urlOrLocation
|
||||
}
|
||||
|
||||
const appAlias = (location.path[2] ?? '').trim()
|
||||
if (!(appAlias.length > 0)) return
|
||||
@@ -363,12 +400,8 @@ export async function getReferenceFromUrl (text: string): Promise<ReferenceNodeP
|
||||
const _id: Ref<Doc> | undefined =
|
||||
linkProvider !== undefined ? (await (await getResource(linkProvider.decode))(id)) ?? id : id
|
||||
|
||||
const label = await getReferenceLabel(objectclass, _id)
|
||||
if (label === '') return
|
||||
|
||||
return {
|
||||
id: _id,
|
||||
objectclass,
|
||||
label
|
||||
_id,
|
||||
_class: objectclass
|
||||
}
|
||||
}
|
||||
|
||||
@@ -27,6 +27,7 @@ import { openImage, downloadImage, expandImage, moreImageActions } from './compo
|
||||
import { configureNote, isEditableNote } from './components/extension/note'
|
||||
import { createInlineComment, shouldShowCreateInlineCommentAction } from './components/extension/inlineComment'
|
||||
import { isTextStylingEnabled, openBackgroundColorOptions, openTextColorOptions } from './components/extension/colors'
|
||||
export { getTargetObjectFromUrl, getReferenceFromUrl, getReferenceLabel } from './components/extension/reference'
|
||||
|
||||
export * from '@hcengineering/presentation/src/types'
|
||||
export type { EditorKitOptions } from './kits/editor-kit'
|
||||
|
||||
@@ -170,11 +170,12 @@ import ProjectSpacePresenter from './components/projects/ProjectSpacePresenter.s
|
||||
|
||||
import { get } from 'svelte/store'
|
||||
import { settingId } from '@hcengineering/setting'
|
||||
import type { TaskType } from '@hcengineering/task'
|
||||
import { getAllStates } from '@hcengineering/task-resources'
|
||||
import view, { type Filter } from '@hcengineering/view'
|
||||
import EstimationValueEditor from './components/issues/timereport/EstimationValueEditor.svelte'
|
||||
import TimePresenter from './components/issues/timereport/TimePresenter.svelte'
|
||||
import type { TaskType } from '@hcengineering/task'
|
||||
import view, { type Filter } from '@hcengineering/view'
|
||||
import { getTargetObjectFromUrl } from '@hcengineering/text-editor-resources'
|
||||
|
||||
export { default as AssigneeEditor } from './components/issues/AssigneeEditor.svelte'
|
||||
export { default as SubIssueList } from './components/issues/edit/SubIssueList.svelte'
|
||||
@@ -265,12 +266,19 @@ async function deleteIssue (issue: Issue | Issue[]): Promise<void> {
|
||||
},
|
||||
action: async () => {
|
||||
const objs = Array.isArray(issue) ? issue : [issue]
|
||||
|
||||
const target = await getTargetObjectFromUrl(getCurrentLocation())
|
||||
const deletingFromTargetIssuePage = objs.some((obj) => obj._id === target?._id)
|
||||
|
||||
try {
|
||||
await deleteObjects(getClient(), objs as unknown as Doc[])
|
||||
} catch (err: any) {
|
||||
Analytics.handleError(err)
|
||||
}
|
||||
closePanel()
|
||||
|
||||
if (deletingFromTargetIssuePage) {
|
||||
closePanel()
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user