Skip to content

Commit 57dbb52

Browse files
committed
update iframe docs
1 parent 5f83858 commit 57dbb52

File tree

1 file changed

+47
-18
lines changed

1 file changed

+47
-18
lines changed

content/arduino-cloud/04.cloud-editor/embedding-create-iframes/embedding-create-iframes.md

Lines changed: 47 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
---
2-
title: 'Embedding your sketches into an HTML page'
2+
title: 'Embedding Sketches with Iframes'
33
description: 'Learn about different methods when embedding your sketches in a website.'
4-
author: 'Karl Söderby'
4+
author: 'Karl Söderby, Hannes Siebeneicher'
55
---
66

77
The Cloud Editor is a great tool for creating and uploading programs while also collecting all of your sketches in one place. Another great feature is embedding them as iframes, such as articles, blogposts or journals.
88

9-
To embed an iframe is very easy, and we just need to copy and paste a link from our sketch in the Cloud Editor. But we can also do a series of modifications to that iframe, and in this tutorial we will take a look at how to do that.
9+
Embedding an iframe is easy. Simply copy and paste the link from your sketch in the Cloud Editor. But we can also do a series of modifications to that iframe, and in this tutorial we will take a look at how to do that.
1010

1111
## Let's start
1212

13-
First of all, we need to navigate to the [Cloud Editor](https://create.arduino.cc/editor). If we do not have an account, we can register one with just a few simple steps.
13+
First of all, we need to navigate to the [Cloud Editor](https://app.arduino.cc/sketches). If we do not have an account, we can register one with just a few simple steps.
1414

1515
Then, we need to have a code. In this tutorial, we are just going to use the good old **blink** example. When we have our sketch ready, click on the **share** button next to the serial monitor tool. This will open up a new window, that will have two fields: **link** and **embed**. Copy the embed field.
1616

@@ -24,52 +24,81 @@ It should look something like this:
2424

2525
This iframe can now simply be embedded in a HTML page, and it will look like this:
2626

27-
<iframe src="https://app.arduino.cc/sketches/examples?eid=01.Basics%2FBlink&view-mode=embed" style="height:510px;width:100%;margin:10px 0" frameborder="0"></iframe>
27+
<iframe src="https://app.arduino.cc/sketches/examples?eid=01.Basics%2FBlink&view-mode=embed" style="height:510px;width:100%;margin:10px 0" frameborder=0></iframe>
2828

2929
But there are many ways we can modify the iframe to look different. So let's take a look the available modifications we can make!
3030

3131
## Creating a snippet
3232

3333
First up is the easiest: making a simple snippet. This removes the other information, such as sketch name and author, and simply presents a good looking snippet!
3434

35-
To do this, we just need to add the following code to the end of the URL:
35+
To do this, we need to change `view-mode=` from `embed` to `snippet` at the end of the URL:
3636

3737
```
38-
&snippet
38+
&view-mode=snippet
3939
```
4040
The result is the following:
4141

42-
<iframe src="https://app.arduino.cc/sketches/examples?eid=01.Basics%2FBlink&view-mode=embed&snippet" style="height:510px;width:100%;margin:10px 0" frameborder="0"></iframe>
42+
<iframe src="https://app.arduino.cc/sketches/examples?eid=01.Basics%2FBlink&view-mode=snippet" style="height:510px;width:100%;margin:10px 0" frameborder=0></iframe>
4343

4444
And the full URL should look like this:
4545

4646
```markup
47-
<iframe src="https://app.arduino.cc/sketches/examples?eid=01.Basics%2FBlink&view-mode=embed&snippet" style="height:510px;width:100%;margin:10px 0" frameborder=0></iframe>
47+
<iframe src="https://app.arduino.cc/sketches/examples?eid=01.Basics%2FBlink&view-mode=snippet" style="height:510px;width:100%;margin:10px 0" frameborder=0></iframe>
4848
```
4949

50-
5150
## Highlighting specific lines
5251

5352
Next is the highlighting feature. To use this, simply add the following lines to the end of your URL:
5453

5554
```
56-
&snippet#L3-L4
55+
&highlight=L6,7
5756
```
5857

59-
The result is that line 3 and 4 are highlighted:
58+
The result is that line 6 and 7 are highlighted:
6059

61-
<iframe src="https://app.arduino.cc/sketches/examples?eid=01.Basics%2FBlink&view-mode=embed&snippet#L3-L4" style="height:510px;width:100%;margin:10px 0" frameborder="0"></iframe>
60+
<iframe src="https://app.arduino.cc/sketches/examples?eid=01.Basics%2FBlink&view-mode=snippet&highlight=L6,7" style="height:510px;width:100%;margin:10px 0" frameborder=0></iframe>
6261

6362
And the full URL should look like this:
6463

6564
```markup
66-
<iframe src="https://app.arduino.cc/sketches/examples?eid=01.Basics%2FBlink&view-mode=embed&snippet#L3-L4" style="height:510px;width:100%;margin:10px 0" frameborder=0></iframe>
65+
<iframe src="https://app.arduino.cc/sketches/examples?eid=01.Basics%2FBlink&view-mode=snippet&highlight=L6,7" style="height:510px;width:100%;margin:10px 0" frameborder=0></iframe>
66+
```
67+
68+
You can highlight as many lines as you want, and it is easily configurable. For example, if we want to highlight line 4 and 6-9, we simply need to add the following to the URL:
69+
70+
```
71+
&highlight=L4,L6-L9
72+
```
73+
74+
## Scope
75+
76+
It's also possible to only show specific lines by adding the `scope` parameter, like this:
77+
78+
```markup
79+
&scope=L3-L30
80+
```
81+
82+
The result is that only lines 3 to 30 are shown.
83+
84+
<iframe src="https://app.arduino.cc/sketches/examples?eid=01.Basics%2FBlink&view-mode=snippet&scope=L3-L30" style="height:510px;width:100%;margin:10px 0" frameborder=0></iframe>
85+
86+
The full URL should look like this:
87+
```markup
88+
<iframe src="https://app.arduino.cc/sketches/examples?eid=01.Basics%2FBlink&view-mode=snippet&scope=L3-L30" style="height:510px;width:100%;margin:10px 0" frameborder=0></iframe>
6789
```
6890

69-
You can highlight as many lines as you want, and it is easily configurable. For example, if we want to highlight line 1, 3 and 5-8, we simply need to add the following to the URL:
91+
## Hide Numbers
92+
93+
To hide the line numbers in the embedded snippet, add the `&hide-numbers` parameter, like this:
7094

95+
```markup
96+
&hide-numbers
7197
```
72-
&snippet#L1,L3,L5-L8
98+
99+
The full URL should look like this:
100+
```markup
101+
<iframe src="https://app.arduino.cc/sketches/examples?eid=01.Basics%2FBlink&view-mode=snippet&scope=L3-L30&hide-numbers" style="height:510px;width:100%;margin:10px 0" frameborder=0></iframe>
73102
```
74103

75104
## Manually changing the size of your widget
@@ -90,7 +119,7 @@ style="height:200px;width:50%;margin:10px 0"
90119

91120
Which will look like this:
92121

93-
<iframe src="https://app.arduino.cc/sketches/examples?eid=01.Basics%2FBlink&view-mode=embed&snippet" style="height:200px;width:50%;margin:10px 0" frameborder="0"></iframe>
122+
<iframe src="https://app.arduino.cc/sketches/examples?eid=01.Basics%2FBlink&view-mode=snippet" style="height:200px;width:50%;margin:10px 0" frameborder=0></iframe>
94123

95124
## Automatically re-sizing your sketches
96125

@@ -100,7 +129,7 @@ We can also choose to automatically re-size our iframes. This is simply done by
100129
<script src="https://content.arduino.cc/assets/arduinoSketchIframeResizer.js"></script>
101130
```
102131

103-
And then using the class `arduino-sketch-iframe` in your HTML element.
132+
And then using the class `arduino-sketch-iframe` in your `HTML element`.
104133

105134
## Summary
106135

0 commit comments

Comments
 (0)