mirror of
https://github.com/hcengineering/platform.git
synced 2025-04-23 08:48:01 +00:00
fix: report invalid content errors to analytics (#6699)
Signed-off-by: Alexander Onnikov <Alexander.Onnikov@xored.com>
This commit is contained in:
parent
ba5a7525d3
commit
daf4247b07
@ -42,6 +42,7 @@
|
|||||||
"@hcengineering/platform": "^0.6.11",
|
"@hcengineering/platform": "^0.6.11",
|
||||||
"svelte": "^4.2.12",
|
"svelte": "^4.2.12",
|
||||||
"@hcengineering/ui": "^0.6.15",
|
"@hcengineering/ui": "^0.6.15",
|
||||||
|
"@hcengineering/analytics": "^0.6.0",
|
||||||
"@hcengineering/presentation": "^0.6.3",
|
"@hcengineering/presentation": "^0.6.3",
|
||||||
"@hcengineering/core": "^0.6.32",
|
"@hcengineering/core": "^0.6.32",
|
||||||
"@hcengineering/view": "^0.6.13",
|
"@hcengineering/view": "^0.6.13",
|
||||||
|
@ -15,6 +15,7 @@
|
|||||||
//
|
//
|
||||||
-->
|
-->
|
||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
|
import { Analytics } from '@hcengineering/analytics'
|
||||||
import { type Space, type Class, type CollaborativeDoc, type Doc, type Ref } from '@hcengineering/core'
|
import { type Space, type Class, type CollaborativeDoc, type Doc, type Ref } from '@hcengineering/core'
|
||||||
import { IntlString, translate } from '@hcengineering/platform'
|
import { IntlString, translate } from '@hcengineering/platform'
|
||||||
import { getFileUrl, getImageSize, imageSizeToRatio } from '@hcengineering/presentation'
|
import { getFileUrl, getImageSize, imageSizeToRatio } from '@hcengineering/presentation'
|
||||||
@ -116,11 +117,12 @@
|
|||||||
objectAttr
|
objectAttr
|
||||||
})
|
})
|
||||||
|
|
||||||
|
let contentError = false
|
||||||
let localSynced = false
|
let localSynced = false
|
||||||
let remoteSynced = false
|
let remoteSynced = false
|
||||||
|
|
||||||
$: loading = !localSynced && !remoteSynced
|
$: loading = !localSynced && !remoteSynced
|
||||||
$: editable = !readonly && remoteSynced
|
$: editable = !readonly && !contentError && remoteSynced
|
||||||
|
|
||||||
void localProvider.loaded.then(() => (localSynced = true))
|
void localProvider.loaded.then(() => (localSynced = true))
|
||||||
void remoteProvider.loaded.then(() => (remoteSynced = true))
|
void remoteProvider.loaded.then(() => (remoteSynced = true))
|
||||||
@ -218,7 +220,10 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
$: if (editor !== undefined) {
|
$: if (editor !== undefined) {
|
||||||
editor.setEditable(editable, true)
|
// When the content is invalid, we don't want to emit an update
|
||||||
|
// Preventing synchronization of the invalid content
|
||||||
|
const emitUpdate = !contentError
|
||||||
|
editor.setEditable(editable, emitUpdate)
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: should be inside the editor
|
// TODO: should be inside the editor
|
||||||
@ -364,6 +369,7 @@
|
|||||||
await ph
|
await ph
|
||||||
|
|
||||||
editor = new Editor({
|
editor = new Editor({
|
||||||
|
enableContentCheck: true,
|
||||||
element,
|
element,
|
||||||
editorProps: { attributes: mergeAttributes(defaultEditorAttributes, editorAttributes, { class: 'flex-grow' }) },
|
editorProps: { attributes: mergeAttributes(defaultEditorAttributes, editorAttributes, { class: 'flex-grow' }) },
|
||||||
extensions: [
|
extensions: [
|
||||||
@ -432,6 +438,11 @@
|
|||||||
|
|
||||||
throttle.call(updateLastUpdateTime)
|
throttle.call(updateLastUpdateTime)
|
||||||
dispatch('update')
|
dispatch('update')
|
||||||
|
},
|
||||||
|
onContentError: ({ error, disableCollaboration }) => {
|
||||||
|
disableCollaboration()
|
||||||
|
contentError = true
|
||||||
|
Analytics.handleError(error)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
@ -14,6 +14,7 @@
|
|||||||
// limitations under the License.
|
// limitations under the License.
|
||||||
-->
|
-->
|
||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
|
import { Analytics } from '@hcengineering/analytics'
|
||||||
import { Markup } from '@hcengineering/core'
|
import { Markup } from '@hcengineering/core'
|
||||||
import { IntlString, translate } from '@hcengineering/platform'
|
import { IntlString, translate } from '@hcengineering/platform'
|
||||||
import { EmptyMarkup, getMarkup, markupToJSON } from '@hcengineering/text'
|
import { EmptyMarkup, getMarkup, markupToJSON } from '@hcengineering/text'
|
||||||
@ -150,6 +151,7 @@
|
|||||||
onMount(() => {
|
onMount(() => {
|
||||||
void ph.then(async () => {
|
void ph.then(async () => {
|
||||||
editor = new Editor({
|
editor = new Editor({
|
||||||
|
enableContentCheck: true,
|
||||||
element,
|
element,
|
||||||
editorProps: {
|
editorProps: {
|
||||||
attributes: mergeAttributes(defaultEditorAttributes, editorAttributes),
|
attributes: mergeAttributes(defaultEditorAttributes, editorAttributes),
|
||||||
@ -197,6 +199,9 @@
|
|||||||
content = getContent()
|
content = getContent()
|
||||||
dispatch('value', content)
|
dispatch('value', content)
|
||||||
dispatch('update', content)
|
dispatch('update', content)
|
||||||
|
},
|
||||||
|
onContentError: ({ error }) => {
|
||||||
|
Analytics.handleError(error)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
Loading…
Reference in New Issue
Block a user