Skip to content

Commit 392953c

Browse files
committed
fix: Tried adding wasm comaptible clipboard library
1 parent 3810fea commit 392953c

File tree

4 files changed

+211
-36
lines changed

4 files changed

+211
-36
lines changed

.github/workflows/pages.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ jobs:
3535
echo "Repo name: ${{ github.event.repository.name }}"
3636
REPO_URL="https://${{ github.repository_owner }}.github.io/${{ github.event.repository.name }}"
3737
echo "Repo URL: $REPO_URL"
38-
RUSTFLAGS="--cfg=web_sys_unstable_apis" ./trunk build --release --public-url "$REPO_URL"
38+
./trunk build --release --public-url "$REPO_URL"
3939
- name: Deploy
4040
uses: JamesIves/github-pages-deploy-action@v4
4141
with:

Cargo.lock

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

Cargo.toml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ edition = "2021"
99
bevy = {version = "0.13.0"}
1010
bevy_egui = "0.25.0"
1111
bevy_pancam = "0.11.0"
12-
clipboard = "0.5.0"
12+
copypasta = "0.10.1"
1313
egui_extras = "0.26.2"
1414
rand = "0.8.5"
1515

@@ -20,3 +20,6 @@ opt-level = 1
2020
# Enable high optimizations for dependencies (incl. Bevy), but not for our code:
2121
[profile.dev.package."*"]
2222
opt-level = 3
23+
24+
[target.wasm32-unknown-unknown]
25+
rustflags = ["--cfg=web_sys_unstable_apis"]

src/main.rs

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,13 @@
1414
//! [![](https://mermaid.ink/img/pako:eNpVkMFuwjAMhl_FyolK8AI9TFqZNmkb0gTXXkxiiNUkRm7CNlHefWHdDvhk2f5-2__FWHFkWnMI8mk9aob3bZ-gxuNi7UVGgpNwyuB4zMr7kllSA6vVw_TMe0loLU_Q_c9aSWf6Al9CAAxHUc4-Nn-CNwqmTkpy5GCLyUms7Nzt5u4r6plH2KBaP8F68UKJFPOdcnNHvLEO8IH1ODvAjthRqKBZmkgakV197nIDepM9RepNW1OHOvSmT9c6hyXL7jtZ02YttDTl5OrCJ8ajYjTtAcNYq-Q4i25mt35Nu_4AUKJpKA?type=png)](https://mermaid.live/edit#pako:eNpVkMFuwjAMhl_FyolK8AI9TFqZNmkb0gTXXkxiiNUkRm7CNlHefWHdDvhk2f5-2__FWHFkWnMI8mk9aob3bZ-gxuNi7UVGgpNwyuB4zMr7kllSA6vVw_TMe0loLU_Q_c9aSWf6Al9CAAxHUc4-Nn-CNwqmTkpy5GCLyUms7Nzt5u4r6plH2KBaP8F68UKJFPOdcnNHvLEO8IH1ODvAjthRqKBZmkgakV197nIDepM9RepNW1OHOvSmT9c6hyXL7jtZ02YttDTl5OrCJ8ajYjTtAcNYq-Q4i25mt35Nu_4AUKJpKA)
1515
1616
use std::fmt::Debug;
17-
use clipboard::ClipboardProvider;
18-
use clipboard::ClipboardContext;
17+
use copypasta::{ClipboardContext, ClipboardProvider};
1918

2019
use bevy::{
21-
input::keyboard::KeyboardInput, prelude::*, sprite::{MaterialMesh2dBundle, Mesh2dHandle}, window::PrimaryWindow
20+
prelude::*, sprite::{MaterialMesh2dBundle, Mesh2dHandle}, window::PrimaryWindow
2221
};
2322
use bevy_egui::{
24-
egui::{self, KeyboardShortcut},
23+
egui::{self},
2524
EguiContexts, EguiPlugin,
2625
};
2726
use bevy_pancam::{PanCam, PanCamPlugin};
@@ -155,10 +154,11 @@ fn keyboard_input_system(input: Res<ButtonInput<KeyCode>>, mut point_data: ResMu
155154
}
156155

157156
if ctrl && input.just_pressed(KeyCode::KeyV) {
158-
let mut ctx: ClipboardContext = ClipboardProvider::new().unwrap();
157+
let mut ctx = ClipboardContext::new().unwrap();
159158
match ctx.get_contents() {
160159
Ok(contents) => {
161-
point_data.1 = contents;
160+
point_data.1 += "\n";
161+
point_data.1 += &contents;
162162
}
163163
Err(e) => eprintln!("{:?}", e)
164164
}
@@ -169,14 +169,13 @@ fn graphics_drawing(
169169
mut commands: Commands,
170170
mut meshes: ResMut<Assets<Mesh>>,
171171
mut materials: ResMut<Assets<ColorMaterial>>,
172-
mut standard_material: ResMut<Assets<StandardMaterial>>,
173172
time: Res<Time>,
174173
mut simulation_timer: ResMut<SimulationTimer>,
175174
gizmo_query: Query<Entity, With<Gizmo>>,
176175
text_query: Query<Entity, With<ColorText>>,
177176
convex_hull_query: Query<Entity, With<ConvexHull>>,
178177
mut drawing_history: ResMut<DrawingHistory>,
179-
mut window: Query<&mut Window, With<PrimaryWindow>>,
178+
window: Query<&mut Window, With<PrimaryWindow>>,
180179
) {
181180
let window = window.single();
182181
if drawing_history.0.is_empty() || drawing_history.0.len() == drawing_history.1 {

0 commit comments

Comments
 (0)