@podlite/editor-react 0.0.18 → 0.0.20

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/scripts/build.ts DELETED
@@ -1,17 +0,0 @@
1
- import { build } from 'esbuild';
2
- import { pnpPlugin } from '@yarnpkg/esbuild-plugin-pnp';
3
-
4
- build({
5
- plugins: [pnpPlugin()],
6
- bundle: true,
7
- entryPoints: ['src/index.tsx'],
8
- external: ['react', 'react-dom', 'codemirror', 'react-codemirror2'],
9
- minify: true,
10
- format: 'cjs',
11
- target: 'node12.0',
12
- sourcemap: true,
13
- outfile: 'lib/index.js',
14
- }).catch((e) => {
15
- console.log('Build not successful', e.message);
16
- process.exit(1);
17
- });
@@ -1,17 +0,0 @@
1
- import { build } from 'esbuild';
2
- import { pnpPlugin } from '@yarnpkg/esbuild-plugin-pnp';
3
-
4
- build({
5
- plugins: [pnpPlugin()],
6
- bundle: true,
7
- entryPoints: ['src/index.tsx'],
8
- external: ['react', 'react-dom', 'codemirror', 'react-codemirror2'],
9
- minify: true,
10
- format: 'esm',
11
- target: 'node12.0',
12
- sourcemap: true,
13
- outfile: 'esm/index.js',
14
- }).catch((e) => {
15
- console.log('Build not successful', e.message);
16
- process.exit(1);
17
- });
package/src/Editor.css DELETED
@@ -1,356 +0,0 @@
1
- .EditorApp {
2
- font-family: Menlo, Monaco, Consolas, "Courier New", monospace;
3
- -webkit-font-smoothing: antialiased;
4
- -moz-osx-font-smoothing: grayscale;
5
- }
6
-
7
- .App-logo {
8
- height: 40vmin;
9
- pointer-events: none;
10
- }
11
-
12
- @media (prefers-reduced-motion: no-preference) {
13
- .App-logo {
14
- animation: App-logo-spin infinite 20s linear;
15
- }
16
- }
17
-
18
- .App-header {
19
- background-color: #282c34;
20
- min-height: 100vh;
21
- display: flex;
22
- flex-direction: column;
23
- align-items: center;
24
- justify-content: center;
25
- font-size: calc(10px + 2vmin);
26
- color: white;
27
- }
28
-
29
- .App-link {
30
- color: #61dafb;
31
- }
32
- .layout {
33
- position: absolute;
34
- width: 100%;
35
- /* height: 100%; */
36
- }
37
- .Editor {
38
- text-align: left;
39
- white-space: pre-wrap;
40
- word-break: break-word;
41
- word-wrap: break-word;
42
- }
43
-
44
- [contenteditable]:focus {
45
- outline: 0px solid transparent;
46
- }
47
- .layout__panel {
48
- position: relative;
49
- width: 100%;
50
- height: 100%;
51
- flex: none;
52
- overflow: hidden;
53
- }
54
-
55
- .flex--row {
56
- flex-direction: row;
57
- }
58
- .flex {
59
- display: flex;
60
- }
61
-
62
- .CodeMirror {
63
- height: auto;
64
- font-family: inherit;
65
- }
66
-
67
- pre {
68
- overflow-x: auto;
69
- white-space: pre-wrap;
70
- white-space: -moz-pre-wrap;
71
- white-space: -pre-wrap;
72
- white-space: -o-pre-wrap;
73
- word-wrap: break-word;
74
- }
75
- .title {
76
- margin:0em;
77
- }
78
- .Editorleft {
79
- border-right: 1px dotted lightgrey;
80
- white-space: pre-wrap;
81
- word-break: break-word;
82
- word-wrap: break-word;
83
- width: 50%;
84
- font-size: 15px;
85
- text-align: left;
86
- }
87
-
88
- /* .Editorright {
89
- text-align: left;
90
- word-break: break-word;
91
- word-wrap: break-word;
92
- margin : 0 1em;
93
- font-size: 15px;
94
- } */
95
-
96
- /* Start pod6 */
97
- body {
98
- margin: 0;
99
- font-family: Menlo, Monaco, Consolas, "Courier New", monospace;
100
- -webkit-font-smoothing: antialiased;
101
- -moz-osx-font-smoothing: grayscale;
102
- }
103
-
104
- code {
105
- font-family: source-code-pro, Menlo, Monaco, Consolas, 'Courier New',
106
- monospace;
107
- }
108
-
109
-
110
- pre {
111
- padding: 9.5px;
112
- display: block;
113
- word-break: break-all;
114
- word-wrap: break-word;
115
- background-color: #f8f8f8;
116
- border-radius: 4px;
117
- }
118
-
119
- code {
120
- padding: 0;
121
- font-size: inherit;
122
- color: inherit;
123
- white-space: pre-wrap;
124
- background-color: transparent;
125
- border-radius: 0;
126
- }
127
-
128
- img {
129
- max-width: 1024px;
130
- }
131
-
132
- table {
133
- word-break: normal;
134
- min-width: 70%;
135
- max-width: 100%;
136
- margin: 1em auto;
137
- border-spacing: 0;
138
- border-collapse: collapse;
139
- text-align: center;
140
- margin-top: 2em;
141
- }
142
- table caption {
143
- margin-bottom: 0.8em;
144
- }
145
-
146
- table tbody tr:hover {
147
- background-color: #eee;
148
- -webkit-transition: .5s;
149
- transition: .5s
150
- }
151
-
152
- tr th {
153
- vertical-align: bottom;
154
- border-bottom: 2px solid #eee;
155
- }
156
-
157
- td {
158
- padding: 8px;
159
- border: 1px solid #eee;
160
- }
161
-
162
- .footnote a {
163
- text-decoration: none;
164
- }
165
- .footnotes {
166
- border-top-style: solid;
167
- border-top-width: 1px;
168
- border-top-color: #eee;
169
- }
170
-
171
- img {
172
- display: block;
173
- margin: 0 auto;
174
- max-width: 100%;
175
- }
176
-
177
- .shadow {
178
- -webkit-box-shadow: 3px 3px 5px 6px #ccc; /* Safari 3-4, iOS 4.0.2 - 4.2, Android 2.3+ */
179
- -moz-box-shadow: 3px 3px 5px 6px #ccc; /* Firefox 3.5 - 3.6 */
180
- box-shadow: 3px 3px 5px 6px #ccc; /* Opera 10.5, IE 9, Firefox 4+, Chrome 6+, iOS 5 */
181
- }
182
- .box {
183
- box-shadow:
184
- 0 2.8px 2.2px rgba(0, 0, 0, 0.034),
185
- 0 6.7px 5.3px rgba(0, 0, 0, 0.048),
186
- 0 12.5px 10px rgba(0, 0, 0, 0.06),
187
- 0 22.3px 17.9px rgba(0, 0, 0, 0.072),
188
- 0 41.8px 33.4px rgba(0, 0, 0, 0.086),
189
- 0 100px 80px rgba(0, 0, 0, 0.12)
190
- ;
191
- margin: 100px auto;
192
- background: white;
193
- border-radius: 5px;
194
- }
195
-
196
- .image_block video {
197
- max-width: 100%;
198
- /* margin: 0 auto; */
199
- margin-bottom: 1em;
200
- }
201
-
202
- .image_block video{
203
- width: 100%;
204
- outline: none;
205
- border: none;
206
- }
207
-
208
- /* plugins */
209
- .mermaid svg {
210
- display: block;
211
- margin: auto;
212
- }
213
-
214
- .toc {
215
- padding: 1rem;
216
- }
217
-
218
- .toc-list {
219
- list-style: none;
220
- font-size: .8rem;
221
- }
222
-
223
- .caption {
224
- text-align: center;
225
- font-size: 0.9rem;
226
- }
227
- /* End of pod6 */
228
-
229
-
230
- .CodeMirror {
231
- height: auto;
232
- font-family: inherit;
233
- }
234
-
235
- .title {
236
- margin:0em;
237
- }
238
-
239
-
240
- .Editorleft {
241
- border-right: 1px dotted lightgrey;
242
- white-space: pre-wrap;
243
- word-break: break-word;
244
- word-wrap: break-word;
245
- width: 50%;
246
- font-size: 15px;
247
- text-align: left;
248
- float: left;
249
- height: 100%;
250
- padding-left: 10px;
251
- visibility:visible;
252
- opacity: 1;
253
- transition: all 0.2s ease-out;
254
- }
255
-
256
- .editorApp,.CodeMirror {
257
- height: 100%;
258
- }
259
-
260
- .Editorright {
261
- text-align: left;
262
- word-break: break-word;
263
- word-wrap: break-word;
264
- margin-right : 0;
265
- height: 100%;
266
- font-size: 15px;
267
- padding-left: 10px;
268
- overflow-y: scroll;
269
- overflow-x: hidden;
270
- background-color: white;
271
- }
272
-
273
- .Editorright .error {
274
- opacity: 0.5;
275
- }
276
- /* restore after reset*/
277
- .Editorright * {
278
- /* all: revert */
279
- }
280
-
281
-
282
- .Editorright img {
283
- display: block;
284
- margin: 0 auto;
285
- max-width: 100%;
286
- }
287
-
288
- .content {
289
- height: 100%;
290
- }
291
-
292
- .layoutPreview .Editorright {
293
- position: absolute;
294
- width: 48%;
295
- /* z-index: -999999; */
296
- float: right;
297
- top: 0;
298
- right: 0;
299
- width: 100%;
300
- background-color: white;
301
- }
302
- .layoutPreview .Editorleft {
303
- visibility: hidden;
304
- opacity: 0;
305
- }
306
-
307
- .layoutPreview .content {
308
- width: 50%;
309
- margin: 0 auto;
310
- height: 100%;
311
- overflow-y: initial;
312
- }
313
- @keyframes App-logo-spin {
314
- from {
315
- transform: rotate(0deg);
316
- }
317
- to {
318
- transform: rotate(360deg);
319
- }
320
- }
321
-
322
- /* scrollbars */
323
-
324
- .CodeMirror-vscrollbar {
325
- user-select: none;
326
- outline: none !important;
327
- }
328
-
329
- ::-webkit-scrollbar-thumb {
330
- background-color: rgba(0, 0, 0, 0.1);
331
- }
332
- ::-webkit-scrollbar {
333
- background-color: (0, 0, 0, 0.05);
334
- }
335
- ::-webkit-scrollbar-thumb:active {
336
- background-color: rgba(0, 0, 0, 0.1);
337
- }
338
- ::-webkit-scrollbar {
339
- width: 10px;
340
- height: 10px;
341
- -webkit-border-radius: 100px;
342
- }
343
- ::-webkit-scrollbar-thumb {
344
- -webkit-border-radius: 100px;
345
- }
346
- ::-webkit-scrollbar-thumb:active {
347
- -webkit-border-radius: 100px;
348
- }
349
- ::-webkit-scrollbar-corner {
350
- background: transparent;
351
- }
352
-
353
- .CodeMirror-hints {
354
- z-index: 1000;
355
- border: none;
356
- }
package/src/dict.ts DELETED
@@ -1,248 +0,0 @@
1
- // this file contains the dictionary ot the messages used in the podlite editor
2
- interface Dict {
3
- displayText: string;
4
- text: string;
5
- lang?: 'pod6' | 'md';
6
- }
7
- const dict: Dict[] = [
8
- {
9
- displayText: 'head1',
10
- text: `=head1 `,
11
- },
12
- {
13
- displayText: 'head2',
14
- text: `=head2 `,
15
- },
16
-
17
- {
18
- displayText: 'head3',
19
- text: `=head3 `,
20
- },
21
- {
22
- displayText: 'item1 *',
23
- text: `=item1 `,
24
- },
25
- {
26
- displayText: 'item1 1.)',
27
- text: `=item1 # `,
28
- },
29
- {
30
- displayText: 'item (1., 2.) 🏷',
31
- text: `=item1 # item
32
- =item2 # item level 2
33
- =item2 # item level 2
34
- =item1 # item
35
- =item2 # item
36
- =item2 # item level 2
37
- `,
38
- },
39
- {
40
- displayText: 'item (*, *) 🏷',
41
- text: `=item1 item
42
- =item2 item level 2
43
- =item2 item level 2
44
- =item1 item
45
- =item2 item
46
- =item3 item level 2
47
- `,
48
- },
49
- {
50
- displayText: 'Image 🏷',
51
- text: `=Image https://github.com/zag/podlite-desktop/blob/master/dist-assets/linux-icon/256x256.png?raw=true
52
- `,
53
- },
54
- {
55
- displayText: 'table simple 🏷',
56
- text: `=for table
57
- mouse | mice
58
- horse | horses
59
- elephant | elephants
60
- `,
61
- },
62
- {
63
- displayText: 'table 2x 🏷',
64
- text: `=begin table :caption('Caption of table')
65
- Constants 1
66
- Variables 10
67
- Subroutines 33
68
- Everything else 57
69
- =end table
70
- `,
71
- },
72
- {
73
- displayText: 'table 3x 🏷',
74
- text: `=for table :caption('Caption of table')
75
- Animal | Legs | Eats
76
- =======================
77
- Zebra + 4 + Cookies
78
- Human + 2 + Pizza
79
- Shark + 0 + Fish
80
- `,
81
- },
82
- {
83
- displayText: 'Diagram simple 🏷',
84
- text: `=begin Diagram :caption('Caption of diagram')
85
- graph LR
86
- A-->B
87
- B-->C
88
- C-->A
89
- D-->C
90
- =end Diagram
91
- `,
92
- },
93
- {
94
- displayText: 'Diagram Sequence 🏷',
95
- text: `=for Diagram :caption('Caption of diagram')
96
- sequenceDiagram
97
- autonumber
98
- Student->>Admin: Can I enrol this semester?
99
- loop enrolmentCheck
100
- Admin->>Admin: Check previous results
101
- end
102
- Note right of Admin: Exam results may <br> be delayed
103
- Admin-->>Student: Enrolment success
104
- Admin->>Professor: Assign student to tutor
105
- Professor-->>Admin: Student is assigned
106
-
107
- `,
108
- },
109
- {
110
- displayText: 'Diagram flowchart 🏷',
111
- text: `=for Diagram :caption('Caption of diagram')
112
- graph LR
113
- A[Square Rect] -- Link text --> B((Circle))
114
- A --> C(Round Rect)
115
- B --> D{Rhombus}
116
- C --> D
117
-
118
- `,
119
- },
120
- {
121
- displayText: 'Diagram class 🏷',
122
- text: `=for Diagram :caption('Caption of diagram')
123
- classDiagram
124
- Person <|-- Student
125
- Person <|-- Professor
126
- Person : +String name
127
- Person : +String phoneNumber
128
- Person : +String emailAddress
129
- Person: +purchaseParkingPass()
130
- Address "1" <-- "0..1" Person:lives at
131
- class Student{
132
- +int studentNumber
133
- +int averageMark
134
- +isEligibleToEnrol()
135
- +getSeminarsTaken()
136
- }
137
- class Professor{
138
- +int salary
139
- }
140
- class Address{
141
- +String street
142
- +String city
143
- +String state
144
- +int postalCode
145
- +String country
146
- -validate()
147
- +outputAsLabel()
148
- }
149
-
150
- `,
151
- },
152
- {
153
- displayText: 'code block with formatting 🏷',
154
- text: `=begin code :allow<I B Z>
155
-
156
- =end code
157
- `,
158
- },
159
- {
160
- displayText: 'Toc head1, head2, head3',
161
- text: `=Toc head1, head2, head3
162
- `,
163
- },
164
- {
165
- displayText: 'Toc (with :title) 🏷',
166
- text: `=for Toc :title('Table of contents')
167
- head1, head2, head3
168
-
169
- `,
170
- },
171
- {
172
- displayText: 'Toc ( Images, Diagrams ) + tables 🏷',
173
- text: `=for Toc :title('List of media')
174
- Image, Diagram
175
- =for Toc :title('List of tables')
176
- table
177
-
178
- `,
179
- },
180
-
181
- {
182
- displayText: 'Markdown',
183
- text: `=begin Markdown
184
-
185
- {}
186
-
187
- =end Markdown
188
- `,
189
- },
190
- // Markdown
191
-
192
- {
193
- displayText: 'head1',
194
- text: `# `,
195
- lang: 'md',
196
- },
197
- {
198
- displayText: 'head2',
199
- text: `## `,
200
- lang: 'md',
201
- },
202
-
203
- {
204
- displayText: 'head3',
205
- text: `### `,
206
- lang: 'md',
207
- },
208
- {
209
- displayText: 'item1 *',
210
- text: `* `,
211
- lang: 'md',
212
- },
213
- {
214
- displayText: 'item1 1.)',
215
- text: `1. `,
216
- lang: 'md',
217
- },
218
- {
219
- displayText: 'Image 🏷',
220
- text: `![Podlite](https://github.com/zag/podlite-desktop/blob/master/dist-assets/linux-icon/256x256.png?raw=true "Podlite logo")
221
-
222
- `,
223
- lang: 'md',
224
- },
225
-
226
- {
227
- displayText: 'Table',
228
- text: `| Syntax | Description |
229
- | ----------- | ----------- |
230
- | Header | Title |
231
- | Paragraph | Text |
232
-
233
- `,
234
- lang: 'md',
235
- },
236
- {
237
- displayText: 'Diagram simple 🏷',
238
- text: `\`\`\`diagram
239
- graph LR
240
- A-->B
241
- B-->C
242
- C-->A
243
- D-->C
244
- \`\`\``,
245
- lang: 'md',
246
- },
247
- ];
248
- export default dict;
package/src/helpers.ts DELETED
@@ -1,74 +0,0 @@
1
- import { getFromTree, PodliteDocument } from '@podlite/schema';
2
- import { frozenIds, podlite as podlite_core } from 'podlite';
3
- export const parse = (str: string): PodliteDocument => {
4
- let podlite = podlite_core({ importPlugins: false });
5
- let tree = podlite.parse(str);
6
- const asAst = podlite.toAstResult(tree);
7
- return asAst.interator;
8
- };
9
- export const getSuggestionContextForLine = (
10
- pod: string,
11
- line: number,
12
- ): 'pod6' | 'md' => {
13
- const tree = parse(pod);
14
- const markdownBlocks = getFromTree(tree, 'Markdown') as any; // TODO: remove `any`
15
- const isMd =
16
- markdownBlocks.findIndex(
17
- ({
18
- location: {
19
- start: { line: lineStart },
20
- end: { line: lineEnd },
21
- },
22
- }) => {
23
- return line > lineStart && line < lineEnd;
24
- },
25
- ) !== -1;
26
- if (isMd) return 'md';
27
- return 'pod6';
28
- };
29
-
30
- interface Pos {
31
- line: number;
32
- offset: number;
33
- }
34
- interface Selection {
35
- start: Pos;
36
- end: Pos;
37
- text?: string; // return result pod, after remove {}
38
- }
39
- export const templateGetSelectionPos = (pod: string): Selection | null => {
40
- // if empty selection
41
- const EMPTY_SELECTION = new RegExp(/\{\}/);
42
- const lineNumEmptySel = pod
43
- .split('\n')
44
- .findIndex((str) => str.match(EMPTY_SELECTION));
45
- if (lineNumEmptySel > -1) {
46
- const line = pod.split('\n')[lineNumEmptySel];
47
- const matchResult = line.match(EMPTY_SELECTION)!;
48
- const start = { line: lineNumEmptySel, offset: matchResult.index! };
49
- const end = { line: lineNumEmptySel, offset: matchResult.index! };
50
- return { start, end, text: pod.replace(EMPTY_SELECTION, '') };
51
- }
52
- const SELECTION = new RegExp(/\{[^}]+\}/);
53
- const lineNum = pod.split('\n').findIndex((str) => str.match(SELECTION));
54
- if (lineNum > -1) {
55
- const line = pod.split('\n')[lineNum];
56
- const matchResult = line.match(SELECTION)!;
57
- const start = { line: lineNum, offset: matchResult.index! };
58
- const end = {
59
- line: lineNum,
60
- offset: matchResult.index! + matchResult[0].length,
61
- };
62
- return { start, end, text: pod };
63
- }
64
- return null;
65
- };
66
-
67
- export const addVMargin = (count: number, pod: string) => {
68
- const addString = ' '.repeat(count);
69
- const [firstLine, ...restLines] = pod.split('\n');
70
- return [
71
- firstLine,
72
- ...[].concat(restLines).map((str) => `${addString}${str}`),
73
- ].join('\n');
74
- };