diff --git a/packages/theme-saas/src/rich-text-editor/index.less b/packages/theme-saas/src/rich-text-editor/index.less index 79f088532..21c6f04d8 100644 --- a/packages/theme-saas/src/rich-text-editor/index.less +++ b/packages/theme-saas/src/rich-text-editor/index.less @@ -633,4 +633,59 @@ border-radius: 8px; } } + + .tiny-image { + &__node__view { + display: inline-block; + margin: 0 5px; + } + + &__view { + position: relative; + box-sizing: border-box; + border: 1px solid transparent; + display: inline-block; + max-width: 100%; + } + + &__handle { + display: inline-block; + width: 10px; + height: 10px; + background: var(--ti-base-color-brand-7); + position: absolute; + } + + &__resize { + border: 2px solid var(--ti-base-color-brand-7); + left: 0; + position: absolute; + top: 0; + z-index: 1; + + &__tl { + left: -5px; + top: -5px; + cursor: nwse-resize; + } + + &__tr { + right: -5px; + top: -5px; + cursor: nesw-resize; + } + + &__bl { + left: -5px; + bottom: -5px; + cursor: nesw-resize; + } + + &__br { + right: -5px; + bottom: -5px; + cursor: nwse-resize; + } + } + } } diff --git a/packages/theme/src/rich-text-editor/index.less b/packages/theme/src/rich-text-editor/index.less index 28c3f19bf..0e9cf68ff 100644 --- a/packages/theme/src/rich-text-editor/index.less +++ b/packages/theme/src/rich-text-editor/index.less @@ -205,8 +205,8 @@ } .isActive { - background-color: rgba(32, 122, 183, 0.5); - border-color: rgba(32, 122, 183, 0.5); + background-color: rgb(32 122 183 / 50%); + border-color: rgb(32 122 183 / 50%); } } } @@ -274,9 +274,8 @@ input { position: absolute; - width: 100%; height: 100%; - left: 0px; + left: 0; opacity: 0; width: 0; } @@ -286,15 +285,15 @@ .line-height-button { position: relative; - .line-height-options { - position: absolute; - padding: 0.15rem; - background-color: var(--ti-rich-text-editor-options-bg-color); - left: 0; - display: none; - border-radius: var(--ti-rich-text-editor-options-border-radius); - box-shadow: var(--ti-rich-text-editor-options-box-shadow); - z-index: 999; + .line-height-options { + position: absolute; + padding: 0.15rem; + background-color: var(--ti-rich-text-editor-options-bg-color); + left: 0; + display: none; + border-radius: var(--ti-rich-text-editor-options-border-radius); + box-shadow: var(--ti-rich-text-editor-options-box-shadow); + z-index: 999; button { color: black; @@ -419,7 +418,6 @@ img { max-width: 100%; - height: auto; } blockquote { @@ -636,4 +634,59 @@ border-radius: 8px; } } + + .tiny-image { + &__node__view { + display: inline-block; + margin: 0 5px; + } + + &__view { + position: relative; + box-sizing: border-box; + border: 1px solid transparent; + display: inline-block; + max-width: 100%; + } + + &__handle { + display: inline-block; + width: 10px; + height: 10px; + background: var(--ti-base-color-brand-7); + position: absolute; + } + + &__resize { + border: 2px solid var(--ti-base-color-brand-7); + left: 0; + position: absolute; + top: 0; + z-index: 1; + + &__tl { + left: -5px; + top: -5px; + cursor: nwse-resize; + } + + &__tr { + right: -5px; + top: -5px; + cursor: nesw-resize; + } + + &__bl { + left: -5px; + bottom: -5px; + cursor: nesw-resize; + } + + &__br { + right: -5px; + bottom: -5px; + cursor: nwse-resize; + } + } + } } diff --git a/packages/vue/src/rich-text-editor/src/extensions/image.ts b/packages/vue/src/rich-text-editor/src/extensions/image.ts new file mode 100644 index 000000000..dfc092794 --- /dev/null +++ b/packages/vue/src/rich-text-editor/src/extensions/image.ts @@ -0,0 +1,55 @@ +import { VueNodeViewRenderer } from '@tiptap/vue-3' +import TiptapImage from '@tiptap/extension-image' +import ImageView from '../image-view.vue' + +const Image = TiptapImage.extend({ + inline() { + return true + }, + group() { + return 'inline' + }, + addAttributes() { + return { + ...this.parent?.(), + width: { + default: 500, + parseHTML(element) { + const width = element.style.width || element.getAttribute('width') + return width + }, + renderHTML: (attributes) => { + const { width } = attributes + return { + width + } + } + }, + height: { + default: 500, + parseHTML(element) { + const height = element.style.height || element.getAttribute('height') + return height + }, + renderHTML: (attributes) => { + const { height } = attributes + return { + height + } + } + } + } + }, + addNodeView() { + return VueNodeViewRenderer(ImageView) + }, + parseHTML() { + return [ + { + tag: 'img[src]' + } + ] + } +}) + +export default Image diff --git a/packages/vue/src/rich-text-editor/src/image-view.vue b/packages/vue/src/rich-text-editor/src/image-view.vue new file mode 100644 index 000000000..d9efbc4b8 --- /dev/null +++ b/packages/vue/src/rich-text-editor/src/image-view.vue @@ -0,0 +1,201 @@ + + + diff --git a/packages/vue/src/rich-text-editor/src/pc.vue b/packages/vue/src/rich-text-editor/src/pc.vue index f58e576fc..9ca1a7b14 100644 --- a/packages/vue/src/rich-text-editor/src/pc.vue +++ b/packages/vue/src/rich-text-editor/src/pc.vue @@ -311,7 +311,8 @@ import Paragraph from '@tiptap/extension-paragraph' import { mergeAttributes } from '@tiptap/core' // image 包 -import Image from '@tiptap/extension-image' +// import Image from '@tiptap/extension-image' +import Image from './extensions/image' // -- HeighLight import Highlight from '@tiptap/extension-highlight'