@modusoperandi/licit-vignette 0.0.18 → 1.0.0
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.
- package/{src/Constants.ts → Constants.js} +6 -6
- package/{dist/CreateCommand.d.ts → CreateCommand.d.ts} +1 -1
- package/CreateCommand.js +36 -0
- package/TableBackgroundColorCommand.d.ts +4 -0
- package/TableBackgroundColorCommand.js +6 -0
- package/TableBorderColorCommand.d.ts +4 -0
- package/TableBorderColorCommand.js +6 -0
- package/{dist/VignetteCommand.d.ts → VignetteCommand.d.ts} +9 -2
- package/VignetteCommand.js +93 -0
- package/VignetteMenuPlugin.d.ts +24 -0
- package/VignetteMenuPlugin.js +112 -0
- package/{dist/VignetteNodeSpec.d.ts → VignetteNodeSpec.d.ts} +3 -3
- package/VignetteNodeSpec.js +67 -0
- package/{dist/VignettePlugin.d.ts → VignettePlugin.d.ts} +1 -1
- package/VignettePlugin.js +39 -0
- package/VignettePlugins.d.ts +3 -0
- package/VignettePlugins.js +6 -0
- package/index.d.ts +10 -0
- package/index.js +10 -0
- package/package.json +31 -70
- package/{dist/ui → ui}/TableColorCommand.d.ts +6 -3
- package/ui/TableColorCommand.js +59 -0
- package/.eslintignore +0 -4
- package/.eslintrc.js +0 -107
- package/.prettierignore +0 -6
- package/.prettierrc +0 -5
- package/.stylelintignore +0 -3
- package/.stylelintrc.json +0 -10
- package/LICENSE +0 -21
- package/README.md +0 -33
- package/babel.config.json +0 -53
- package/dist/Constants.js +0 -18
- package/dist/CreateCommand.js +0 -30
- package/dist/TableBackgroundColorCommand.d.ts +0 -5
- package/dist/TableBackgroundColorCommand.js +0 -21
- package/dist/TableBorderColorCommand.d.ts +0 -5
- package/dist/TableBorderColorCommand.js +0 -21
- package/dist/VignetteCommand.js +0 -104
- package/dist/VignetteMenuPlugin.d.ts +0 -5
- package/dist/VignetteMenuPlugin.js +0 -116
- package/dist/VignetteNodeSpec.js +0 -83
- package/dist/VignettePlugin.js +0 -49
- package/dist/VignettePlugins.d.ts +0 -4
- package/dist/VignettePlugins.js +0 -11
- package/dist/index.d.ts +0 -2
- package/dist/index.js +0 -13
- package/dist/index.test.js +0 -48
- package/dist/ui/TableColorCommand.js +0 -64
- package/jest.config.ts +0 -208
- package/jest.setup.js +0 -2
- package/lint.sh +0 -4
- package/sonar-project.properties +0 -11
- package/src/CreateCommand.ts +0 -38
- package/src/TableBackgroundColorCommand.ts +0 -9
- package/src/TableBorderColorCommand.ts +0 -9
- package/src/VignetteCommand.ts +0 -103
- package/src/VignetteMenuPlugin.ts +0 -151
- package/src/VignetteNodeSpec.ts +0 -74
- package/src/VignettePlugin.ts +0 -53
- package/src/VignettePlugins.ts +0 -7
- package/src/index.test.ts +0 -59
- package/src/index.ts +0 -3
- package/src/ui/TableColorCommand.tsx +0 -79
- package/tsconfig.json +0 -38
- package/webpack.config.js +0 -89
- /package/{dist/Constants.d.ts → Constants.d.ts} +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
export const VIGNETTE = 'vignette';
|
|
2
|
-
export const PARAGRAPH = 'paragraph';
|
|
3
|
-
export const TABLE = 'table';
|
|
4
|
-
export const TABLE_CELL = 'table_cell';
|
|
5
|
-
export const DEF_BORDER_COLOR = '#36598d';
|
|
6
|
-
export const DEF_BORDER_RADIUS = '10px';
|
|
1
|
+
export const VIGNETTE = 'vignette';
|
|
2
|
+
export const PARAGRAPH = 'paragraph';
|
|
3
|
+
export const TABLE = 'table';
|
|
4
|
+
export const TABLE_CELL = 'table_cell';
|
|
5
|
+
export const DEF_BORDER_COLOR = '#36598d';
|
|
6
|
+
export const DEF_BORDER_RADIUS = '10px';
|
|
@@ -3,5 +3,5 @@ import { Transform } from 'prosemirror-transform';
|
|
|
3
3
|
import { EditorView } from 'prosemirror-view';
|
|
4
4
|
import { UICommand } from '@modusoperandi/licit-doc-attrs-step';
|
|
5
5
|
type ExecuteCall = (state: EditorState, dispatch?: (tr: Transform) => void, view?: EditorView) => boolean;
|
|
6
|
-
export
|
|
6
|
+
export declare function createCommand(execute: ExecuteCall): UICommand;
|
|
7
7
|
export {};
|
package/CreateCommand.js
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { UICommand } from '@modusoperandi/licit-doc-attrs-step';
|
|
2
|
+
export function createCommand(execute) {
|
|
3
|
+
class CustomCommand extends UICommand {
|
|
4
|
+
isEnabled = (state) => {
|
|
5
|
+
return this.execute(state);
|
|
6
|
+
};
|
|
7
|
+
execute = (state, dispatch, view) => {
|
|
8
|
+
const tr = state.tr;
|
|
9
|
+
let endTr = tr;
|
|
10
|
+
execute(state, (nextTr) => {
|
|
11
|
+
endTr = nextTr;
|
|
12
|
+
dispatch?.(endTr);
|
|
13
|
+
}, view);
|
|
14
|
+
return endTr.docChanged || tr !== endTr;
|
|
15
|
+
};
|
|
16
|
+
waitForUserInput = (_state, _dispatch, _view, _event) => {
|
|
17
|
+
return Promise.resolve(undefined);
|
|
18
|
+
};
|
|
19
|
+
executeWithUserInput = (_state, _dispatch, _view, _inputs) => {
|
|
20
|
+
return false;
|
|
21
|
+
};
|
|
22
|
+
cancel() {
|
|
23
|
+
return null;
|
|
24
|
+
}
|
|
25
|
+
renderLabel() {
|
|
26
|
+
return null;
|
|
27
|
+
}
|
|
28
|
+
isActive() {
|
|
29
|
+
return true;
|
|
30
|
+
}
|
|
31
|
+
executeCustom(_state, tr) {
|
|
32
|
+
return tr;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
return new CustomCommand();
|
|
36
|
+
}
|
|
@@ -2,11 +2,18 @@ import { Schema } from 'prosemirror-model';
|
|
|
2
2
|
import { EditorState, Transaction } from 'prosemirror-state';
|
|
3
3
|
import { EditorView } from 'prosemirror-view';
|
|
4
4
|
import { UICommand } from '@modusoperandi/licit-doc-attrs-step';
|
|
5
|
-
|
|
5
|
+
import * as React from 'react';
|
|
6
|
+
import { Transform } from 'prosemirror-transform';
|
|
7
|
+
export declare class VignetteCommand extends UICommand {
|
|
6
8
|
isEnabled: (state: EditorState, view?: EditorView) => boolean;
|
|
7
9
|
execute: (state: EditorState, dispatch?: (tr: Transaction) => void, view?: EditorView) => boolean;
|
|
10
|
+
waitForUserInput: (_state: EditorState, _dispatch: (tr: Transform) => void, _view: EditorView, _event: React.SyntheticEvent<Element, Event>) => Promise<undefined>;
|
|
11
|
+
executeWithUserInput: (_state: EditorState, _dispatch: (tr: Transform) => void, _view: EditorView, _inputs: string) => boolean;
|
|
12
|
+
cancel(): void;
|
|
8
13
|
__isEnabled: (_state: EditorState, _view?: EditorView) => boolean;
|
|
9
14
|
insertTable(tr: Transaction, schema: Schema, rows: number, cols: number): Transaction;
|
|
10
15
|
insertParagraph(state: EditorState, tr: Transaction): Transaction;
|
|
16
|
+
renderLabel(): any;
|
|
17
|
+
isActive(): boolean;
|
|
18
|
+
executeCustom(_state: EditorState, tr: Transform): Transform;
|
|
11
19
|
}
|
|
12
|
-
export default VignetteCommand;
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
import { Fragment } from 'prosemirror-model';
|
|
2
|
+
import { TextSelection } from 'prosemirror-state';
|
|
3
|
+
import { UICommand } from '@modusoperandi/licit-doc-attrs-step';
|
|
4
|
+
import { DEF_BORDER_COLOR, PARAGRAPH, TABLE, TABLE_CELL } from './Constants';
|
|
5
|
+
export class VignetteCommand extends UICommand {
|
|
6
|
+
isEnabled = (state, view) => {
|
|
7
|
+
return this.__isEnabled(state, view);
|
|
8
|
+
};
|
|
9
|
+
execute = (state, dispatch, view) => {
|
|
10
|
+
if (dispatch) {
|
|
11
|
+
const { schema } = state;
|
|
12
|
+
let { tr } = state;
|
|
13
|
+
tr = this.insertTable(tr, schema, 1, 1);
|
|
14
|
+
tr = this.insertParagraph(state, tr);
|
|
15
|
+
dispatch(tr);
|
|
16
|
+
view?.focus();
|
|
17
|
+
}
|
|
18
|
+
return true;
|
|
19
|
+
};
|
|
20
|
+
waitForUserInput = (_state, _dispatch, _view, _event) => {
|
|
21
|
+
return Promise.resolve(undefined);
|
|
22
|
+
};
|
|
23
|
+
executeWithUserInput = (_state, _dispatch, _view, _inputs) => {
|
|
24
|
+
return false;
|
|
25
|
+
};
|
|
26
|
+
cancel() {
|
|
27
|
+
return null;
|
|
28
|
+
}
|
|
29
|
+
__isEnabled = (_state, _view) => {
|
|
30
|
+
return true;
|
|
31
|
+
};
|
|
32
|
+
insertTable(tr, schema, rows, cols) {
|
|
33
|
+
if (!tr.selection || !tr.doc) {
|
|
34
|
+
return tr;
|
|
35
|
+
}
|
|
36
|
+
const { from, to } = tr.selection;
|
|
37
|
+
if (from !== to) {
|
|
38
|
+
return tr;
|
|
39
|
+
}
|
|
40
|
+
const { nodes } = schema;
|
|
41
|
+
const cell = nodes[TABLE_CELL];
|
|
42
|
+
const paragraph = nodes[PARAGRAPH];
|
|
43
|
+
const row = nodes['table_row'];
|
|
44
|
+
const table = nodes[TABLE];
|
|
45
|
+
if (!(cell && paragraph && row && table)) {
|
|
46
|
+
return tr;
|
|
47
|
+
}
|
|
48
|
+
const rowNodes = [];
|
|
49
|
+
for (let rr = 0; rr < rows; rr++) {
|
|
50
|
+
const cellNodes = [];
|
|
51
|
+
for (let cc = 0; cc < cols; cc++) {
|
|
52
|
+
// [FS] IRAD-950 2020-05-25
|
|
53
|
+
// Fix:Extra arrow key required for cell navigation using arrow right/Left
|
|
54
|
+
const cellNode = cell.create({
|
|
55
|
+
borderColor: DEF_BORDER_COLOR,
|
|
56
|
+
background: '#dce6f2',
|
|
57
|
+
vignette: true,
|
|
58
|
+
}, Fragment.fromArray([paragraph.create()]));
|
|
59
|
+
cellNodes.push(cellNode);
|
|
60
|
+
}
|
|
61
|
+
const rowNode = row.create({}, Fragment.from(cellNodes));
|
|
62
|
+
rowNodes.push(rowNode);
|
|
63
|
+
}
|
|
64
|
+
const tableNode = table.create({ vignette: true }, Fragment.from(rowNodes));
|
|
65
|
+
tr = tr.insert(from, Fragment.from(tableNode));
|
|
66
|
+
const selection = TextSelection.create(tr.doc, from + 5, from + 5);
|
|
67
|
+
tr = tr.setSelection(selection);
|
|
68
|
+
return tr;
|
|
69
|
+
}
|
|
70
|
+
// [FS] 2021-04-01
|
|
71
|
+
// Add empty line after table drop
|
|
72
|
+
// To make easier to enter a line after table
|
|
73
|
+
insertParagraph(state, tr) {
|
|
74
|
+
const paragraph = state.schema.nodes[PARAGRAPH];
|
|
75
|
+
const textNode = state.schema.text(' ');
|
|
76
|
+
const { from, to } = tr.selection;
|
|
77
|
+
if (from !== to) {
|
|
78
|
+
return tr;
|
|
79
|
+
}
|
|
80
|
+
const paragraphNode = paragraph.create({}, textNode, null);
|
|
81
|
+
tr = tr.insert(from + tr.selection.$head.node(1).nodeSize - 4, Fragment.from(paragraphNode));
|
|
82
|
+
return tr;
|
|
83
|
+
}
|
|
84
|
+
renderLabel() {
|
|
85
|
+
return null;
|
|
86
|
+
}
|
|
87
|
+
isActive() {
|
|
88
|
+
return true;
|
|
89
|
+
}
|
|
90
|
+
executeCustom(_state, tr) {
|
|
91
|
+
return tr;
|
|
92
|
+
}
|
|
93
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { EditorState, Plugin } from 'prosemirror-state';
|
|
2
|
+
import { EditorView } from 'prosemirror-view';
|
|
3
|
+
import { Node } from 'prosemirror-model';
|
|
4
|
+
import { UICommand } from '@modusoperandi/licit-doc-attrs-step';
|
|
5
|
+
import { TableView } from 'prosemirror-tables';
|
|
6
|
+
export declare class VignetteView {
|
|
7
|
+
constructor(editorView: EditorView);
|
|
8
|
+
setCustomMenu(editorView: EditorView): void;
|
|
9
|
+
setCustomTableNodeViewUpdate(editorView: EditorView): void;
|
|
10
|
+
tableNodeViewEx(tableNodeView: (node: Node, view: EditorView) => TableView, node: Node, view: EditorView): TableView;
|
|
11
|
+
updateEx(update: (node: Node) => boolean, self: VignetteView, node: Node): boolean;
|
|
12
|
+
updateBorder(tableView: TableView): void;
|
|
13
|
+
static isVignette(state: EditorState, actionNode: Node): boolean;
|
|
14
|
+
getMenu(state: EditorState, actionNode: Node, cmdGrps: Array<{
|
|
15
|
+
[key: string]: UICommand;
|
|
16
|
+
}>): Array<{
|
|
17
|
+
[key: string]: UICommand;
|
|
18
|
+
}>;
|
|
19
|
+
isEnabledEx(isEnabled: (state: EditorState, view?: EditorView) => boolean, state: EditorState, view?: EditorView): boolean;
|
|
20
|
+
destroy: () => void;
|
|
21
|
+
}
|
|
22
|
+
export declare class VignetteMenuPlugin extends Plugin {
|
|
23
|
+
constructor();
|
|
24
|
+
}
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
import { Plugin, PluginKey } from 'prosemirror-state';
|
|
2
|
+
import { TableBackgroundColorCommand } from './TableBackgroundColorCommand';
|
|
3
|
+
import { TableBorderColorCommand } from './TableBorderColorCommand';
|
|
4
|
+
import { createCommand } from './CreateCommand';
|
|
5
|
+
import { CellSelection, deleteTable } from 'prosemirror-tables';
|
|
6
|
+
import { TABLE } from './Constants';
|
|
7
|
+
const TABLE_BACKGROUND_COLOR = new TableBackgroundColorCommand();
|
|
8
|
+
const TABLE_BORDER_COLOR = new TableBorderColorCommand();
|
|
9
|
+
const TABLE_DELETE_TABLE = createCommand(deleteTable);
|
|
10
|
+
const VIGNETTE_COMMANDS_GROUP = [
|
|
11
|
+
{
|
|
12
|
+
'Fill Color...': TABLE_BACKGROUND_COLOR,
|
|
13
|
+
'Border Color....': TABLE_BORDER_COLOR,
|
|
14
|
+
},
|
|
15
|
+
{
|
|
16
|
+
'Delete Vignette': TABLE_DELETE_TABLE,
|
|
17
|
+
},
|
|
18
|
+
];
|
|
19
|
+
export class VignetteView {
|
|
20
|
+
constructor(editorView) {
|
|
21
|
+
this.setCustomMenu(editorView);
|
|
22
|
+
this.setCustomTableNodeViewUpdate(editorView);
|
|
23
|
+
}
|
|
24
|
+
setCustomMenu(editorView) {
|
|
25
|
+
editorView['pluginViews'].forEach((pluginView) => {
|
|
26
|
+
if (
|
|
27
|
+
// 'TableCellTooltipView' has property _cellElement
|
|
28
|
+
Object.hasOwn(pluginView, '_cellElement')) {
|
|
29
|
+
pluginView['getMenu'] = this.getMenu.bind(this);
|
|
30
|
+
}
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
setCustomTableNodeViewUpdate(editorView) {
|
|
34
|
+
const tableNodeView = editorView['nodeViews']['table'];
|
|
35
|
+
const tableNodeViewEx = this.tableNodeViewEx.bind(this, tableNodeView);
|
|
36
|
+
editorView['nodeViews'][TABLE] = tableNodeViewEx;
|
|
37
|
+
const index = editorView.state.plugins.findIndex((plugin) => {
|
|
38
|
+
let found = false;
|
|
39
|
+
if (plugin.spec.key) {
|
|
40
|
+
found = plugin.spec.key['key'].includes('tableColumnResizing$');
|
|
41
|
+
}
|
|
42
|
+
return found;
|
|
43
|
+
});
|
|
44
|
+
if (-1 != index) {
|
|
45
|
+
editorView.state.plugins[index].spec.props.nodeViews[TABLE] =
|
|
46
|
+
tableNodeViewEx;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
tableNodeViewEx(tableNodeView, node, view) {
|
|
50
|
+
const base = tableNodeView?.(node, view);
|
|
51
|
+
if (base?.update && node.attrs.vignette) {
|
|
52
|
+
base.update = this.updateEx.bind(base, base.update, this);
|
|
53
|
+
this.updateBorder(base);
|
|
54
|
+
}
|
|
55
|
+
return base;
|
|
56
|
+
}
|
|
57
|
+
updateEx(update, self, node) {
|
|
58
|
+
const result = update.call(this, node);
|
|
59
|
+
if (result) {
|
|
60
|
+
self.updateBorder(this);
|
|
61
|
+
}
|
|
62
|
+
return result;
|
|
63
|
+
}
|
|
64
|
+
updateBorder(tableView) {
|
|
65
|
+
if (tableView.table) {
|
|
66
|
+
tableView.table.style.border = 'none';
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
static isVignette(state, actionNode) {
|
|
70
|
+
let vignette = false;
|
|
71
|
+
if (state.selection instanceof CellSelection) {
|
|
72
|
+
if (state.selection.$anchorCell.node(-1).attrs.vignette) {
|
|
73
|
+
vignette = true;
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
if (actionNode?.attrs.vignette) {
|
|
77
|
+
vignette = true;
|
|
78
|
+
}
|
|
79
|
+
if (state.selection.$anchor.node(1).attrs.vignette) {
|
|
80
|
+
vignette = true;
|
|
81
|
+
}
|
|
82
|
+
return vignette;
|
|
83
|
+
}
|
|
84
|
+
getMenu(state, actionNode, cmdGrps) {
|
|
85
|
+
const vignette = VignetteView.isVignette(state, actionNode);
|
|
86
|
+
cmdGrps.forEach((cmdGrp) => {
|
|
87
|
+
Object.entries(cmdGrp).forEach((entry) => {
|
|
88
|
+
entry[1].isEnabled = this.isEnabledEx.bind(entry[1], entry[1].isEnabled);
|
|
89
|
+
});
|
|
90
|
+
});
|
|
91
|
+
return vignette ? VIGNETTE_COMMANDS_GROUP : cmdGrps;
|
|
92
|
+
}
|
|
93
|
+
isEnabledEx(isEnabled, state, view) {
|
|
94
|
+
return VignetteView.isVignette(state, null)
|
|
95
|
+
? false
|
|
96
|
+
: isEnabled.call(this, state, view);
|
|
97
|
+
}
|
|
98
|
+
destroy = () => {
|
|
99
|
+
// do nothing.
|
|
100
|
+
};
|
|
101
|
+
}
|
|
102
|
+
const SPEC = {
|
|
103
|
+
key: new PluginKey('VignetteMenuPlugin'),
|
|
104
|
+
view(editorView) {
|
|
105
|
+
return new VignetteView(editorView);
|
|
106
|
+
},
|
|
107
|
+
};
|
|
108
|
+
export class VignetteMenuPlugin extends Plugin {
|
|
109
|
+
constructor() {
|
|
110
|
+
super(SPEC);
|
|
111
|
+
}
|
|
112
|
+
}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
export declare const
|
|
3
|
-
export
|
|
1
|
+
import { NodeSpec } from 'prosemirror-model';
|
|
2
|
+
export declare const VignetteTableNodeSpec: (nodespec: NodeSpec) => NodeSpec;
|
|
3
|
+
export declare const VignetteTableCellNodeSpec: (nodespec: NodeSpec) => NodeSpec;
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import { TABLE, VIGNETTE } from './Constants';
|
|
2
|
+
// Override the default table node spec to support custom attributes.
|
|
3
|
+
export const VignetteTableNodeSpec = (nodespec) => ({
|
|
4
|
+
...nodespec,
|
|
5
|
+
attrs: {
|
|
6
|
+
marginLeft: { default: null },
|
|
7
|
+
vignette: { default: false },
|
|
8
|
+
},
|
|
9
|
+
parseDOM: [
|
|
10
|
+
{
|
|
11
|
+
tag: TABLE,
|
|
12
|
+
getAttrs(dom) {
|
|
13
|
+
const { marginLeft } = dom.style;
|
|
14
|
+
const vignette = dom.getAttribute(VIGNETTE) === 'true' || false;
|
|
15
|
+
const marginAmount = parseFloat(marginLeft);
|
|
16
|
+
if (marginLeft &&
|
|
17
|
+
!Number.isNaN(marginAmount) &&
|
|
18
|
+
marginLeft.includes('px')) {
|
|
19
|
+
return { marginLeft: marginAmount, vignette };
|
|
20
|
+
}
|
|
21
|
+
return { vignette };
|
|
22
|
+
},
|
|
23
|
+
style: 'border',
|
|
24
|
+
},
|
|
25
|
+
],
|
|
26
|
+
toDOM(node) {
|
|
27
|
+
// Normally, the DOM structure of the table node is rendered by
|
|
28
|
+
// `TableNodeView`. This method is only called when user selects a
|
|
29
|
+
// table node and copies it, which triggers the "serialize to HTML" flow
|
|
30
|
+
// that calles this method.
|
|
31
|
+
const { marginLeft, vignette } = node.attrs;
|
|
32
|
+
const domAttrs = { vignette };
|
|
33
|
+
let style = 'border: none';
|
|
34
|
+
if (marginLeft) {
|
|
35
|
+
style += `margin-left: ${marginLeft}px`;
|
|
36
|
+
}
|
|
37
|
+
domAttrs['style'] = style;
|
|
38
|
+
return [TABLE, domAttrs, 0];
|
|
39
|
+
},
|
|
40
|
+
});
|
|
41
|
+
export const VignetteTableCellNodeSpec = (nodespec) => ({
|
|
42
|
+
...nodespec,
|
|
43
|
+
attrs: { ...nodespec.attrs, vignette: { default: false } },
|
|
44
|
+
parseDOM: [
|
|
45
|
+
{
|
|
46
|
+
tag: 'td',
|
|
47
|
+
getAttrs: (dom) => {
|
|
48
|
+
return {
|
|
49
|
+
...nodespec.parseDOM[0].getAttrs(dom),
|
|
50
|
+
vignette: dom.getAttribute(VIGNETTE) === 'true' || false,
|
|
51
|
+
};
|
|
52
|
+
},
|
|
53
|
+
},
|
|
54
|
+
],
|
|
55
|
+
toDOM(node) {
|
|
56
|
+
const base = nodespec.toDOM(node);
|
|
57
|
+
if (node.attrs.vignette &&
|
|
58
|
+
Array.isArray(base) &&
|
|
59
|
+
1 < base.length &&
|
|
60
|
+
base[1].style) {
|
|
61
|
+
base[1].style +=
|
|
62
|
+
'border-radius: 10px; border-style: solid; border-width: thin';
|
|
63
|
+
}
|
|
64
|
+
base[1].vignette = node.attrs.vignette;
|
|
65
|
+
return base;
|
|
66
|
+
},
|
|
67
|
+
});
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Plugin } from 'prosemirror-state';
|
|
2
2
|
import { EditorView } from 'prosemirror-view';
|
|
3
3
|
import { Schema } from 'prosemirror-model';
|
|
4
|
-
import VignetteCommand from './VignetteCommand';
|
|
4
|
+
import { VignetteCommand } from './VignetteCommand';
|
|
5
5
|
export declare class VignettePlugin extends Plugin {
|
|
6
6
|
_view: EditorView;
|
|
7
7
|
constructor();
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
// Plugin to handle Citation.
|
|
2
|
+
import { Plugin, PluginKey } from 'prosemirror-state';
|
|
3
|
+
import { Schema } from 'prosemirror-model';
|
|
4
|
+
import { VignetteCommand } from './VignetteCommand';
|
|
5
|
+
import { VignetteTableCellNodeSpec, VignetteTableNodeSpec, } from './VignetteNodeSpec';
|
|
6
|
+
import { TABLE, TABLE_CELL } from './Constants';
|
|
7
|
+
export class VignettePlugin extends Plugin {
|
|
8
|
+
_view = null;
|
|
9
|
+
constructor() {
|
|
10
|
+
super({
|
|
11
|
+
key: new PluginKey('VignettePlugin'),
|
|
12
|
+
state: {
|
|
13
|
+
init(_config, _state) {
|
|
14
|
+
// do nothing
|
|
15
|
+
},
|
|
16
|
+
apply(_tr, _set) {
|
|
17
|
+
//do nothing
|
|
18
|
+
},
|
|
19
|
+
},
|
|
20
|
+
props: {
|
|
21
|
+
nodeViews: {},
|
|
22
|
+
},
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
getEffectiveSchema(schema) {
|
|
26
|
+
let nodes = schema.spec.nodes.update(TABLE, VignetteTableNodeSpec(schema.spec.nodes.get(TABLE)));
|
|
27
|
+
nodes = nodes.update(TABLE_CELL, VignetteTableCellNodeSpec(schema.spec.nodes.get(TABLE_CELL)));
|
|
28
|
+
const marks = schema.spec.marks;
|
|
29
|
+
return new Schema({
|
|
30
|
+
nodes: nodes,
|
|
31
|
+
marks: marks,
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
initButtonCommands() {
|
|
35
|
+
return {
|
|
36
|
+
'[crop] Insert Vignette': new VignetteCommand(),
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
}
|
package/index.d.ts
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export * from './VignettePlugins';
|
|
2
|
+
export * from './ui/TableColorCommand';
|
|
3
|
+
export * from './CreateCommand';
|
|
4
|
+
export * from './TableBackgroundColorCommand';
|
|
5
|
+
export * from './TableBorderColorCommand';
|
|
6
|
+
export * from './VignetteCommand';
|
|
7
|
+
export * from './VignettePlugin';
|
|
8
|
+
export * from './Constants';
|
|
9
|
+
export * from './VignetteMenuPlugin';
|
|
10
|
+
export * from './VignetteNodeSpec';
|
package/index.js
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export * from './VignettePlugins';
|
|
2
|
+
export * from './ui/TableColorCommand';
|
|
3
|
+
export * from './CreateCommand';
|
|
4
|
+
export * from './TableBackgroundColorCommand';
|
|
5
|
+
export * from './TableBorderColorCommand';
|
|
6
|
+
export * from './VignetteCommand';
|
|
7
|
+
export * from './VignettePlugin';
|
|
8
|
+
export * from './Constants';
|
|
9
|
+
export * from './VignetteMenuPlugin';
|
|
10
|
+
export * from './VignetteNodeSpec';
|
package/package.json
CHANGED
|
@@ -1,111 +1,72 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@modusoperandi/licit-vignette",
|
|
3
|
-
"version": "0.0
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"type": "module",
|
|
4
5
|
"subversion": "1",
|
|
5
6
|
"description": "Vignette plugin built with ProseMirror",
|
|
6
|
-
"main": "
|
|
7
|
+
"main": "index.js",
|
|
8
|
+
"types": "index.d.ts",
|
|
9
|
+
"style": "styles.css",
|
|
7
10
|
"repository": {
|
|
8
11
|
"type": "git",
|
|
9
12
|
"url": ""
|
|
10
13
|
},
|
|
11
|
-
"bundleDependencies": [],
|
|
12
14
|
"scripts": {
|
|
13
|
-
"clean": "rm -rf dist/
|
|
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'",
|
|
15
|
+
"clean": "rm -rf dist/ bin/ && rm -f modusoperandi-licit-vignette-*.*.*.tgz",
|
|
19
16
|
"lint:ts": "eslint src --ext .ts,.tsx --fix",
|
|
20
17
|
"lint:css": "echo 'no CSS files available'",
|
|
21
18
|
"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
19
|
"test:unit": "jest",
|
|
24
20
|
"test:coverage": "jest --coverage",
|
|
25
|
-
"prepare": "npm run build:dist",
|
|
26
21
|
"test": "jest --coverage",
|
|
27
22
|
"debug": "node --debug-brk --inspect ./node_modules/.bin/jest -i",
|
|
28
|
-
"ci:bom": "cyclonedx-
|
|
29
|
-
"
|
|
23
|
+
"ci:bom": "cyclonedx-npm --ignore-npm-errors --short-PURLs --output-format XML --output-file dist/bom.xml",
|
|
24
|
+
"ci:build": "tsc --build && copyfiles --up 1 \"src/**/*.css\" dist && copyfiles package.json dist"
|
|
25
|
+
},
|
|
26
|
+
"peerDependencies": {
|
|
27
|
+
"@modusoperandi/licit-ui-commands": "^1.0.0"
|
|
30
28
|
},
|
|
31
29
|
"devDependencies": {
|
|
32
|
-
"@
|
|
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",
|
|
30
|
+
"@cyclonedx/cyclonedx-npm": "^1.11.0",
|
|
54
31
|
"@testing-library/dom": "^8.19.0",
|
|
55
32
|
"@testing-library/jest-dom": "^5.16.5",
|
|
56
33
|
"@testing-library/react": "^13.4.0",
|
|
57
34
|
"@testing-library/user-event": "^14.4.3",
|
|
58
|
-
"@types/jest": "^29.
|
|
35
|
+
"@types/jest": "^29.2.0",
|
|
59
36
|
"@types/node": "^18.11.0",
|
|
60
|
-
"@typescript-eslint/eslint-plugin": "^5.
|
|
61
|
-
"@typescript-eslint/parser": "^5.
|
|
62
|
-
"
|
|
63
|
-
"
|
|
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",
|
|
37
|
+
"@typescript-eslint/eslint-plugin": "^5.41.0",
|
|
38
|
+
"@typescript-eslint/parser": "^5.41.0",
|
|
39
|
+
"ajv": "^7.2.4",
|
|
40
|
+
"copyfiles": "^2.4.1",
|
|
69
41
|
"enzyme": "^3.11.0",
|
|
70
|
-
"eslint": "8.
|
|
42
|
+
"eslint": "^8.26.0",
|
|
71
43
|
"eslint-config-prettier": "^8.5.0",
|
|
72
44
|
"eslint-plugin-import": "^2.26.0",
|
|
73
|
-
"eslint-plugin-jest": "^27.1.
|
|
45
|
+
"eslint-plugin-jest": "^27.1.3",
|
|
74
46
|
"eslint-plugin-prettier": "^4.2.1",
|
|
75
|
-
"eslint-plugin-react": "7.31.10",
|
|
76
|
-
"file-loader": "^6.2.0",
|
|
47
|
+
"eslint-plugin-react": "^7.31.10",
|
|
77
48
|
"husky": "^8.0.1",
|
|
78
49
|
"identity-obj-proxy": "^3.0.0",
|
|
79
|
-
"jest": "^29.2.
|
|
80
|
-
"jest-environment-jsdom": "^29.2.
|
|
50
|
+
"jest": "^29.2.2",
|
|
51
|
+
"jest-environment-jsdom": "^29.2.2",
|
|
81
52
|
"jest-json": "^2.0.0",
|
|
82
|
-
"jest-junit": "^
|
|
83
|
-
"jest-prosemirror": "^2.0.
|
|
53
|
+
"jest-junit": "^15.0.0",
|
|
54
|
+
"jest-prosemirror": "^2.0.0",
|
|
84
55
|
"jest-sonar-reporter": "^2.0.0",
|
|
85
56
|
"lint-staged": "^13.0.3",
|
|
86
|
-
"prettier": "^2.
|
|
57
|
+
"prettier": "^3.2.0",
|
|
87
58
|
"react-test-renderer": "^18.2.0",
|
|
88
59
|
"resize-observer-polyfill": "^1.5.1",
|
|
89
|
-
"
|
|
90
|
-
"stylelint": "^
|
|
91
|
-
"stylelint-config-standard": "^29.0.0",
|
|
60
|
+
"stylelint": "^16.2.0",
|
|
61
|
+
"stylelint-config-standard": "^36.0.0",
|
|
92
62
|
"stylelint-prettier": "^2.0.0",
|
|
93
|
-
"terser-webpack-plugin": "^5.3.6",
|
|
94
63
|
"ts-jest": "^29.0.3",
|
|
95
64
|
"ts-node": "^10.9.1",
|
|
96
65
|
"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"
|
|
66
|
+
"url": "^0.11.0"
|
|
101
67
|
},
|
|
102
|
-
"
|
|
103
|
-
"
|
|
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"
|
|
68
|
+
"overrides": {
|
|
69
|
+
"semver": "^7.5.2"
|
|
109
70
|
},
|
|
110
71
|
"importSort": {
|
|
111
72
|
".js": {
|
|
@@ -129,4 +90,4 @@
|
|
|
129
90
|
"prettier --write"
|
|
130
91
|
]
|
|
131
92
|
}
|
|
132
|
-
}
|
|
93
|
+
}
|