@live-change/wysiwyg-frontend 0.1.5 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/front/src/App.vue +7 -1
- package/front/src/DocumentEditor.vue +52 -9
- package/front/src/NavBar.vue +1 -1
- package/front/src/schemaJson.js +1 -1
- package/index.js +13 -0
- package/package.json +15 -15
- package/server/init.js +1 -0
- package/server/services.config.js +2 -1
package/front/src/App.vue
CHANGED
|
@@ -23,10 +23,16 @@
|
|
|
23
23
|
})
|
|
24
24
|
|
|
25
25
|
import { watch } from 'vue'
|
|
26
|
-
import { client as useClient } from '@live-change/vue3-ssr'
|
|
26
|
+
import { client as useClient, useApi } from '@live-change/vue3-ssr'
|
|
27
27
|
const client = useClient()
|
|
28
28
|
watch(client, (newClient, oldClient) => {
|
|
29
29
|
console.log("WATCH CLIENT", oldClient, '=>', newClient)
|
|
30
30
|
})
|
|
31
31
|
|
|
32
|
+
const api = useApi()
|
|
33
|
+
import emailValidator from "@live-change/email-service/clientEmailValidator.js"
|
|
34
|
+
import passwordValidator from "@live-change/password-authentication-service/clientPasswordValidator.js"
|
|
35
|
+
api.validators.email = emailValidator
|
|
36
|
+
api.validators.password = passwordValidator
|
|
37
|
+
|
|
32
38
|
</script>
|
|
@@ -59,12 +59,11 @@
|
|
|
59
59
|
content: props.initialContent,
|
|
60
60
|
version: 0
|
|
61
61
|
}
|
|
62
|
-
|
|
63
|
-
await api.command(['prosemirror', 'createDocument'], documentData)
|
|
62
|
+
documentData = await api.command(['prosemirror', 'createDocumentIfNotExists'], documentData)
|
|
64
63
|
}
|
|
65
64
|
|
|
66
65
|
const extensions = getExtensions(props.config)
|
|
67
|
-
console.log("CONFIG", props.config, 'EXTENSIONS', extensions)
|
|
66
|
+
//console.log("CONFIG", props.config, 'EXTENSIONS', extensions)
|
|
68
67
|
const editor = useEditor({
|
|
69
68
|
content: documentData.content,
|
|
70
69
|
extensions: [
|
|
@@ -80,22 +79,64 @@
|
|
|
80
79
|
}
|
|
81
80
|
})
|
|
82
81
|
|
|
83
|
-
|
|
82
|
+
let sentSteps = []
|
|
83
|
+
let sentVersion = 0
|
|
84
|
+
|
|
85
|
+
const sleep = (ms) => new Promise(resolve => setTimeout(resolve, ms))
|
|
86
|
+
|
|
87
|
+
async function save() {
|
|
84
88
|
const state = editor.value.reactiveState.value
|
|
85
89
|
const sendable = sendableSteps(state)
|
|
86
90
|
if(sendable) {
|
|
91
|
+
let version = sendable.version
|
|
92
|
+
let firstOriginalStepIndex = 0
|
|
93
|
+
let resynchronization = false
|
|
87
94
|
console.log("SENDABLE STEPS", sendable)
|
|
88
|
-
const serializedSteps = sendable.steps.map(step => step.toJSON())
|
|
95
|
+
const serializedSteps = sendable.steps.map((step, index) => ({ version: version + index, step: step.toJSON() }))
|
|
89
96
|
console.log("SERIALIZED STEPS", serializedSteps)
|
|
90
|
-
|
|
97
|
+
if(sendable.version <= sentVersion) { // found resend, check for duplicated steps
|
|
98
|
+
for(let i = 0; i < serializedSteps.length; i++) {
|
|
99
|
+
const step = serializedSteps[i]
|
|
100
|
+
const sentStep = sentSteps.find(({ version }) => version == step.version)
|
|
101
|
+
if(sentStep) {
|
|
102
|
+
console.log('FOUND SENT STEP WITH THE SAME VERSION', sentStep, '==', step)
|
|
103
|
+
if(JSON.stringify(sentStep) != JSON.stringify(step)) {
|
|
104
|
+
resynchronization = true
|
|
105
|
+
break
|
|
106
|
+
}
|
|
107
|
+
firstOriginalStepIndex = i + 1
|
|
108
|
+
} else break
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
serializedSteps.splice(0, firstOriginalStepIndex)
|
|
112
|
+
if(resynchronization && sentSteps.length > 0) {
|
|
113
|
+
console.log("RESYNCHRONIZATION!")
|
|
114
|
+
const firstVersion = serializedSteps[0].version
|
|
115
|
+
sentSteps = sentSteps.filter(({ version }) => version < firstVersion)
|
|
116
|
+
}
|
|
117
|
+
if(serializedSteps.length == 0) {
|
|
118
|
+
console.log("NOTHING TO SEND")
|
|
119
|
+
return
|
|
120
|
+
}
|
|
121
|
+
sentVersion = serializedSteps[0].version
|
|
122
|
+
sentSteps = sentSteps.concat(serializedSteps)
|
|
123
|
+
if(sentSteps.length > 200) sentSteps = sentSteps.slice(-100)
|
|
124
|
+
const data = {
|
|
91
125
|
document, type: props.type,
|
|
92
|
-
version:
|
|
93
|
-
|
|
126
|
+
version: sentVersion, steps: serializedSteps.map(({ step }) => step), window: api.windowId,
|
|
127
|
+
continuation: firstOriginalStepIndex > 0
|
|
128
|
+
}
|
|
129
|
+
console.log("SEND DATA", data)
|
|
130
|
+
//await sleep(1000)
|
|
131
|
+
await api.command(['prosemirror', 'doSteps'], data)
|
|
94
132
|
}
|
|
95
133
|
}
|
|
96
|
-
|
|
97
134
|
const saveDebounced = useDebounceFn(save, 100)
|
|
98
135
|
|
|
136
|
+
api.source.on('connect', () => {
|
|
137
|
+
save()
|
|
138
|
+
})
|
|
139
|
+
|
|
99
140
|
if(typeof window != 'undefined') {
|
|
100
141
|
const stepsReader = inboxReader(
|
|
101
142
|
(rawPosition, bucketSize) => {
|
|
@@ -123,6 +164,8 @@
|
|
|
123
164
|
)
|
|
124
165
|
onUnmounted(() => stepsReader.dispose())
|
|
125
166
|
}
|
|
167
|
+
|
|
168
|
+
const schemaSpec = ref(getSchemaSpecFromConfig(props.config))
|
|
126
169
|
</script>
|
|
127
170
|
|
|
128
171
|
<style scoped>
|
package/front/src/NavBar.vue
CHANGED
package/front/src/schemaJson.js
CHANGED
package/index.js
CHANGED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import * as config from './front/src/contentConfig.js'
|
|
2
|
+
import * as extensions from './front/src/contentConfigExtensions.js'
|
|
3
|
+
export { config, extensions }
|
|
4
|
+
|
|
5
|
+
import ContentView from "./front/src/ContentView.js"
|
|
6
|
+
export { ContentView }
|
|
7
|
+
|
|
8
|
+
import DocumentEditor from "./front/src/DocumentEditor.vue"
|
|
9
|
+
import Editor from "./front/src/Editor.vue"
|
|
10
|
+
import EditorMenu from "./front/src/EditorMenu.vue"
|
|
11
|
+
import ImageComponent from "./front/src/ImageComponent.vue"
|
|
12
|
+
import ImageNode from "./front/src/ImageNode.js"
|
|
13
|
+
export { DocumentEditor, Editor, EditorMenu, ImageComponent, ImageNode }
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@live-change/wysiwyg-frontend",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.0",
|
|
4
4
|
"scripts": {
|
|
5
5
|
"memDev": "lcli memDev --enableSessions --initScript ./init.js --dbAccess",
|
|
6
6
|
"localDevInit": "rm tmp.db; lcli localDev --enableSessions --initScript ./init.js",
|
|
@@ -21,18 +21,18 @@
|
|
|
21
21
|
},
|
|
22
22
|
"dependencies": {
|
|
23
23
|
"@fortawesome/fontawesome-free": "^6.1.1",
|
|
24
|
-
"@live-change/cli": "0.6.
|
|
25
|
-
"@live-change/dao": "0.5.
|
|
26
|
-
"@live-change/dao-vue3": "0.5.
|
|
27
|
-
"@live-change/dao-websocket": "0.5.
|
|
28
|
-
"@live-change/framework": "0.6.
|
|
29
|
-
"@live-change/password-authentication-service": "0.2.
|
|
30
|
-
"@live-change/prosemirror-service": "0.2.
|
|
31
|
-
"@live-change/secret-code-service": "0.2.
|
|
32
|
-
"@live-change/secret-link-service": "0.2.
|
|
33
|
-
"@live-change/session-service": "0.2.
|
|
34
|
-
"@live-change/vue3-components": "0.2.
|
|
35
|
-
"@live-change/vue3-ssr": "0.2.
|
|
24
|
+
"@live-change/cli": "0.6.14",
|
|
25
|
+
"@live-change/dao": "0.5.6",
|
|
26
|
+
"@live-change/dao-vue3": "0.5.6",
|
|
27
|
+
"@live-change/dao-websocket": "0.5.6",
|
|
28
|
+
"@live-change/framework": "0.6.14",
|
|
29
|
+
"@live-change/password-authentication-service": "0.2.51",
|
|
30
|
+
"@live-change/prosemirror-service": "0.2.51",
|
|
31
|
+
"@live-change/secret-code-service": "0.2.51",
|
|
32
|
+
"@live-change/secret-link-service": "0.2.51",
|
|
33
|
+
"@live-change/session-service": "0.2.51",
|
|
34
|
+
"@live-change/vue3-components": "0.2.15",
|
|
35
|
+
"@live-change/vue3-ssr": "0.2.15",
|
|
36
36
|
"@tiptap/extension-blockquote": "^2.0.0-beta.29",
|
|
37
37
|
"@tiptap/extension-bold": "^2.0.0-beta.28",
|
|
38
38
|
"@tiptap/extension-bullet-list": "^2.0.0-beta.29",
|
|
@@ -73,7 +73,7 @@
|
|
|
73
73
|
"vue3-scroll-border": "0.1.2"
|
|
74
74
|
},
|
|
75
75
|
"devDependencies": {
|
|
76
|
-
"@live-change/codeceptjs-helper": "0.6.
|
|
76
|
+
"@live-change/codeceptjs-helper": "0.6.14",
|
|
77
77
|
"@wdio/selenium-standalone-service": "^7.20.8",
|
|
78
78
|
"codeceptjs": "^3.3.4",
|
|
79
79
|
"generate-password": "1.7.0",
|
|
@@ -85,5 +85,5 @@
|
|
|
85
85
|
"author": "",
|
|
86
86
|
"license": "ISC",
|
|
87
87
|
"description": "",
|
|
88
|
-
"gitHead": "
|
|
88
|
+
"gitHead": "b7109dab79e452d391c00405c9a8108efda660d5"
|
|
89
89
|
}
|
package/server/init.js
CHANGED