Merge branch 'master' of code.gitlink.org.cn:zolo2468216537/coeditor

master
joefalmko 1 month ago
commit baa9131710

@ -8,8 +8,8 @@ import (
"goskeleton/app/http/validator/core/data_transfer"
"goskeleton/app/utils/response"
"image"
_ "image/jpeg"
"math"
"github.com/gin-gonic/gin"
)
@ -50,6 +50,7 @@ func (p PicRecognition) CheckParams(context *gin.Context) {
// 将字节数据转换为图像以检查格式和尺寸
img, _, err := image.Decode(bytes.NewReader(decodedData))
if err != nil {
response.ErrorSystem(context, "PicRecognition表单参数验证器图片格式不正确", "")
return
}
bounds := img.Bounds()

@ -20,7 +20,7 @@
"jquery": "^3.7.1",
"jwt-decode": "^4.0.0",
"mitt": "^3.0.1",
"vue": "^3.2.13",
"vue": "^3.5.13",
"vue-router": "^4.0.3",
"vuex": "^4.0.0"
},
@ -8689,7 +8689,7 @@
},
"node_modules/mitt": {
"version": "3.0.1",
"resolved": "https://registry.npmjs.org/mitt/-/mitt-3.0.1.tgz",
"resolved": "https://registry.npmmirror.com/mitt/-/mitt-3.0.1.tgz",
"integrity": "sha512-vKivATfr97l2/QBCYAkXYDbrIWPM2IIKEl7YPhjCvKlG3kE2gm+uBo6nEXK3M5/Ffh/FLpKExzOQ3JJoJGFKBw=="
},
"node_modules/mkdirp": {

@ -608,20 +608,18 @@ class AiFormat extends Plugin {
}
// 智能识别发送消息
function sendRecMsg(type) {
const selection = window.getSelection();
function sendRecMsg(type, editor) {
//const selection = window.getSelection();
// const editor = this.editor;
const model = editor.model;
const imageUtils=editor.plugins.get( 'ImageUtils' );
const imageElement = imageUtils.getClosestSelectedImageElement( model.document.selection );
const formData = new FormData();
var src = '';
if (type === 'pic_recognition') {
const range = selection.getRangeAt(0);
const imageElements = range.commonAncestorContainer.parentNode.querySelectorAll('img');
if (imageElements.length > 0) {
const selectedImage = imageElements[0];
src = selectedImage.getAttribute('src');
const prefix = "data:image/png;base64,";
if (src.startsWith(prefix)) {
src = src.substring(prefix.length);
}
if (imageElement) {
var imageSrc = imageElement.getAttribute('src');
src = imageSrc.replace(/^data:image\/\w+;base64,/, "");
}
if (src.trim() === '') return;
formData.append('pic', src);
@ -682,7 +680,7 @@ class PicRecog extends Plugin {
// Execute a callback function when the button is clicked
button.on('execute', () => {
sendRecMsg('pic_recognition');
sendRecMsg('pic_recognition', this.editor);
});
return button;

@ -44,7 +44,7 @@ export default {
const register = () => {
$.ajax({
url:'http://47.106.113.194:8000/register/',
url:'http://1.94.171.222:8000/register/',
type:'post',
data:{
username:username.value,

Loading…
Cancel
Save