Skip to content

Commit f1ed4de

Browse files
Merge pull request #2215 from arduino/hannes7eicher/Update-Cloud-Editor-Docs
[MKC-1924] Update iframe docs
2 parents 399fc1b + 1a39a6a commit f1ed4de

15 files changed

+57
-93
lines changed
Loading
Loading

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

+57-23
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,26 @@
11
---
2-
title: 'Embedding your sketches into an HTML page'
3-
description: 'Learn about different methods when embedding your sketches in a website.'
4-
author: 'Karl Söderby'
2+
title: 'Embed & Share Sketches'
3+
description: 'Learn about sharing your sketches and different methods to embed your sketches in a website.'
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

17-
![embed field](assets/iframe-highlight.png)
17+
![Embed in HTML code](./assets/Embed_1.png)
18+
1819

1920
It should look something like this:
2021

2122
```markup
22-
<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>
23+
<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>
2324
```
2425

2526
This iframe can now simply be embedded in a HTML page, and it will look like this:
@@ -32,44 +33,73 @@ But there are many ways we can modify the iframe to look different. So let's tak
3233

3334
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!
3435

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

3738
```
38-
&snippet
39+
&view-mode=snippet
3940
```
4041
The result is the following:
4142

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>
43+
<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>
4344

4445
And the full URL should look like this:
4546

4647
```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>
48+
<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>
4849
```
4950

50-
5151
## Highlighting specific lines
5252

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

5555
```
56-
&snippet#L3-L4
56+
&highlight=L6,7
5757
```
5858

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

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>
61+
<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>
6262

6363
And the full URL should look like this:
6464

6565
```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>
66+
<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>
6767
```
6868

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:
69+
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:
7070

7171
```
72-
&snippet#L1,L3,L5-L8
72+
&highlight=L4,L6-L9
73+
```
74+
75+
## Scope
76+
77+
It's also possible to only show specific lines by adding the `scope` parameter, like this:
78+
79+
```markup
80+
&scope=L24-L37
81+
```
82+
83+
The result is that only lines 24 to 37 are shown.
84+
85+
<iframe src="https://app.arduino.cc/sketches/examples?eid=01.Basics%2FBlink&view-mode=snippet&scope=L24-L37" style="height:510px;width:100%;margin:10px 0" frameborder="0"></iframe>
86+
87+
The full URL should look like this:
88+
```markup
89+
<iframe src="https://app.arduino.cc/sketches/examples?eid=01.Basics%2FBlink&view-mode=snippet&scope=24-28" style="height:510px;width:100%;margin:10px 0" frameborder="0"></iframe>
90+
```
91+
92+
## Hide Numbers
93+
94+
To hide the line numbers in the embedded snippet, add the `&hide-numbers` parameter, like this:
95+
96+
```markup
97+
&hide-numbers
98+
```
99+
100+
The full URL should look like this:
101+
```markup
102+
<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>
73103
```
74104

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

91121
Which will look like this:
92122

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>
123+
<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>
94124

95125
## Automatically re-sizing your sketches
96126

@@ -100,13 +130,17 @@ We can also choose to automatically re-size our iframes. This is simply done by
100130
<script src="https://content.arduino.cc/assets/arduinoSketchIframeResizer.js"></script>
101131
```
102132

103-
And then using the class `arduino-sketch-iframe` in your HTML element.
133+
And then using the class `arduino-sketch-iframe` in your `HTML element`.
134+
135+
## Share your Code
136+
137+
If you want to share you're code with others can you do so by following the same steps as above, but instead of clicking on "Embed in HTML code:" you click on "Link to share:"
104138

105-
## Summary
139+
![Share Code](./assets/Share_1.png)
106140

107-
There are several cool ways of working with iframes from the Cloud Editor, and it is a really easy process that requires very little coding.
141+
This link will direct others to a preview of our code where they can copy it or directly add it to their sketchbook.
108142

109-
The Cloud Editor helps you keep track on all of your sketches, and with the iframes, including your projects on other pages has never been easier.
143+
***Note: If you want to learn how to keep sensitive data in your code safe, read [Store Sensitive Data in Sketches](/arduino-cloud/cloud-editor/share-your-sketches/).***
110144

111145
### More tutorials
112146

content/arduino-cloud/04.cloud-editor/share-your-sketches/share-your-sketches.md

-70
This file was deleted.

0 commit comments

Comments
 (0)