Skip to content

Commit c238bbc

Browse files
iframe: auto resize dynamic content + wide mode(#1489)
1 parent a217612 commit c238bbc

39 files changed

Lines changed: 579 additions & 402 deletions

znai-core/src/main/java/org/testingisdocumenting/znai/extensions/html/IframeIncludePlugin.java

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,10 @@
1818

1919
import org.testingisdocumenting.znai.core.AuxiliaryFile;
2020
import org.testingisdocumenting.znai.core.ComponentsRegistry;
21+
import org.testingisdocumenting.znai.extensions.PluginParamType;
2122
import org.testingisdocumenting.znai.extensions.PluginParams;
23+
import org.testingisdocumenting.znai.extensions.PluginParamsDefinition;
24+
import org.testingisdocumenting.znai.extensions.PluginParamsDefinitionCommon;
2225
import org.testingisdocumenting.znai.extensions.PluginResult;
2326
import org.testingisdocumenting.znai.extensions.include.IncludePlugin;
2427
import org.testingisdocumenting.znai.parser.ParserHandler;
@@ -45,6 +48,20 @@ public IncludePlugin create() {
4548
return new IframeIncludePlugin();
4649
}
4750

51+
@Override
52+
public PluginParamsDefinition parameters() {
53+
PluginParamsDefinition params = new PluginParamsDefinition();
54+
params.add(PluginParamsDefinitionCommon.title);
55+
params.add("fit", PluginParamType.BOOLEAN, "automatically set iframe height to fit its content", "true");
56+
params.add("height", PluginParamType.NUMBER, "force specific iframe height in pixels, acts as minimum height when fit is true", "200");
57+
params.add("maxHeight", PluginParamType.NUMBER, "limit the automatically calculated height, adds scrollbar", "64");
58+
params.add("wide", PluginParamType.BOOLEAN, "take all the available horizontal space", "true");
59+
params.add("aspectRatio", PluginParamType.STRING, "aspect ratio for video embedding", "\"16:9\"");
60+
params.add("light", PluginParamType.OBJECT, "CSS properties override for light theme", "{ \"--color\": \"#333\" }");
61+
params.add("dark", PluginParamType.OBJECT, "CSS properties override for dark theme", "{ \"--color\": \"#eee\" }");
62+
return params;
63+
}
64+
4865
@Override
4966
public PluginResult process(ComponentsRegistry componentsRegistry, ParserHandler parserHandler, Path markupPath, PluginParams pluginParams) {
5067
DocElement iframe = new DocElement("Iframe");

znai-docs/znai/llm.txt

Lines changed: 38 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -146,8 +146,8 @@ answer-link: znai-from-export/introduction/getting-started#command-line
146146
## CLI download
147147

148148
Download and unzip
149-
[znai](https://repo.maven.apache.org/maven2/org/testingisdocumenting/znai/znai-dist/1.87/znai-dist-1.87-znai.zip). Add
150-
it to your `PATH`.
149+
[znai](https://repo.maven.apache.org/maven2/org/testingisdocumenting/znai/znai-dist/1.87.2-SNAPSHOT/znai-dist-1.87.2-SNAPSHOT-znai.zip).
150+
Add it to your `PATH`.
151151

152152
## Brew
153153

@@ -162,7 +162,7 @@ answer-link: znai-from-export/introduction/getting-started#maven-plugin
162162
<plugin>
163163
<groupId>org.testingisdocumenting.znai</groupId>
164164
<artifactId>znai-maven-plugin</artifactId>
165-
<version>1.87</version>
165+
<version>1.87.2-SNAPSHOT</version>
166166
</plugin>
167167
```
168168

@@ -4692,7 +4692,7 @@ scenario("capture screenshot") {
46924692
"type" : "badge",
46934693
"text" : "2",
46944694
"x" : 367,
4695-
"y" : 594,
4695+
"y" : 604,
46964696
"align" : "Center"
46974697
} ],
46984698
"pixelRatio" : 2
@@ -6239,10 +6239,35 @@ Use `title` parameter to display title bar on top of the embedded content:
62396239
}
62406240
```
62416241

6242-
# Visuals :: Iframe :: Height
6243-
answer-link: znai-from-export/visuals/iframe#height
6242+
# Visuals :: Iframe :: Dynamic Content
6243+
answer-link: znai-from-export/visuals/iframe#dynamic-content
62446244

6245-
Use `height` to force container height. Use `maxHeight` to limit the automatically calculated height.
6245+
When iframe content changes after page load, the iframe automatically resizes to fit. Click buttons below to see it in
6246+
action:
6247+
6248+
6249+
Use `height` and `maxHeight` to limit the height when content grows:
6250+
6251+
```markdown
6252+
:include-iframe: iframe/custom-delayed.html {
6253+
fit: true,
6254+
height: 120,
6255+
maxHeight: 200
6256+
}
6257+
```
6258+
6259+
# Visuals :: Iframe :: Wide
6260+
answer-link: znai-from-export/visuals/iframe#wide
6261+
6262+
Use `wide` to take all the available horizontal space:
6263+
6264+
```markdown
6265+
:include-iframe: iframe/custom.html {
6266+
title: "my wide iframe content",
6267+
fit: true,
6268+
wide: true
6269+
}
6270+
```
62466271

62476272
# Visuals :: Iframe :: Embedding Video
62486273
answer-link: znai-from-export/visuals/iframe#embedding-video
@@ -8589,7 +8614,7 @@ scenario("capture screenshot") {
85898614
"type" : "badge",
85908615
"text" : "2",
85918616
"x" : 367,
8592-
"y" : 594,
8617+
"y" : 604,
85938618
"align" : "Center"
85948619
} ],
85958620
"pixelRatio" : 2
@@ -9064,6 +9089,11 @@ export PATH=$(pwd)/dist:$PATH
90649089
znai --version
90659090
```
90669091

9092+
# Release Notes :: 2026 :: 1.88
9093+
answer-link: znai-from-export/release-notes/2026#188
9094+
9095+
9096+
90679097
# Release Notes :: 2026 :: 1.87
90689098
answer-link: znai-from-export/release-notes/2026#187
90699099

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
* Add: iframe resize on content changes
2+
* Add: iframe wide mode
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
* Add: api params wide mode title is aligned with content block
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
* Add: code snippets wide mode title is aligned with content block
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
* Add: image wide mode title layout consistent with iframes
2+
* Add: image wide mode fits and takes all the space
3+
* Add: images are fit by default now

znai-docs/znai/release-notes/2026.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
# 1.88
2+
3+
:include-markdowns: 1.88
4+
15
# 1.87
26

37
:include-markdowns: 1.87

znai-docs/znai/snippets/api-parameters.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,7 @@ Use `wide: true` to use all the available horizontal space
224224
line with *markdown* support and few moe lines"
225225
```
226226

227-
```api-parameters {anchorPrefix: "customPrefix", noWrap: true, wide: true}
227+
```api-parameters {anchorPrefix: "customPrefix", title: "wide mode", noWrap: true, wide: true}
228228
VERY_LONG_PARAMETER_NAME_WITHOUT_SPACES, String, "longer line longer line, description with *markdown* support"
229229
VERY_LONG_ANOTHER_PARAMETER_NAME_WITHOUT_SPACES, String, "longer line longer line, another description
230230
line with *markdown* support and few moe lines"

znai-docs/znai/snippets/code-snippets.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ Use the `wide` option to stretch wide code to occupy as much horizontal real est
103103
}
104104
```
105105

106-
```java {wide: true}
106+
```java {wide: true, title: "wide code snippet"}
107107
class InternationalPriceService implements PriceService {
108108
private static void LongJavaInterfaceNameWithSuperFactory createMegaAbstractFactory(final ExchangeCalendarLongerThanLife calendar) {
109109
...

znai-docs/znai/snippets/external-code-snippets.md

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -63,13 +63,11 @@ Use `anchorId` to override auto generated identifier.
6363

6464
Use the `wide` option to stretch wide code to occupy as much horizontal screen real estate as possible.
6565

66-
:include-file: WideCode.java {wide: true}
66+
```markdown
67+
:include-file: WideCode.java {wide: true, title: "wide code"}
68+
```
6769

68-
:include-file: WideCode.java {wide: true}
69-
70-
Without the `wide` option code will be aligned with the rest of the text and users can use scrollbars.
71-
72-
:include-file: WideCode.java
70+
:include-file: WideCode.java {wide: true, title: "wide code"}
7371

7472
Note: Good placement of a *Wide Code* element is at the end of a page or a section to show the full version of a code sample.
7573

0 commit comments

Comments
 (0)