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
5499f2c8
Commit
5499f2c8
authored
Oct 02, 2023
by
Nikita
Browse files
added remove iframe button
parent
6ce5f728
Changes
6
Expand all
Hide whitespace changes
Inline
Side-by-side
src/QEditor.jsx
View file @
5499f2c8
This diff is collapsed.
Click to expand it.
src/extensions/Iframe.js
View file @
5499f2c8
...
@@ -21,6 +21,18 @@ const Iframe = Node.create({
...
@@ -21,6 +21,18 @@ const Iframe = Node.create({
console
.
log
(
this
)
console
.
log
(
this
)
},
},
},
},
"
setInnerModalType
"
:
{
default
:
null
},
"
setModalIsOpen
"
:
{
default
:
null
},
"
setModalTitle
"
:
{
default
:
null
},
"
setCurrentRemoveIframe
"
:
{
default
:
null
}
}
}
},
},
...
@@ -38,21 +50,35 @@ const Iframe = Node.create({
...
@@ -38,21 +50,35 @@ const Iframe = Node.create({
addNodeView
()
{
addNodeView
()
{
return
({
editor
,
node
,
...
a
})
=>
{
return
({
editor
,
node
,
...
a
})
=>
{
const
container
=
document
.
createElement
(
'
div
'
);
// div.className = 'aspect-w-16 aspect-h-9' + (editor.isEditable ? ' cursor-pointer' : '');
const
iframe
=
document
.
createElement
(
'
iframe
'
);
const
iframe
=
document
.
createElement
(
'
iframe
'
);
if
(
editor
.
isEditable
)
{
iframe
.
className
=
'
pointer-events-none
'
;
}
iframe
.
src
=
node
.
attrs
.
src
;
iframe
.
src
=
node
.
attrs
.
src
;
iframe
.
frameBorder
=
node
.
attrs
.
frameborder
;
iframe
.
allowfullscreen
=
node
.
attrs
.
allowfullscreen
;
iframe
.
allowfullscreen
=
node
.
attrs
.
allowfullscreen
;
iframe
.
style
=
'
width:1280px;height:auto;aspect-ratio: 16 / 9;
'
;
iframe
.
classList
.
add
(
'
customIframe
'
);
// div.append(video);
const
closeBtn
=
document
.
createElement
(
'
button
'
);
closeBtn
.
textContent
=
'
X
'
;
closeBtn
.
classList
.
add
(
'
closeBtn
'
);
closeBtn
.
addEventListener
(
'
click
'
,
function
()
{
try
{
node
.
attrs
.
setModalTitle
(
'
Вы уверены, что хотите удалить?
'
);
node
.
attrs
.
setInnerModalType
(
'
remove_iframe
'
);
node
.
attrs
.
setModalIsOpen
(
true
);
node
.
attrs
.
setCurrentRemoveIframe
(
container
);
}
catch
{
container
.
remove
();
}
});
// if (editor.isEditable) {
// container.classList.add('pointer-events-none');
// }
container
.
append
(
closeBtn
,
iframe
);
return
{
return
{
dom
:
iframe
,
dom
:
container
,
}
}
}
}
},
},
...
@@ -62,7 +88,7 @@ const Iframe = Node.create({
...
@@ -62,7 +88,7 @@ const Iframe = Node.create({
setIframe
:
(
options
)
=>
({
tr
,
dispatch
})
=>
{
setIframe
:
(
options
)
=>
({
tr
,
dispatch
})
=>
{
const
{
selection
}
=
tr
const
{
selection
}
=
tr
const
node
=
this
.
type
.
create
(
options
)
const
node
=
this
.
type
.
create
(
options
)
//
if
(
dispatch
)
{
if
(
dispatch
)
{
tr
.
replaceRangeWith
(
selection
.
from
,
selection
.
to
,
node
)
tr
.
replaceRangeWith
(
selection
.
from
,
selection
.
to
,
node
)
}
}
...
...
src/index.scss
View file @
5499f2c8
...
@@ -1022,4 +1022,25 @@ body{
...
@@ -1022,4 +1022,25 @@ body{
.qseparator{
.qseparator{
width: 16px;
width: 16px;
}
}
.closeBtn {
position: relative;
display: flex;
justify-content: end;
border-radius: 50%;
border: none;
background-color: #2677e3;
color: #fff;
font-size: 0.5rem;
padding: 4px 6px;
top: 10px;
cursor: pointer;
right: 8px;
}
.customIframe {
width:1280px;
height:auto;
aspect-ratio: 16 / 9;
}
}
}
src/modals/IframeCustomModal.js
0 → 100644
View file @
5499f2c8
import
React
,
{
Fragment
}
from
"
react
"
;
export
default
function
IframeCustomModal
({
embedContent
,
setEmbedContent
})
{
return
(
<
Fragment
>
<
textarea
style
=
{{
width
:
'
100%
'
,
height
:
'
100%
'
}}
rows
=
{
18
}
value
=
{
embedContent
}
placeholder
=
{
'
<iframe></iframe>
'
}
onInput
=
{(
e
)
=>
setEmbedContent
(
e
.
target
.
value
)}
/
>
<
/Fragment
>
)
}
src/modals/IframeModal.js
0 → 100644
View file @
5499f2c8
import
React
,
{
Fragment
}
from
"
react
"
;
export
default
function
IframeModal
({
embedContent
,
setEmbedContent
})
{
return
(
<
Fragment
>
<
input
type
=
"
text
"
value
=
{
embedContent
}
placeholder
=
{
'
https://
'
}
onInput
=
{(
e
)
=>
setEmbedContent
(
e
.
target
.
value
)
}
/
>
<
ul
className
=
{
'
atma-editor-soc-video
'
}
>
<
li
className
=
{
'
youtube
'
}
/
>
<
li
className
=
{
'
vimeo
'
}
/
>
{
/* <li className={'vk'}/> */
}
<
li
className
=
{
'
ok
'
}
/
>
<
li
className
=
{
'
rutube
'
}
/
>
<
/ul
>
<
/Fragment
>
)
}
src/modals/RemoveIframeModal.js
0 → 100644
View file @
5499f2c8
import
React
,
{
Fragment
}
from
"
react
"
;
export
default
function
RemoveIframeModal
(){
return
(
<
Fragment
>
<
/Fragment
>
)
}
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