Skip to content

Commit

Permalink
Append the dialog to the prose-editor element instead of to the body
Browse files Browse the repository at this point in the history
  • Loading branch information
matthiask committed Dec 6, 2024
1 parent d01d07a commit cfd36a0
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 9 deletions.
10 changes: 5 additions & 5 deletions django_prose_editor/static/django_prose_editor/editor.js

Large diffs are not rendered by default.

5 changes: 3 additions & 2 deletions src/commands.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ const formFieldForProperty = ([name, config]) => {
return `<p><label>${config.title || name}</label> ${widget}</p>`
}

export const updateAttrsDialog = (properties) => (attrs) => {
export const updateAttrsDialog = (properties) => (editor, attrs) => {
const { messages } = settings()
return new Promise((resolve) => {
const div = document.createElement("div")
Expand All @@ -27,7 +27,8 @@ export const updateAttrsDialog = (properties) => (attrs) => {
</form>
</dialog>
`
document.body.append(div)

editor.view.dom.closest(".prose-editor").append(div)
const dialog = div.querySelector("dialog")
const form = div.querySelector("form")

Expand Down
2 changes: 1 addition & 1 deletion src/html.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export const HTML = Extension.create({
editHTML:
() =>
({ editor }) => {
htmlDialog({ html: editor.getHTML() }).then((attrs) => {
htmlDialog(editor, { html: editor.getHTML() }).then((attrs) => {
if (attrs) {
editor.chain().focus().setContent(attrs.html).run()
}
Expand Down
2 changes: 1 addition & 1 deletion src/link.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export const Link = BaseLink.extend({
({ editor }) => {
const attrs = editor.getAttributes(this.name)

linkDialog(attrs).then((attrs) => {
linkDialog(editor, attrs).then((attrs) => {
if (attrs) {
const cmd = editor
.chain()
Expand Down

0 comments on commit cfd36a0

Please sign in to comment.