|
45 | 45 | <div class="form-floating mb-3">
|
46 | 46 | <textarea
|
47 | 47 | v-model="form.markdown"
|
48 |
| - class="form-control" |
| 48 | + class="form-control md-area" |
49 | 49 | placeholder="Blogpost"
|
50 | 50 | ref="markdownArea"
|
51 | 51 | style="height: 40vh; min-height: 200px"
|
@@ -422,11 +422,22 @@ const dropMarkdown = (evt: DragEvent) => {
|
422 | 422 | const textArea = evt.target as HTMLTextAreaElement;
|
423 | 423 | if (items && textArea) {
|
424 | 424 | for (const item of items) {
|
425 |
| - if (item.kind === "string" && item.type === "text/markdown") { |
426 |
| - evt.preventDefault(); |
427 |
| - item.getAsString((markdown) => { |
428 |
| - form.markdown = insertIntoTextarea(markdown, textArea, "beforeCursor"); |
429 |
| - }); |
| 425 | + // evt.preventDefault(); |
| 426 | + // We cannot use preventDefault(), because we will be unable to get the cursor position to drop to. |
| 427 | + // instead we have to pase everything and remove the base64 string afterwards |
| 428 | + if (item.kind === "string") { |
| 429 | + if (item.type === "text/markdown") { |
| 430 | + item.getAsString((markdown_img_link) => { |
| 431 | + form.markdown = insertIntoTextarea(markdown_img_link, textArea, "beforeCursor"); |
| 432 | + }); |
| 433 | + } else { |
| 434 | + // Remove base64 string from drop events default behaviour |
| 435 | + item.getAsString((str) => { |
| 436 | + setTimeout(() => { |
| 437 | + form.markdown = form.markdown.replace(str, ""); |
| 438 | + }, 0); |
| 439 | + }); |
| 440 | + } |
430 | 441 | }
|
431 | 442 | }
|
432 | 443 | }
|
@@ -549,7 +560,6 @@ const insertIntoTextarea = (
|
549 | 560 | const text = area.value;
|
550 | 561 | const before = text.substring(0, insertPosition === "afterCursor" ? end : start);
|
551 | 562 | const after = text.substring(insertPosition === "beforeCursor" ? start : end);
|
552 |
| -
|
553 | 563 | return before + insertedText + after;
|
554 | 564 | };
|
555 | 565 |
|
|
0 commit comments