@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.
- package/lib/components/index.d.ts +2 -0
- package/lib/components/index.js +14 -0
- package/lib/components/iqr-form/fields/datePicker.d.ts +8 -0
- package/lib/components/iqr-form/fields/datePicker.js +42 -0
- package/lib/components/iqr-form/fields/dateTimePicker.d.ts +8 -0
- package/lib/components/iqr-form/fields/dateTimePicker.js +42 -0
- package/lib/components/iqr-form/fields/measureField.d.ts +8 -0
- package/lib/components/iqr-form/fields/measureField.js +42 -0
- package/lib/components/iqr-form/fields/multipleChoice.d.ts +8 -0
- package/lib/components/iqr-form/fields/multipleChoice.js +42 -0
- package/lib/components/iqr-form/fields/numberField.d.ts +8 -0
- package/lib/components/iqr-form/fields/numberField.js +42 -0
- package/lib/components/iqr-form/fields/textfield.d.ts +1 -0
- package/lib/components/iqr-form/fields/textfield.js +86 -0
- package/lib/components/iqr-form/fields/timePicker.d.ts +8 -0
- package/lib/components/iqr-form/fields/timePicker.js +42 -0
- package/lib/components/iqr-form/index.d.ts +7 -0
- package/lib/components/iqr-form/index.js +83 -0
- package/lib/components/iqr-form/model/index.d.ts +78 -0
- package/lib/components/iqr-form/model/index.js +114 -0
- package/lib/components/iqr-form/renderer/cards.d.ts +2 -0
- package/lib/components/iqr-form/renderer/cards.js +43 -0
- package/lib/components/iqr-form/renderer/form.d.ts +2 -0
- package/lib/components/iqr-form/renderer/form.js +44 -0
- package/lib/components/iqr-form/renderer/index.d.ts +3 -0
- package/lib/components/iqr-form/renderer/index.js +2 -0
- package/lib/components/iqr-text-field/index.d.ts +2 -0
- package/lib/components/iqr-text-field/index.js +335 -0
- package/lib/components/iqr-text-field/plugin/caret-fix-plugin.d.ts +2 -0
- package/lib/components/iqr-text-field/plugin/caret-fix-plugin.js +23 -0
- package/lib/components/iqr-text-field/plugin/has-content-class-plugin.d.ts +2 -0
- package/lib/components/iqr-text-field/plugin/has-content-class-plugin.js +18 -0
- package/lib/components/iqr-text-field/plugin/mask-plugin.d.ts +2 -0
- package/lib/components/iqr-text-field/plugin/mask-plugin.js +143 -0
- package/lib/components/iqr-text-field/plugin/regexp-plugin.d.ts +2 -0
- package/lib/components/iqr-text-field/plugin/regexp-plugin.js +46 -0
- package/lib/components/iqr-text-field/prosemirror-commands.d.ts +4 -0
- package/lib/components/iqr-text-field/prosemirror-commands.js +52 -0
- package/lib/components/iqr-text-field/prosemirror-utils.d.ts +5 -0
- package/lib/components/iqr-text-field/prosemirror-utils.js +15 -0
- package/lib/components/iqr-text-field/schema/common-marks.d.ts +10 -0
- package/lib/components/iqr-text-field/schema/common-marks.js +90 -0
- package/lib/components/iqr-text-field/schema/date-time-schema.d.ts +7 -0
- package/lib/components/iqr-text-field/schema/date-time-schema.js +88 -0
- package/lib/components/iqr-text-field/schema/decimal-schema.d.ts +3 -0
- package/lib/components/iqr-text-field/schema/decimal-schema.js +27 -0
- package/lib/components/iqr-text-field/schema/index.d.ts +11 -0
- package/lib/components/iqr-text-field/schema/index.js +18 -0
- package/lib/components/iqr-text-field/schema/markdown-schema.d.ts +8 -0
- package/lib/components/iqr-text-field/schema/markdown-schema.js +139 -0
- package/lib/components/iqr-text-field/schema/measure-schema.d.ts +3 -0
- package/lib/components/iqr-text-field/schema/measure-schema.js +35 -0
- package/lib/components/iqr-text-field/schema/token-schema.d.ts +6 -0
- package/lib/components/iqr-text-field/schema/token-schema.js +36 -0
- package/lib/components/iqr-text-field/schema/utils.d.ts +11 -0
- package/lib/components/iqr-text-field/schema/utils.js +11 -0
- package/lib/components/iqr-text-field/selection-companion.d.ts +11 -0
- package/lib/components/iqr-text-field/selection-companion.js +52 -0
- package/lib/components/iqr-text-field/suggestion-palette.d.ts +33 -0
- package/lib/components/iqr-text-field/suggestion-palette.js +139 -0
- package/lib/index.d.ts +1 -2
- package/lib/index.js +1 -2
- package/package.json +1 -1
- package/.editorconfig +0 -12
- package/.mocharc.json +0 -5
- package/app/demo-app.ts +0 -191
- package/test/form.yaml +0 -96
- package/test/simple/test.spec.ts +0 -303
- package/webpack.config.js +0 -41
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Form = exports.Section = exports.Group = exports.MultipleChoice = exports.DateTimePicker = exports.TimePicker = exports.DatePicker = exports.NumberField = exports.MeasureField = exports.TextField = exports.Field = void 0;
|
|
4
|
+
class Field {
|
|
5
|
+
constructor(type, label, shortLabel, rows, columns, grows, schema, tags, codifications, options) {
|
|
6
|
+
this.field = label;
|
|
7
|
+
this.type = type;
|
|
8
|
+
this.shortLabel = shortLabel;
|
|
9
|
+
this.rows = rows;
|
|
10
|
+
this.columns = columns;
|
|
11
|
+
this.grows = grows;
|
|
12
|
+
this.schema = schema;
|
|
13
|
+
this.tags = tags;
|
|
14
|
+
this.codifications = codifications;
|
|
15
|
+
this.options = options;
|
|
16
|
+
}
|
|
17
|
+
static parse(json) {
|
|
18
|
+
switch (json.type) {
|
|
19
|
+
case 'textfield':
|
|
20
|
+
return new TextField(json.field, json.shortLabel, json.rows, json.grows, json.schema, json.tags, json.codifications, json.options);
|
|
21
|
+
case 'measure-field':
|
|
22
|
+
return new MeasureField(json.field, json.shortLabel, json.tags, json.codifications, json.options);
|
|
23
|
+
case 'number-field':
|
|
24
|
+
return new NumberField(json.field, json.shortLabel, json.tags, json.codifications, json.options);
|
|
25
|
+
case 'date-picker':
|
|
26
|
+
return new DatePicker(json.field, json.shortLabel, json.tags, json.codifications, json.options);
|
|
27
|
+
case 'time-picker':
|
|
28
|
+
return new TimePicker(json.field, json.shortLabel, json.tags, json.codifications, json.options);
|
|
29
|
+
case 'date-time-picker':
|
|
30
|
+
return new DateTimePicker(json.field, json.shortLabel, json.tags, json.codifications, json.options);
|
|
31
|
+
case 'multiple-choice':
|
|
32
|
+
return new MultipleChoice(json.field, json.shortLabel, json.rows, json.columns, json.tags, json.codifications, json.options);
|
|
33
|
+
default:
|
|
34
|
+
throw Error("Invalid field type " + json.type);
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
exports.Field = Field;
|
|
39
|
+
class TextField extends Field {
|
|
40
|
+
constructor(label, shortLabel, rows, grows, schema, tags, codifications, options) {
|
|
41
|
+
super('textfield', label, shortLabel, rows, undefined, grows, schema || 'styled-text-with-codes', tags, codifications, options);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
exports.TextField = TextField;
|
|
45
|
+
class MeasureField extends Field {
|
|
46
|
+
constructor(label, shortLabel, tags, codifications, options) {
|
|
47
|
+
super('measure-field', label, shortLabel, undefined, undefined, undefined, undefined, tags, codifications, options);
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
exports.MeasureField = MeasureField;
|
|
51
|
+
class NumberField extends Field {
|
|
52
|
+
constructor(label, shortLabel, tags, codifications, options) {
|
|
53
|
+
super('number-field', label, shortLabel, undefined, undefined, undefined, undefined, tags, codifications, options);
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
exports.NumberField = NumberField;
|
|
57
|
+
class DatePicker extends Field {
|
|
58
|
+
constructor(label, shortLabel, tags, codifications, options) {
|
|
59
|
+
super('date-picker', label, shortLabel, undefined, undefined, undefined, undefined, tags, codifications, options);
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
exports.DatePicker = DatePicker;
|
|
63
|
+
class TimePicker extends Field {
|
|
64
|
+
constructor(label, shortLabel, tags, codifications, options) {
|
|
65
|
+
super('time-picker', label, shortLabel, undefined, undefined, undefined, undefined, tags, codifications, options);
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
exports.TimePicker = TimePicker;
|
|
69
|
+
class DateTimePicker extends Field {
|
|
70
|
+
constructor(label, shortLabel, tags, codifications, options) {
|
|
71
|
+
super('date-time-picker', label, shortLabel, undefined, undefined, undefined, undefined, tags, codifications, options);
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
exports.DateTimePicker = DateTimePicker;
|
|
75
|
+
class MultipleChoice extends Field {
|
|
76
|
+
constructor(label, shortLabel, rows, columns, tags, codifications, options) {
|
|
77
|
+
super('multiple-choice', label, shortLabel, rows, columns, undefined, undefined, tags, codifications, options);
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
exports.MultipleChoice = MultipleChoice;
|
|
81
|
+
class Group {
|
|
82
|
+
constructor(title, fields) {
|
|
83
|
+
this.group = title;
|
|
84
|
+
this.fields = fields;
|
|
85
|
+
}
|
|
86
|
+
static parse(json) {
|
|
87
|
+
return new Group(json.group, json.fields.map((s) => s.group ? Group.parse(s) : Field.parse(s)));
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
exports.Group = Group;
|
|
91
|
+
class Section {
|
|
92
|
+
constructor(title, fields, description, keywords) {
|
|
93
|
+
this.section = title;
|
|
94
|
+
this.fields = fields;
|
|
95
|
+
this.description = description;
|
|
96
|
+
this.keywords = keywords;
|
|
97
|
+
}
|
|
98
|
+
static parse(json) {
|
|
99
|
+
return new Section(json.section, json.fields.map((s) => s.group ? Group.parse(s) : Field.parse(s)), json.description, json.keywords);
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
exports.Section = Section;
|
|
103
|
+
class Form {
|
|
104
|
+
constructor(title, sections, description, keywords) {
|
|
105
|
+
this.form = title;
|
|
106
|
+
this.description = description;
|
|
107
|
+
this.keywords = keywords;
|
|
108
|
+
this.sections = sections;
|
|
109
|
+
}
|
|
110
|
+
static parse(json) {
|
|
111
|
+
return new Form(json.form, json.sections.map((s) => Section.parse(s)), json.description, json.keywords);
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
exports.Form = Form;
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.render = void 0;
|
|
4
|
+
const lit_element_1 = require("lit-element");
|
|
5
|
+
const model_1 = require("../model");
|
|
6
|
+
exports.render = (form, props, state, setState) => {
|
|
7
|
+
var _a;
|
|
8
|
+
const h = function (level, content) {
|
|
9
|
+
return level === 1 ? lit_element_1.html `<h1>${content}</h1>` :
|
|
10
|
+
level === 2 ? lit_element_1.html `<h2>${content}</h2>` :
|
|
11
|
+
level === 3 ? lit_element_1.html `<h3>${content}</h3>` :
|
|
12
|
+
level === 4 ? lit_element_1.html `<h4>${content}</h4>` :
|
|
13
|
+
level === 5 ? lit_element_1.html `<h5>${content}</h5>` :
|
|
14
|
+
lit_element_1.html `<h6>${content}</h6>`;
|
|
15
|
+
};
|
|
16
|
+
const renderFieldOrGroup = function (fg, level) {
|
|
17
|
+
var _a;
|
|
18
|
+
return fg instanceof model_1.Group ? lit_element_1.html `
|
|
19
|
+
<div class="group">
|
|
20
|
+
${h(level, lit_element_1.html `${fg.group}`)}
|
|
21
|
+
${(_a = fg.fields) === null || _a === void 0 ? void 0 : _a.map(f => renderFieldOrGroup(f, level + 1))}` :
|
|
22
|
+
lit_element_1.html `${fg.type === 'textfield' ? lit_element_1.html `<iqr-form-textfield label="${fg.field}" multiline="${(fg.rows || 0) > 1 || fg.grows}" rows="${fg.rows || 1}" grows="${fg.grows || false}"></iqr-form-textfield>` :
|
|
23
|
+
fg.type === 'measure-field' ? lit_element_1.html `<iqr-form-measure-field label="${fg.field}"></iqr-form-measure-field>` :
|
|
24
|
+
fg.type === 'number-field' ? lit_element_1.html `<iqr-form-number-field label="${fg.field}"></iqr-form-number-field>` :
|
|
25
|
+
fg.type === 'date-picker' ? lit_element_1.html `<iqr-form-date-picker label="${fg.field}"></iqr-form-date-picker>` :
|
|
26
|
+
fg.type === 'time-picker' ? lit_element_1.html `<iqr-form-time-picker label="${fg.field}"></iqr-form-time-picker>` :
|
|
27
|
+
fg.type === 'date-time-picker' ? lit_element_1.html `<iqr-form-date-time-picker label="${fg.field}"></iqr-form-date-time-picker>` :
|
|
28
|
+
fg.type === 'multiple-choice' ? lit_element_1.html `<iqr-form-multiple-choice label="${fg.field}"></iqr-form-multiple-choice>` : ''}
|
|
29
|
+
</div>`;
|
|
30
|
+
};
|
|
31
|
+
return lit_element_1.html `
|
|
32
|
+
<div class="iqr-form">
|
|
33
|
+
${(_a = form === null || form === void 0 ? void 0 : form.sections) === null || _a === void 0 ? void 0 : _a.map(s => {
|
|
34
|
+
var _a;
|
|
35
|
+
return lit_element_1.html `
|
|
36
|
+
<h2>${s.section}</h2>
|
|
37
|
+
${s.description ? lit_element_1.html `<p>${s.description}</p>` : ''}
|
|
38
|
+
${(_a = s.fields) === null || _a === void 0 ? void 0 : _a.map(f => renderFieldOrGroup(f, 3))}
|
|
39
|
+
`;
|
|
40
|
+
})}
|
|
41
|
+
</div>
|
|
42
|
+
`;
|
|
43
|
+
};
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.render = void 0;
|
|
4
|
+
const lit_element_1 = require("lit-element");
|
|
5
|
+
const model_1 = require("../model");
|
|
6
|
+
exports.render = (form, props, state, setState) => {
|
|
7
|
+
var _a;
|
|
8
|
+
const h = function (level, content) {
|
|
9
|
+
return level === 1 ? lit_element_1.html `<h1>${content}</h1>` :
|
|
10
|
+
level === 2 ? lit_element_1.html `<h2>${content}</h2>` :
|
|
11
|
+
level === 3 ? lit_element_1.html `<h3>${content}</h3>` :
|
|
12
|
+
level === 4 ? lit_element_1.html `<h4>${content}</h4>` :
|
|
13
|
+
level === 5 ? lit_element_1.html `<h5>${content}</h5>` :
|
|
14
|
+
lit_element_1.html `<h6>${content}</h6>`;
|
|
15
|
+
};
|
|
16
|
+
const renderFieldOrGroup = function (fg, level) {
|
|
17
|
+
var _a, _b, _c, _d, _e, _f;
|
|
18
|
+
return fg instanceof model_1.Group ? lit_element_1.html `
|
|
19
|
+
<div class="group">
|
|
20
|
+
${h(level, lit_element_1.html `${fg.group}`)}
|
|
21
|
+
${(_a = fg.fields) === null || _a === void 0 ? void 0 : _a.map(f => renderFieldOrGroup(f, level + 1))}` :
|
|
22
|
+
lit_element_1.html `${fg.type === 'textfield' ? lit_element_1.html `<iqr-form-textfield labelPosition=${props.labelPosition} label="${fg.field}" multiline="${(fg.rows || 0) > 1 || fg.grows}" rows="${fg.rows || 1}" grows="${fg.grows || false}"
|
|
23
|
+
.linksProvider=${(_b = fg.options) === null || _b === void 0 ? void 0 : _b.linksProvider} .suggestionProvider=${(_c = fg.options) === null || _c === void 0 ? void 0 : _c.suggestionProvider} .codeColorProvider=${(_d = fg.options) === null || _d === void 0 ? void 0 : _d.codeColorProvider} .linkColorProvider=${(_e = fg.options) === null || _e === void 0 ? void 0 : _e.linkColorProvider} .codeContentProvider=${(_f = fg.options) === null || _f === void 0 ? void 0 : _f.codeContentProvider}></iqr-form-textfield>` :
|
|
24
|
+
fg.type === 'measure-field' ? lit_element_1.html `<iqr-form-measure-field labelPosition=${props.labelPosition} label="${fg.field}"></iqr-form-measure-field>` :
|
|
25
|
+
fg.type === 'number-field' ? lit_element_1.html `<iqr-form-number-field labelPosition=${props.labelPosition} label="${fg.field}"></iqr-form-number-field>` :
|
|
26
|
+
fg.type === 'date-picker' ? lit_element_1.html `<iqr-form-date-picker labelPosition=${props.labelPosition} label="${fg.field}"></iqr-form-date-picker>` :
|
|
27
|
+
fg.type === 'time-picker' ? lit_element_1.html `<iqr-form-time-picker labelPosition=${props.labelPosition} label="${fg.field}"></iqr-form-time-picker>` :
|
|
28
|
+
fg.type === 'date-time-picker' ? lit_element_1.html `<iqr-form-date-time-picker labelPosition=${props.labelPosition} label="${fg.field}"></iqr-form-date-time-picker>` :
|
|
29
|
+
fg.type === 'multiple-choice' ? lit_element_1.html `<iqr-form-multiple-choice labelPosition=${props.labelPosition} label="${fg.field}"></iqr-form-multiple-choice>` : ''}
|
|
30
|
+
</div>`;
|
|
31
|
+
};
|
|
32
|
+
return lit_element_1.html `
|
|
33
|
+
<div class="iqr-form">
|
|
34
|
+
${(_a = form === null || form === void 0 ? void 0 : form.sections) === null || _a === void 0 ? void 0 : _a.map(s => {
|
|
35
|
+
var _a;
|
|
36
|
+
return lit_element_1.html `
|
|
37
|
+
<h2>${s.section}</h2>
|
|
38
|
+
${s.description ? lit_element_1.html `<p>${s.description}</p>` : ''}
|
|
39
|
+
${(_a = s.fields) === null || _a === void 0 ? void 0 : _a.map(f => renderFieldOrGroup(f, 3))}
|
|
40
|
+
`;
|
|
41
|
+
})}
|
|
42
|
+
</div>
|
|
43
|
+
`;
|
|
44
|
+
};
|
|
@@ -0,0 +1,335 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
+
};
|
|
11
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
12
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
13
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
14
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
15
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
16
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
17
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
18
|
+
});
|
|
19
|
+
};
|
|
20
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
21
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
22
|
+
};
|
|
23
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
24
|
+
// Import the LitElement base class and html helper function
|
|
25
|
+
const lit_element_1 = require("lit-element");
|
|
26
|
+
const prosemirror_state_1 = require("prosemirror-state");
|
|
27
|
+
const prosemirror_view_1 = require("prosemirror-view");
|
|
28
|
+
const prosemirror_history_1 = require("prosemirror-history");
|
|
29
|
+
const prosemirror_keymap_1 = require("prosemirror-keymap");
|
|
30
|
+
const prosemirror_commands_1 = require("prosemirror-commands");
|
|
31
|
+
const prosemirror_schema_list_1 = require("prosemirror-schema-list");
|
|
32
|
+
const schema_1 = require("./schema");
|
|
33
|
+
const markdown_it_1 = __importDefault(require("markdown-it"));
|
|
34
|
+
const prosemirror_markdown_1 = require("prosemirror-markdown");
|
|
35
|
+
const prosemirror_commands_2 = require("./prosemirror-commands");
|
|
36
|
+
const selection_companion_1 = require("./selection-companion");
|
|
37
|
+
const suggestion_palette_1 = require("./suggestion-palette");
|
|
38
|
+
const caret_fix_plugin_1 = require("./plugin/caret-fix-plugin");
|
|
39
|
+
const prosemirror_utils_1 = require("./prosemirror-utils");
|
|
40
|
+
// @ts-ignore
|
|
41
|
+
const style_scss_1 = __importDefault(require("./styles/style.scss"));
|
|
42
|
+
// @ts-ignore
|
|
43
|
+
const kendo_scss_1 = __importDefault(require("./styles/kendo.scss"));
|
|
44
|
+
const mask_plugin_1 = require("./plugin/mask-plugin");
|
|
45
|
+
const has_content_class_plugin_1 = require("./plugin/has-content-class-plugin");
|
|
46
|
+
const regexp_plugin_1 = require("./plugin/regexp-plugin");
|
|
47
|
+
// Extend the LitElement base class
|
|
48
|
+
class IqrTextField extends lit_element_1.LitElement {
|
|
49
|
+
constructor() {
|
|
50
|
+
super();
|
|
51
|
+
this.suggestionStopWords = new Set();
|
|
52
|
+
this.linksProvider = () => Promise.resolve(undefined);
|
|
53
|
+
this.suggestionProvider = () => [];
|
|
54
|
+
this.codeColorProvider = () => 'XI';
|
|
55
|
+
this.linkColorProvider = () => 'cat1';
|
|
56
|
+
this.codeContentProvider = (codes) => codes.map(c => c.code).join(',');
|
|
57
|
+
this.schema = 'styled-text-with-codes';
|
|
58
|
+
this.label = '';
|
|
59
|
+
this.labelPosition = 'float';
|
|
60
|
+
this.placeholder = '';
|
|
61
|
+
this.value = '';
|
|
62
|
+
this.displayOwnerMenu = false;
|
|
63
|
+
this.suggestions = false;
|
|
64
|
+
this.links = false;
|
|
65
|
+
this.textRegex = '';
|
|
66
|
+
this.windowListeners = [];
|
|
67
|
+
this.mouseCount = 0;
|
|
68
|
+
}
|
|
69
|
+
connectedCallback() {
|
|
70
|
+
super.connectedCallback();
|
|
71
|
+
const cmu = this.mouseUp.bind(this);
|
|
72
|
+
const cmd = this.mouseDown.bind(this);
|
|
73
|
+
this.windowListeners.push(['mouseup', cmu], ['mousedown', cmd]);
|
|
74
|
+
window.addEventListener('mouseup', cmu);
|
|
75
|
+
window.addEventListener('mousedown', cmd);
|
|
76
|
+
}
|
|
77
|
+
disconnectedCallback() {
|
|
78
|
+
super.disconnectedCallback();
|
|
79
|
+
this.windowListeners.forEach(wl => window.removeEventListener(wl[0], wl[1]));
|
|
80
|
+
}
|
|
81
|
+
static get styles() {
|
|
82
|
+
return [style_scss_1.default, kendo_scss_1.default];
|
|
83
|
+
}
|
|
84
|
+
render() {
|
|
85
|
+
return lit_element_1.html `
|
|
86
|
+
<div id="root" class="iqr-text-field" data-placeholder=${this.placeholder}>
|
|
87
|
+
<label class="iqr-label ${this.labelPosition}"><span>${this.label}</span></label>
|
|
88
|
+
<div class="iqr-input">
|
|
89
|
+
<div id="editor"></div>
|
|
90
|
+
<div id="extra" class=${'extra' + (this.displayOwnerMenu ? ' forced' : '')}>
|
|
91
|
+
<div class="info">
|
|
92
|
+
~${this.owner}
|
|
93
|
+
</div>
|
|
94
|
+
<div class="buttons-container">
|
|
95
|
+
<div class="menu-container">
|
|
96
|
+
<button data-content="${this.owner}" @click="${this.toggleOwnerMenu}" class="btn menu-trigger author">
|
|
97
|
+
<svg width="10" height="10" viewBox="0 0 10 10" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
98
|
+
<path fill-rule="evenodd" clip-rule="evenodd" d="M10 5C10 7.76142 7.76142 10 5 10C2.23858 10 0 7.76142 0 5C0 2.23858 2.23858 0 5 0C7.76142 0 10 2.23858 10 5ZM7 3C7 4.10457 6.10457 5 5 5C3.89543 5 3 4.10457 3 3C3 1.89543 3.89543 1 5 1C6.10457 1 7 1.89543 7 3ZM5.00001 9C6.53071 9 7.8606 8.1402 8.53306 6.8772C7.62844 6.33518 6.37946 6 5.00001 6C3.62055 6 2.37158 6.33517 1.46695 6.87719C2.13941 8.14019 3.4693 9 5.00001 9Z"/>
|
|
99
|
+
</svg>
|
|
100
|
+
</button>
|
|
101
|
+
${this.displayOwnerMenu ? lit_element_1.html `
|
|
102
|
+
<div id="menu" class="menu">
|
|
103
|
+
<div class="input-container">
|
|
104
|
+
<svg width="20" height="20" viewBox="0 0 20 20" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
105
|
+
<path d="M12.9167 11.6667H12.2583L12.025 11.4417C12.8417 10.4917 13.3333 9.25833 13.3333 7.91667C13.3333 4.925 10.9083 2.5 7.91667 2.5C4.925 2.5 2.5 4.925 2.5 7.91667C2.5 10.9083 4.925 13.3333 7.91667 13.3333C9.25833 13.3333 10.4917 12.8417 11.4417 12.025L11.6667 12.2583V12.9167L15.8333 17.075L17.075 15.8333L12.9167 11.6667ZM7.91667 11.6667C5.84167 11.6667 4.16667 9.99167 4.16667 7.91667C4.16667 5.84167 5.84167 4.16667 7.91667 4.16667C9.99167 4.16667 11.6667 5.84167 11.6667 7.91667C11.6667 9.99167 9.99167 11.6667 7.91667 11.6667Z" fill="#809AB4"/>
|
|
106
|
+
</svg>
|
|
107
|
+
<input>
|
|
108
|
+
</div>
|
|
109
|
+
<button class="item">
|
|
110
|
+
Jean René
|
|
111
|
+
</button>
|
|
112
|
+
<button class="item">
|
|
113
|
+
Jean José
|
|
114
|
+
</button>
|
|
115
|
+
<button class="item">
|
|
116
|
+
Marie-Josée Perrec
|
|
117
|
+
</button>
|
|
118
|
+
</div>
|
|
119
|
+
` : ''}
|
|
120
|
+
</div>
|
|
121
|
+
<div class="menu-container">
|
|
122
|
+
<button data-content="01/02/20" class="btn date">
|
|
123
|
+
<svg width="10" height="10" viewBox="0 0 10 10" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
124
|
+
<path fill-rule="evenodd" clip-rule="evenodd" d="M2 0C0.895431 0 0 0.89543 0 2V8C0 9.10457 0.89543 10 2 10H8C9.10457 10 10 9.10457 10 8V2C10 0.895431 9.10457 0 8 0H2ZM1 3V8C1 8.55229 1.44772 9 2 9H8C8.55229 9 9 8.55229 9 8V3H1ZM8 8H5V5H8V8Z"/>
|
|
125
|
+
</svg>
|
|
126
|
+
</button>
|
|
127
|
+
</div>
|
|
128
|
+
<div class="menu-container">
|
|
129
|
+
<button data-content="1.0" class="btn version">
|
|
130
|
+
<svg width="10" height="10" viewBox="0 0 10 10" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
131
|
+
<path fill-rule="evenodd" clip-rule="evenodd" d="M5 10C7.76141 10 10 7.76142 10 5C10 2.23858 7.76141 0 5 0C2.23859 0 0 2.23858 0 5C0 7.76142 2.23859 10 5 10ZM3.5 3.33172C3.03394 3.16698 2.70001 2.72249 2.70001 2.2C2.70001 1.53726 3.23727 1 3.90002 1C4.56274 1 5.10001 1.53726 5.10001 2.2C5.10001 2.72249 4.76608 3.16698 4.30002 3.33172V5.04041C4.73386 4.59767 5.31354 4.29838 5.96133 4.22028C6.12021 3.74364 6.56998 3.4 7.10001 3.4C7.76276 3.4 8.30002 3.93726 8.30002 4.6C8.30002 5.26274 7.76276 5.8 7.10001 5.8C6.58722 5.8 6.14957 5.47836 5.97775 5.02583C5.13132 5.16293 4.46295 5.8313 4.32584 6.67775C4.77838 6.84955 5.10001 7.28722 5.10001 7.8C5.10001 8.46274 4.56274 9 3.90002 9C3.23727 9 2.70001 8.46274 2.70001 7.8C2.70001 7.27751 3.03394 6.83302 3.5 6.66828V3.33172ZM3.5 7.8C3.5 7.58001 3.67758 7.4015 3.89722 7.4H3.9028C4.12241 7.4015 4.29999 7.58001 4.29999 7.8C4.29999 8.0209 4.12091 8.2 3.89999 8.2C3.67908 8.2 3.5 8.0209 3.5 7.8ZM6.70001 4.59555V4.60446C6.70239 4.82333 6.88055 5.00001 7.09998 5.00001C7.32089 5.00001 7.5 4.82092 7.5 4.60001C7.5 4.37909 7.32089 4.2 7.09998 4.2C6.88055 4.2 6.70239 4.37669 6.70001 4.59555ZM3.89999 2.6C4.12091 2.6 4.29999 2.42091 4.29999 2.2C4.29999 1.97909 4.12091 1.8 3.89999 1.8C3.67908 1.8 3.5 1.97909 3.5 2.2C3.5 2.42091 3.67908 2.6 3.89999 2.6Z"/>
|
|
132
|
+
</svg>
|
|
133
|
+
</button>
|
|
134
|
+
</div>
|
|
135
|
+
<div class="menu-container">
|
|
136
|
+
<button data-content="fr" class="btn language">
|
|
137
|
+
<svg width="10" height="10" viewBox="0 0 10 10" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
138
|
+
<path d="M5 0C2.2379 0 0 2.2379 0 5C0 7.7621 2.2379 10 5 10C7.7621 10 10 7.7621 10 5C10 2.2379 7.7621 0 5 0ZM9.03226 5C9.03226 5.45363 8.95363 5.89113 8.81452 6.29839H8.40524C8.31855 6.29839 8.23589 6.26411 8.1754 6.20161L7.53024 5.54435C7.43952 5.45161 7.43952 5.3004 7.53226 5.20766L7.78427 4.95565V4.78024C7.78427 4.71976 7.76008 4.66129 7.71774 4.61895L7.52823 4.42944C7.48589 4.3871 7.42742 4.3629 7.36694 4.3629H7.04435C6.91935 4.3629 6.81653 4.26008 6.81653 4.13508C6.81653 4.0746 6.84073 4.01613 6.88306 3.97379L7.07258 3.78427C7.11492 3.74194 7.17339 3.71774 7.23387 3.71774H7.87903C8.00403 3.71774 8.10685 3.61492 8.10685 3.48992V3.3004C8.10685 3.1754 8.00403 3.07258 7.87903 3.07258H7.13911C6.96169 3.07258 6.81653 3.21774 6.81653 3.39516V3.48589C6.81653 3.625 6.72782 3.74798 6.59677 3.79234L5.95968 4.00403C5.89315 4.02621 5.84879 4.08669 5.84879 4.15726V4.20161C5.84879 4.29032 5.77621 4.3629 5.6875 4.3629H5.36492C5.27621 4.3629 5.20363 4.29032 5.20363 4.20161C5.20363 4.1129 5.13105 4.04032 5.04234 4.04032H4.97984C4.91935 4.04032 4.8629 4.0746 4.83468 4.12903L4.64516 4.50605C4.59073 4.61492 4.47984 4.68347 4.35685 4.68347H3.91129C3.73387 4.68347 3.58871 4.53831 3.58871 4.36089V3.85081C3.58871 3.76613 3.62298 3.68347 3.68347 3.62298L4.08871 3.21774C4.18145 3.125 4.23387 2.99798 4.23387 2.86492C4.23387 2.79637 4.27823 2.73387 4.34476 2.71169L5.15121 2.44355C5.18548 2.43145 5.21573 2.41331 5.23992 2.38911L5.78024 1.84879C5.82258 1.80645 5.84677 1.74798 5.84677 1.6875C5.84677 1.5625 5.74395 1.45968 5.61895 1.45968H5.20161L4.87903 1.78226V1.94355C4.87903 2.03226 4.80645 2.10484 4.71774 2.10484H4.39516C4.30645 2.10484 4.23387 2.03226 4.23387 1.94355V1.54032C4.23387 1.48992 4.25806 1.44153 4.29839 1.41129L4.88105 0.97379C4.91935 0.971774 4.95766 0.967742 4.99597 0.967742C7.22379 0.967742 9.03226 2.77621 9.03226 5ZM2.62298 2.84476C2.62298 2.78427 2.64718 2.72581 2.68952 2.68347L3.20161 2.17137C3.24395 2.12903 3.30242 2.10484 3.3629 2.10484C3.4879 2.10484 3.59073 2.20766 3.59073 2.33266V2.65524C3.59073 2.71573 3.56653 2.77419 3.52419 2.81653L3.33468 3.00605C3.29234 3.04839 3.23387 3.07258 3.17339 3.07258H2.85081C2.72581 3.07258 2.62298 2.96976 2.62298 2.84476ZM5.20363 9.02218V8.87903C5.20363 8.70161 5.05847 8.55645 4.88105 8.55645H4.47379C4.25605 8.55645 3.93548 8.4496 3.76008 8.31855L3.3125 7.98185C3.08065 7.80847 2.94556 7.53629 2.94556 7.24798V6.76613C2.94556 6.44355 3.11492 6.14516 3.39113 5.97984L4.25605 5.46169C4.39919 5.37702 4.5625 5.33065 4.72782 5.33065H5.35685C5.57661 5.33065 5.78831 5.40927 5.95363 5.5504L6.8246 6.29839H7.19355C7.36492 6.29839 7.52823 6.36694 7.64919 6.4879L7.99798 6.83669C8.06653 6.90524 8.16129 6.94355 8.25806 6.94355H8.52823C7.875 8.13105 6.6371 8.9496 5.20363 9.02218Z"/>
|
|
139
|
+
</svg>
|
|
140
|
+
</button>
|
|
141
|
+
</div>
|
|
142
|
+
</div>
|
|
143
|
+
</div>
|
|
144
|
+
</div>
|
|
145
|
+
</div>
|
|
146
|
+
`;
|
|
147
|
+
}
|
|
148
|
+
toggleOwnerMenu() {
|
|
149
|
+
this.displayOwnerMenu = !this.displayOwnerMenu;
|
|
150
|
+
}
|
|
151
|
+
mouseDown() {
|
|
152
|
+
this.mouseCount++;
|
|
153
|
+
console.log(this.mouseCount);
|
|
154
|
+
}
|
|
155
|
+
mouseUp() {
|
|
156
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
157
|
+
this.mouseCount = 0;
|
|
158
|
+
if (!((_c = (_b = (_a = this.view) === null || _a === void 0 ? void 0 : _a.dom) === null || _b === void 0 ? void 0 : _b.classList) === null || _c === void 0 ? void 0 : _c.contains('ProseMirror-focused'))) {
|
|
159
|
+
(_g = (_f = (_e = (_d = this.view) === null || _d === void 0 ? void 0 : _d.dom) === null || _e === void 0 ? void 0 : _e.parentElement) === null || _f === void 0 ? void 0 : _f.querySelectorAll('.companion')) === null || _g === void 0 ? void 0 : _g.forEach(x => {
|
|
160
|
+
x.style.display = 'none';
|
|
161
|
+
});
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
firstUpdated() {
|
|
165
|
+
var _a;
|
|
166
|
+
const schema = this.proseMirrorSchema = schema_1.createSchema(this.schema, (t, c, isC) => isC ? this.codeColorProvider(t, c) : this.linkColorProvider(t, c), this.codeContentProvider);
|
|
167
|
+
const tokenizer = markdown_it_1.default("commonmark", { html: false });
|
|
168
|
+
this.parser = this.schema === 'date' ? {
|
|
169
|
+
parse: (value) => schema.node("paragraph", {}, [
|
|
170
|
+
schema.node("date", {}, value ? [schema.text(value)] : []),
|
|
171
|
+
])
|
|
172
|
+
} : this.schema === 'date-time' ? {
|
|
173
|
+
parse: (value) => {
|
|
174
|
+
const date = value ? value.split(' ')[0] : '';
|
|
175
|
+
const time = value ? value.split(' ')[1] : '';
|
|
176
|
+
return schema.node("paragraph", {}, [
|
|
177
|
+
schema.node("date", {}, date && date.length ? [schema.text(date)] : [schema.text(' ')]),
|
|
178
|
+
schema.node("time", {}, time && time.length ? [schema.text(time)] : [schema.text(' ')]),
|
|
179
|
+
]);
|
|
180
|
+
}
|
|
181
|
+
} : this.schema === 'text-document' ? new prosemirror_markdown_1.MarkdownParser(schema, markdown_it_1.default("commonmark", { html: false }), {
|
|
182
|
+
blockquote: { block: "blockquote" },
|
|
183
|
+
paragraph: { block: "paragraph" },
|
|
184
|
+
list_item: { block: "list_item" },
|
|
185
|
+
bullet_list: { block: "bullet_list" },
|
|
186
|
+
ordered_list: { block: "ordered_list", getAttrs: tok => ({ order: +(tok.attrGet("start") || 1) }) },
|
|
187
|
+
heading: { block: "heading", getAttrs: tok => ({ level: +tok.tag.slice(1) }) },
|
|
188
|
+
hr: { node: "horizontal_rule" },
|
|
189
|
+
image: { node: "image", getAttrs: tok => {
|
|
190
|
+
var _a;
|
|
191
|
+
return ({
|
|
192
|
+
src: tok.attrGet("src"),
|
|
193
|
+
title: tok.attrGet("title") || null,
|
|
194
|
+
alt: ((_a = (tok.children || [])[0]) === null || _a === void 0 ? void 0 : _a.content) || null
|
|
195
|
+
});
|
|
196
|
+
} },
|
|
197
|
+
hardbreak: { node: "hard_break" },
|
|
198
|
+
em: prosemirror_utils_1.hasMark(schema.spec.marks, 'em') ? { mark: "em" } : { ignore: true },
|
|
199
|
+
strong: prosemirror_utils_1.hasMark(schema.spec.marks, 'strong') ? { mark: "strong" } : { ignore: true },
|
|
200
|
+
link: prosemirror_utils_1.hasMark(schema.spec.marks, 'link') ? { mark: "link", getAttrs: tok => ({
|
|
201
|
+
href: tok.attrGet("href"),
|
|
202
|
+
title: tok.attrGet("title") || null
|
|
203
|
+
}) } : { ignore: true }
|
|
204
|
+
}) : new prosemirror_markdown_1.MarkdownParser(schema, { parse: (src, env) => {
|
|
205
|
+
return tokenizer.parse(src, env).filter(t => !t.type.startsWith('paragraph_'));
|
|
206
|
+
} }, {
|
|
207
|
+
em: prosemirror_utils_1.hasMark(schema.spec.marks, 'em') ? { mark: "em" } : { ignore: true },
|
|
208
|
+
strong: prosemirror_utils_1.hasMark(schema.spec.marks, 'strong') ? { mark: "strong" } : { ignore: true },
|
|
209
|
+
link: prosemirror_utils_1.hasMark(schema.spec.marks, 'link') ? { mark: "link", getAttrs: tok => ({
|
|
210
|
+
href: tok.attrGet("href"),
|
|
211
|
+
title: tok.attrGet("title") || null
|
|
212
|
+
}) } : { ignore: true }
|
|
213
|
+
});
|
|
214
|
+
const cmp = this;
|
|
215
|
+
this.container = ((_a = this.shadowRoot) === null || _a === void 0 ? void 0 : _a.getElementById('editor')) || undefined;
|
|
216
|
+
let br = schema.nodes.hard_break;
|
|
217
|
+
const hardBreak = prosemirror_commands_1.chainCommands(prosemirror_commands_1.exitCode, (state, dispatch) => {
|
|
218
|
+
dispatch && dispatch(state.tr.replaceSelectionWith(br.create()).scrollIntoView());
|
|
219
|
+
return true;
|
|
220
|
+
});
|
|
221
|
+
const replaceRangeWithSuggestion = (from, to, sug) => __awaiter(this, void 0, void 0, function* () {
|
|
222
|
+
const link = yield this.linksProvider(sug);
|
|
223
|
+
return link && cmp.view.state.tr.replaceWith(from, to, this.proseMirrorSchema.text(sug.text, [this.proseMirrorSchema.mark('link', link)])) || undefined;
|
|
224
|
+
});
|
|
225
|
+
if (this.container) {
|
|
226
|
+
let headingsKeymap = prosemirror_keymap_1.keymap([1, 2, 3, 4, 5, 6].reduce((acc, idx) => {
|
|
227
|
+
return Object.assign(acc, { [`Mod-ctrl-${idx}`]: prosemirror_commands_1.setBlockType(this.proseMirrorSchema.nodes.heading, { level: '' + idx }) });
|
|
228
|
+
}, {}));
|
|
229
|
+
const parsedDoc = this.parser.parse(this.value);
|
|
230
|
+
this.view = new prosemirror_view_1.EditorView(this.container, {
|
|
231
|
+
state: prosemirror_state_1.EditorState.create({
|
|
232
|
+
doc: parsedDoc,
|
|
233
|
+
schema: this.proseMirrorSchema,
|
|
234
|
+
plugins: [
|
|
235
|
+
caret_fix_plugin_1.caretFixPlugin(),
|
|
236
|
+
prosemirror_history_1.history(),
|
|
237
|
+
this.links ?
|
|
238
|
+
new prosemirror_state_1.Plugin({
|
|
239
|
+
view(editorView) { return new selection_companion_1.SelectionCompanion(editorView, () => cmp.mouseCount > 0); }
|
|
240
|
+
}) : null,
|
|
241
|
+
this.suggestions ?
|
|
242
|
+
new prosemirror_state_1.Plugin({
|
|
243
|
+
view(editorView) { return (cmp.suggestionPalette = new suggestion_palette_1.SuggestionPalette(editorView, (terms) => cmp.suggestionProvider(terms), () => cmp.suggestionStopWords)); }
|
|
244
|
+
}) : null,
|
|
245
|
+
this.suggestions ?
|
|
246
|
+
prosemirror_keymap_1.keymap({
|
|
247
|
+
"Tab": (state, dispatch) => { return cmp.suggestionPalette && cmp.suggestionPalette.focusOrInsert(this.view, replaceRangeWithSuggestion) || false; },
|
|
248
|
+
"ArrowUp": (state, dispatch) => { return cmp.suggestionPalette && cmp.suggestionPalette.arrowUp() || false; },
|
|
249
|
+
"ArrowDown": (state, dispatch) => { return cmp.suggestionPalette && cmp.suggestionPalette.arrowDown() || false; },
|
|
250
|
+
"Enter": (state, dispatch) => { return cmp.suggestionPalette && cmp.suggestionPalette.insert(this.view, replaceRangeWithSuggestion) || false; },
|
|
251
|
+
}) : null,
|
|
252
|
+
prosemirror_keymap_1.keymap({ "Mod-z": prosemirror_history_1.undo, "Mod-Shift-z": prosemirror_history_1.redo }),
|
|
253
|
+
prosemirror_keymap_1.keymap(Object.assign({}, schema.marks.strong ? { "Mod-b": prosemirror_commands_1.toggleMark(schema.marks.strong) } : {}, schema.marks.em ? { "Mod-i": prosemirror_commands_1.toggleMark(schema.marks.em) } : {}, schema.nodes.paragraph ? { "Alt-ArrowUp": prosemirror_commands_1.joinUp } : {}, schema.nodes.paragraph ? { "Alt-ArrowDown": prosemirror_commands_1.joinDown } : {}, schema.nodes.paragraph ? { "Alt-Enter": hardBreak } : {}, schema.nodes.paragraph ? { "Shift-Enter": hardBreak } : {}, schema.nodes.ordered_list ? { "Shift-ctrl-1": prosemirror_schema_list_1.wrapInList(schema.nodes.ordered_list) } : {}, schema.nodes.bullet_list ? { "Shift-ctrl-*": prosemirror_schema_list_1.wrapInList(schema.nodes.bullet_list) } : {}, schema.nodes.blockquote ? { "Shift-ctrl-w": prosemirror_commands_2.wrapInIfNeeded(schema.nodes.blockquote) } : {}, schema.nodes.blockquote ? { "Shift-ctrl-u": prosemirror_commands_2.unwrapFrom(schema.nodes.blockquote) } : {}, schema.nodes.paragraph ? { "Mod-ctrl-0": prosemirror_commands_1.setBlockType(schema.nodes.paragraph) } : {}, schema.nodes.paragraph ? { "Shift-ctrl-0": prosemirror_commands_1.setBlockType(schema.nodes.paragraph) } : {}, schema.nodes.list_item ? { "Enter": prosemirror_schema_list_1.splitListItem(schema.nodes.list_item) } : {}, schema.nodes.ordered_list || schema.nodes.bullet_list ? { "Mod-(": prosemirror_schema_list_1.liftListItem(schema.nodes.list_item) } : {}, schema.nodes.ordered_list || schema.nodes.bullet_list ? { "Mod-[": prosemirror_schema_list_1.liftListItem(schema.nodes.list_item) } : {}, schema.nodes.ordered_list || schema.nodes.bullet_list ? { "Mod-)": prosemirror_schema_list_1.sinkListItem(schema.nodes.list_item) } : {}, schema.nodes.ordered_list || schema.nodes.bullet_list ? { "Mod-]": prosemirror_schema_list_1.sinkListItem(schema.nodes.list_item) } : {})),
|
|
254
|
+
schema.nodes.heading ? headingsKeymap : null,
|
|
255
|
+
mask_plugin_1.maskPlugin(),
|
|
256
|
+
regexp_plugin_1.regexpPlugin(),
|
|
257
|
+
has_content_class_plugin_1.hasContentClassPlugin(this.shadowRoot),
|
|
258
|
+
prosemirror_keymap_1.keymap(prosemirror_commands_1.baseKeymap)
|
|
259
|
+
].filter(x => !!x).map(x => x)
|
|
260
|
+
}),
|
|
261
|
+
dispatchTransaction: (tr) => {
|
|
262
|
+
this.view && this.view.updateState(this.view.state.apply(tr));
|
|
263
|
+
//current state as json in text area
|
|
264
|
+
//this.view && console.log(JSON.stringify(this.view.state.doc.toJSON(), null, 2));
|
|
265
|
+
}
|
|
266
|
+
});
|
|
267
|
+
}
|
|
268
|
+
}
|
|
269
|
+
}
|
|
270
|
+
__decorate([
|
|
271
|
+
lit_element_1.property(),
|
|
272
|
+
__metadata("design:type", Set)
|
|
273
|
+
], IqrTextField.prototype, "suggestionStopWords", void 0);
|
|
274
|
+
__decorate([
|
|
275
|
+
lit_element_1.property(),
|
|
276
|
+
__metadata("design:type", Function)
|
|
277
|
+
], IqrTextField.prototype, "linksProvider", void 0);
|
|
278
|
+
__decorate([
|
|
279
|
+
lit_element_1.property(),
|
|
280
|
+
__metadata("design:type", Function)
|
|
281
|
+
], IqrTextField.prototype, "suggestionProvider", void 0);
|
|
282
|
+
__decorate([
|
|
283
|
+
lit_element_1.property(),
|
|
284
|
+
__metadata("design:type", Function)
|
|
285
|
+
], IqrTextField.prototype, "codeColorProvider", void 0);
|
|
286
|
+
__decorate([
|
|
287
|
+
lit_element_1.property(),
|
|
288
|
+
__metadata("design:type", Function)
|
|
289
|
+
], IqrTextField.prototype, "linkColorProvider", void 0);
|
|
290
|
+
__decorate([
|
|
291
|
+
lit_element_1.property(),
|
|
292
|
+
__metadata("design:type", Function)
|
|
293
|
+
], IqrTextField.prototype, "codeContentProvider", void 0);
|
|
294
|
+
__decorate([
|
|
295
|
+
lit_element_1.property(),
|
|
296
|
+
__metadata("design:type", String)
|
|
297
|
+
], IqrTextField.prototype, "schema", void 0);
|
|
298
|
+
__decorate([
|
|
299
|
+
lit_element_1.property(),
|
|
300
|
+
__metadata("design:type", String)
|
|
301
|
+
], IqrTextField.prototype, "label", void 0);
|
|
302
|
+
__decorate([
|
|
303
|
+
lit_element_1.property(),
|
|
304
|
+
__metadata("design:type", String)
|
|
305
|
+
], IqrTextField.prototype, "labelPosition", void 0);
|
|
306
|
+
__decorate([
|
|
307
|
+
lit_element_1.property(),
|
|
308
|
+
__metadata("design:type", String)
|
|
309
|
+
], IqrTextField.prototype, "placeholder", void 0);
|
|
310
|
+
__decorate([
|
|
311
|
+
lit_element_1.property(),
|
|
312
|
+
__metadata("design:type", String)
|
|
313
|
+
], IqrTextField.prototype, "value", void 0);
|
|
314
|
+
__decorate([
|
|
315
|
+
lit_element_1.property(),
|
|
316
|
+
__metadata("design:type", String)
|
|
317
|
+
], IqrTextField.prototype, "owner", void 0);
|
|
318
|
+
__decorate([
|
|
319
|
+
lit_element_1.property(),
|
|
320
|
+
__metadata("design:type", Boolean)
|
|
321
|
+
], IqrTextField.prototype, "displayOwnerMenu", void 0);
|
|
322
|
+
__decorate([
|
|
323
|
+
lit_element_1.property(),
|
|
324
|
+
__metadata("design:type", Boolean)
|
|
325
|
+
], IqrTextField.prototype, "suggestions", void 0);
|
|
326
|
+
__decorate([
|
|
327
|
+
lit_element_1.property(),
|
|
328
|
+
__metadata("design:type", Boolean)
|
|
329
|
+
], IqrTextField.prototype, "links", void 0);
|
|
330
|
+
__decorate([
|
|
331
|
+
lit_element_1.property(),
|
|
332
|
+
__metadata("design:type", String)
|
|
333
|
+
], IqrTextField.prototype, "textRegex", void 0);
|
|
334
|
+
// Register the new element with the browser.
|
|
335
|
+
customElements.define('iqr-text-field', IqrTextField);
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.caretFixPlugin = void 0;
|
|
4
|
+
const prosemirror_state_1 = require("prosemirror-state");
|
|
5
|
+
exports.caretFixPlugin = () => {
|
|
6
|
+
let focusing = false;
|
|
7
|
+
return new prosemirror_state_1.Plugin({
|
|
8
|
+
props: {
|
|
9
|
+
handleDOMEvents: {
|
|
10
|
+
focus: view => {
|
|
11
|
+
if (focusing) {
|
|
12
|
+
focusing = false;
|
|
13
|
+
}
|
|
14
|
+
else {
|
|
15
|
+
focusing = true;
|
|
16
|
+
setTimeout(() => { view.dom.blur(); view.dom.focus(); }, 0);
|
|
17
|
+
}
|
|
18
|
+
return false;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
});
|
|
23
|
+
};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.hasContentClassPlugin = void 0;
|
|
4
|
+
const prosemirror_state_1 = require("prosemirror-state");
|
|
5
|
+
exports.hasContentClassPlugin = (root) => {
|
|
6
|
+
return new prosemirror_state_1.Plugin({
|
|
7
|
+
view: (v) => {
|
|
8
|
+
var _a, _b;
|
|
9
|
+
v.state.doc.textContent && v.state.doc.textContent.length && ((_b = (_a = root === null || root === void 0 ? void 0 : root.getElementById('root')) === null || _a === void 0 ? void 0 : _a.classList) === null || _b === void 0 ? void 0 : _b.add('has-content'));
|
|
10
|
+
return {
|
|
11
|
+
update: (v, s) => {
|
|
12
|
+
var _a, _b, _c, _d;
|
|
13
|
+
v.state.doc.textContent && v.state.doc.textContent.length ? (_b = (_a = root === null || root === void 0 ? void 0 : root.getElementById('root')) === null || _a === void 0 ? void 0 : _a.classList) === null || _b === void 0 ? void 0 : _b.add('has-content') : (_d = (_c = root.getElementById('root')) === null || _c === void 0 ? void 0 : _c.classList) === null || _d === void 0 ? void 0 : _d.remove('has-content');
|
|
14
|
+
}
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
});
|
|
18
|
+
};
|