mirror of
https://github.com/hcengineering/platform.git
synced 2026-09-13 13:17:45 +02:00
Reuse one metadata interface (#10444)
* Reuse one metadata interface Signed-off-by: Artem Savchenko <armisav@gmail.com> * Fix imports Signed-off-by: Artem Savchenko <armisav@gmail.com> --------- Signed-off-by: Artem Savchenko <armisav@gmail.com>
This commit is contained in:
@@ -16,19 +16,7 @@ import { markdownToMarkup } from '@hcengineering/text-markdown'
|
||||
import { Extension } from '@tiptap/core'
|
||||
import { Fragment, Node } from '@tiptap/pm/model'
|
||||
import { Plugin } from '@tiptap/pm/state'
|
||||
|
||||
// TableMetadata type - matches the definition in @hcengineering/view-resources
|
||||
// Defined here to avoid circular dependency (view-resources depends on text-editor-resources)
|
||||
interface TableMetadata {
|
||||
version: string
|
||||
cardClass: string
|
||||
viewletId?: string
|
||||
config?: Array<string | Record<string, any>>
|
||||
query?: Record<string, any>
|
||||
documentIds: string[]
|
||||
timestamp: number
|
||||
workspace?: string
|
||||
}
|
||||
import type { TableMetadata } from '@hcengineering/view'
|
||||
|
||||
export const TableMetadataPasteExtension = Extension.create({
|
||||
name: 'tableMetadataPaste',
|
||||
|
||||
+1
-2
@@ -18,9 +18,8 @@
|
||||
import presentation, { Card } from '@hcengineering/presentation'
|
||||
import textEditor from '@hcengineering/text-editor'
|
||||
import { Component, Loading } from '@hcengineering/ui'
|
||||
import type { BuildModelKey, Viewlet } from '@hcengineering/view'
|
||||
import type { BuildModelKey, TableMetadata, Viewlet } from '@hcengineering/view'
|
||||
import { createEventDispatcher } from 'svelte'
|
||||
import type { TableMetadata } from '../tableMetadata'
|
||||
|
||||
import TableSourceInfo from './TableSourceInfo.svelte'
|
||||
|
||||
|
||||
+1
-1
@@ -18,7 +18,7 @@
|
||||
import presentation, { Card } from '@hcengineering/presentation'
|
||||
import textEditor from '@hcengineering/text-editor'
|
||||
import { createEventDispatcher } from 'svelte'
|
||||
import type { TableMetadata } from '../tableMetadata'
|
||||
import type { TableMetadata } from '@hcengineering/view'
|
||||
|
||||
import MarkupDiffViewer from '../../../MarkupDiffViewer.svelte'
|
||||
import TableSourceInfo from './TableSourceInfo.svelte'
|
||||
|
||||
+1
-1
@@ -19,7 +19,7 @@
|
||||
import textEditor from '@hcengineering/text-editor'
|
||||
import { Button } from '@hcengineering/ui'
|
||||
import { createEventDispatcher } from 'svelte'
|
||||
import type { TableMetadata } from '../tableMetadata'
|
||||
import type { TableMetadata } from '@hcengineering/view'
|
||||
|
||||
import MarkupDiffViewer from '../../../MarkupDiffViewer.svelte'
|
||||
import TableSourceInfo from './TableSourceInfo.svelte'
|
||||
|
||||
+1
-2
@@ -17,9 +17,8 @@
|
||||
import core from '@hcengineering/core'
|
||||
import { IconWithEmoji, getClient } from '@hcengineering/presentation'
|
||||
import ui, { Icon, Label } from '@hcengineering/ui'
|
||||
import view from '@hcengineering/view'
|
||||
import view, { type TableMetadata } from '@hcengineering/view'
|
||||
import textEditor from '@hcengineering/text-editor'
|
||||
import type { TableMetadata } from '../tableMetadata'
|
||||
|
||||
export let metadata: TableMetadata
|
||||
|
||||
|
||||
@@ -16,8 +16,8 @@ import { type Node } from '@tiptap/pm/model'
|
||||
import { TableMap } from '@tiptap/pm/tables'
|
||||
import type { Client } from '@hcengineering/core'
|
||||
import { getClient } from '@hcengineering/presentation'
|
||||
import type { TableMetadata } from '@hcengineering/view'
|
||||
import { buildMarkdownTableFromDocs } from '../refreshTable'
|
||||
import type { TableMetadata } from '../tableMetadata'
|
||||
|
||||
/**
|
||||
* Extract markdown string from a ProseMirror table node
|
||||
|
||||
@@ -14,8 +14,7 @@
|
||||
|
||||
import type { Client, Doc } from '@hcengineering/core'
|
||||
import { getResource } from '@hcengineering/platform'
|
||||
import view, { type BuildMarkdownTableMetadata } from '@hcengineering/view'
|
||||
import type { TableMetadata } from './tableMetadata'
|
||||
import view, { type BuildMarkdownTableMetadata, type TableMetadata } from '@hcengineering/view'
|
||||
|
||||
/**
|
||||
* Build markdown table string from documents and metadata
|
||||
|
||||
@@ -13,16 +13,7 @@
|
||||
//
|
||||
|
||||
import type { Node } from '@tiptap/pm/model'
|
||||
import type { BuildMarkdownTableMetadata } from '@hcengineering/view'
|
||||
|
||||
// Extended TableMetadata for text editor storage (includes additional fields for persistence)
|
||||
export interface TableMetadata extends BuildMarkdownTableMetadata {
|
||||
version: string
|
||||
documentIds: string[]
|
||||
timestamp: number
|
||||
workspace?: string
|
||||
originalUrl?: string // Original URL of the page/view where the table was created
|
||||
}
|
||||
import type { TableMetadata } from '@hcengineering/view'
|
||||
|
||||
/**
|
||||
* Extract table metadata from a ProseMirror table node
|
||||
|
||||
@@ -32,7 +32,8 @@ import viewPlugin, {
|
||||
type Viewlet,
|
||||
type AttributeModel,
|
||||
type BuildModelKey,
|
||||
type BuildMarkdownTableMetadata
|
||||
type BuildMarkdownTableMetadata,
|
||||
type TableMetadata
|
||||
} from '@hcengineering/view'
|
||||
import presentation, { getClient } from '@hcengineering/presentation'
|
||||
import { getName, getPersonByPersonId } from '@hcengineering/contact'
|
||||
@@ -479,22 +480,6 @@ export interface CopyRelationshipTableAsMarkdownProps {
|
||||
query?: DocumentQuery<Doc> // Original query used to fetch documents
|
||||
}
|
||||
|
||||
/**
|
||||
* Metadata structure for table clipboard data
|
||||
* Used to preserve query and configuration for refresh/diff functionality
|
||||
*/
|
||||
export interface TableMetadata {
|
||||
version: string // For future compatibility
|
||||
cardClass: Ref<Class<Doc>>
|
||||
viewletId?: Ref<Viewlet>
|
||||
config?: Array<string | BuildModelKey>
|
||||
query?: DocumentQuery<Doc>
|
||||
documentIds: Array<Ref<Doc>>
|
||||
timestamp: number
|
||||
workspace?: string // Optional workspace identifier
|
||||
originalUrl?: string // Original URL of the page/view where the table was created
|
||||
}
|
||||
|
||||
/**
|
||||
* Build metadata object from props and documents
|
||||
* If viewlet is not provided, tries to find a default viewlet for the class
|
||||
|
||||
@@ -225,7 +225,6 @@ export {
|
||||
type CopyRelationshipTableAsMarkdownProps,
|
||||
type RelationshipCellModel,
|
||||
type RelationshipRowModel,
|
||||
type TableMetadata,
|
||||
type ValueFormatter,
|
||||
registerValueFormatterForClass,
|
||||
registerValueFormatter,
|
||||
|
||||
@@ -906,3 +906,15 @@ export interface BuildMarkdownTableMetadata {
|
||||
query?: Record<string, any> | DocumentQuery<Doc>
|
||||
originalUrl?: string // Original URL of the page/view where the table was created
|
||||
}
|
||||
|
||||
/**
|
||||
* @public
|
||||
* Complete table metadata including persistence fields
|
||||
* Extends BuildMarkdownTableMetadata with additional fields for storage and versioning
|
||||
*/
|
||||
export interface TableMetadata extends BuildMarkdownTableMetadata {
|
||||
version: string // For future compatibility
|
||||
documentIds: Array<string | Ref<Doc>> // Document IDs used in the table
|
||||
timestamp: number // Timestamp when the table was created/updated
|
||||
workspace?: string // Optional workspace identifier
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user