Skip to content

Commit

Permalink
Merge pull request #345 from NDLANO/update/use-h5p-settings
Browse files Browse the repository at this point in the history
Update/use h5p settings
  • Loading branch information
Bruswei authored May 25, 2023
2 parents d366499 + 3f30293 commit fece451
Show file tree
Hide file tree
Showing 38 changed files with 5,546 additions and 1,005 deletions.
2 changes: 2 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
dist/
node_modules/
79 changes: 2 additions & 77 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -1,79 +1,4 @@
{
"env": {
"browser": true,
"es2021": true
},
"extends": [
"plugin:react/recommended",
"airbnb",
"plugin:@typescript-eslint/recommended",
"prettier",
"prettier/prettier"
],
"parser": "@typescript-eslint/parser",
"parserOptions": {
"ecmaFeatures": {
"jsx": true
},
"ecmaVersion": 12,
"sourceType": "module"
},
"plugins": ["react", "@typescript-eslint", "react-hooks"],
"rules": {
"default-case": "off",
"no-use-before-define": "off",
"no-shadow": "off",
"no-console": ["error", { "allow": ["warn", "error", "info"] }],
"no-restricted-syntax": "off",
"class-methods-use-this": "off",
"@typescript-eslint/no-shadow": ["error"],
"@typescript-eslint/explicit-function-return-type": [
"error",
{
"allowExpressions": true
}
],
"@typescript-eslint/no-use-before-define": ["error"],
"import/prefer-default-export": "off",
"import/extensions": [
"error",
"ignorePackages",
{
"ts": "never",
"tsx": "never"
}
],
"import/no-extraneous-dependencies": [
"error",
{
"devDependencies": ["**/*.test.*", "**/*.stories.*", "vite.config.ts"]
}
],
"react-hooks/rules-of-hooks": "error",
"react-hooks/exhaustive-deps": "warn",
"react/prop-types": "off",
"react/require-default-props": "off",
"react/function-component-definition": [
"error",
{ "namedComponents": "arrow-function" }
],
"react/jsx-filename-extension": [
"warn",
{
"extensions": [".tsx"]
}
]
},
"settings": {
"import/resolver": {
"typescript": {}
}
},
"ignorePatterns": [
"dist",
"stories",
"storybook-static",
"node_modules",
"docs"
]
"extends": ["eslint-config-ndla-h5p"],
"parser": "@typescript-eslint/parser"
}
7 changes: 7 additions & 0 deletions .h5pignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ src
.babelrc
.gitignore
.h5pignore
.eslintignore
.eslintrc.json
.github
package.json
package-lock.json
README.md
Expand All @@ -12,3 +15,7 @@ storybook-static
docs
babel.config.js
tsconfig.json
jest.config.ts
typings.d.ts
build_info
H5P.d.ts
3 changes: 0 additions & 3 deletions .prettierignore

This file was deleted.

10 changes: 0 additions & 10 deletions .prettierrc

This file was deleted.

118 changes: 59 additions & 59 deletions H5P.d.ts
Original file line number Diff line number Diff line change
@@ -1,62 +1,6 @@
import { NDLATagsPicker } from "./src/widgets/NDLATagsPicker.widget";
import { H5PField } from "./src/types/H5P/H5PField";
import { H5PForm } from "./src/types/H5P/H5PForm";

export interface H5PObject {
EventDispatcher: typeof EventDispatcher;
getPath: (path: string, contentId: string) => string;
createUUID: () => string;
}

export interface H5PEditorObject {
NDLATagsPicker: typeof NDLATagsPicker;
widgets: {
NDLATagsPicker: typeof NDLATagsPicker;
};
$: typeof jQuery;
contentId: string;

/**
* Translate text strings.
*
* @param library The library name(machineName), or "core".
* @param key Translation string identifier.
* @param vars Placeholders and values to replace in the text.
*
* @returns Translated string, or a default text if the translation is missing.
*/
t: (
library: "H5PEditor.NDLATimeline" | "core",
key: string,
vars?: Record<string, string>,
) => string;

/**
* Recursive processing of the semantics chunks.
*
* @param semanticsChunk Array of semantics
* @param params
* @param $wrapper
* @param parent
*/
processSemanticsChunk: (
semanticsChunk: H5PField | Array<H5PField>,
params: unknown,
$wrapper: JQuery<HTMLElement>,
parent: H5PForm,
) => void;

/**
* Search for a field or a set of fields. Returns `null` if the field isn't found.
*
* @param fieldName
* @param semanticsStructure
*/
findSemanticsField: (
fieldName: string,
semanticsStructure: H5PField | Array<H5PField>,
) => H5PField | Array<H5PField> | null;
}
import { NDLATagsPicker } from './src/widgets/NDLATagsPicker.widget';
import { H5PField } from './src/types/H5P/H5PField';
import { H5PForm } from './src/types/H5P/H5PForm';

declare class EventDispatcher {
/**
Expand Down Expand Up @@ -139,3 +83,59 @@ declare interface IH5PEditorWrapper {
validate(): boolean;
remove(): void;
}

export interface H5PEditorObject {
NDLATagsPicker: typeof NDLATagsPicker;
widgets: {
NDLATagsPicker: typeof NDLATagsPicker;
};
$: typeof jQuery;
contentId: string;

/**
* Translate text strings.
*
* @param library The library name(machineName), or "core".
* @param key Translation string identifier.
* @param vars Placeholders and values to replace in the text.
*
* @returns Translated string, or a default text if the translation is missing.
*/
t: (
library: 'H5PEditor.NDLATimeline' | 'core',
key: string,
vars?: Record<string, string>,
) => string;

/**
* Recursive processing of the semantics chunks.
*
* @param semanticsChunk Array of semantics
* @param params
* @param $wrapper
* @param parent
*/
processSemanticsChunk: (
semanticsChunk: H5PField | Array<H5PField>,
params: unknown,
$wrapper: JQuery<HTMLElement>,
parent: H5PForm,
) => void;

/**
* Search for a field or a set of fields. Returns `null` if the field isn't found.
*
* @param fieldName
* @param semanticsStructure
*/
findSemanticsField: (
fieldName: string,
semanticsStructure: H5PField | Array<H5PField>,
) => H5PField | Array<H5PField> | null;
}

export interface H5PObject {
EventDispatcher: typeof EventDispatcher;
getPath: (path: string, contentId: string) => string;
createUUID: () => string;
}
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2021 NDLA - H5P

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
6 changes: 3 additions & 3 deletions babel.config.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
module.exports = {
presets: [
"@babel/preset-env",
"@babel/preset-react",
"@babel/preset-typescript",
'@babel/preset-env',
'@babel/preset-react',
'@babel/preset-typescript',
],
};
14 changes: 7 additions & 7 deletions jest.config.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
import type { Config } from "@jest/types";
import type { Config } from '@jest/types';
// eslint-disable-next-line import/no-extraneous-dependencies
import { defaults } from "jest-config";
import { defaults } from 'jest-config';

const config: Config.InitialOptions = {
moduleNameMapper: {
"\\.(jpg|jpeg|png|gif|eot|otf|webp|svg|ttf|woff|woff2|mp4|webm|wav|mp3|m4a|aac|oga)$":
"<rootDir>/__mocks__/fileMock.js",
"\\.module\\.(css|sass|scss)$": "identity-obj-proxy",
'\\.(jpg|jpeg|png|gif|eot|otf|webp|svg|ttf|woff|woff2|mp4|webm|wav|mp3|m4a|aac|oga)$':
'<rootDir>/__mocks__/fileMock.js',
'\\.module\\.(css|sass|scss)$': 'identity-obj-proxy',
},
testPathIgnorePatterns: [...defaults.testPathIgnorePatterns, "e2e"],
testEnvironment: "jsdom",
testPathIgnorePatterns: [...defaults.testPathIgnorePatterns, 'e2e'],
testEnvironment: 'jsdom',
};

export default config;
10 changes: 7 additions & 3 deletions library.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,20 @@
"machineName": "H5PEditor.NDLATimeline",
"majorVersion": 0,
"minorVersion": 0,
"patchVersion": 5,
"patchVersion": 6,
"license": "MIT",
"runnable": 0,
"preloadedJs": [
{
"path": "dist/bundle.js"
"path": "dist/h5p-editor-timeline.js"
},
{
"path": "dist/vendor.js"
}
],
"preloadedCss": [
{
"path": "dist/main.css"
"path": "dist/h5p-editor-timeline.css"
}
]
}
Loading

0 comments on commit fece451

Please sign in to comment.