forked from opentiny/tiny-vue
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(rich-text-editor): [rich-text-editor] add image drag adjustment (o…
…pentiny#1504) * feat(rich-text-editor): [rich-text-editor] add image drag adjustment to rich-text-editor * fix(rich-text-editor/image-view): change script to uniform writing rules * fix(rich-text-editor/image-view): initialize image size to 400 and optimize insertion of images
- Loading branch information
Showing
5 changed files
with
380 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
Oops, something went wrong.