@live-change/wysiwyg-frontend 0.2.57 → 0.3.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.
@@ -0,0 +1,22 @@
1
+ /* eslint-disable */
2
+ /* prettier-ignore */
3
+ // @ts-nocheck
4
+ // Generated by unplugin-vue-components
5
+ // Read more: https://github.com/vuejs/core/pull/3399
6
+ export {}
7
+
8
+ declare module 'vue' {
9
+ export interface GlobalComponents {
10
+ DocumentEditor: typeof import('./src/components/DocumentEditor.vue')['default']
11
+ Editor: typeof import('./src/components/Editor.vue')['default']
12
+ EditorMenu: typeof import('./src/components/EditorMenu.vue')['default']
13
+ EmptyComponent: typeof import('./src/components/EmptyComponent.vue')['default']
14
+ LinkEditor: typeof import('./src/components/LinkEditor.vue')['default']
15
+ PaddingEditor: typeof import('./src/components/PaddingEditor.vue')['default']
16
+ RouterLink: typeof import('vue-router')['RouterLink']
17
+ RouterView: typeof import('vue-router')['RouterView']
18
+ SettingsEditor: typeof import('./src/components/SettingsEditor.vue')['default']
19
+ StyleEditor: typeof import('./src/components/StyleEditor.vue')['default']
20
+ TemplatesMenu: typeof import('./src/components/TemplatesMenu.vue')['default']
21
+ }
22
+ }
@@ -32,11 +32,12 @@
32
32
  <div class="flex flex-row flex-shrink-0">
33
33
  <label class="my-2 flex-grow-1">Style:</label>
34
34
  </div>
35
- <prism-editor v-if="isMounted"
35
+ <div class="style-editor p-inputtext flex-grow-1" ref="codeMirrorWrapper"></div>
36
+ <!-- <prism-editor v-if="isMounted"
36
37
  class="style-editor p-inputtext flex-grow-1" :highlight="highlightCss"
37
38
  :style="{ height: (nodeStyleLines * 1.35 + 1.1) + 'em' }"
38
39
  :modelValue="nodeStyle" @update:modelValue="handleStyleUpdate"
39
- :readonly="false" :line-numbers="nodeStyleLines > 1" />
40
+ :readonly="false" :line-numbers="nodeStyleLines > 1" />-->
40
41
  </div>
41
42
  </div>
42
43
  </div>
@@ -48,15 +49,15 @@
48
49
 
49
50
  import PaddingEditor from "./PaddingEditor.vue"
50
51
 
51
- import 'vue-prism-editor/dist/prismeditor.min.css'
52
- import 'prismjs/themes/prism-coy.css'
53
- import * as Prism from 'prismjs/components/prism-core'
54
- import 'prismjs/components/prism-css'
52
+ import { EditorState as CMState } from '@codemirror/state'
53
+ import { EditorView as CMView, keymap as cmKeymap, drawSelection } from '@codemirror/view'
54
+ import {css} from "@codemirror/lang-css"
55
55
 
56
- import { PrismEditor } from 'vue-prism-editor'
57
-
58
- import {ref, computed, watch, provide, defineEmits, defineProps, onMounted} from 'vue'
59
- import { toRefs } from '@vueuse/core'
56
+ import { ref, computed, watch, provide, defineEmits, defineProps, onMounted, toRefs } from 'vue'
57
+ import {defaultKeymap} from "@codemirror/commands";
58
+ import {defaultHighlightStyle, syntaxHighlighting} from "@codemirror/language";
59
+ import {exitCode} from "@tiptap/pm/commands";
60
+ import {redo, undo} from "@tiptap/pm/history";
60
61
 
61
62
  const isMounted = ref(false)
62
63
  onMounted(() => isMounted.value = true)
@@ -151,9 +152,7 @@
151
152
  return nodeControl.value.attrs.style
152
153
  })
153
154
  const nodeStyleLines = computed(() => (nodeStyle.value || '').split('\n').length)
154
- function highlightCss(code) {
155
- return Prism.highlight(code, Prism.languages.css, "css")
156
- }
155
+
157
156
  function handleStyleUpdate(style) {
158
157
  console.log("NC", nodeControl.value)
159
158
  nodeControl.value.updateAttributes({ attrs: {
@@ -162,18 +161,63 @@
162
161
  }})
163
162
  }
164
163
 
164
+
165
+ const codeMirrorWrapper = ref()
166
+
167
+ let cmView, cmState
168
+
169
+ const dispatch = (tr) => {
170
+ console.log("TR", tr)
171
+ cmView.setState(tr.state)
172
+ if(tr.docChanged) handleStyleUpdate(tr.newDoc.toString())
173
+ }
174
+
175
+ onMounted(() => {
176
+ //console.log("WRAPPER", codeMirrorWrapper.value)
177
+ cmView = new CMView({
178
+ dispatch,
179
+ parent: codeMirrorWrapper.value,
180
+ })
181
+ cmState = CMState.create({
182
+ doc: nodeStyle.value || '',
183
+ extensions: [
184
+ cmKeymap.of([
185
+ ...defaultKeymap,
186
+ ...[
187
+ { key: "Ctrl-z", mac: "Cmd-z", run: () => undo(view.state, view.dispatch) },
188
+ { key: "Shift-Ctrl-z", mac: "Shift-Cmd-z", run: () => redo(view.state, view.dispatch) },
189
+ { key: "Ctrl-y", mac: "Cmd-y", run: () => redo(view.state, view.dispatch) }
190
+ ]
191
+ ]),
192
+ drawSelection(),
193
+ syntaxHighlighting(defaultHighlightStyle),
194
+ css(),
195
+ ],
196
+ })
197
+ })
198
+
165
199
  </script>
166
200
 
167
201
  <style lang="scss">
168
202
  .autocomplete-w-full > ul {
169
203
  width: 100%;
170
204
  }
171
- .prism-editor__textarea {
172
- outline: 0 none;
173
- outline-offset: 0;
174
- }
175
205
  .style-editor:focus-within {
176
206
  box-shadow: 0 0 0 0.2rem #b7e0b8;
177
207
  border-color: #4CAF50;
178
208
  }
209
+ .style-editor {
210
+ display: flex;
211
+ flex-direction: column;
212
+ align-items: stretch;
213
+ padding: 0;
214
+ & > .cm-editor {
215
+ margin: 0;
216
+ padding: 0.5em;
217
+ }
218
+ .cm-focused {
219
+ outline: none;
220
+ }
221
+ }
222
+
179
223
  </style>
@@ -146,21 +146,18 @@ class CodeBlockView {
146
146
  codeMirrorKeymap() {
147
147
  let view = this.view
148
148
  return [
149
- {key: "ArrowUp", run: this.maybeEscape("line", -1)},
150
- {key: "ArrowLeft", run: this.maybeEscape("char", -1)},
151
- {key: "ArrowDown", run: this.maybeEscape("line", 1)},
152
- {key: "ArrowRight", run: this.maybeEscape("char", 1)},
153
- {key: "Ctrl-Enter", run: () => {
149
+ { key: "ArrowUp", run: this.maybeEscape("line", -1)},
150
+ { key: "ArrowLeft", run: this.maybeEscape("char", -1)},
151
+ { key: "ArrowDown", run: this.maybeEscape("line", 1)},
152
+ { key: "ArrowRight", run: this.maybeEscape("char", 1)},
153
+ { key: "Ctrl-Enter", run: () => {
154
154
  if (!exitCode(view.state, view.dispatch)) return false
155
155
  view.focus()
156
156
  return true
157
157
  }},
158
- {key: "Ctrl-z", mac: "Cmd-z",
159
- run: () => undo(view.state, view.dispatch)},
160
- {key: "Shift-Ctrl-z", mac: "Shift-Cmd-z",
161
- run: () => redo(view.state, view.dispatch)},
162
- {key: "Ctrl-y", mac: "Cmd-y",
163
- run: () => redo(view.state, view.dispatch)}
158
+ { key: "Ctrl-z", mac: "Cmd-z", run: () => undo(view.state, view.dispatch) },
159
+ { key: "Shift-Ctrl-z", mac: "Shift-Cmd-z", run: () => redo(view.state, view.dispatch) },
160
+ { key: "Ctrl-y", mac: "Cmd-y", run: () => redo(view.state, view.dispatch) }
164
161
  ]
165
162
  }
166
163
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@live-change/wysiwyg-frontend",
3
- "version": "0.2.57",
3
+ "version": "0.3.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,6 +21,7 @@
21
21
  },
22
22
  "dependencies": {
23
23
  "@codemirror/commands": "^6.1.2",
24
+ "@codemirror/lang-css": "^6.2.1",
24
25
  "@codemirror/lang-javascript": "^6.1.2",
25
26
  "@codemirror/language": "^6.1.2",
26
27
  "@codemirror/view": "^6.7.1",
@@ -93,5 +94,5 @@
93
94
  "author": "",
94
95
  "license": "ISC",
95
96
  "description": "",
96
- "gitHead": "1e6eb5611e366432319359c48025d6a3ddce059e"
97
+ "gitHead": "ad1cf7e6deb52afdc69eb4748656f121417d31b3"
97
98
  }