-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #8 from NDLA-H5P/feature/make_editor_run
make editor run preserving functionality
- Loading branch information
Showing
8 changed files
with
301 additions
and
53 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,25 @@ | ||
{ | ||
"title": "h5p-editor-timeline Editor", | ||
"machineName": "H5PEditor.H5pEditorTimeline", | ||
"majorVersion": 1, | ||
"machineName": "H5PEditor.Timeline", | ||
"majorVersion": 2, | ||
"minorVersion": 0, | ||
"patchVersion": 0, | ||
"runnable": 1, | ||
"runnable": 0, | ||
"preloadedJs": [ | ||
{ | ||
"path": "src/h5p-editor-timeline.js" | ||
"path": "dist/bundle.js" | ||
} | ||
], | ||
"preloadedCss": [ | ||
{ | ||
"path": "dist/main.css" | ||
} | ||
], | ||
"preloadedDependencies": [ | ||
{ | ||
"machineName": "H5P.Timeline", | ||
"majorVersion": 2, | ||
"minorVersion": 0 | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,45 @@ | ||
/* eslint-disable react/prefer-stateless-function */ | ||
import * as React from "react"; | ||
import { hot } from "react-hot-loader/root"; | ||
import { H5PField } from "./types/h5p/H5PField"; | ||
import { H5PForm } from "./types/h5p/H5PForm"; | ||
import { Params } from "./types/h5p/Params"; | ||
import { | ||
fillInMissingParamsProperties, | ||
getEmptyParams, | ||
} from "./utils/H5P/form.utils"; | ||
|
||
type Props = { | ||
adjective: string; | ||
type AppProps = { | ||
setValue: (params: Params) => void; | ||
semantics: H5PField; | ||
initialParams: Partial<Params> | undefined; | ||
parent: H5PForm; | ||
}; | ||
|
||
class App extends React.Component<Props> { | ||
render(): JSX.Element { | ||
const { adjective } = this.props; | ||
return ( | ||
<> | ||
<h1>Hi, you're {adjective}</h1> | ||
</> | ||
); | ||
} | ||
} | ||
const App: React.FC<AppProps> = ({ | ||
setValue, | ||
semantics, | ||
initialParams, | ||
parent, | ||
}) => { | ||
const [params, setParams] = React.useState<Params>( | ||
initialParams | ||
? fillInMissingParamsProperties(initialParams) | ||
: getEmptyParams() | ||
); | ||
|
||
return <div className="h5p-editor-topic-map">test</div>; | ||
}; | ||
|
||
// class App extends React.Component<Props> { | ||
// render(): JSX.Element { | ||
// const { adjective } = this.props; | ||
// return ( | ||
// <> | ||
// <h1>Hi, you're {adjective}</h1> | ||
// </> | ||
// ); | ||
// } | ||
// } | ||
|
||
export default hot(App); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,63 @@ | ||
/* eslint-disable no-console */ | ||
import * as React from "react"; | ||
import * as ReactDOM from "react-dom"; | ||
import App from "../App"; | ||
import { H5PField } from "../types/h5p/H5PField"; | ||
import { H5PForm } from "../types/h5p/H5PForm"; | ||
import { H5PSetValue } from "../types/h5p/H5PSetValue"; | ||
import { Params } from "../types/h5p/Params"; | ||
import { H5P } from "./H5P.util"; | ||
|
||
export class H5PWrapper extends H5P.EventDispatcher { | ||
private wrapper: HTMLElement; | ||
|
||
constructor(params: unknown, contentId: string, extras?: unknown) { | ||
public field: H5PField; | ||
|
||
constructor( | ||
parent: H5PForm, | ||
semantics: H5PField, | ||
params: Params, | ||
setValue: H5PSetValue | ||
) { | ||
super(); | ||
this.wrapper = H5PWrapper.createWrapperElement(); | ||
this.field = semantics; | ||
super(); | ||
console.log("H5PWrapper.constructor", params); | ||
this.wrapper = H5PWrapper.createWrapperElement(); | ||
|
||
ReactDOM.render(<App adjective="astonishing" />, this.wrapper); | ||
ReactDOM.render( | ||
<App | ||
setValue={(newParams) => setValue(semantics, newParams)} | ||
semantics={semantics} | ||
initialParams={params} | ||
parent={parent} | ||
/>, | ||
this.wrapper | ||
); | ||
} | ||
|
||
attach([containerElement]: JQuery<HTMLElement>): void { | ||
console.log("H5PWrapper.attach", containerElement); | ||
containerElement.appendChild(this.wrapper); | ||
containerElement.classList.add("h5p-h5p-editor-timeline"); | ||
} | ||
|
||
appendTo([containerElement]: JQuery<HTMLElement>): void { | ||
containerElement.appendChild(this.wrapper); | ||
containerElement.classList.add("h5p-timeline"); | ||
} | ||
|
||
validate(): boolean { | ||
return this.wrapper !== null; | ||
} | ||
|
||
remove(): void { | ||
console.log("H5PWrapper.remove", this); | ||
} | ||
|
||
private static createWrapperElement(): HTMLDivElement { | ||
console.log("H5PWrapper.createWrapperElement"); | ||
return document.createElement("div"); | ||
} | ||
} |
Oops, something went wrong.