@modusoperandi/licit-vignette 0.0.16

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (51) hide show
  1. package/.eslintignore +4 -0
  2. package/.eslintrc.js +107 -0
  3. package/.prettierignore +6 -0
  4. package/.prettierrc +5 -0
  5. package/.stylelintignore +3 -0
  6. package/.stylelintrc.json +10 -0
  7. package/LICENSE +21 -0
  8. package/README.md +33 -0
  9. package/babel.config.json +53 -0
  10. package/dist/Constants.d.ts +6 -0
  11. package/dist/Constants.js +18 -0
  12. package/dist/CreateCommand.d.ts +7 -0
  13. package/dist/CreateCommand.js +30 -0
  14. package/dist/TableBackgroundColorCommand.d.ts +5 -0
  15. package/dist/TableBackgroundColorCommand.js +21 -0
  16. package/dist/TableBorderColorCommand.d.ts +5 -0
  17. package/dist/TableBorderColorCommand.js +21 -0
  18. package/dist/VignetteCommand.d.ts +12 -0
  19. package/dist/VignetteCommand.js +104 -0
  20. package/dist/VignetteMenuPlugin.d.ts +19 -0
  21. package/dist/VignetteMenuPlugin.js +120 -0
  22. package/dist/VignetteNodeSpec.d.ts +34 -0
  23. package/dist/VignetteNodeSpec.js +83 -0
  24. package/dist/VignettePlugin.d.ts +12 -0
  25. package/dist/VignettePlugin.js +49 -0
  26. package/dist/VignettePlugins.d.ts +4 -0
  27. package/dist/VignettePlugins.js +11 -0
  28. package/dist/index.d.ts +2 -0
  29. package/dist/index.js +13 -0
  30. package/dist/index.test.js +48 -0
  31. package/dist/ui/TableColorCommand.d.ts +14 -0
  32. package/dist/ui/TableColorCommand.js +64 -0
  33. package/jest.config.ts +208 -0
  34. package/jest.setup.js +2 -0
  35. package/lint.sh +4 -0
  36. package/package.json +132 -0
  37. package/sonar-project.properties +11 -0
  38. package/src/Constants.ts +6 -0
  39. package/src/CreateCommand.ts +38 -0
  40. package/src/TableBackgroundColorCommand.ts +9 -0
  41. package/src/TableBorderColorCommand.ts +9 -0
  42. package/src/VignetteCommand.ts +103 -0
  43. package/src/VignetteMenuPlugin.ts +151 -0
  44. package/src/VignetteNodeSpec.ts +74 -0
  45. package/src/VignettePlugin.ts +53 -0
  46. package/src/VignettePlugins.ts +7 -0
  47. package/src/index.test.ts +59 -0
  48. package/src/index.ts +3 -0
  49. package/src/ui/TableColorCommand.tsx +79 -0
  50. package/tsconfig.json +38 -0
  51. package/webpack.config.js +89 -0
@@ -0,0 +1,83 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = exports.VignetteTableNodeSpec = exports.VignetteTableCellNodeSpec = void 0;
7
+ var _Constants = require("./Constants");
8
+ // Override the default table node spec to support custom attributes.
9
+ const VignetteTableNodeSpec = nodespec => Object.assign({}, nodespec, {
10
+ attrs: {
11
+ marginLeft: {
12
+ default: null
13
+ },
14
+ vignette: {
15
+ default: false
16
+ }
17
+ },
18
+ parseDOM: [{
19
+ tag: _Constants.TABLE,
20
+ getAttrs(dom) {
21
+ const {
22
+ marginLeft
23
+ } = dom.style;
24
+ const vignette = dom.getAttribute(_Constants.VIGNETTE) === 'true' || false;
25
+ if (marginLeft && /\d+px/.test(marginLeft)) {
26
+ return {
27
+ marginLeft: parseFloat(marginLeft),
28
+ vignette
29
+ };
30
+ }
31
+ return {
32
+ vignette
33
+ };
34
+ },
35
+ style: 'border'
36
+ }],
37
+ toDOM(node) {
38
+ // Normally, the DOM structure of the table node is rendered by
39
+ // `TableNodeView`. This method is only called when user selects a
40
+ // table node and copies it, which triggers the "serialize to HTML" flow
41
+ // that calles this method.
42
+ const {
43
+ marginLeft,
44
+ vignette
45
+ } = node.attrs;
46
+ const domAttrs = {
47
+ vignette
48
+ };
49
+ let style = 'border: none';
50
+ if (marginLeft) {
51
+ style += `margin-left: ${marginLeft}px`;
52
+ }
53
+ domAttrs['style'] = style;
54
+ return [_Constants.TABLE, domAttrs, 0];
55
+ }
56
+ });
57
+ exports.VignetteTableNodeSpec = VignetteTableNodeSpec;
58
+ const VignetteTableCellNodeSpec = nodespec => Object.assign({}, nodespec, {
59
+ attrs: Object.assign({}, nodespec.attrs, {
60
+ vignette: {
61
+ default: false
62
+ }
63
+ }),
64
+ parseDOM: [{
65
+ tag: 'td',
66
+ getAttrs: dom => {
67
+ return Object.assign({}, nodespec.parseDOM[0].getAttrs(dom), {
68
+ vignette: dom.getAttribute(_Constants.VIGNETTE) || false
69
+ });
70
+ }
71
+ }],
72
+ toDOM(node) {
73
+ const base = nodespec.toDOM(node);
74
+ if (node.attrs.vignette && Array.isArray(base) && 1 < base.length && base[1].style) {
75
+ base[1].style += 'border-radius: 10px; border-style: solid; border-width: thin';
76
+ }
77
+ base[1].vignette = node.attrs.vignette;
78
+ return base;
79
+ }
80
+ });
81
+ exports.VignetteTableCellNodeSpec = VignetteTableCellNodeSpec;
82
+ var _default = VignetteTableNodeSpec;
83
+ exports.default = _default;
@@ -0,0 +1,12 @@
1
+ import { Plugin } from 'prosemirror-state';
2
+ import { EditorView } from 'prosemirror-view';
3
+ import { Schema } from 'prosemirror-model';
4
+ import VignetteCommand from './VignetteCommand';
5
+ export declare class VignettePlugin extends Plugin {
6
+ _view: EditorView;
7
+ constructor();
8
+ getEffectiveSchema(schema: Schema): Schema;
9
+ initButtonCommands(): {
10
+ '[crop] Insert Vignette': VignetteCommand;
11
+ };
12
+ }
@@ -0,0 +1,49 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.VignettePlugin = void 0;
7
+ var _prosemirrorState = require("prosemirror-state");
8
+ var _prosemirrorModel = require("prosemirror-model");
9
+ var _VignetteCommand = _interopRequireDefault(require("./VignetteCommand"));
10
+ var _VignetteNodeSpec = require("./VignetteNodeSpec");
11
+ var _Constants = require("./Constants");
12
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
13
+ function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
14
+ function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
15
+ function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
16
+ class VignettePlugin extends _prosemirrorState.Plugin {
17
+ constructor() {
18
+ super({
19
+ key: new _prosemirrorState.PluginKey('VignettePlugin'),
20
+ state: {
21
+ init(_config, _state) {
22
+ // do nothing
23
+ },
24
+ apply(_tr, _set) {
25
+ //do nothing
26
+ }
27
+ },
28
+ props: {
29
+ nodeViews: {}
30
+ }
31
+ });
32
+ _defineProperty(this, "_view", null);
33
+ }
34
+ getEffectiveSchema(schema) {
35
+ let nodes = schema.spec.nodes.update(_Constants.TABLE, (0, _VignetteNodeSpec.VignetteTableNodeSpec)(schema.spec.nodes.get(_Constants.TABLE)));
36
+ nodes = nodes.update(_Constants.TABLE_CELL, (0, _VignetteNodeSpec.VignetteTableCellNodeSpec)(schema.spec.nodes.get(_Constants.TABLE_CELL)));
37
+ const marks = schema.spec.marks;
38
+ return new _prosemirrorModel.Schema({
39
+ nodes: nodes,
40
+ marks: marks
41
+ });
42
+ }
43
+ initButtonCommands() {
44
+ return {
45
+ '[crop] Insert Vignette': new _VignetteCommand.default()
46
+ };
47
+ }
48
+ }
49
+ exports.VignettePlugin = VignettePlugin;
@@ -0,0 +1,4 @@
1
+ import { VignettePlugin } from './VignettePlugin';
2
+ import VignetteMenuPlugin from './VignetteMenuPlugin';
3
+ declare const _default: (VignetteMenuPlugin | VignettePlugin)[];
4
+ export default _default;
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+ var _VignettePlugin = require("./VignettePlugin");
8
+ var _VignetteMenuPlugin = _interopRequireDefault(require("./VignetteMenuPlugin"));
9
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
10
+ var _default = [new _VignetteMenuPlugin.default(), new _VignettePlugin.VignettePlugin()];
11
+ exports.default = _default;
@@ -0,0 +1,2 @@
1
+ import VignettePlugins from './VignettePlugins';
2
+ export { VignettePlugins };
package/dist/index.js ADDED
@@ -0,0 +1,13 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ Object.defineProperty(exports, "VignettePlugins", {
7
+ enumerable: true,
8
+ get: function () {
9
+ return _VignettePlugins.default;
10
+ }
11
+ });
12
+ var _VignettePlugins = _interopRequireDefault(require("./VignettePlugins"));
13
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
@@ -0,0 +1,48 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ var _jestProsemirror = require("jest-prosemirror");
7
+ var _Constants = require("./Constants");
8
+ var _VignetteCommand = _interopRequireDefault(require("./VignetteCommand"));
9
+ var _VignettePlugin = require("./VignettePlugin");
10
+ var _VignettePlugins = _interopRequireDefault(require("./VignettePlugins"));
11
+ var _CreateCommand = _interopRequireDefault(require("./CreateCommand"));
12
+ var _prosemirrorTables = require("prosemirror-tables");
13
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
14
+ describe('VignettePlugin', () => {
15
+ it('should handle VignetteCommand', () => {
16
+ (0, _jestProsemirror.createEditor)((0, _jestProsemirror.doc)((0, _jestProsemirror.p)('<cursor>')), {
17
+ plugins: [..._VignettePlugins.default]
18
+ }).command((state, dispatch) => {
19
+ if (dispatch) {
20
+ new _VignetteCommand.default().execute(state, dispatch);
21
+ }
22
+ return true;
23
+ }).callback(content => {
24
+ expect(content.state.doc).toEqualProsemirrorNode((0, _jestProsemirror.doc)((0, _jestProsemirror.p)(), (0, _jestProsemirror.table)((0, _jestProsemirror.tr)((0, _jestProsemirror.td)({
25
+ colspan: 1,
26
+ rowspan: 1,
27
+ colwidth: null,
28
+ pretty: true,
29
+ ugly: false
30
+ }, (0, _jestProsemirror.p)()))), (0, _jestProsemirror.p)(' ')));
31
+ });
32
+ });
33
+ it('should handle getEffectiveSchema', () => {
34
+ var _schema$spec$nodes$ge, _schema$spec$nodes$ge2, _newSchema$spec$nodes, _newSchema$spec$nodes2;
35
+ const schema = (0, _jestProsemirror.createEditor)((0, _jestProsemirror.doc)((0, _jestProsemirror.p)('<cursor>'))).schema;
36
+ expect((_schema$spec$nodes$ge = schema.spec.nodes.get(_Constants.TABLE)) === null || _schema$spec$nodes$ge === void 0 ? void 0 : (_schema$spec$nodes$ge2 = _schema$spec$nodes$ge.attrs) === null || _schema$spec$nodes$ge2 === void 0 ? void 0 : _schema$spec$nodes$ge2.vignette).toBeFalsy();
37
+ const newSchema = new _VignettePlugin.VignettePlugin().getEffectiveSchema(schema);
38
+ expect((_newSchema$spec$nodes = newSchema.spec.nodes.get(_Constants.TABLE)) === null || _newSchema$spec$nodes === void 0 ? void 0 : (_newSchema$spec$nodes2 = _newSchema$spec$nodes.attrs) === null || _newSchema$spec$nodes2 === void 0 ? void 0 : _newSchema$spec$nodes2.vignette).toBeTruthy();
39
+ });
40
+ it('should handle createCommand', () => {
41
+ (0, _jestProsemirror.createEditor)((0, _jestProsemirror.doc)((0, _jestProsemirror.p)('<cursor>')), {
42
+ plugins: [..._VignettePlugins.default]
43
+ }).command((state, _dispatch) => {
44
+ (0, _CreateCommand.default)(_prosemirrorTables.deleteTable).isEnabled(state);
45
+ return true;
46
+ });
47
+ });
48
+ });
@@ -0,0 +1,14 @@
1
+ import { EditorState } from 'prosemirror-state';
2
+ import { Transform } from 'prosemirror-transform';
3
+ import { EditorView } from 'prosemirror-view';
4
+ import { UICommand } from '@modusoperandi/licit-doc-attrs-step';
5
+ declare class TableColorCommand extends UICommand {
6
+ _popUp: any;
7
+ getAttrName: () => string;
8
+ isEnabled: (_state: EditorState) => boolean;
9
+ shouldRespondToUIEvent: (e: React.SyntheticEvent | MouseEvent) => boolean;
10
+ waitForUserInput: (_state: EditorState, _dispatch?: (tr: Transform) => void, _view?: EditorView, event?: React.SyntheticEvent) => Promise<unknown>;
11
+ executeWithUserInput: (state: EditorState, dispatch?: (tr: Transform) => void, view?: EditorView, color?: string) => boolean;
12
+ cancel(): void;
13
+ }
14
+ export default TableColorCommand;
@@ -0,0 +1,64 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+ var _nullthrows = _interopRequireDefault(require("nullthrows"));
8
+ var _prosemirrorTables = require("prosemirror-tables");
9
+ var _licitUiCommands = require("@modusoperandi/licit-ui-commands");
10
+ var _licitDocAttrsStep = require("@modusoperandi/licit-doc-attrs-step");
11
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
12
+ function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
13
+ function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
14
+ function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
15
+ class TableColorCommand extends _licitDocAttrsStep.UICommand {
16
+ constructor() {
17
+ super(...arguments);
18
+ _defineProperty(this, "_popUp", null);
19
+ _defineProperty(this, "getAttrName", () => {
20
+ return '';
21
+ });
22
+ _defineProperty(this, "isEnabled", _state => {
23
+ return true;
24
+ });
25
+ _defineProperty(this, "shouldRespondToUIEvent", e => {
26
+ return e.type === _licitDocAttrsStep.UICommand.EventType.MOUSEENTER;
27
+ });
28
+ _defineProperty(this, "waitForUserInput", (_state, _dispatch, _view, event) => {
29
+ if (this._popUp) {
30
+ return Promise.resolve(undefined);
31
+ }
32
+ const target = (0, _nullthrows.default)(event).currentTarget;
33
+ if (!(target instanceof HTMLElement)) {
34
+ return Promise.resolve(undefined);
35
+ }
36
+ const anchor = event ? event.currentTarget : null;
37
+ return new Promise(resolve => {
38
+ this._popUp = (0, _licitUiCommands.createPopUp)(_licitUiCommands.ColorEditor, null, {
39
+ anchor,
40
+ position: _licitUiCommands.atAnchorRight,
41
+ onClose: val => {
42
+ if (this._popUp) {
43
+ this._popUp = null;
44
+ resolve(val);
45
+ }
46
+ }
47
+ });
48
+ });
49
+ });
50
+ _defineProperty(this, "executeWithUserInput", (state, dispatch, view, color) => {
51
+ if (dispatch && color !== undefined) {
52
+ const cmd = (0, _prosemirrorTables.setCellAttr)(this.getAttrName(), color);
53
+ cmd(state, dispatch, view);
54
+ return true;
55
+ }
56
+ return false;
57
+ });
58
+ }
59
+ cancel() {
60
+ this._popUp && this._popUp.close(undefined);
61
+ }
62
+ }
63
+ var _default = TableColorCommand;
64
+ exports.default = _default;
package/jest.config.ts ADDED
@@ -0,0 +1,208 @@
1
+ /*
2
+ * For a detailed explanation regarding each configuration property and type check, visit:
3
+ * https://jestjs.io/docs/configuration
4
+ */
5
+
6
+ export default {
7
+ // All imported modules in your tests should be mocked automatically
8
+ // automock: false,
9
+
10
+ // Stop running tests after `n` failures
11
+ // bail: 0,
12
+
13
+ // The directory where Jest should store its cached dependency information
14
+ // cacheDirectory: "/tmp/jest_rs",
15
+
16
+ // Automatically clear mock calls and instances between every test
17
+ clearMocks: true,
18
+
19
+ // Indicates whether the coverage information should be collected while executing the test
20
+ collectCoverage: true,
21
+
22
+ // An array of glob patterns indicating a set of files for which coverage information should be collected
23
+ collectCoverageFrom: ['**/*.{js,jsx,ts,tsx}'],
24
+
25
+ // The directory where Jest should output its coverage files
26
+ coverageDirectory: '../coverage',
27
+
28
+ // An array of regexp pattern strings used to skip coverage collection
29
+ // coveragePathIgnorePatterns: [
30
+ // "/node_modules/"
31
+ // ],
32
+
33
+ // Indicates which provider should be used to instrument code for coverage
34
+ // coverageProvider: "babel",
35
+
36
+ // A list of reporter names that Jest uses when writing coverage reports
37
+ coverageReporters: [
38
+ // "json",
39
+ 'text',
40
+ 'cobertura',
41
+ 'lcov',
42
+ // "clover"
43
+ ],
44
+
45
+ // An object that configures minimum threshold enforcement for coverage results
46
+ coverageThreshold: {global:{branches:80,functions:80,lines:80,},},
47
+
48
+ // A path to a custom dependency extractor
49
+ // dependencyExtractor: undefined,
50
+
51
+ // Make calling deprecated APIs throw helpful error messages
52
+ // errorOnDeprecated: false,
53
+
54
+ // Force coverage collection from ignored files using an array of glob patterns
55
+ // forceCoverageMatch: [],
56
+
57
+ // A path to a module which exports an async function that is triggered once before all test suites
58
+ // globalSetup: undefined,
59
+
60
+ // A path to a module which exports an async function that is triggered once after all test suites
61
+ // globalTeardown: undefined,
62
+
63
+ // A set of global variables that need to be available in all test environments
64
+ // globals: {},
65
+
66
+ // The maximum amount of workers used to run your tests. Can be specified as % or a number. E.g. maxWorkers: 10% will use 10% of your CPU amount + 1 as the maximum worker number. maxWorkers: 2 will use a maximum of 2 workers.
67
+ // maxWorkers: "50%",
68
+
69
+ // An array of directory names to be searched recursively up from the requiring module's location
70
+ // moduleDirectories: [
71
+ // "node_modules"
72
+ // ],
73
+
74
+ // An array of file extensions your modules use
75
+ moduleFileExtensions: [
76
+ 'js',
77
+ // "jsx",
78
+ 'ts',
79
+ 'tsx',
80
+ // "json",
81
+ // "node"
82
+ ],
83
+
84
+ // A map from regular expressions to module names or to arrays of module names that allow to stub out resources with a single module
85
+ moduleNameMapper: {
86
+ '\\.(css|less|scss|sass)$': 'identity-obj-proxy',
87
+ },
88
+
89
+ // An array of regexp pattern strings, matched against all module paths before considered 'visible' to the module loader
90
+ // modulePathIgnorePatterns: [],
91
+
92
+ // Activates notifications for test results
93
+ // notify: false,
94
+
95
+ // An enum that specifies notification mode. Requires { notify: true }
96
+ // notifyMode: "failure-change",
97
+
98
+ // A preset that is used as a base for Jest's configuration
99
+ preset: 'ts-jest/presets/default',
100
+
101
+ // Run tests from one or more projects
102
+ // projects: undefined,
103
+
104
+ // Use this configuration option to add custom reporters to Jest
105
+ reporters: [
106
+ 'default',
107
+ [
108
+ 'jest-junit',
109
+ {
110
+ outputDirectory: 'coverage',
111
+ outputName: 'TESTS.xml'
112
+ }
113
+ ]
114
+ ]
115
+ ,
116
+
117
+ // Automatically reset mock state between every test
118
+ // resetMocks: false,
119
+
120
+ // Reset the module registry before running each individual test
121
+ // resetModules: false,
122
+
123
+ // A path to a custom resolver
124
+ // resolver: undefined,
125
+
126
+ // Automatically restore mock state between every test
127
+ // restoreMocks: false,
128
+
129
+ // The root directory that Jest should scan for tests and modules within
130
+ rootDir: 'src',
131
+
132
+ // A list of paths to directories that Jest should use to search for files in
133
+ // roots: [
134
+ // "<rootDir>"
135
+ // ],
136
+
137
+ // Allows you to use a custom runner instead of Jest's default test runner
138
+ // runner: "jest-runner",
139
+
140
+ // The paths to modules that run some code to configure or set up the testing environment before each test
141
+ setupFiles: ['../jest.setup.js'],
142
+
143
+ // A list of paths to modules that run some code to configure or set up the testing framework before each test
144
+ setupFilesAfterEnv: ['jest-prosemirror/environment', 'jest-json'],
145
+
146
+ // The number of seconds after which a test is considered as slow and reported as such in the results.
147
+ // slowTestThreshold: 5,
148
+
149
+ // A list of paths to snapshot serializer modules Jest should use for snapshot testing
150
+ // snapshotSerializers: [],
151
+
152
+ // The test environment that will be used for testing
153
+ testEnvironment: 'jsdom',
154
+
155
+ // Options that will be passed to the testEnvironment
156
+ // testEnvironmentOptions: {},
157
+
158
+ // Adds a location field to test results
159
+ // testLocationInResults: false,
160
+
161
+ // The glob patterns Jest uses to detect test files
162
+ testMatch: [
163
+ // "**/__tests__/**/*.[jt]s?(x)",
164
+ '**/?(*.)+(spec|test).[tj]s?(x)',
165
+ ],
166
+
167
+ // An array of regexp pattern strings that are matched against all test paths, matched tests are skipped
168
+ testPathIgnorePatterns:
169
+ [ "/node_modules/"],
170
+
171
+ // The regexp pattern or array of patterns that Jest uses to detect test files
172
+ //testRegex: ["((\\.|/*.)(test))\\.ts?$"],
173
+
174
+ // This option allows the use of a custom results processor
175
+ // testResultsProcessor: "jest-sonar-reporter",
176
+
177
+ // This option allows use of a custom test runner
178
+ // testRunner: "jest-circus/runner",
179
+
180
+ // This option sets the URL for the jsdom environment. It is reflected in properties such as location.href
181
+ // testURL: "http://localhost",
182
+
183
+ // Setting this value to "fake" allows the use of fake timers for functions such as "setTimeout"
184
+ // timers: "real",
185
+
186
+ // A map from regular expressions to paths to transformers
187
+ transform: {
188
+ '^.+\\.(ts|tsx)$': 'ts-jest',
189
+ '^.+\\.(js|jsx)$': 'babel-jest',
190
+ },
191
+
192
+ // An array of regexp pattern strings that are matched against all source file paths, matched files will skip transformation
193
+ transformIgnorePatterns: ['node_modules/(?!(@modusoperandi|@mo)/).+\\.js$'],
194
+
195
+ // An array of regexp pattern strings that are matched against all modules before the module loader will automatically return a mock for them
196
+ // unmockedModulePathPatterns: undefined,
197
+
198
+ // Indicates whether each individual test should be reported during the run
199
+ verbose: true,
200
+
201
+ // An array of regexp patterns that are matched against all source file paths before re-running tests in watch mode
202
+ // watchPathIgnorePatterns: [],
203
+
204
+ // Whether to use watchman for file crawling
205
+ // watchman: true,
206
+ // Default timeout of a test in milliseconds.
207
+ testTimeout: 30000,
208
+ };
package/jest.setup.js ADDED
@@ -0,0 +1,2 @@
1
+ // needed to mock this due to execute during loading
2
+ document.execCommand = document.execCommand || function execCommandMock() {};
package/lint.sh ADDED
@@ -0,0 +1,4 @@
1
+ #!/bin/bash
2
+
3
+ node node_modules/eslint/bin/eslint.js --fix src/
4
+
package/package.json ADDED
@@ -0,0 +1,132 @@
1
+ {
2
+ "name": "@modusoperandi/licit-vignette",
3
+ "version": "0.0.16",
4
+ "subversion": "1",
5
+ "description": "Vignette plugin built with ProseMirror",
6
+ "main": "dist/index.js",
7
+ "repository": {
8
+ "type": "git",
9
+ "url": ""
10
+ },
11
+ "bundleDependencies": [],
12
+ "scripts": {
13
+ "clean": "rm -rf dist/ coverage/ bin/ && rm -f modusoperandi-licit-vignette-*.*.*.tgz",
14
+ "build:ts": "tsc -p tsconfig.json",
15
+ "build:babel": "babel src --out-dir dist --extensions .ts,.tsx",
16
+ "build:dist": "npm run clean && npm run build:ts && npm run webpack && npm run build:babel && npm run build:css",
17
+ "webpack": "webpack",
18
+ "build:css": "echo 'no CSS files available'",
19
+ "lint:ts": "eslint src --ext .ts,.tsx --fix",
20
+ "lint:css": "echo 'no CSS files available'",
21
+ "lint": "npm run lint:css & npm run lint:ts",
22
+ "ci:build": "npm run clean && npm run build:ts && npm run webpack && npm run build:babel && npm run build:css",
23
+ "test:unit": "jest",
24
+ "test:coverage": "jest --coverage",
25
+ "prepare": "npm run build:dist",
26
+ "test": "jest --coverage",
27
+ "debug": "node --debug-brk --inspect ./node_modules/.bin/jest -i",
28
+ "ci:bom": "cyclonedx-bom -o dist/bom.xml",
29
+ "publish:dist": "npm publish"
30
+ },
31
+ "devDependencies": {
32
+ "@babel/cli": "^7.19.3",
33
+ "@babel/core": "^7.19.3",
34
+ "@babel/eslint-parser": "^7.19.1",
35
+ "@babel/plugin-proposal-class-properties": "^7.18.6",
36
+ "@babel/plugin-proposal-decorators": "^7.19.3",
37
+ "@babel/plugin-proposal-do-expressions": "^7.18.6",
38
+ "@babel/plugin-proposal-export-default-from": "^7.18.10",
39
+ "@babel/plugin-proposal-export-namespace-from": "^7.18.9",
40
+ "@babel/plugin-proposal-function-sent": "^7.18.6",
41
+ "@babel/plugin-proposal-logical-assignment-operators": "^7.18.9",
42
+ "@babel/plugin-proposal-object-rest-spread": "^7.19.4",
43
+ "@babel/plugin-proposal-pipeline-operator": "^7.18.9",
44
+ "@babel/plugin-proposal-throw-expressions": "^7.18.6",
45
+ "@babel/plugin-syntax-dynamic-import": "^7.8.3",
46
+ "@babel/plugin-syntax-import-meta": "^7.10.4",
47
+ "@babel/plugin-transform-parameters": "^7.18.8",
48
+ "@babel/plugin-transform-runtime": "^7.19.1",
49
+ "@babel/plugin-transform-typescript": "^7.19.3",
50
+ "@babel/preset-env": "^7.19.4",
51
+ "@babel/preset-react": "^7.18.6",
52
+ "@babel/preset-typescript": "^7.18.6",
53
+ "@cyclonedx/bom": "^3.0.3",
54
+ "@testing-library/dom": "^8.19.0",
55
+ "@testing-library/jest-dom": "^5.16.5",
56
+ "@testing-library/react": "^13.4.0",
57
+ "@testing-library/user-event": "^14.4.3",
58
+ "@types/jest": "^29.1.2",
59
+ "@types/node": "^18.11.0",
60
+ "@typescript-eslint/eslint-plugin": "^5.40.1",
61
+ "@typescript-eslint/parser": "^5.40.1",
62
+ "babel-eslint": "^10.1.0",
63
+ "babel-jest": "^29.2.0",
64
+ "babel-loader": "8.2.5",
65
+ "babel-plugin-transform-react-remove-prop-types": "0.4.24",
66
+ "clean-webpack-plugin": "^4.0.0",
67
+ "copy-webpack-plugin": "^11.0.0",
68
+ "css-loader": "^6.7.1",
69
+ "enzyme": "^3.11.0",
70
+ "eslint": "8.25.0",
71
+ "eslint-config-prettier": "^8.5.0",
72
+ "eslint-plugin-import": "^2.26.0",
73
+ "eslint-plugin-jest": "^27.1.2",
74
+ "eslint-plugin-prettier": "^4.2.1",
75
+ "eslint-plugin-react": "7.31.10",
76
+ "file-loader": "^6.2.0",
77
+ "husky": "^8.0.1",
78
+ "identity-obj-proxy": "^3.0.0",
79
+ "jest": "^29.2.0",
80
+ "jest-environment-jsdom": "^29.2.0",
81
+ "jest-json": "^2.0.0",
82
+ "jest-junit": "^14.0.1",
83
+ "jest-prosemirror": "^2.0.6",
84
+ "jest-sonar-reporter": "^2.0.0",
85
+ "lint-staged": "^13.0.3",
86
+ "prettier": "^2.7.1",
87
+ "react-test-renderer": "^18.2.0",
88
+ "resize-observer-polyfill": "^1.5.1",
89
+ "style-loader": "^3.3.1",
90
+ "stylelint": "^14.14.0",
91
+ "stylelint-config-standard": "^29.0.0",
92
+ "stylelint-prettier": "^2.0.0",
93
+ "terser-webpack-plugin": "^5.3.6",
94
+ "ts-jest": "^29.0.3",
95
+ "ts-node": "^10.9.1",
96
+ "typescript": "^4.8.4",
97
+ "url": "^0.11.0",
98
+ "webpack": "^5.74.0",
99
+ "webpack-cli": "^4.10.0",
100
+ "write-file-webpack-plugin": "^4.5.1"
101
+ },
102
+ "dependencies": {
103
+ "@modusoperandi/licit-ui-commands": "^0.1.13",
104
+ "@types/node": "^16.10.1",
105
+ "axios": "^1.1.3",
106
+ "orderedmap": "^1.1.8",
107
+ "prop-types": "^15.8.1",
108
+ "rewire": "^6.0.0"
109
+ },
110
+ "importSort": {
111
+ ".js": {
112
+ "parser": "babylon",
113
+ "style": "module-grouping"
114
+ }
115
+ },
116
+ "husky": {
117
+ "hooks": {
118
+ "pre-commit": "lint-staged"
119
+ }
120
+ },
121
+ "lint-staged": {
122
+ "*.css": [
123
+ "stylelint --fix"
124
+ ],
125
+ "!(*test|*.setup).ts": [
126
+ "eslint --fix"
127
+ ],
128
+ "*.json": [
129
+ "prettier --write"
130
+ ]
131
+ }
132
+ }
@@ -0,0 +1,11 @@
1
+ sonar.projectKey=licit-vignette
2
+ sonar.scm.disabled=true
3
+ sonar.sourceEncoding=UTF-8
4
+ # only analyzing actual library source
5
+ sonar.sources=src
6
+ sonar.tests=src
7
+ sonar.test.inclusions=**/*.test.ts
8
+ # exclude unit tests from coverage and analysis
9
+ sonar.exclusions=**/*.test.ts
10
+ # tell sonar where to find coverage results
11
+ sonar.typescript.lcov.reportPaths=coverage/lcov.info