Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
V
visual_editor
Manage
Activity
Members
Labels
Plan
Wiki
Custom issue tracker
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Model registry
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
project
visual_editor
Merge requests
!14
️ Issue
#3442698
: Improve onload scripts
Code
Review changes
Check out branch
Download
Patches
Plain diff
Merged
️ Issue
#3442698
: Improve onload scripts
3442698
into
1.0.x
Overview
0
Commits
4
Pipelines
5
Changes
1
Merged
Jesus Manuel Olivas
requested to merge
3442698
into
1.0.x
1 year ago
Overview
0
Commits
4
Pipelines
5
Changes
1
Expand
0
0
Merge request reports
Compare
1.0.x
version 3
b1d2a990
1 year ago
version 2
526c4c6f
1 year ago
version 1
a73162e0
1 year ago
1.0.x (base)
and
latest version
latest version
882d415b
4 commits,
1 year ago
version 3
b1d2a990
3 commits,
1 year ago
version 2
526c4c6f
2 commits,
1 year ago
version 1
a73162e0
1 commit,
1 year ago
1 file
+
37
−
30
Inline
Compare changes
Side-by-side
Inline
Show whitespace changes
Show one file at a time
js/visual_editor.node_view.js
+
37
−
30
Options
@@ -61,9 +61,10 @@
$
.
fn
.
dialogToggle
();
});
}
//
Open dialog on load
//
Body ready events
once
(
'
visual_editor
'
,
selector
,
context
).
forEach
(()
=>
{
if
(
openLoad
&&
node
)
{
// Open dialog
$
.
fn
.
visualEditorOpenDialog
(
`/visual_editor/form/node/
${
node
}
/edit?preview=
${
isPreview
}
`
,
{
@@ -71,16 +72,14 @@
resizable
:
false
,
},
);
}
});
// Dialog aftercreate event
once
(
'
dialog-beforecreate
'
,
'
body
'
,
context
).
forEach
(
function
()
{
jQuery
(
window
).
on
(
'
dialog:aftercreate
'
,
function
()
{
jQuery
(
'
#drupal-off-canvas
'
).
dialog
(
'
option
'
,
{
width
,
resizable
:
false
,
// Remove resizable from dialog
jQuery
(
window
).
on
(
'
dialog:aftercreate
'
,
function
()
{
jQuery
(
'
#drupal-off-canvas
'
).
dialog
(
'
option
'
,
{
width
,
resizable
:
false
,
});
});
}
);
}
});
},
};
@@ -92,20 +91,25 @@
(
event
)
=>
{
const
{
wrapper
}
=
drupalSettings
.
visual_editor
;
const
{
data
}
=
event
;
if
(
data
.
type
===
'
VISUAL_EDITOR_COMPONENT
'
)
{
// Exapnd dialog if collapsed
$
.
fn
.
dialogToggleOnlyWhenCollapsed
();
const
{
type
,
uuid
}
=
data
;
const
{
uuid
}
=
data
;
const
uuidInput
=
$
(
`input[data-visual-editor-uuid="
${
uuid
}
"]`
);
const
inputId
=
uuidInput
.
attr
(
'
id
'
);
const
divSelector
=
`edit-
${
inputId
.
substring
(
0
,
inputId
.
indexOf
(
'
-edit--
'
),
)}
`
;
const
divId
=
$
(
`div[data-drupal-selector="
${
divSelector
}
"]`
).
attr
(
'
id
'
,
);
if
(
!
type
||
!
uuid
)
{
return
;
}
if
(
type
===
'
VISUAL_EDITOR_COMPONENT
'
)
{
const
paragraph
=
$
(
`input[data-visual-editor-uuid="
${
uuid
}
"]`
);
const
paragraphId
=
paragraph
.
attr
(
'
id
'
);
const
paragraphSelector
=
jQuery
(
`#
${
paragraphId
}
`
)
.
parent
()
.
parent
()
.
parent
()
.
data
(
'
drupal-selector
'
);
// Expand paragraph
paragraph
.
trigger
(
'
mousedown
'
);
// Expand dialog
$
.
fn
.
dialogToggleOnlyWhenCollapsed
();
if
(
wrapper
.
type
&&
@@ -125,14 +129,17 @@
}
}
// Expand paragraph
uuidInput
.
trigger
(
'
mousedown
'
);
// @todo: find why scrollIntoView got reset
// Scroll to paragraph
document
.
getElementById
(
divId
).
scrollIntoView
({
behavior
:
'
smooth
'
,
block
:
'
start
'
,
inline
:
'
end
'
,
});
if
(
paragraphSelector
)
{
const
selector
=
`[data-drupal-selector="
${
paragraphSelector
}
"]`
;
document
.
querySelector
(
selector
).
scrollIntoView
({
behavior
:
'
auto
'
,
block
:
'
center
'
,
inline
:
'
nearest
'
,
});
}
event
.
stopImmediatePropagation
();
}
},
Loading