@witchcraft/editor 0.1.1 → 0.2.1

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.
Files changed (42) hide show
  1. package/README.md +1 -0
  2. package/dist/module.d.mts +1 -1
  3. package/dist/module.json +1 -1
  4. package/dist/module.mjs +2 -2
  5. package/dist/runtime/components/EditorDemoApp.vue +31 -1
  6. package/dist/runtime/components/EditorDemoControls.d.vue.ts +3 -0
  7. package/dist/runtime/components/EditorDemoControls.vue +55 -12
  8. package/dist/runtime/components/EditorDemoControls.vue.d.ts +3 -0
  9. package/dist/runtime/pm/features/Base/plugins/debugSelectionPlugin.d.ts +1 -5
  10. package/dist/runtime/pm/features/Base/plugins/debugSelectionPlugin.js +43 -17
  11. package/dist/runtime/pm/features/CodeBlock/components/CodeBlockView.vue +0 -1
  12. package/dist/runtime/pm/features/Collaboration/Collaboration.d.ts +14 -63
  13. package/dist/runtime/pm/features/Collaboration/Collaboration.js +4 -164
  14. package/dist/runtime/pm/features/Collaboration/createCollaborationPlugins.d.ts +16 -0
  15. package/dist/runtime/pm/features/Collaboration/createCollaborationPlugins.js +85 -0
  16. package/dist/runtime/pm/features/DocumentApi/DocumentApi.d.ts +16 -3
  17. package/dist/runtime/pm/features/DocumentApi/DocumentApi.js +19 -2
  18. package/dist/runtime/pm/features/DocumentApi/composables/useEditorContent.js +8 -2
  19. package/dist/runtime/pm/features/DocumentApi/composables/useTestDocumentApi.d.ts +4 -1
  20. package/dist/runtime/pm/features/DocumentApi/composables/useTestDocumentApi.js +39 -8
  21. package/dist/runtime/pm/features/DocumentApi/types.d.ts +26 -48
  22. package/dist/runtime/pm/features/Link/components/BubbleMenuExternalLink.vue +0 -2
  23. package/dist/runtime/pm/features/Link/components/BubbleMenuInternalLink.vue +0 -1
  24. package/package.json +38 -37
  25. package/src/module.ts +3 -3
  26. package/src/runtime/components/EditorDemoApp.vue +32 -1
  27. package/src/runtime/components/EditorDemoControls.vue +57 -12
  28. package/src/runtime/pm/features/Base/plugins/debugSelectionPlugin.ts +53 -28
  29. package/src/runtime/pm/features/CodeBlock/components/CodeBlockView.vue +0 -1
  30. package/src/runtime/pm/features/Collaboration/Collaboration.ts +19 -286
  31. package/src/runtime/pm/features/Collaboration/createCollaborationPlugins.ts +132 -0
  32. package/src/runtime/pm/features/DocumentApi/DocumentApi.ts +35 -5
  33. package/src/runtime/pm/features/DocumentApi/composables/useEditorContent.ts +8 -2
  34. package/src/runtime/pm/features/DocumentApi/composables/useTestDocumentApi.ts +56 -8
  35. package/src/runtime/pm/features/DocumentApi/types.ts +30 -52
  36. package/src/runtime/pm/features/Link/components/BubbleMenuExternalLink.vue +0 -2
  37. package/src/runtime/pm/features/Link/components/BubbleMenuInternalLink.vue +0 -1
  38. package/src/runtime/pm/utils/generator/createPsuedoSentence.ts +1 -1
  39. package/dist/runtime/demo/App.d.vue.ts +0 -3
  40. package/dist/runtime/demo/App.vue +0 -100
  41. package/dist/runtime/demo/App.vue.d.ts +0 -3
  42. package/src/runtime/demo/App.vue +0 -113
@@ -1,113 +0,0 @@
1
- <template>
2
- <WRoot class="items-center py-4">
3
- <style>
4
- {{ codeBlocksThemeCss.join("\n") }}
5
- </style>
6
- <DemoControls
7
- :code-blocks-theme-list="codeBlocksThemeList"
8
- v-model:code-blocks-theme="codeBlocksTheme"
9
- @blur="blur"
10
- />
11
- <Editor
12
- class="max-w-[700px] flex-1 max-h-[700px] flex"
13
- v-bind="{
14
- codeBlocksThemeIsDark,
15
- cssVariables: {
16
- pmCodeBlockBgColor: codeBlocksThemeBgColor
17
- },
18
- docId,
19
- documentApi,
20
- linkOptions,
21
- editorOptions,
22
- menus
23
- }"
24
- />
25
- <div class="py-[50px]"/>
26
- </WRoot>
27
- </template>
28
-
29
- <script setup lang="ts">
30
- import type { EditorOptions } from "@tiptap/core"
31
- import WRoot from "@witchcraft/ui/components/LibRoot"
32
- import { nextTick, reactive, ref, shallowRef } from "vue"
33
-
34
- import Editor from "../components/Editor.vue"
35
- import DemoControls from "../components/EditorDemoControls.vue"
36
- import { useHighlightJsTheme } from "../pm/features/CodeBlock/composables/useHighlightJsTheme.js"
37
- import { defaultCommandBarMenuItems } from "../pm/features/CommandsMenus/commandBarMenuItems"
38
- import CommandBar from "../pm/features/CommandsMenus/components/CommandBar.vue"
39
- import { useTestDocumentApi } from "../pm/features/DocumentApi/composables/useTestDocumentApi.js"
40
- import BubbleMenuLink from "../pm/features/Link/components/BubbleMenuLink.vue"
41
- import type { EditorLinkOptions } from "../pm/features/Link/types.js"
42
- import type { MenuRenderInfo } from "../pm/features/Menus/types"
43
- import { testExtensions } from "../pm/testSchema.js"
44
- import { testDocuments } from "../testDocuments"
45
-
46
- const {
47
- theme: codeBlocksTheme,
48
- knownThemes: codeBlocksThemeList,
49
- themeCss: codeBlocksThemeCss,
50
- isDark: codeBlocksThemeIsDark,
51
- backgroundColor: codeBlocksThemeBgColor
52
- } = useHighlightJsTheme()
53
-
54
- function blur(): void {
55
- const was = codeBlocksTheme.value
56
- codeBlocksTheme.value = ""
57
- nextTick(() => {
58
- codeBlocksTheme.value = was
59
- })
60
- }
61
-
62
- const editorOptions: Partial<EditorOptions> = {
63
- extensions: testExtensions as any
64
- }
65
-
66
- const linkOptions: EditorLinkOptions = {
67
- openInternal: href => {
68
- window.alert(`This would open an internal link to ${href}.`)
69
-
70
- // eslint-disable-next-line no-console
71
- console.log(`Would open internal link to ${href}.`)
72
- }
73
- }
74
- const fakeSuggestions = reactive<string[]>(["some", "suggestions"])
75
-
76
- const menus = shallowRef<Record<string, MenuRenderInfo>>({
77
- linkMenu: {
78
- component: BubbleMenuLink,
79
- props: editor => ({
80
- editor,
81
- linkSuggestions: fakeSuggestions,
82
- getInternalLinkHref(href: string) {
83
- return `internal://${href.replace(/[^\w-]/g, "")}`
84
- }
85
- })
86
- },
87
- commandBar: {
88
- component: CommandBar,
89
- props: editor => ({
90
- editor,
91
- commands: defaultCommandBarMenuItems.commands
92
- }),
93
- popupOptions: {
94
- pinToItemDistance: state => {
95
- const { $from, $to } = state.selection
96
- const fromNode = $from.node(-1)
97
- const toNode = $to.node(-1)
98
- // tables don't support selections outside of each cell, so no need to check we're in the same table or anything
99
- if (fromNode.type !== toNode.type) {
100
- return 0
101
- }
102
- return (fromNode.type.name.startsWith("table")) ? 120 : 0
103
- }
104
- }
105
- }
106
- })
107
-
108
- const { documentApi } = useTestDocumentApi(
109
- editorOptions as any,
110
- testDocuments
111
- )
112
- const docId = ref("root")
113
- </script>