Skip to content

Commit c541536

Browse files
committed
Merge branch 'development'
2 parents 29a1f7a + 550b7ef commit c541536

30 files changed

+651
-183
lines changed

VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
3.5.8
1+
3.5.9

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "typedb-studio",
3-
"version": "3.5.8",
3+
"version": "3.5.9",
44
"scripts": {
55
"ng": "ng",
66
"generate-grammar": "lezer-generator --typeScript src/framework/codemirror-lang-typeql/typeql.grammar -o src/framework/codemirror-lang-typeql/generated/typeql.grammar.generated",
@@ -64,6 +64,7 @@
6464
"@sanity/types": "3.14.4",
6565
"@types/chroma-js": "3.1.1",
6666
"@types/jasmine": "~5.1.0",
67+
"@types/prismjs": "1.26.5",
6768
"graphology-types": "0.24.8",
6869
"jasmine-core": "~5.1.0",
6970
"karma": "~6.4.0",

pnpm-lock.yaml

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

src-tauri/Cargo.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src-tauri/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "typedb-studio"
3-
version = "3.5.8"
3+
version = "3.5.9"
44
description = "A Tauri App"
55
authors = ["you"]
66
edition = "2021"

src-tauri/tauri.conf.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"$schema": "https://schema.tauri.app/config/2",
33
"productName": "typedb-studio",
4-
"version": "3.5.8",
4+
"version": "3.5.9",
55
"identifier": "com.typedb.studio",
66
"build": {
77
"beforeDevCommand": "pnpm start",
@@ -31,7 +31,7 @@
3131
],
3232
"windows": {
3333
"wix": {
34-
"version": "3.5.8"
34+
"version": "3.5.9"
3535
}
3636
},
3737
"macOS": {
Lines changed: 20 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,22 @@
1-
<div class="cs-root text-code">
2-
@if (snippet.language && snippet.language !== 'typedb-console') {
3-
<div class="cs-line-numbers">
4-
<ol>
5-
@for (lineNumber of lineNumbers; track lineNumber) {
6-
<li>{{ lineNumber }}</li>
7-
}
8-
</ol>
1+
<div class="cs-root text-code" #rootElement (mouseenter)="showOverlay.set(true)" (mouseleave)="showOverlay.set(false)">
2+
<!-- Copy overlay - outside the scrollable area -->
3+
<div class="copy-overlay" [class.visible]="showOverlay()" matTooltip="Copy" matTooltipPosition="below" (click)="copyCode()">
4+
<i class="fas" [class.fa-copy]="!copied()" [class.fa-check]="copied()"></i>
5+
</div>
6+
7+
<!-- Scrollable container for both line numbers and code -->
8+
<div class="cs-scrollable-content">
9+
@if (snippet.language && snippet.language !== 'typedb-console') {
10+
<div class="cs-line-numbers">
11+
<ol>
12+
@for (lineNumber of lineNumbers; track lineNumber) {
13+
<li>{{ lineNumber }}</li>
14+
}
15+
</ol>
16+
</div>
17+
}
18+
<div class="cs-code-area">
19+
<pre><code [class]="snippet.language ? 'language-' + snippet.language : undefined" [innerHTML]="snippet.code"></code></pre>
920
</div>
10-
}
11-
<div class="cs-code-area">
12-
<pre><code [class]="snippet.language ? 'language-' + snippet.language : undefined" [innerHTML]="snippet.code"></code></pre>
1321
</div>
14-
</div>
22+
</div>

src/framework/code-snippet/code-snippet.component.scss

Lines changed: 55 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,33 +4,35 @@
44
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
55
*/
66

7-
7+
@use "colors";
8+
@use "shapes";
89
@use "typography";
910

1011
:host {
1112
display: block;
1213
height: 100%;
13-
overflow: auto;
14-
scrollbar-width: none;
15-
16-
&::-webkit-scrollbar {
17-
width: 0;
18-
height: 0;
19-
}
14+
/* Remove overflow: auto */
2015
}
2116

2217
.cs-root {
2318
min-height: 100%;
2419
width: 100%;
20+
position: relative;
21+
height: 100%;
22+
}
23+
24+
.cs-scrollable-content {
2525
display: flex;
2626
gap: 4px;
27+
padding: 4px;
28+
height: 100%;
29+
overflow: auto; /* Move overflow here */
2730
}
2831

2932
.cs-line-numbers {
3033
flex-shrink: 0;
3134
padding: 0 7px;
3235
color: #66637f;
33-
overflow: hidden;
3436
}
3537

3638
.cs-code-area {
@@ -42,7 +44,50 @@
4244
}
4345
}
4446

47+
.copy-overlay {
48+
position: absolute;
49+
top: 12px;
50+
right: 24px;
51+
display: flex;
52+
align-items: center;
53+
justify-content: center;
54+
width: 32px;
55+
height: 32px;
56+
background: rgba(255, 255, 255, 0.1);
57+
backdrop-filter: blur(8px);
58+
border: shapes.$border;
59+
color: rgba(255, 255, 255, 0.8);
60+
border-radius: 8px;
61+
cursor: pointer;
62+
opacity: 0;
63+
transform: translateY(-4px);
64+
transition: all 100ms;
65+
}
66+
67+
.copy-overlay i {
68+
font-size: 14px;
69+
transition: all 100ms;
70+
display: flex;
71+
align-items: center;
72+
justify-content: center;
73+
width: 100%;
74+
height: 100%;
75+
line-height: 1; /* Remove any line-height that might offset the icon */
76+
}
77+
78+
/* Keep your existing hover and visible states */
79+
.copy-overlay.visible {
80+
opacity: 1;
81+
transform: translateY(0);
82+
}
83+
84+
.copy-overlay:hover {
85+
background: rgba(255, 255, 255, 0.15);
86+
border-color: colors.$secondary-mid-deep-grey;
87+
color: rgba(255, 255, 255, 1);
88+
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
89+
}
90+
4591
ol {
4692
list-style: none;
47-
height: 0;
4893
}

src/framework/code-snippet/code-snippet.component.ts

Lines changed: 31 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,11 @@
44
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
55
*/
66

7-
import { AfterViewChecked, AfterViewInit, ChangeDetectionStrategy, Component, ElementRef, Input, NgZone, ViewChild } from "@angular/core";
7+
import { AfterViewInit, ChangeDetectionStrategy, Component, ElementRef, Input, NgZone, OnChanges, signal, ViewChild } from "@angular/core";
88

99
import Prism from "prismjs";
1010
import { initCustomScrollbars } from "typedb-web-common/lib";
11+
import { MatTooltipModule } from "@angular/material/tooltip";
1112

1213
const DEFAULT_MIN_LINES = { desktop: 33, mobile: 13 };
1314

@@ -17,12 +18,16 @@ const DEFAULT_MIN_LINES = { desktop: 33, mobile: 13 };
1718
styleUrls: ["code-snippet.component.scss"],
1819
changeDetection: ChangeDetectionStrategy.OnPush,
1920
standalone: true,
20-
imports: [],
21+
imports: [MatTooltipModule],
2122
})
22-
export class CodeSnippetComponent implements AfterViewInit, AfterViewChecked {
23+
export class CodeSnippetComponent implements AfterViewInit, OnChanges {
2324
@Input({ required: true }) snippet!: { language?: string, code: string };
2425
@ViewChild("scrollbarX") scrollbarX!: ElementRef<HTMLElement>;
2526
@ViewChild("scrollbarY") scrollbarY!: ElementRef<HTMLElement>;
27+
@ViewChild("rootElement") rootElement!: ElementRef<HTMLElement>;
28+
29+
showOverlay = signal(false);
30+
copied = signal(false);
2631

2732
get lineNumbers() {
2833
return [...Array(Math.max(
@@ -34,10 +39,30 @@ export class CodeSnippetComponent implements AfterViewInit, AfterViewChecked {
3439
constructor(private ngZone: NgZone, private elementRef: ElementRef) { }
3540

3641
ngAfterViewInit() {
37-
this.ngZone.runOutsideAngular(() => initCustomScrollbars(this.elementRef.nativeElement));
42+
this.maybeInitScrollbarsAndHighlighting();
43+
}
44+
45+
ngOnChanges() {
46+
this.maybeInitScrollbarsAndHighlighting();
47+
}
48+
49+
maybeInitScrollbarsAndHighlighting() {
50+
if (this.snippet && this.rootElement) {
51+
Prism.highlightAllUnder(this.elementRef.nativeElement);
52+
}
3853
}
3954

40-
ngAfterViewChecked() {
41-
Prism.highlightAll();
55+
async copyCode() {
56+
try {
57+
await navigator.clipboard.writeText(this.snippet.code);
58+
this.copied.set(true);
59+
60+
// Reset copied state after 2 seconds
61+
setTimeout(() => {
62+
this.copied.set(false);
63+
}, 2000);
64+
} catch (err) {
65+
console.error('Failed to copy code:', err);
66+
}
4267
}
4368
}

src/framework/modal/modal.component.scss

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,6 @@
1414
right: 0;
1515
}
1616

17-
.mdc-dialog__content {
18-
overflow: visible;
19-
}
20-
2117
h1 {
2218
@include typography.font-style(22px, typography.$semi-bold, normal, 0);
2319
}

0 commit comments

Comments
 (0)