@icure/form 1.0.1 → 1.0.2

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 (69) hide show
  1. package/lib/components/index.d.ts +2 -0
  2. package/lib/components/index.js +14 -0
  3. package/lib/components/iqr-form/fields/datePicker.d.ts +8 -0
  4. package/lib/components/iqr-form/fields/datePicker.js +42 -0
  5. package/lib/components/iqr-form/fields/dateTimePicker.d.ts +8 -0
  6. package/lib/components/iqr-form/fields/dateTimePicker.js +42 -0
  7. package/lib/components/iqr-form/fields/measureField.d.ts +8 -0
  8. package/lib/components/iqr-form/fields/measureField.js +42 -0
  9. package/lib/components/iqr-form/fields/multipleChoice.d.ts +8 -0
  10. package/lib/components/iqr-form/fields/multipleChoice.js +42 -0
  11. package/lib/components/iqr-form/fields/numberField.d.ts +8 -0
  12. package/lib/components/iqr-form/fields/numberField.js +42 -0
  13. package/lib/components/iqr-form/fields/textfield.d.ts +1 -0
  14. package/lib/components/iqr-form/fields/textfield.js +86 -0
  15. package/lib/components/iqr-form/fields/timePicker.d.ts +8 -0
  16. package/lib/components/iqr-form/fields/timePicker.js +42 -0
  17. package/lib/components/iqr-form/index.d.ts +7 -0
  18. package/lib/components/iqr-form/index.js +83 -0
  19. package/lib/components/iqr-form/model/index.d.ts +78 -0
  20. package/lib/components/iqr-form/model/index.js +114 -0
  21. package/lib/components/iqr-form/renderer/cards.d.ts +2 -0
  22. package/lib/components/iqr-form/renderer/cards.js +43 -0
  23. package/lib/components/iqr-form/renderer/form.d.ts +2 -0
  24. package/lib/components/iqr-form/renderer/form.js +44 -0
  25. package/lib/components/iqr-form/renderer/index.d.ts +3 -0
  26. package/lib/components/iqr-form/renderer/index.js +2 -0
  27. package/lib/components/iqr-text-field/index.d.ts +2 -0
  28. package/lib/components/iqr-text-field/index.js +335 -0
  29. package/lib/components/iqr-text-field/plugin/caret-fix-plugin.d.ts +2 -0
  30. package/lib/components/iqr-text-field/plugin/caret-fix-plugin.js +23 -0
  31. package/lib/components/iqr-text-field/plugin/has-content-class-plugin.d.ts +2 -0
  32. package/lib/components/iqr-text-field/plugin/has-content-class-plugin.js +18 -0
  33. package/lib/components/iqr-text-field/plugin/mask-plugin.d.ts +2 -0
  34. package/lib/components/iqr-text-field/plugin/mask-plugin.js +143 -0
  35. package/lib/components/iqr-text-field/plugin/regexp-plugin.d.ts +2 -0
  36. package/lib/components/iqr-text-field/plugin/regexp-plugin.js +46 -0
  37. package/lib/components/iqr-text-field/prosemirror-commands.d.ts +4 -0
  38. package/lib/components/iqr-text-field/prosemirror-commands.js +52 -0
  39. package/lib/components/iqr-text-field/prosemirror-utils.d.ts +5 -0
  40. package/lib/components/iqr-text-field/prosemirror-utils.js +15 -0
  41. package/lib/components/iqr-text-field/schema/common-marks.d.ts +10 -0
  42. package/lib/components/iqr-text-field/schema/common-marks.js +90 -0
  43. package/lib/components/iqr-text-field/schema/date-time-schema.d.ts +7 -0
  44. package/lib/components/iqr-text-field/schema/date-time-schema.js +88 -0
  45. package/lib/components/iqr-text-field/schema/decimal-schema.d.ts +3 -0
  46. package/lib/components/iqr-text-field/schema/decimal-schema.js +27 -0
  47. package/lib/components/iqr-text-field/schema/index.d.ts +11 -0
  48. package/lib/components/iqr-text-field/schema/index.js +18 -0
  49. package/lib/components/iqr-text-field/schema/markdown-schema.d.ts +8 -0
  50. package/lib/components/iqr-text-field/schema/markdown-schema.js +139 -0
  51. package/lib/components/iqr-text-field/schema/measure-schema.d.ts +3 -0
  52. package/lib/components/iqr-text-field/schema/measure-schema.js +35 -0
  53. package/lib/components/iqr-text-field/schema/token-schema.d.ts +6 -0
  54. package/lib/components/iqr-text-field/schema/token-schema.js +36 -0
  55. package/lib/components/iqr-text-field/schema/utils.d.ts +11 -0
  56. package/lib/components/iqr-text-field/schema/utils.js +11 -0
  57. package/lib/components/iqr-text-field/selection-companion.d.ts +11 -0
  58. package/lib/components/iqr-text-field/selection-companion.js +52 -0
  59. package/lib/components/iqr-text-field/suggestion-palette.d.ts +33 -0
  60. package/lib/components/iqr-text-field/suggestion-palette.js +139 -0
  61. package/lib/index.d.ts +1 -2
  62. package/lib/index.js +1 -2
  63. package/package.json +1 -1
  64. package/.editorconfig +0 -12
  65. package/.mocharc.json +0 -5
  66. package/app/demo-app.ts +0 -191
  67. package/test/form.yaml +0 -96
  68. package/test/simple/test.spec.ts +0 -303
  69. package/webpack.config.js +0 -41
@@ -0,0 +1,143 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.maskPlugin = void 0;
4
+ const prosemirror_state_1 = require("prosemirror-state");
5
+ const prosemirror_view_1 = require("prosemirror-view");
6
+ exports.maskPlugin = () => {
7
+ const maskText = ($pos, text, mask, tr, setSelection = true) => {
8
+ const textFromBeginning = $pos.parent.textBetween(0, $pos.parentOffset) + text;
9
+ const trailingText = $pos.parent.textBetween($pos.parentOffset, $pos.parent.content.size);
10
+ let t = textFromBeginning;
11
+ let skip = 0;
12
+ let completed = false;
13
+ if (t.length === 0) {
14
+ t += trailingText.substring(text.length + skip);
15
+ completed = true;
16
+ }
17
+ for (let i = 0; i < mask.length && i < t.length; i++) {
18
+ if (mask[i] === '.' && t[i].normalize("NFD").replace(/[\u0300-\u036f]/g, "").match(/\w|-/) ||
19
+ mask[i] === '-' && t[i].match(/\d/)) {
20
+ //skip
21
+ }
22
+ else {
23
+ if (mask[i] === t[i]) {
24
+ //skip
25
+ }
26
+ else {
27
+ t = t.substring(0, i) + mask[i] + t.substring(i);
28
+ if (!completed)
29
+ skip++;
30
+ }
31
+ }
32
+ if (t.length === i + 1 && !completed) {
33
+ t += trailingText.substring(text.length + skip);
34
+ completed = true;
35
+ }
36
+ }
37
+ const tail = t.length > mask.length ? t.substring(mask.length) : '';
38
+ t = t.substring(0, mask.length);
39
+ let trail = t.length < mask.length ? mask.substring(t.length) : '';
40
+ if (t === textFromBeginning && trail === trailingText) {
41
+ return undefined;
42
+ }
43
+ const currentSel = tr.selection;
44
+ tr = tr.insertText(t + trail, $pos.pos - $pos.parentOffset, $pos.pos - $pos.parentOffset + $pos.parent.content.size);
45
+ if (setSelection) {
46
+ tr = tr.setSelection(prosemirror_state_1.TextSelection.create(tr.doc, Math.min($pos.pos + text.length + skip, tr.doc.content.size - 1)));
47
+ }
48
+ else {
49
+ tr = tr.setSelection(prosemirror_state_1.TextSelection.create(tr.doc, Math.min(currentSel.$anchor.pos, tr.doc.content.size - 1), Math.min(currentSel.$head.pos, tr.doc.content.size - 1)));
50
+ }
51
+ tr.setMeta("tailText", tail);
52
+ return tr;
53
+ };
54
+ function applyDocMasks(state) {
55
+ let tr = undefined;
56
+ let posMark = 0;
57
+ //Scan nodes and add mask when needed
58
+ while ((tr || state).doc && posMark < (tr || state).doc.content.size) {
59
+ const $pos = (tr || state).doc.resolve(posMark);
60
+ const node = $pos.node($pos.depth) || undefined;
61
+ const mask = node === null || node === void 0 ? void 0 : node.type.spec.mask;
62
+ if (mask) {
63
+ tr = tr || state.tr;
64
+ tr = maskText(tr.doc.resolve(posMark), '', mask, tr, false) || tr;
65
+ const $newPos = tr.doc.resolve(posMark);
66
+ const newNode = $newPos.node($newPos.depth);
67
+ if (newNode) {
68
+ posMark += newNode.content.size + 1;
69
+ }
70
+ else
71
+ posMark++;
72
+ }
73
+ else {
74
+ posMark++;
75
+ }
76
+ }
77
+ return tr;
78
+ }
79
+ return new prosemirror_state_1.Plugin({
80
+ view: (v) => {
81
+ let tr = applyDocMasks(v.state);
82
+ if (tr)
83
+ v.updateState(v.state.apply(tr));
84
+ return {};
85
+ },
86
+ props: {
87
+ decorations(state) {
88
+ let $pos = state.doc.resolve(Math.min(state.selection.$from.pos, state.doc.content.size));
89
+ let node = $pos.parent;
90
+ let start = $pos.pos - $pos.parentOffset;
91
+ if (node.type.spec.mask) {
92
+ if (node.type.spec.mask.length === $pos.parentOffset && node.type.spec.mask.length === node.content.size) {
93
+ //Move to the next one
94
+ while ($pos.pos < state.doc.content.size - 1) {
95
+ $pos = state.doc.resolve($pos.pos + 1);
96
+ node = $pos.parent;
97
+ if (node && node.type.spec.mask) {
98
+ start = $pos.pos - $pos.parentOffset;
99
+ break;
100
+ }
101
+ }
102
+ }
103
+ return prosemirror_view_1.DecorationSet.create(state.doc, [
104
+ prosemirror_view_1.Decoration.node(start - 1, start - 1 + node.nodeSize, { class: "focused" })
105
+ ]);
106
+ }
107
+ return undefined;
108
+ },
109
+ handleTextInput: (view, from, to, text) => {
110
+ if (view.composing)
111
+ return false;
112
+ const state = view.state;
113
+ const $from = state.doc.resolve(from);
114
+ const mask = $from.parent.type.spec.mask;
115
+ const regexp = $from.parent.type.spec.regexp;
116
+ if (!mask)
117
+ return false;
118
+ const tr = maskText($from, regexp && regexp.length ? text.split('').filter(x => x.match(new RegExp(regexp))).join('') : text, mask, state.tr);
119
+ if (tr) {
120
+ const tail = tr.getMeta('tailText');
121
+ if (tail === null || tail === void 0 ? void 0 : tail.length) {
122
+ const nextPos = tr.selection.$to.pos < tr.doc.content.size ? tr.doc.resolve(tr.selection.$to.pos + 1) : undefined;
123
+ if (nextPos) {
124
+ const nextNode = nextPos.node(nextPos.depth);
125
+ if (nextNode && nextNode.type.spec.mask && nextNode.type.spec.mask.length) {
126
+ maskText(nextPos, tail, nextNode.type.spec.mask, tr);
127
+ }
128
+ else if (nextNode && (nextNode.type.isText || nextNode.type.isTextblock)) {
129
+ tr.insertText(tail, nextPos.pos, nextPos.pos);
130
+ }
131
+ }
132
+ }
133
+ view.dispatch(tr);
134
+ return true;
135
+ }
136
+ return false;
137
+ }
138
+ },
139
+ appendTransaction: (transactions, oldState, newState) => {
140
+ return applyDocMasks(newState);
141
+ }
142
+ });
143
+ };
@@ -0,0 +1,2 @@
1
+ import { Plugin } from 'prosemirror-state';
2
+ export declare const regexpPlugin: () => Plugin<any, any>;
@@ -0,0 +1,46 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.regexpPlugin = void 0;
4
+ const prosemirror_state_1 = require("prosemirror-state");
5
+ exports.regexpPlugin = () => {
6
+ return new prosemirror_state_1.Plugin({
7
+ props: {
8
+ handleTextInput: (view, from, to, text) => {
9
+ if (view.composing)
10
+ return false;
11
+ const state = view.state;
12
+ const $from = state.doc.resolve(from);
13
+ const mask = $from.parent.type.spec.mask;
14
+ const regexp = $from.parent.type.spec.regexp;
15
+ if (mask || !regexp)
16
+ return false; // Will be handled by mask plugin
17
+ const allowedCharacters = text.split('').filter(x => x.match(new RegExp(regexp))).join('');
18
+ if (allowedCharacters === text)
19
+ return false;
20
+ let tr = state.tr;
21
+ if (allowedCharacters.length) {
22
+ tr = tr.insertText(allowedCharacters, from, to);
23
+ tr = tr.setSelection(prosemirror_state_1.TextSelection.create(tr.doc, Math.min(to + allowedCharacters.length, tr.doc.content.size - 1)));
24
+ }
25
+ if (text.startsWith(allowedCharacters)) {
26
+ const tail = text.substring(allowedCharacters.length);
27
+ if (tail === null || tail === void 0 ? void 0 : tail.length) {
28
+ let posMark = tr.selection.$to.pos + 1;
29
+ while (posMark < tr.doc.content.size) {
30
+ const nextPos = tr.doc.resolve(posMark);
31
+ const nextNode = nextPos.node(nextPos.depth);
32
+ if (nextNode && (nextNode.type.isText || nextNode.type.isTextblock)) {
33
+ tr = tr.insertText(tail, nextPos.pos, nextPos.pos);
34
+ tr = tr.setSelection(prosemirror_state_1.TextSelection.create(tr.doc, Math.min(nextPos.pos + tail.length, tr.doc.content.size - 1)));
35
+ break;
36
+ }
37
+ posMark++;
38
+ }
39
+ }
40
+ }
41
+ view.dispatch(tr);
42
+ return true;
43
+ }
44
+ }
45
+ });
46
+ };
@@ -0,0 +1,4 @@
1
+ import { NodeType } from "prosemirror-model";
2
+ import { EditorState, Transaction } from "prosemirror-state";
3
+ export declare function wrapInIfNeeded(nodeType: NodeType, attrs?: any): (state: EditorState, dispatch?: ((tr: Transaction) => void) | undefined) => boolean;
4
+ export declare function unwrapFrom(nodeType: NodeType): (state: EditorState, dispatch?: ((tr: Transaction) => void) | undefined) => boolean;
@@ -0,0 +1,52 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.unwrapFrom = exports.wrapInIfNeeded = void 0;
4
+ const prosemirror_transform_1 = require("prosemirror-transform");
5
+ const prosemirror_model_1 = require("prosemirror-model");
6
+ const prosemirror_state_1 = require("prosemirror-state");
7
+ // :: (NodeType, ?Object) → (state: EditorState, dispatch: ?(tr: Transaction)) → bool
8
+ // Wrap the selection in a node of the given type with the given
9
+ // attributes.
10
+ function wrapInIfNeeded(nodeType, attrs) {
11
+ return function (state, dispatch) {
12
+ var _a, _b;
13
+ const { $from, $to, to } = state.selection;
14
+ const range = $from.blockRange($to);
15
+ if (!range) {
16
+ return false;
17
+ }
18
+ let same = range.$from.sharedDepth(to);
19
+ if (same) {
20
+ const pos = $from.before(same);
21
+ if (((_b = (_a = prosemirror_state_1.NodeSelection.create(state.doc, pos).$from) === null || _a === void 0 ? void 0 : _a.node()) === null || _b === void 0 ? void 0 : _b.type) === nodeType) {
22
+ return false;
23
+ }
24
+ }
25
+ const wrapping = range && prosemirror_transform_1.findWrapping(range, nodeType, attrs);
26
+ if (!wrapping)
27
+ return false;
28
+ if (dispatch)
29
+ dispatch(state.tr.wrap(range, wrapping).scrollIntoView());
30
+ return true;
31
+ };
32
+ }
33
+ exports.wrapInIfNeeded = wrapInIfNeeded;
34
+ // :: (NodeType, ?Object) → (state: EditorState, dispatch: ?(tr: Transaction)) → bool
35
+ // Wrap the selection in a node of the given type with the given
36
+ // attributes.
37
+ function unwrapFrom(nodeType) {
38
+ return function (state, dispatch) {
39
+ const { $from, $to } = state.selection;
40
+ const range = $from.blockRange($to);
41
+ const depth = range && prosemirror_transform_1.liftTarget(range);
42
+ if (depth === null || depth === undefined) {
43
+ return false;
44
+ }
45
+ let gapStart = $from.before(depth + 1), gapEnd = $to.after(depth + 1);
46
+ const frag = prosemirror_model_1.Fragment.from($from.node());
47
+ if (dispatch)
48
+ dispatch(state.tr.replaceRange(gapStart, gapEnd, new prosemirror_model_1.Slice(frag, 0, 0)).scrollIntoView());
49
+ return true;
50
+ };
51
+ }
52
+ exports.unwrapFrom = unwrapFrom;
@@ -0,0 +1,5 @@
1
+ import { MarkSpec } from "prosemirror-model";
2
+ import OrderedMap = require('orderedmap');
3
+ export declare function hasMark(ms: {
4
+ [key: string]: MarkSpec;
5
+ } | OrderedMap<MarkSpec> | null | undefined, mark: string): boolean;
@@ -0,0 +1,15 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.hasMark = void 0;
4
+ function hasMark(ms, mark) {
5
+ if (!ms) {
6
+ return false;
7
+ }
8
+ if (!!ms.get) {
9
+ return !!(ms.get(mark));
10
+ }
11
+ else {
12
+ return !!ms[mark];
13
+ }
14
+ }
15
+ exports.hasMark = hasMark;
@@ -0,0 +1,10 @@
1
+ import { MarkSpec } from "prosemirror-model";
2
+ export declare const colors: {
3
+ [key: string]: [string, string];
4
+ };
5
+ export declare function getMarks(contentProvider: (codes: {
6
+ type: string;
7
+ code: string;
8
+ }[]) => string, colorProvider: (type: string, code: string, isCode: boolean) => string): {
9
+ [key: string]: MarkSpec;
10
+ };
@@ -0,0 +1,90 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getMarks = exports.colors = void 0;
4
+ exports.colors = {
5
+ 'I': ['#F44336', 'white'],
6
+ 'II': ['#E91E63', 'white'],
7
+ 'III': ['#9C27B0', 'white'],
8
+ 'IV': ['#673AB7', 'white'],
9
+ 'V': ['#009688', 'white'],
10
+ 'VI': ['#4CAF50', 'white'],
11
+ 'VII': ['#8BC34A', 'white'],
12
+ 'VIII': ['#03A9F4', 'white'],
13
+ 'IX': ['#00BCD4', 'white'],
14
+ 'X': ['#FFC107', 'black'],
15
+ 'XI': ['#FF9800', 'black'],
16
+ 'XII': ['#FF5722', 'white'],
17
+ 'XIII': ['#795548', 'white'],
18
+ 'XIV': ['#3949AB', 'white'],
19
+ 'XV': ['#C0CA33', 'black'],
20
+ 'XVI': ['#07F87F', 'black'],
21
+ 'XVII': ['#FF6262', 'white'],
22
+ 'XVIII': ['#718792', 'white'],
23
+ 'XIX': ['#00ECB9', 'black'],
24
+ 'XX': ['#FF20A3', 'black'],
25
+ 'XXI': ['#FFCE38', 'black'],
26
+ 'XXII': ['#721F01', 'white']
27
+ };
28
+ const getColor = (c) => exports.colors[c] || [c, 'white'];
29
+ function getMarks(contentProvider, colorProvider) {
30
+ return {
31
+ em: {
32
+ parseDOM: [{ tag: 'i' }, { tag: 'em' },
33
+ { style: 'font-style', getAttrs: value => value === 'italic' && null }],
34
+ toDOM() {
35
+ return ['em'];
36
+ }
37
+ },
38
+ strong: {
39
+ parseDOM: [{ tag: 'b' }, { tag: 'strong' }, { style: 'font-weight', getAttrs: value => /^(bold(er)?|[5-9]\d{2,})$/.test(value) && null }],
40
+ toDOM() {
41
+ return ['strong'];
42
+ }
43
+ },
44
+ link: {
45
+ attrs: {
46
+ href: {},
47
+ title: { default: null }
48
+ },
49
+ inclusive: false,
50
+ parseDOM: [{
51
+ tag: 'span[data-href]',
52
+ getAttrs(dom) {
53
+ const el = dom;
54
+ return { href: el.dataset.href, title: el.dataset.title };
55
+ }
56
+ }],
57
+ toDOM(node) {
58
+ const urls = node.attrs.href;
59
+ if (urls) {
60
+ const refs = urls.split(',').map(url => {
61
+ let pos = url.indexOf('://');
62
+ const protocol = url.substring(0, pos);
63
+ const code = url.substring(pos + 3);
64
+ let parts = protocol.split('-');
65
+ const category = parts[0];
66
+ const type = parts[1];
67
+ return { category, type, code };
68
+ });
69
+ const codes = refs.filter(x => x.category === 'c');
70
+ const ilinks = refs.filter(x => x.category === 'i');
71
+ const classes = (refs.some(x => x.category === 'x') ? ['ext-link'] : []).concat(codes.length ? [`code-count-${codes.length}`] : []);
72
+ const dataAttributes = (codes.length ? [{ 'data-content': contentProvider(codes) }] : [])
73
+ .concat(ilinks.map((c, idx) => ({ [`data-link-color-${idx}`]: colorProvider(c.type, c.code, false) })));
74
+ const styles = codes.map((c, idx) => {
75
+ const color = getColor(colorProvider(c.type, c.code, true));
76
+ return (`--bg-code-color-${idx + 1}: ${color[0]}; --text-code-color-${idx + 1}: ${color[1]};`);
77
+ });
78
+ return ['span', dataAttributes.reduce((acc, da) => Object.assign(da, acc), {
79
+ ['data-href']: node.attrs.href,
80
+ ['data-title']: node.attrs.title,
81
+ 'class': classes.join(' '),
82
+ 'style': styles.join('')
83
+ })];
84
+ }
85
+ return ['span', { ['data-href']: node.attrs.href, ['data-title']: node.attrs.title }];
86
+ }
87
+ }
88
+ };
89
+ }
90
+ exports.getMarks = getMarks;
@@ -0,0 +1,7 @@
1
+ import { SchemaSpec } from 'prosemirror-model';
2
+ export declare type DateSchema = 'date';
3
+ export declare type TimeSchema = 'time';
4
+ export declare type DateTimeSchema = 'date-time';
5
+ export declare function getDateSpec(): SchemaSpec;
6
+ export declare function getTimeSpec(): SchemaSpec;
7
+ export declare function getDateTimeSpec(): SchemaSpec;
@@ -0,0 +1,88 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getDateTimeSpec = exports.getTimeSpec = exports.getDateSpec = void 0;
4
+ function getDateSpec() {
5
+ return {
6
+ topNode: 'paragraph',
7
+ nodes: {
8
+ paragraph: {
9
+ content: 'date',
10
+ },
11
+ date: {
12
+ content: 'inline*',
13
+ group: 'block',
14
+ parseDOM: [{ tag: 'span' }],
15
+ toDOM() {
16
+ return ['span', 0];
17
+ },
18
+ regexp: '[0-9]',
19
+ mask: '--/--/----'
20
+ },
21
+ text: {
22
+ group: 'inline'
23
+ }
24
+ },
25
+ marks: {}
26
+ };
27
+ }
28
+ exports.getDateSpec = getDateSpec;
29
+ function getTimeSpec() {
30
+ return {
31
+ topNode: 'paragraph',
32
+ nodes: {
33
+ paragraph: {
34
+ content: 'time',
35
+ },
36
+ time: {
37
+ content: 'inline*',
38
+ group: 'block',
39
+ parseDOM: [{ tag: 'span' }],
40
+ toDOM() {
41
+ return ['span', 0];
42
+ },
43
+ regexp: '[0-9]',
44
+ mask: '--:--:--'
45
+ },
46
+ text: {
47
+ group: 'inline'
48
+ }
49
+ },
50
+ marks: {}
51
+ };
52
+ }
53
+ exports.getTimeSpec = getTimeSpec;
54
+ function getDateTimeSpec() {
55
+ return {
56
+ topNode: 'paragraph',
57
+ nodes: {
58
+ paragraph: {
59
+ content: 'date time',
60
+ },
61
+ date: {
62
+ content: 'inline*',
63
+ group: 'block',
64
+ parseDOM: [{ tag: 'span' }],
65
+ toDOM() {
66
+ return ['span', { class: 'date' }, 0];
67
+ },
68
+ regexp: '[0-9]',
69
+ mask: '--/--/----'
70
+ },
71
+ time: {
72
+ content: 'inline*',
73
+ group: 'block',
74
+ parseDOM: [{ tag: 'span' }],
75
+ toDOM() {
76
+ return ['span', { class: 'time' }, 0];
77
+ },
78
+ regexp: '[0-9]',
79
+ mask: '--:--:--'
80
+ },
81
+ text: {
82
+ group: 'inline'
83
+ }
84
+ },
85
+ marks: {}
86
+ };
87
+ }
88
+ exports.getDateTimeSpec = getDateTimeSpec;
@@ -0,0 +1,3 @@
1
+ import { SchemaSpec } from 'prosemirror-model';
2
+ export declare type DecimalSchema = 'decimal';
3
+ export declare function getDecimalSpec(): SchemaSpec;
@@ -0,0 +1,27 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getDecimalSpec = void 0;
4
+ function getDecimalSpec() {
5
+ return {
6
+ topNode: 'paragraph',
7
+ nodes: {
8
+ paragraph: {
9
+ content: 'decimal',
10
+ },
11
+ decimal: {
12
+ content: 'inline*',
13
+ group: 'block',
14
+ parseDOM: [{ tag: 'span' }],
15
+ toDOM() {
16
+ return ['span', 0];
17
+ },
18
+ regexp: '[,. 0-9-]'
19
+ },
20
+ text: {
21
+ group: 'inline'
22
+ }
23
+ },
24
+ marks: {}
25
+ };
26
+ }
27
+ exports.getDecimalSpec = getDecimalSpec;
@@ -0,0 +1,11 @@
1
+ import { Schema } from 'prosemirror-model';
2
+ import { DocumentSchema, InlineSchema, StyledSchema } from "./markdown-schema";
3
+ import { DateSchema, DateTimeSchema, TimeSchema } from "./date-time-schema";
4
+ import { TokensSchema } from "./token-schema";
5
+ import { MeasureSchema } from "./measure-schema";
6
+ import { DecimalSchema } from "./decimal-schema";
7
+ export declare type IqrTextFieldSchema = DocumentSchema | TokensSchema | StyledSchema | InlineSchema | DateSchema | TimeSchema | DateTimeSchema | DecimalSchema | MeasureSchema;
8
+ export declare function createSchema(type: IqrTextFieldSchema, colorProvider: (type: string, code: string, isCode: boolean) => string, contentProvider: (codes: {
9
+ type: string;
10
+ code: string;
11
+ }[]) => string): Schema<any, any>;
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.createSchema = void 0;
4
+ const prosemirror_model_1 = require("prosemirror-model");
5
+ const markdown_schema_1 = require("./markdown-schema");
6
+ const date_time_schema_1 = require("./date-time-schema");
7
+ const token_schema_1 = require("./token-schema");
8
+ const measure_schema_1 = require("./measure-schema");
9
+ const decimal_schema_1 = require("./decimal-schema");
10
+ function createSchema(type, colorProvider, contentProvider) {
11
+ return new prosemirror_model_1.Schema(type === 'decimal' ? decimal_schema_1.getDecimalSpec() :
12
+ type === 'measure' ? measure_schema_1.getMeasureSpec() :
13
+ type === 'date' ? date_time_schema_1.getDateSpec() :
14
+ type === 'time' ? date_time_schema_1.getTimeSpec() :
15
+ type === 'date-time' ? date_time_schema_1.getDateTimeSpec() :
16
+ type === 'tokens-list' || type === 'styled-tokens-list' || type === 'tokens-list-with-codes' || type === 'styled-tokens-list-with-codes' ? token_schema_1.getTokensSpec(type, contentProvider, colorProvider) : markdown_schema_1.getMarkdownSpec(type, contentProvider, colorProvider));
17
+ }
18
+ exports.createSchema = createSchema;
@@ -0,0 +1,8 @@
1
+ import { SchemaSpec } from 'prosemirror-model';
2
+ export declare type DocumentSchema = 'text-document';
3
+ export declare type InlineSchema = 'styled-text' | 'text' | 'text-with-codes' | 'styled-text-with-codes';
4
+ export declare type StyledSchema = 'text-document' | 'styled-text' | 'styled-text-with-codes';
5
+ export declare function getMarkdownSpec(type: DocumentSchema | InlineSchema, contentProvider: (codes: {
6
+ type: string;
7
+ code: string;
8
+ }[]) => string, colorProvider: (type: string, code: string, isCode: boolean) => string): SchemaSpec;