Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
lib
react-ag-qeditor
Commits
c25fc29a
Commit
c25fc29a
authored
Jul 29, 2025
by
Яков
Browse files
update
parent
7353b25c
Changes
2
Hide whitespace changes
Inline
Side-by-side
package.json
View file @
c25fc29a
{
{
"name"
:
"react-ag-qeditor"
,
"name"
:
"react-ag-qeditor"
,
"version"
:
"1.1.1
2
"
,
"version"
:
"1.1.1
3
"
,
"description"
:
"WYSIWYG html editor"
,
"description"
:
"WYSIWYG html editor"
,
"author"
:
"atma"
,
"author"
:
"atma"
,
"license"
:
"
MIT
"
,
"license"
:
"
MIT
"
,
...
...
src/extensions/Image.jsx
View file @
c25fc29a
import
{
NodeViewWrapper
,
ReactNodeViewRenderer
}
from
"
@tiptap/react
"
;
import
{
NodeViewWrapper
,
ReactNodeViewRenderer
}
from
"
@tiptap/react
"
;
import
React
,
{
useEffect
,
useRef
,
useState
,
Fragment
}
from
"
react
"
;
import
React
,
{
useEffect
,
useRef
,
useState
,
Fragment
}
from
"
react
"
;
import
TipTapImage
from
"
@tiptap/extension-image
"
;
import
TipTapImage
from
"
@tiptap/extension-image
"
;
import
{
Button
,
Modal
,
Input
}
from
'
antd
'
;
import
{
Button
,
Modal
,
Input
,
Typography
}
from
'
antd
'
;
import
{
FontSizeOutlined
}
from
"
@ant-design/icons
"
;
import
{
FontSizeOutlined
}
from
"
@ant-design/icons
"
;
const
{
TextArea
}
=
Input
;
const
{
TextArea
}
=
Input
;
const
{
Text
}
=
Typography
;
const
MIN_WIDTH
=
60
;
const
MIN_WIDTH
=
60
;
const
BORDER_COLOR
=
'
#0096fd
'
;
const
BORDER_COLOR
=
'
#0096fd
'
;
...
@@ -18,6 +18,7 @@ const ResizableImageTemplate = ({ node, updateAttributes, editor, getPos, select
...
@@ -18,6 +18,7 @@ const ResizableImageTemplate = ({ node, updateAttributes, editor, getPos, select
const
[
isResizing
,
setIsResizing
]
=
useState
(
false
);
const
[
isResizing
,
setIsResizing
]
=
useState
(
false
);
const
[
altModalVisible
,
setAltModalVisible
]
=
useState
(
false
);
const
[
altModalVisible
,
setAltModalVisible
]
=
useState
(
false
);
const
[
tempAlt
,
setTempAlt
]
=
useState
(
node
.
attrs
.
alt
||
''
);
const
[
tempAlt
,
setTempAlt
]
=
useState
(
node
.
attrs
.
alt
||
''
);
const
[
tempFrontAlt
,
setTempFrontAlt
]
=
useState
(
node
.
attrs
.
frontAlt
||
''
);
// Добавляем прозрачный нулевой пробел после изображения
// Добавляем прозрачный нулевой пробел после изображения
...
@@ -361,6 +362,7 @@ const ResizableImageTemplate = ({ node, updateAttributes, editor, getPos, select
...
@@ -361,6 +362,7 @@ const ResizableImageTemplate = ({ node, updateAttributes, editor, getPos, select
objectFit
:
'
contain
'
objectFit
:
'
contain
'
});
});
console
.
log
(
node
.
attrs
.
frontAlt
);
return
(
return
(
<
NodeViewWrapper
<
NodeViewWrapper
as
=
"div"
as
=
"div"
...
@@ -401,14 +403,35 @@ const ResizableImageTemplate = ({ node, updateAttributes, editor, getPos, select
...
@@ -401,14 +403,35 @@ const ResizableImageTemplate = ({ node, updateAttributes, editor, getPos, select
}
}
}
}
}
}
/>
/>
{
node
.
attrs
.
frontAlt
?.
length
>
0
&&
<
div
style
=
{
{
backgroundColor
:
'
#FDE674
'
,
borderRadius
:
'
35px
'
,
padding
:
'
5px 25px
'
,
textAlign
:
'
center
'
,
color
:
'
#000000D9
'
,
position
:
'
absolute
'
,
left
:
'
50%
'
,
transform
:
'
translateX(-50%)
'
,
fontSize
:
'
12px
'
,
lineHeight
:
'
16px
'
,
letterSpacing
:
'
2%
'
,
fontWeight
:
'
500
'
,
bottom
:
'
10px
'
,
whiteSpace
:
'
pre-line
'
}
}
>
{
node
.
attrs
.
frontAlt
}
</
div
>
}
<
Button
<
Button
size
=
"default"
size
=
"default"
shape
=
{
'
circle
'
}
shape
=
{
'
circle
'
}
type
=
{
node
.
attrs
.
alt
?.
length
>
0
?
'
primary
'
:
'
default
'
}
type
=
{
node
.
attrs
.
alt
?.
length
>
0
||
node
.
attrs
.
frontAlt
?.
length
?
'
primary
'
:
'
default
'
}
onClick
=
{
(
e
)
=>
{
onClick
=
{
(
e
)
=>
{
e
.
stopPropagation
();
e
.
stopPropagation
();
setTempAlt
(
node
.
attrs
.
alt
||
''
);
setTempAlt
(
node
.
attrs
.
alt
||
''
);
setTempFrontAlt
(
node
.
attrs
.
frontAlt
||
''
);
setAltModalVisible
(
true
);
setAltModalVisible
(
true
);
}
}
}
}
style
=
{
{
style
=
{
{
...
@@ -534,21 +557,29 @@ const ResizableImageTemplate = ({ node, updateAttributes, editor, getPos, select
...
@@ -534,21 +557,29 @@ const ResizableImageTemplate = ({ node, updateAttributes, editor, getPos, select
</
Fragment
>
</
Fragment
>
)
}
)
}
<
Modal
<
Modal
title
=
"Текст
овая сторона
"
title
=
"Текст
на картинке
"
open
=
{
altModalVisible
}
open
=
{
altModalVisible
}
onOk
=
{
()
=>
{
onOk
=
{
()
=>
{
updateAttributes
({
alt
:
tempAlt
});
updateAttributes
({
alt
:
tempAlt
,
frontAlt
:
tempFrontAlt
});
setAltModalVisible
(
false
);
setAltModalVisible
(
false
);
}
}
}
}
onCancel
=
{
()
=>
setAltModalVisible
(
false
)
}
onCancel
=
{
()
=>
setAltModalVisible
(
false
)
}
okText
=
"Применить"
okText
=
"Применить"
cancelText
=
"Отмена"
cancelText
=
"Отмена"
>
>
<
div
style
=
{
{
marginBottom
:
'
5px
'
}
}
><
Text
>
Лицевая сторона
</
Text
></
div
>
<
TextArea
value
=
{
tempFrontAlt
}
onChange
=
{
(
e
)
=>
setTempFrontAlt
(
e
.
target
.
value
)
}
rows
=
{
4
}
placeholder
=
"Введите текст"
/>
<
div
style
=
{
{
marginTop
:
'
15px
'
,
marginBottom
:
'
5px
'
}
}
><
Text
>
Обратная сторона
</
Text
></
div
>
<
TextArea
<
TextArea
value
=
{
tempAlt
}
value
=
{
tempAlt
}
onChange
=
{
(
e
)
=>
setTempAlt
(
e
.
target
.
value
)
}
onChange
=
{
(
e
)
=>
setTempAlt
(
e
.
target
.
value
)
}
rows
=
{
4
}
rows
=
{
4
}
placeholder
=
"Введите
alt-
текст
изображения...
"
placeholder
=
"Введите текст"
/>
/>
</
Modal
>
</
Modal
>
</
NodeViewWrapper
>
</
NodeViewWrapper
>
...
@@ -572,6 +603,18 @@ const ResizableImageExtension = TipTapImage.extend({
...
@@ -572,6 +603,18 @@ const ResizableImageExtension = TipTapImage.extend({
:
{}
:
{}
}
}
},
},
frontAlt
:
{
default
:
null
,
parseHTML
:
element
=>
{
const
raw
=
element
.
getAttribute
(
'
frontAlt
'
)
return
raw
?.
replace
(
/ /g
,
'
\n
'
)
||
null
},
renderHTML
:
attributes
=>
{
return
attributes
.
frontAlt
?
{
frontAlt
:
attributes
.
frontAlt
.
replace
(
/
\n
/g
,
'
'
)
}
:
{}
}
},
title
:
{
default
:
null
},
title
:
{
default
:
null
},
width
:
{
width
:
{
default
:
null
,
default
:
null
,
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment