Skip to content

Commit cfd36a0

Browse files
committed
Append the dialog to the prose-editor element instead of to the body
1 parent d01d07a commit cfd36a0

File tree

4 files changed

+10
-9
lines changed

4 files changed

+10
-9
lines changed

django_prose_editor/static/django_prose_editor/editor.js

Lines changed: 5 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/commands.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ const formFieldForProperty = ([name, config]) => {
1414
return `<p><label>${config.title || name}</label> ${widget}</p>`
1515
}
1616

17-
export const updateAttrsDialog = (properties) => (attrs) => {
17+
export const updateAttrsDialog = (properties) => (editor, attrs) => {
1818
const { messages } = settings()
1919
return new Promise((resolve) => {
2020
const div = document.createElement("div")
@@ -27,7 +27,8 @@ export const updateAttrsDialog = (properties) => (attrs) => {
2727
</form>
2828
</dialog>
2929
`
30-
document.body.append(div)
30+
31+
editor.view.dom.closest(".prose-editor").append(div)
3132
const dialog = div.querySelector("dialog")
3233
const form = div.querySelector("form")
3334

src/html.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ export const HTML = Extension.create({
1010
editHTML:
1111
() =>
1212
({ editor }) => {
13-
htmlDialog({ html: editor.getHTML() }).then((attrs) => {
13+
htmlDialog(editor, { html: editor.getHTML() }).then((attrs) => {
1414
if (attrs) {
1515
editor.chain().focus().setContent(attrs.html).run()
1616
}

src/link.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ export const Link = BaseLink.extend({
2323
({ editor }) => {
2424
const attrs = editor.getAttributes(this.name)
2525

26-
linkDialog(attrs).then((attrs) => {
26+
linkDialog(editor, attrs).then((attrs) => {
2727
if (attrs) {
2828
const cmd = editor
2929
.chain()

0 commit comments

Comments
 (0)