Skip to content

Commit 1d188f9

Browse files
committed
contenteditable code editor demo
1 parent 6ba7ca3 commit 1d188f9

50 files changed

Lines changed: 5354 additions & 2064 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
name: Free Disk Space
2+
description: Free up disk space on the runner
3+
runs:
4+
using: composite
5+
steps:
6+
- name: Free Disk Space (Ubuntu)
7+
if: runner.os == 'Linux'
8+
shell: bash
9+
run: |
10+
echo "Freeing up disk space..."
11+
sudo rm -rf /opt/ghc
12+
sudo rm -rf /usr/share/dotnet
13+
sudo rm -rf /usr/local/lib/android
14+
sudo rm -rf /usr/share/swift
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
name: Clean Up Preview
2+
3+
on:
4+
pull_request_target:
5+
types:
6+
- closed
7+
8+
permissions:
9+
contents: write
10+
pages: write
11+
12+
jobs:
13+
cleanup-preview:
14+
runs-on: ubuntu-latest
15+
steps:
16+
- uses: actions/checkout@v4
17+
- name: Create empty directory
18+
run: echo "empty_dir=$(mktemp -d)" >> "$GITHUB_ENV"
19+
- name: Deploy empty preview
20+
uses: JamesIves/github-pages-deploy-action@v4.2.3
21+
with:
22+
branch: gh-pages
23+
folder: ${{ env.empty_dir }}
24+
target-folder: pr-preview/pr-${{ github.event.pull_request.number }}/
25+
clean: true
26+
single-commit: true

.github/workflows/gh-pages.yml

Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
name: GitHub Pages
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
schedule:
8+
- cron: "42 8 * * *"
9+
workflow_dispatch:
10+
11+
concurrency:
12+
group: ${{ github.workflow }}-${{ github.ref }}
13+
cancel-in-progress: true
14+
15+
permissions:
16+
contents: write
17+
pages: write
18+
19+
jobs:
20+
build-deploy:
21+
name: Build And Deploy Demo
22+
runs-on: ubuntu-latest
23+
env:
24+
CARGO_INCREMENTAL: 1
25+
steps:
26+
- uses: actions/checkout@v4
27+
- uses: awalsh128/cache-apt-pkgs-action@latest
28+
with:
29+
packages: libwebkit2gtk-4.1-dev libgtk-3-dev libayatana-appindicator3-dev libxdo-dev
30+
version: 1.0
31+
- uses: dtolnay/rust-toolchain@stable
32+
with:
33+
targets: x86_64-unknown-linux-gnu,wasm32-unknown-unknown
34+
- uses: Swatinem/rust-cache@v2
35+
with:
36+
cache-all-crates: "true"
37+
cache-on-failure: "false"
38+
cache-directories: "target/dx"
39+
- uses: cargo-bins/cargo-binstall@main
40+
- name: Install Dioxus CLI
41+
run: cargo binstall dioxus-cli -y --force --version 0.7.7
42+
- name: Build
43+
run: cd demo && dx build --web --release --no-default-features --features web --debug-symbols false --base-path "${{ github.event.repository.name }}"
44+
- name: Copy output
45+
run: cp -r target/dx/dioxus-code-demo/release/web/public docs
46+
- name: Add GitHub Pages 404
47+
run: |
48+
cat > docs/404.html <<'EOF'
49+
<!DOCTYPE html>
50+
<html lang="en">
51+
<head>
52+
<meta charset="UTF-8">
53+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
54+
<title>Redirecting</title>
55+
</head>
56+
<body>
57+
<script>
58+
const parts = window.location.pathname.split('/');
59+
let realUrl;
60+
if (parts[2] === 'pr-preview') {
61+
realUrl = '/' + parts.slice(1, 4).join('/') + '/';
62+
} else {
63+
realUrl = '/' + parts.slice(1, 2).join('/') + '/';
64+
}
65+
fetch(realUrl)
66+
.then(response => response.text())
67+
.then(html => {
68+
document.documentElement.innerHTML = html;
69+
document.documentElement.querySelectorAll('script').forEach(oldScript => {
70+
const newScript = document.createElement('script');
71+
for (const { name, value } of oldScript.attributes) {
72+
newScript.setAttribute(name, value);
73+
}
74+
newScript.textContent = oldScript.textContent;
75+
oldScript.replaceWith(newScript);
76+
});
77+
});
78+
</script>
79+
</body>
80+
</html>
81+
EOF
82+
- name: Deploy
83+
uses: JamesIves/github-pages-deploy-action@v4.2.3
84+
with:
85+
branch: gh-pages
86+
folder: docs
87+
target-folder: .
88+
clean: true
89+
clean-exclude: pr-preview/**

.github/workflows/main.yml

Lines changed: 138 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,138 @@
1+
name: Rust CI
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
paths:
8+
- "**"
9+
pull_request:
10+
types: [opened, synchronize, reopened, ready_for_review]
11+
branches:
12+
- main
13+
paths:
14+
- "**"
15+
16+
concurrency:
17+
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
18+
cancel-in-progress: true
19+
20+
jobs:
21+
check:
22+
if: github.event.pull_request.draft == false
23+
name: Check
24+
runs-on: ubuntu-latest
25+
steps:
26+
- uses: actions/checkout@v4
27+
- uses: awalsh128/cache-apt-pkgs-action@latest
28+
with:
29+
packages: libwebkit2gtk-4.1-dev libgtk-3-dev libayatana-appindicator3-dev libxdo-dev
30+
version: 1.0
31+
- uses: dtolnay/rust-toolchain@stable
32+
- uses: Swatinem/rust-cache@v2
33+
with:
34+
cache-all-crates: "true"
35+
cache-on-failure: "false"
36+
- name: Check
37+
run: cargo check --workspace --all-features
38+
39+
test:
40+
if: github.event.pull_request.draft == false
41+
name: Test Suite
42+
runs-on: ubuntu-24.04
43+
steps:
44+
- uses: actions/checkout@v4
45+
- name: Free Disk Space
46+
uses: ./.github/actions/free-disk-space
47+
- uses: awalsh128/cache-apt-pkgs-action@latest
48+
with:
49+
packages: libwebkit2gtk-4.1-dev libgtk-3-dev libayatana-appindicator3-dev libxdo-dev
50+
version: 1.0
51+
- uses: dtolnay/rust-toolchain@stable
52+
with:
53+
components: rustfmt, clippy
54+
- uses: Swatinem/rust-cache@v2
55+
with:
56+
cache-all-crates: "true"
57+
- uses: browser-actions/setup-firefox@latest
58+
- name: Test
59+
run: cargo test --workspace
60+
61+
fmt:
62+
if: github.event.pull_request.draft == false
63+
name: Rustfmt
64+
runs-on: ubuntu-24.04
65+
steps:
66+
- uses: actions/checkout@v4
67+
- uses: dtolnay/rust-toolchain@stable
68+
with:
69+
components: rustfmt
70+
- uses: Swatinem/rust-cache@v2
71+
with:
72+
cache-all-crates: "true"
73+
- name: Format
74+
run: cargo fmt --all -- --check
75+
76+
docs:
77+
if: github.event.pull_request.draft == false
78+
name: Docs
79+
runs-on: ubuntu-24.04
80+
steps:
81+
- uses: actions/checkout@v4
82+
- uses: awalsh128/cache-apt-pkgs-action@latest
83+
with:
84+
packages: libwebkit2gtk-4.1-dev libgtk-3-dev libayatana-appindicator3-dev libxdo-dev
85+
version: 1.0
86+
- uses: dtolnay/rust-toolchain@nightly
87+
- uses: Swatinem/rust-cache@v2
88+
with:
89+
cache-all-crates: "true"
90+
- name: Docs
91+
run: cargo doc --workspace --no-deps --all-features --document-private-items
92+
env:
93+
RUSTDOCFLAGS: -Dwarnings --document-private-items
94+
95+
clippy:
96+
if: github.event.pull_request.draft == false
97+
name: Clippy
98+
runs-on: ubuntu-24.04
99+
steps:
100+
- uses: actions/checkout@v4
101+
- uses: awalsh128/cache-apt-pkgs-action@latest
102+
with:
103+
packages: libwebkit2gtk-4.1-dev libgtk-3-dev libayatana-appindicator3-dev libxdo-dev
104+
version: 1.0
105+
- uses: dtolnay/rust-toolchain@stable
106+
with:
107+
components: rustfmt, clippy
108+
- uses: Swatinem/rust-cache@v2
109+
with:
110+
cache-all-crates: "true"
111+
- name: Clippy
112+
run: cargo clippy --workspace --examples --tests --all-features --all-targets -- -D warnings
113+
114+
web-demo:
115+
if: github.event.pull_request.draft == false
116+
name: Web Demo
117+
runs-on: ubuntu-latest
118+
env:
119+
CARGO_INCREMENTAL: 1
120+
steps:
121+
- uses: actions/checkout@v4
122+
- uses: awalsh128/cache-apt-pkgs-action@latest
123+
with:
124+
packages: libwebkit2gtk-4.1-dev libgtk-3-dev libayatana-appindicator3-dev libxdo-dev
125+
version: 1.0
126+
- uses: dtolnay/rust-toolchain@stable
127+
with:
128+
targets: x86_64-unknown-linux-gnu,wasm32-unknown-unknown
129+
- uses: Swatinem/rust-cache@v2
130+
with:
131+
cache-all-crates: "true"
132+
cache-on-failure: "false"
133+
cache-directories: "target/dx"
134+
- uses: cargo-bins/cargo-binstall@main
135+
- name: Install Dioxus CLI
136+
run: cargo binstall dioxus-cli -y --force --version 0.7.7
137+
- name: Build web demo
138+
run: cd demo && dx build --web --release --no-default-features --features web --debug-symbols false --base-path "${{ github.event.repository.name }}"

.github/workflows/nightly.yml

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
name: Nightly
2+
3+
on:
4+
schedule:
5+
- cron: "21 8 * * *"
6+
workflow_dispatch:
7+
8+
concurrency:
9+
group: ${{ github.workflow }}-${{ github.ref }}
10+
cancel-in-progress: true
11+
12+
jobs:
13+
nightly:
14+
name: Nightly Toolchain
15+
runs-on: ubuntu-24.04
16+
steps:
17+
- uses: actions/checkout@v4
18+
- uses: awalsh128/cache-apt-pkgs-action@latest
19+
with:
20+
packages: libwebkit2gtk-4.1-dev libgtk-3-dev libayatana-appindicator3-dev libxdo-dev
21+
version: 1.0
22+
- uses: dtolnay/rust-toolchain@nightly
23+
with:
24+
components: rustfmt, clippy
25+
targets: x86_64-unknown-linux-gnu,wasm32-unknown-unknown
26+
- uses: Swatinem/rust-cache@v2
27+
with:
28+
cache-all-crates: "true"
29+
cache-on-failure: "true"
30+
- name: Check
31+
run: cargo check --workspace --all-features
32+
- name: Test
33+
run: cargo test --workspace
34+
- name: Clippy
35+
run: cargo clippy --workspace --examples --tests --all-features --all-targets -- -D warnings
36+
37+
web-demo:
38+
name: Nightly Web Demo Build
39+
runs-on: ubuntu-latest
40+
env:
41+
CARGO_INCREMENTAL: 1
42+
steps:
43+
- uses: actions/checkout@v4
44+
- uses: awalsh128/cache-apt-pkgs-action@latest
45+
with:
46+
packages: libwebkit2gtk-4.1-dev libgtk-3-dev libayatana-appindicator3-dev libxdo-dev
47+
version: 1.0
48+
- uses: dtolnay/rust-toolchain@nightly
49+
with:
50+
targets: x86_64-unknown-linux-gnu,wasm32-unknown-unknown
51+
- uses: Swatinem/rust-cache@v2
52+
with:
53+
cache-all-crates: "true"
54+
cache-on-failure: "true"
55+
cache-directories: "target/dx"
56+
- uses: cargo-bins/cargo-binstall@main
57+
- name: Install Dioxus CLI
58+
run: cargo binstall dioxus-cli -y --force --version 0.7.7
59+
- name: Build web demo
60+
run: cd demo && dx build --web --release --no-default-features --features web --debug-symbols false --base-path "${{ github.event.repository.name }}"

.github/workflows/preview.yml

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
name: Deploy PR Preview
2+
3+
on:
4+
pull_request_target:
5+
types: [opened, synchronize, reopened, ready_for_review]
6+
branches:
7+
- main
8+
9+
concurrency:
10+
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
11+
cancel-in-progress: true
12+
13+
permissions:
14+
contents: write
15+
pages: write
16+
pull-requests: write
17+
18+
jobs:
19+
deploy-preview:
20+
if: github.event.pull_request.draft == false
21+
name: Deploy PR Preview
22+
runs-on: ubuntu-latest
23+
env:
24+
CARGO_INCREMENTAL: 1
25+
steps:
26+
- uses: actions/checkout@v4
27+
with:
28+
ref: refs/pull/${{ github.event.pull_request.number }}/merge
29+
fetch-depth: 0
30+
- uses: awalsh128/cache-apt-pkgs-action@latest
31+
with:
32+
packages: libwebkit2gtk-4.1-dev libgtk-3-dev libayatana-appindicator3-dev libxdo-dev
33+
version: 1.0
34+
- uses: dtolnay/rust-toolchain@stable
35+
with:
36+
targets: x86_64-unknown-linux-gnu,wasm32-unknown-unknown
37+
- uses: Swatinem/rust-cache@v2
38+
with:
39+
cache-all-crates: "true"
40+
cache-on-failure: "false"
41+
cache-directories: "target/dx"
42+
- uses: cargo-bins/cargo-binstall@main
43+
- name: Install Dioxus CLI
44+
run: cargo binstall dioxus-cli -y --force --version 0.7.7
45+
- name: Build
46+
run: cd demo && dx build --web --release --no-default-features --features web --debug-symbols false --base-path "${{ github.event.repository.name }}/pr-preview/pr-${{ github.event.pull_request.number }}/"
47+
- name: Copy output
48+
run: cp -r target/dx/dioxus-code-demo/release/web/public docs
49+
- name: Deploy
50+
uses: JamesIves/github-pages-deploy-action@v4.2.3
51+
with:
52+
token: ${{ github.token }}
53+
branch: gh-pages
54+
folder: docs
55+
target-folder: pr-preview/pr-${{ github.event.pull_request.number }}/
56+
clean: false
57+
single-commit: true
58+
- name: Comment PR
59+
if: github.event.action == 'opened' || github.event.action == 'reopened' || github.event.action == 'ready_for_review'
60+
uses: thollander/actions-comment-pull-request@v3
61+
with:
62+
message: |
63+
Preview available at https://${{ github.repository_owner }}.github.io/${{ github.event.repository.name }}/pr-preview/pr-${{ github.event.pull_request.number }}/
64+
comment-tag: pr-preview

0 commit comments

Comments
 (0)