Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
public interface PluginParamType {
PluginParamType STRING = new PluginParamTypeString();
PluginParamType NUMBER = new PluginParamTypeNumber();
PluginParamType NUMBER_OR_STRING = new PluginParamTypeNumberOrString();
PluginParamType BOOLEAN = new PluginParamTypeBoolean();
PluginParamType OBJECT = new PluginParamTypeObject();
PluginParamType LIST_OR_OBJECT = new PluginParamTypeListOrObject();
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
/*
* Copyright 2022 znai maintainers
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package org.testingisdocumenting.znai.extensions.paramtypes;

import org.testingisdocumenting.znai.extensions.PluginParamType;

public class PluginParamTypeNumberOrString implements PluginParamType {
@Override
public String description() {
return "number or string";
}

@Override
public String example() {
return "5";
}

@Override
public boolean isValid(Object param) {
return CommonTypeValidation.matchStringOrNumber(param);
}
}
4 changes: 2 additions & 2 deletions znai-docs/znai/visuals/asciinema.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
To embedd [Acsiinema Player](https://docs.asciinema.org/manual/player/quick-start/) use:

```markdown
:include-asciinema: intro.cast
:include-asciinema: intro.cast {startAt: 10}
```

:include-asciinema: asciinema/intro.cast
:include-asciinema: asciinema/intro.cast {startAt: 10}
4 changes: 2 additions & 2 deletions znai-reactjs/src/doc-elements/asciinema/Asciinema.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,13 @@ import * as AsciinemaPlayer from 'asciinema-player';
import "asciinema-player/dist/bundle/asciinema-player.css";
import "./Asciinema.css"

export function Asciinema({src}) {
export function Asciinema({src, startAt = 0}) {
const containerRef = useRef(null);
const playerRef = useRef(null);

useEffect(() => {
if (containerRef.current) {
playerRef.current = AsciinemaPlayer.create(src, containerRef.current, {preload: true, fit: false});
playerRef.current = AsciinemaPlayer.create(src, containerRef.current, {preload: true, fit: false, startAt});
}

return () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,7 @@

import org.testingisdocumenting.znai.core.AuxiliaryFile;
import org.testingisdocumenting.znai.core.ComponentsRegistry;
import org.testingisdocumenting.znai.extensions.PluginParams;
import org.testingisdocumenting.znai.extensions.PluginResult;
import org.testingisdocumenting.znai.extensions.*;
import org.testingisdocumenting.znai.extensions.include.IncludePlugin;
import org.testingisdocumenting.znai.parser.ParserHandler;

Expand All @@ -36,6 +35,14 @@ public String id() {
return "asciinema";
}

@Override
public PluginParamsDefinition parameters() {
PluginParamsDefinition params = new PluginParamsDefinition();
params.add("startAt", PluginParamType.NUMBER_OR_STRING, "start the playback at a given time", "10 (seconds) or \"2:03\" (\"mm:ss\")");

return params;
}

@Override
public IncludePlugin create() {
return new AsciinemaIncludePlugin();
Expand Down