diff options
author | Hsieh Chin Fan <pham@topo.tw> | 2024-09-24 15:50:40 +0800 |
---|---|---|
committer | Hsieh Chin Fan <pham@topo.tw> | 2024-09-24 15:50:48 +0800 |
commit | d9a29f863c1bbf946f481de5817488ed679206af (patch) | |
tree | 538b531cf4ec62dd3371fd2ed641999481edd44e /src | |
parent | a3a5ab51aa4ee8f6c771e3dd1f9a51b579b06e3d (diff) |
feat(CSS): add focus visual to editor and output
Diffstat (limited to 'src')
-rw-r--r-- | src/css/index.css | 11 | ||||
-rw-r--r-- | src/editor.mjs | 8 |
2 files changed, 19 insertions, 0 deletions
diff --git a/src/css/index.css b/src/css/index.css index db80277..47c5c1e 100644 --- a/src/css/index.css +++ b/src/css/index.css | |||
@@ -1,6 +1,7 @@ | |||
1 | :root { | 1 | :root { |
2 | --content-border: solid lightgray 2px; | 2 | --content-border: solid lightgray 2px; |
3 | --content-border-radius: 5px; | 3 | --content-border-radius: 5px; |
4 | --content-focus-border: solid gray 2px; | ||
4 | } | 5 | } |
5 | 6 | ||
6 | .editor { | 7 | .editor { |
@@ -27,6 +28,11 @@ body { | |||
27 | 28 | ||
28 | border: var(--content-border); | 29 | border: var(--content-border); |
29 | border-radius: var(--content-border-radius); | 30 | border-radius: var(--content-border-radius); |
31 | |||
32 | &.focus { | ||
33 | border: var(--content-focus-border); | ||
34 | outline: var(--content-focus-border); | ||
35 | } | ||
30 | } | 36 | } |
31 | 37 | ||
32 | .editor { | 38 | .editor { |
@@ -62,6 +68,11 @@ body { | |||
62 | font-family: monospace; | 68 | font-family: monospace; |
63 | font-size: 1.0rem; | 69 | font-size: 1.0rem; |
64 | 70 | ||
71 | &.focus { | ||
72 | border: var(--content-focus-border); | ||
73 | outline: var(--content-focus-border); | ||
74 | } | ||
75 | |||
65 | span { | 76 | span { |
66 | white-space: pre; | 77 | white-space: pre; |
67 | } | 78 | } |
diff --git a/src/editor.mjs b/src/editor.mjs index 35b1949..6456293 100644 --- a/src/editor.mjs +++ b/src/editor.mjs | |||
@@ -183,6 +183,12 @@ cm.on("change", (_, change) => { | |||
183 | completeForCodeBlock(change) | 183 | completeForCodeBlock(change) |
184 | }) | 184 | }) |
185 | 185 | ||
186 | // Set class for focus | ||
187 | cm.on("focus", () => { | ||
188 | cm.getWrapperElement().classList.add('focus') | ||
189 | HtmlContainer.classList.remove('focus') | ||
190 | }) | ||
191 | |||
186 | cm.on("beforeChange", (_, change) => { | 192 | cm.on("beforeChange", (_, change) => { |
187 | const line = change.to.line | 193 | const line = change.to.line |
188 | // Don't allow more content after YAML doc separator | 194 | // Don't allow more content after YAML doc separator |
@@ -507,6 +513,8 @@ cm.on("cursorActivity", (_) => { | |||
507 | }); | 513 | }); |
508 | cm.on("blur", () => { | 514 | cm.on("blur", () => { |
509 | suggestionsEle.style.display = 'none' | 515 | suggestionsEle.style.display = 'none' |
516 | cm.getWrapperElement().classList.remove('focus') | ||
517 | HtmlContainer.classList.add('focus') | ||
510 | }) | 518 | }) |
511 | // }}} | 519 | // }}} |
512 | // EVENT: keydown for suggestions {{{ | 520 | // EVENT: keydown for suggestions {{{ |