Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions common/config/rush/command-line.json
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,14 @@
"safeForSimultaneousRushProcesses": true,
"shellCommand": "./common/scripts/docker.sh"
},
{
"commandKind": "global",
"name": "docker-server",
"summary": "Build docker with platform",
"description": "use to build all docker containers required for platform",
"safeForSimultaneousRushProcesses": true,
"shellCommand": "./common/scripts/docker-server.sh && rush docker:up"
},
{
"commandKind": "global",
"name": "docker:up",
Expand Down
3 changes: 2 additions & 1 deletion common/config/rush/pnpm-lock.yaml

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

3 changes: 3 additions & 0 deletions common/scripts/docker-server.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
rush docker:build -p 20 \
--to @hcengineering/pod-server \
--to @hcengineering/tool
18 changes: 18 additions & 0 deletions models/card/src/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,24 @@ export function createActions (builder: Builder): void {
card.action.UnsetParent
)

createAction(builder, {
action: view.actionImpl.CopyDocumentMarkdown,
actionProps: {
contentClass: card.class.Card,
contentField: 'content'
},
label: view.string.CopyDocumentMarkdown,
icon: view.icon.Print,
input: 'any',
category: card.category.Card,
target: card.class.Card,
query: {},
context: {
mode: ['context', 'browser'],
group: 'tools'
}
})

createAction(builder, {
action: view.actionImpl.ShowPopup,
actionProps: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -458,6 +458,7 @@
onContentError: ({ error, disableCollaboration }) => {
disableCollaboration()
contentError = true
console.error(error)
Analytics.handleError(error)
}
})
Expand Down
3 changes: 3 additions & 0 deletions plugins/view-assets/assets/icons.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions plugins/view-assets/lang/cs.json
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@
"Or": "Nebo",
"HyperlinkPlaceholder": "https://jappleseed.com",
"CopyToClipboard": "Kopírovat do schránky",
"CopyDocumentMarkdown": "Kopírovat jako Markdown",
"PublicView": "Veřejné",

"ChooseIcon": "Vybrat ikonu",
Expand Down
1 change: 1 addition & 0 deletions plugins/view-assets/lang/de.json
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@
"Or": "Oder",
"HyperlinkPlaceholder": "https://jappleseed.com",
"CopyToClipboard": "In die Zwischenablage kopieren",
"CopyDocumentMarkdown": "Als Markdown kopieren",
"PublicView": "Öffentlich",

"ChooseIcon": "Symbol wählen",
Expand Down
1 change: 1 addition & 0 deletions plugins/view-assets/lang/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@
"Or": "Or",
"HyperlinkPlaceholder": "https://jappleseed.com",
"CopyToClipboard": "Copy to clipboard",
"CopyDocumentMarkdown": "Copy as Markdown",
"PublicView": "Public",

"ChooseIcon": "Choose icon",
Expand Down
1 change: 1 addition & 0 deletions plugins/view-assets/lang/es.json
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@
"Or": "O",
"HyperlinkPlaceholder": "https://jappleseed.com",
"CopyToClipboard": "Copiar al portapapeles",
"CopyDocumentMarkdown": "Copiar como Markdown",
"PublicView": "Público",
"ChooseIcon": "Elegir icono",
"IconColor": "Elegir color del icono",
Expand Down
1 change: 1 addition & 0 deletions plugins/view-assets/lang/fr.json
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@
"Or": "Ou",
"HyperlinkPlaceholder": "https://jappleseed.com",
"CopyToClipboard": "Copier dans le presse-papiers",
"CopyDocumentMarkdown": "Copier en Markdown",
"PublicView": "Vue publique",
"ChooseIcon": "Choisir une icône",
"IconColor": "Choisir la couleur de l'icône",
Expand Down
1 change: 1 addition & 0 deletions plugins/view-assets/lang/it.json
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@
"Or": "O",
"HyperlinkPlaceholder": "https://jappleseed.com",
"CopyToClipboard": "Copia negli appunti",
"CopyDocumentMarkdown": "Copia come Markdown",
"PublicView": "Vista pubblica",
"ChooseIcon": "Scegli icona",
"IconColor": "Scegli colore icona",
Expand Down
1 change: 1 addition & 0 deletions plugins/view-assets/lang/ja.json
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@
"Or": "または",
"HyperlinkPlaceholder": "https://jappleseed.com",
"CopyToClipboard": "クリップボードにコピー",
"CopyDocumentMarkdown": "Markdownとしてコピー",
"PublicView": "公開",
"ChooseIcon": "アイコンを選択",
"IconColor": "アイコンの色を選択",
Expand Down
1 change: 1 addition & 0 deletions plugins/view-assets/lang/pt.json
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@
"Or": "Ou",
"HyperlinkPlaceholder": "https://jappleseed.com",
"CopyToClipboard": "Copiar para área de transferência",
"CopyDocumentMarkdown": "Copiar como Markdown",
"PublicView": "Público",
"ChooseIcon": "Escolher ícone",
"IconColor": "Escolher cor do ícone",
Expand Down
1 change: 1 addition & 0 deletions plugins/view-assets/lang/ru.json
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@
"Or": "Или",
"HyperlinkPlaceholder": "https://jappleseed.com",
"CopyToClipboard": "Скопировать в буфер обмена",
"CopyDocumentMarkdown": "Скопировать как Markdown",
"PublicView": "Публичный",

"ChooseIcon": "Выбрать иконку",
Expand Down
1 change: 1 addition & 0 deletions plugins/view-assets/lang/tr.json
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@
"Or": "Veya",
"HyperlinkPlaceholder": "https://ornek.com",
"CopyToClipboard": "Panoya kopyala",
"CopyDocumentMarkdown": "Markdown olarak kopyala",
"PublicView": "Genel",
"ChooseIcon": "İkon seç",
"IconColor": "İkon rengi seç",
Expand Down
1 change: 1 addition & 0 deletions plugins/view-assets/lang/zh.json
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@
"Or": "或",
"HyperlinkPlaceholder": "https://jappleseed.com",
"CopyToClipboard": "复制到剪贴板",
"CopyDocumentMarkdown": "复制为 Markdown",
"PublicView": "公开视图",

"ChooseIcon": "选择图标",
Expand Down
3 changes: 2 additions & 1 deletion plugins/view-assets/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,8 @@ loadMetadata(view.icon, {
Feather: `${icons}#feather`,
MasterDetail: `${icons}#master-detail`,
Tree: `${icons}#tree`,
Document: `${icons}#document`
Document: `${icons}#document`,
Print: `${icons}#print`
})
loadMetadata(core.icon, {
TypeString: `${icons}#string`,
Expand Down
1 change: 1 addition & 0 deletions plugins/view-resources/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@
"@hcengineering/ui": "^0.7.0",
"@hcengineering/task": "^0.7.0",
"@hcengineering/text": "^0.7.5",
"@hcengineering/text-markdown": "^0.7.5",
"@hcengineering/preference": "^0.7.0",
"@hcengineering/notification": "^0.7.0",
"@hcengineering/presentation": "^0.7.0",
Expand Down
80 changes: 60 additions & 20 deletions plugins/view-resources/src/actionImpl.ts
Original file line number Diff line number Diff line change
@@ -1,33 +1,41 @@
import {
import contact from '@hcengineering/contact'
import core, {
type Blob,
type Class,
type Doc,
type DocumentQuery,
Hierarchy,
type Ref,
type Space,
type TxResult,
getCurrentAccount
getCurrentAccount,
makeDocCollabId
} from '@hcengineering/core'
import { type Asset, type IntlString, type Resource, getResource } from '@hcengineering/platform'
import {
MessageBox,
getClient,
updateAttribute,
type ContextStore,
MessageBox,
contextStore,
copyTextToClipboardOldBrowser
copyTextToClipboardOldBrowser,
getClient,
getMarkup,
updateAttribute
} from '@hcengineering/presentation'
import { markupToJSON } from '@hcengineering/text'
import { markupToMarkdown } from '@hcengineering/text-markdown'
import {
type AnyComponent,
type AnySvelteComponent,
type PopupAlignment,
type PopupPosAlignment,
closeTooltip,
isPopupPosAlignment,
locationToUrl,
navigate,
showPanel,
showPopup
} from '@hcengineering/ui'
import { get } from 'svelte/store'
import MoveView from './components/Move.svelte'
import view from './plugin'
import {
Expand All @@ -36,13 +44,10 @@ import {
type SelectionStore,
focusStore,
previewDocument,
selectionStore,
selectionLimit
selectionLimit,
selectionStore
} from './selection'
import { deleteObjects, getObjectId, getObjectLinkFragment, restrictionStore } from './utils'
import contact from '@hcengineering/contact'
import { locationToUrl } from '@hcengineering/ui'
import { get } from 'svelte/store'

/**
* Action to be used for copying text to clipboard.
Expand All @@ -65,21 +70,20 @@ async function CopyTextToClipboard (
}
): Promise<void> {
const getText = await getResource(props.textProvider)
const text = Array.isArray(doc)
? (await Promise.all(doc.map(async (d) => await getText(d, props.props)))).join(',')
: await getText(doc, props.props)
await copyText(text, 'text/plain')
}

async function copyText (text: any, contentType: string = 'text/plain'): Promise<void> {
try {
// Safari specific behavior
// see https://bugs.webkit.org/show_bug.cgi?id=222262
const text = Array.isArray(doc)
? (await Promise.all(doc.map(async (d) => await getText(d, props.props)))).join(',')
: await getText(doc, props.props)
const clipboardItem = new ClipboardItem({
'text/plain': text
})
await navigator.clipboard.write([clipboardItem])
} catch {
// Fallback to default clipboard API implementation
const text = Array.isArray(doc)
? (await Promise.all(doc.map(async (d) => await getText(d, props.props)))).join(',')
: await getText(doc, props.props)
if (navigator.clipboard != null && typeof navigator.clipboard.writeText === 'function') {
await navigator.clipboard.writeText(text)
} else copyTextToClipboardOldBrowser(text)
Expand Down Expand Up @@ -589,6 +593,41 @@ async function getPopupAlignment (
}
}

async function CopyDocumentMarkdown (
doc: Doc | Doc[],
evt: Event,
props: {
contentClass: Ref<Class<Doc>>
contentField: string
}
): Promise<void> {
const docs = Array.isArray(doc) ? doc : doc !== undefined ? [doc] : []
if (docs.length !== 1) {
return
}
const client = getClient()
const hierarchy = client.getHierarchy()
const contentClass = hierarchy.getClass(props.contentClass)
if (contentClass == null) {
return
}
const contentField = hierarchy.findAttribute(props.contentClass, props.contentField)
if (contentField == null) {
return
}
if (contentField.type._class === core.class.TypeCollaborativeDoc) {
const content = await getMarkup(
makeDocCollabId(docs[0], props.contentField),
(docs[0] as any)[props.contentField] as Ref<Blob>
)
if (content !== null) {
const jsonMarkup = markupToJSON(content)
const contentJson = markupToMarkdown(jsonMarkup)
await copyText(contentJson, 'text/markdown')
}
}
}

/**
* @public
*/
Expand Down Expand Up @@ -616,5 +655,6 @@ export const actionImpl = {
ShowPopup,
ShowEditor,
ValueSelector,
AttributeSelector
AttributeSelector,
CopyDocumentMarkdown
}
13 changes: 10 additions & 3 deletions plugins/view/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,8 @@ const view = plugin(viewId, {
OpenInNewTab: '' as Ref<Action>,
RemoveRelation: '' as Ref<Action>,

CopyLink: '' as Ref<Action<Doc, any>>
CopyLink: '' as Ref<Action<Doc, any>>,
CopyDocumentMarkdown: '' as Ref<Action<Doc, any>>
},
viewlet: {
Table: '' as Ref<ViewletDescriptor>,
Expand Down Expand Up @@ -250,7 +251,8 @@ const view = plugin(viewId, {
Icon: '' as IntlString,
Select: '' as IntlString,
Color: '' as IntlString,
AutomationOnly: '' as IntlString
AutomationOnly: '' as IntlString,
CopyDocumentMarkdown: '' as IntlString
},
icon: {
Table: '' as Asset,
Expand Down Expand Up @@ -301,7 +303,8 @@ const view = plugin(viewId, {
Feather: '' as Asset,
MasterDetail: '' as Asset,
Tree: '' as Asset,
Document: '' as Asset
Document: '' as Asset,
Print: '' as Asset
},
category: {
General: '' as Ref<ActionCategory>,
Expand Down Expand Up @@ -344,6 +347,10 @@ const view = plugin(viewId, {
textProvider: Resource<(doc: Doc, props: Record<string, any>) => Promise<string>>
props?: Record<string, any>
}>,
CopyDocumentMarkdown: '' as ViewAction<{
contentClass: Ref<Class<Doc>>
contentField: string
}>,
UpdateDocument: '' as ViewAction<{
key: string
value: any
Expand Down
Loading