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
52 changes: 18 additions & 34 deletions packages/renderless/src/rich-text-edtior/vue.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,6 @@ export const renderless = (
{ vm, emit, parent },
{
Editor,
Collaboration,
CodehighComp,
Y,
WebrtcProvider,
StarterKit,
Table,
TableCell,
Expand All @@ -57,9 +53,10 @@ export const renderless = (
CodeBlockLowlight,
lowlight,
VueNodeViewRenderer,
NodeViewContent,
nodeViewProps,
NodeViewWrapper,
// CodehighComp,
// NodeViewContent,
// nodeViewProps,
// NodeViewWrapper,
Placeholder,
codeHighlight
}
Expand Down Expand Up @@ -98,8 +95,6 @@ export const renderless = (
if (props.customToolBar) {
toolBar = props.customToolBar
}
let ydoc = null
let provider = null
// 自定义图片
const CustomImage = Image.extend({
addAttributes() {
Expand Down Expand Up @@ -140,9 +135,9 @@ export const renderless = (
return {
setP:
(attributes) =>
({ commands }) => {
return commands.setNode(this.name, attributes)
}
({ commands }) => {
return commands.setNode(this.name, attributes)
}
}
}
})
Expand All @@ -168,9 +163,9 @@ export const renderless = (
return {
setSize:
(attributes) =>
({ commands }) => {
return commands.setNode(this.name, attributes)
}
({ commands }) => {
return commands.setNode(this.name, attributes)
}
}
}
})
Expand All @@ -179,24 +174,24 @@ export const renderless = (
return {
bgColor: {
default: null,
renderHTML: attributes => {
renderHTML: (attributes) => {
if (!attributes.bgColor) {
return {}
}
return {
style: `background: ${attributes.bgColor}`,
style: `background: ${attributes.bgColor}`
}
},
}
}
}
},
addCommands() {
return {
setBackColor:
attributes =>
({ commands }) => {
return commands.setMark(this.name, attributes)
}
(attributes) =>
({ commands }) => {
return commands.setMark(this.name, attributes)
}
}
}
})
Expand Down Expand Up @@ -281,18 +276,7 @@ export const renderless = (
},
...props.options
}
if (props.Collaboration) {
if (!window._yDoc) {
window._yDoc = new Y.Doc()
}
ydoc = window._yDoc
provider = new WebrtcProvider('tiny-examsple-document', ydoc)
defaultOptions.extensions.push(
Collaboration?.configure({
document: ydoc
}),
)
}

let options = props.options ? Object.assign(defaultOptions, props.options) : defaultOptions
const editor = new Editor(options)

Expand Down
5 changes: 1 addition & 4 deletions packages/vue/src/rich-text-editor/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,6 @@
"@tiptap/vue-2": "^2.1.10",
"@tiptap/vue-3": "^2.0.4",
"highlight.js": "^11.8.0",
"lowlight": "^2.9.0",
"y-prosemirror": "^1.2.1",
"y-webrtc": "^10.2.5",
"yjs": "^13.6.7"
"lowlight": "^2.9.0"
}
}
41 changes: 0 additions & 41 deletions packages/vue/src/rich-text-editor/src/code-highlight.tsx

This file was deleted.

39 changes: 19 additions & 20 deletions packages/vue/src/rich-text-editor/src/pc.vue
Original file line number Diff line number Diff line change
Expand Up @@ -287,10 +287,10 @@ import {
Editor,
EditorContent,
BubbleMenu,
VueNodeViewRenderer,
NodeViewContent,
nodeViewProps,
NodeViewWrapper
VueNodeViewRenderer
// NodeViewContent,
// nodeViewProps,
// NodeViewWrapper
} from '@tiptap/vue'
import StarterKit from '@tiptap/starter-kit'
// 段落包
Expand Down Expand Up @@ -327,21 +327,23 @@ import js from 'highlight.js/lib/languages/javascript'
import ts from 'highlight.js/lib/languages/typescript'
import html from 'highlight.js/lib/languages/xml'
import { lowlight } from 'lowlight'
lowlight.registerLanguage('html', html)
lowlight.registerLanguage('css', css)
lowlight.registerLanguage('js', js)
lowlight.registerLanguage('ts', ts)

function initLowLight() {
lowlight.registerLanguage('html', html)
lowlight.registerLanguage('css', css)
lowlight.registerLanguage('js', js)
lowlight.registerLanguage('ts', ts)
}
/* @__PURE__ */
initLowLight()

// Placeholder
import Placeholder from '@tiptap/extension-placeholder'
// collaboration 包
import Collaboration from '@tiptap/extension-collaboration'
import * as Y from 'yjs'
import { WebrtcProvider } from 'y-webrtc'

import { props, setup, defineComponent, $prefix } from '@opentiny/vue-common'
import { t } from '@opentiny/vue-locale'
import '@opentiny/vue-theme/rich-text-editor/index.less'
import Codehighlight from './code-highlight'
// import Codehighlight from './code-highlight.vue'

export default defineComponent({
name: $prefix + 'RichTextEditor',
Expand Down Expand Up @@ -417,10 +419,7 @@ export default defineComponent({
mono: true,
extendOptions: {
Editor,
Collaboration,
StarterKit,
Y,
WebrtcProvider,
Table,
TableCell,
TableHeader,
Expand All @@ -441,10 +440,10 @@ export default defineComponent({
CodeBlockLowlight,
lowlight,
VueNodeViewRenderer,
CodehighComp: VueNodeViewRenderer(Codehighlight(NodeViewContent, nodeViewProps, NodeViewWrapper)),
NodeViewContent,
nodeViewProps,
NodeViewWrapper,
// CodehighComp: VueNodeViewRenderer(Codehighlight(NodeViewContent, nodeViewProps, NodeViewWrapper)),
// NodeViewContent,
// nodeViewProps,
// NodeViewWrapper,
Placeholder,
codeHighlight
}
Expand Down