|
10 | 10 |
|
11 | 11 | let lints: Lint[] = [];
|
12 | 12 | let focused: number | undefined;
|
| 13 | + let editor: HTMLTextAreaElement | null; |
13 | 14 |
|
14 | 15 | $: lintText(content).then((newLints) => (lints = newLints));
|
| 16 | + $: boxHeight = calcHeight(content); |
15 | 17 |
|
16 |
| - $: console.log(focused); |
| 18 | + function calcHeight(boxContent: string): number { |
| 19 | + let numberOfLineBreaks = (boxContent.match(/\n/g) || []).length; |
| 20 | + let newHeight = 20 + numberOfLineBreaks * 30 + 12 + 2; |
| 21 | + console.log(newHeight); |
| 22 | + return newHeight; |
| 23 | + } |
17 | 24 | </script>
|
18 | 25 |
|
19 |
| -<div class="flex flex-row w-full h-full [&>*]:m-5"> |
20 |
| - <Card class="flex-auto max-w-full p-5 grid z-10 text-lg overflow-auto"> |
| 26 | +<div class="flex flex-row w-full h-full p-5"> |
| 27 | + <Card |
| 28 | + class="flex-grow h-full p-5 grid z-10 max-w-full text-lg overflow-auto mr-5" |
| 29 | + on:click={() => editor && editor.focus()} |
| 30 | + > |
21 | 31 | <div class="m-0 p-0" style="grid-row: 1; grid-column: 1">
|
22 | 32 | <Underlines {content} focusLintIndex={focused} />
|
23 | 33 | </div>
|
24 | 34 | <textarea
|
25 |
| - class="w-full m-0 rounded-none p-0 z-0 bg-transparent border-none text-lg resize-none" |
26 |
| - rows={content.length - content.replaceAll('\n', '').length + 1} |
| 35 | + bind:this={editor} |
| 36 | + class="w-full m-0 rounded-none p-0 z-0 bg-transparent border-none text-lg resize-none focus:border-0" |
27 | 37 | spellcheck="false"
|
28 |
| - style="grid-row: 1; grid-column: 1" |
| 38 | + style={`grid-row: 1; grid-column: 1; height: ${boxHeight}px`} |
29 | 39 | bind:value={content}
|
30 | 40 | ></textarea>
|
31 | 41 | </Card>
|
32 |
| - <Card class="flex flex-col flex-grow overflow-auto h-full"> |
| 42 | + <Card class="flex flex-col flex-none basis-[400px] overflow-auto h-full"> |
33 | 43 | <h2 class="text-2xl font-bold m-1">Suggestions</h2>
|
34 | 44 | {#each lints as lint, i}
|
35 | 45 | <Card class="m-1 hover:translate-x-3 transition-all" on:click={() => (focused = i)}>
|
|
51 | 61 | {#each lint.suggestions as suggestion}
|
52 | 62 | <Button
|
53 | 63 | color="primary"
|
54 |
| - class="w-full mb-1" |
| 64 | + class="w-full m-1" |
55 | 65 | style="height: 40px; margin: 5px 0px;"
|
56 | 66 | on:click={() =>
|
57 | 67 | applySuggestion(content, suggestion, lint.span).then(
|
|
0 commit comments