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
e6845c5b
Commit
e6845c5b
authored
Apr 17, 2026
by
Яков
Browse files
add change size text
parent
aeacfa26
Changes
3
Show whitespace changes
Inline
Side-by-side
src/QEditor.jsx
View file @
e6845c5b
...
@@ -37,6 +37,7 @@ import Audio from './extensions/Audio'
...
@@ -37,6 +37,7 @@ import Audio from './extensions/Audio'
import
TableExtension
from
'
./extensions/TableExtension
'
import
TableExtension
from
'
./extensions/TableExtension
'
import
ToggleBlock
from
'
./extensions/ToggleBlock
'
import
ToggleBlock
from
'
./extensions/ToggleBlock
'
import
InteractiveImage
from
'
./extensions/InteractiveImage
'
import
InteractiveImage
from
'
./extensions/InteractiveImage
'
import
FontSize
from
'
./extensions/FontSize
'
// import Image from '@tiptap/extension-image'
// import Image from '@tiptap/extension-image'
// import ImageResize from 'tiptap-extension-resize-image';
// import ImageResize from 'tiptap-extension-resize-image';
...
@@ -75,6 +76,7 @@ const initialBubbleItems = [
...
@@ -75,6 +76,7 @@ const initialBubbleItems = [
'
superscript
'
,
'
superscript
'
,
'
subscript
'
,
'
subscript
'
,
'
|
'
,
'
|
'
,
'
fontSize
'
,
'
colorText
'
,
'
colorText
'
,
'
highlight
'
,
'
highlight
'
,
'
|
'
,
'
|
'
,
...
@@ -201,6 +203,7 @@ const QEditor = ({
...
@@ -201,6 +203,7 @@ const QEditor = ({
'
#ffe672
'
'
#ffe672
'
]
]
}
}
const
fontSizes
=
[
'
default
'
,
'
12px
'
,
'
14px
'
,
'
16px
'
,
'
18px
'
,
'
20px
'
,
'
24px
'
,
'
28px
'
,
'
32px
'
]
const
toolsLib
=
{
const
toolsLib
=
{
link
:
{
link
:
{
...
@@ -438,6 +441,13 @@ const QEditor = ({
...
@@ -438,6 +441,13 @@ const QEditor = ({
editor
.
chain
().
focus
()
editor
.
chain
().
focus
()
}
}
},
},
fontSize
:
{
title
:
'
Размер текста
'
,
onClick
:
()
=>
{
setColorsSelected
(
'
fontSize
'
)
editor
.
chain
().
focus
()
}
},
highlight
:
{
highlight
:
{
title
:
'
Цвет фона
'
,
title
:
'
Цвет фона
'
,
onClick
:
()
=>
setColorsSelected
(
'
highlight
'
)
onClick
:
()
=>
setColorsSelected
(
'
highlight
'
)
...
@@ -554,6 +564,7 @@ const QEditor = ({
...
@@ -554,6 +564,7 @@ const QEditor = ({
alignments
:
[
'
left
'
,
'
center
'
,
'
right
'
,
'
justify
'
]
alignments
:
[
'
left
'
,
'
center
'
,
'
right
'
,
'
justify
'
]
}),
}),
TextStyle
,
TextStyle
,
FontSize
,
Color
.
configure
({
Color
.
configure
({
types
:
[
'
textStyle
'
]
types
:
[
'
textStyle
'
]
}),
}),
...
@@ -1365,7 +1376,30 @@ const QEditor = ({
...
@@ -1365,7 +1376,30 @@ const QEditor = ({
onClick
=
{
(
e
)
=>
e
.
stopPropagation
()
}
onClick
=
{
(
e
)
=>
e
.
stopPropagation
()
}
>
>
{
colorsSelected
!==
null
{
colorsSelected
!==
null
?
colors
[
colorsSelected
].
map
((
itemColor
,
i
)
=>
{
?
(
colorsSelected
===
'
fontSize
'
?
fontSizes
.
map
((
fontSize
,
i
)
=>
{
const
currentFontSize
=
editor
.
getAttributes
(
'
textStyle
'
).
fontSize
||
'
default
'
return
(
<
button
key
=
{
'
fontSize
'
+
i
}
type
=
'button'
className
=
{
'
qfont-size-option
'
+
(
currentFontSize
===
fontSize
?
'
active
'
:
''
)
}
onClick
=
{
()
=>
{
if
(
fontSize
===
'
default
'
)
{
editor
.
chain
().
focus
().
unsetFontSize
().
run
()
}
else
{
editor
.
chain
().
focus
().
setFontSize
(
fontSize
).
run
()
}
setColorsSelected
(
null
)
}
}
>
{
fontSize
===
'
default
'
?
'
A
'
:
fontSize
.
replace
(
'
px
'
,
''
)
}
</
button
>
)
})
:
colors
[
colorsSelected
].
map
((
itemColor
,
i
)
=>
{
return
(
return
(
<
div
<
div
key
=
{
'
colors
'
+
colorsSelected
+
i
}
key
=
{
'
colors
'
+
colorsSelected
+
i
}
...
@@ -1387,7 +1421,7 @@ const QEditor = ({
...
@@ -1387,7 +1421,7 @@ const QEditor = ({
}
}
}
}
/>
/>
)
)
})
})
)
:
bubbleItems
.
map
((
type
,
i
)
=>
{
:
bubbleItems
.
map
((
type
,
i
)
=>
{
if
(
type
===
'
|
'
)
{
if
(
type
===
'
|
'
)
{
return
(
return
(
...
...
src/extensions/FontSize.js
0 → 100644
View file @
e6845c5b
import
{
Extension
}
from
'
@tiptap/core
'
const
FontSize
=
Extension
.
create
({
name
:
'
fontSize
'
,
addOptions
()
{
return
{
types
:
[
'
textStyle
'
]
}
},
addGlobalAttributes
()
{
return
[
{
types
:
this
.
options
.
types
,
attributes
:
{
fontSize
:
{
default
:
null
,
parseHTML
:
(
element
)
=>
element
.
style
.
fontSize
||
null
,
renderHTML
:
(
attributes
)
=>
{
if
(
!
attributes
.
fontSize
)
{
return
{}
}
return
{
style
:
`font-size:
${
attributes
.
fontSize
}
`
}
}
}
}
}
]
},
addCommands
()
{
return
{
setFontSize
:
(
fontSize
)
=>
({
chain
})
=>
{
return
chain
().
setMark
(
'
textStyle
'
,
{
fontSize
}).
run
()
},
unsetFontSize
:
()
=>
({
chain
})
=>
{
return
chain
().
setMark
(
'
textStyle
'
,
{
fontSize
:
null
}).
removeEmptyTextStyle
().
run
()
}
}
}
})
export
default
FontSize
src/index.scss
View file @
e6845c5b
...
@@ -913,6 +913,9 @@ body{
...
@@ -913,6 +913,9 @@ body{
.qicon{
.qicon{
&.qfontSize{
background-image: url("data:image/svg+xml,%3Csvg width='
18
' height='
18
' viewBox='
0
0
18
18
' fill='
none
' xmlns='
http
:
//
www
.w3.org
/
2000
/
svg
'%3E%3Cpath d='
M4
.2
13
.8L6.84
5
.4H7.98L10.62
13
.8H9.51L8.88
11
.76H5.91L5.28
13
.8H4.2ZM6.15
10
.86H8.64L7.41
6
.84L6.15
10
.86ZM11.58
13
.8V8.43H12.6V9.12C13.02
8
.58
13
.59
8
.31
14
.34
8
.31C14.73
8
.31
15
.09
8
.4
15
.39
8
.58C15.69
8
.76
15
.93
9
.03
16
.08
9
.39C16.23
9
.75
16
.32
10
.17
16
.32
10
.65C16.32
11
.16
16
.23
11
.61
16
.05
12C15
.87
12
.39
15
.6
12
.69
15
.24
12
.9C14.88
13
.11
14
.49
13
.2
14
.07
13
.2C13.47
13
.2
12
.99
12
.99
12
.66
12
.6V13.8H11.58ZM12.6
10
.74C12.6
11
.37
12
.72
11
.82
12
.96
12
.12C13.2
12
.42
13
.5
12
.57
13
.89
12
.57C14.28
12
.57
14
.61
12
.42
14
.88
12
.09C15.15
11
.76
15
.27
11
.28
15
.27
10
.62C15.27
10
.02
15
.15
9
.57
14
.91
9
.27C14.67
8
.97
14
.37
8
.82
14
.01
8
.82C13.65
8
.82
13
.32
8
.97
13
.05
9
.3C12.75
9
.6
12
.6
10
.08
12
.6
10
.74Z
' fill='
%231D1D1F
'/%3E%3C/svg%3E");
}
&.qemoji{
&.qemoji{
background-image: url("data:image/svg+xml,%3Csvg width='
18
' height='
18
' viewBox='
0
0
18
18
' fill='
none
' xmlns='
http
:
//
www
.w3.org
/
2000
/
svg
'%3E%3Ccircle cx='
9
' cy='
9
' r='
7
.25
' stroke='
%231D1D1F
' stroke-width='
1
.5
'/%3E%3Ccircle cx='
6
.1
' cy='
7
' r='
1
' fill='
%231D1D1F
'/%3E%3Ccircle cx='
11
.9
' cy='
7
' r='
1
' fill='
%231D1D1F
'/%3E%3Cpath d='
M5
.75
10
.4C6.4
11
.65
7
.57
12
.25
9
12
.25C10.43
12
.25
11
.6
11
.65
12
.25
10
.4
' stroke='
%231D1D1F
' stroke-width='
1
.5
' stroke-linecap='
round
'/%3E%3C/svg%3E");
background-image: url("data:image/svg+xml,%3Csvg width='
18
' height='
18
' viewBox='
0
0
18
18
' fill='
none
' xmlns='
http
:
//
www
.w3.org
/
2000
/
svg
'%3E%3Ccircle cx='
9
' cy='
9
' r='
7
.25
' stroke='
%231D1D1F
' stroke-width='
1
.5
'/%3E%3Ccircle cx='
6
.1
' cy='
7
' r='
1
' fill='
%231D1D1F
'/%3E%3Ccircle cx='
11
.9
' cy='
7
' r='
1
' fill='
%231D1D1F
'/%3E%3Cpath d='
M5
.75
10
.4C6.4
11
.65
7
.57
12
.25
9
12
.25C10.43
12
.25
11
.6
11
.65
12
.25
10
.4
' stroke='
%231D1D1F
' stroke-width='
1
.5
' stroke-linecap='
round
'/%3E%3C/svg%3E");
}
}
...
@@ -1126,6 +1129,32 @@ body{
...
@@ -1126,6 +1129,32 @@ body{
}
}
}
}
.qfont-size-option{
display: inline-flex;
align-items: center;
justify-content: center;
min-width: 32px;
height: 28px;
border: none;
border-radius: 6px;
background: #f5f5f5;
color: #1d1d1f;
font-size: 13px;
line-height: 1;
padding: 0 8px;
margin-right: 4px;
&:hover{
cursor: pointer;
background: #e8e8e8;
}
&.active{
background: #dcecff;
color: #0050b3;
}
}
.qseparator{
.qseparator{
width: 16px;
width: 16px;
}
}
...
...
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