glib-web 2.3.0 → 2.3.1

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/LICENSE CHANGED
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
@@ -1,8 +1,8 @@
1
1
  <template>
2
2
  <div :style="$styles()" :class="$classes()">
3
3
  <v-tabs v-model="mode" fixed-tabs>
4
- <v-tab>Editor</v-tab>
5
- <v-tab>Code</v-tab>
4
+ <v-tab @click="onRichTextClicked">Editor</v-tab>
5
+ <v-tab @click="onRawTextClicked">Code</v-tab>
6
6
  </v-tabs>
7
7
 
8
8
  <v-progress-linear v-if="showProgress" v-model="progress.value" />
@@ -11,22 +11,22 @@
11
11
  <VueEditor
12
12
  v-if="!rawMode"
13
13
  id="rich-editor"
14
- v-model="htmlValue"
14
+ v-model="richEditorValue"
15
15
  :editor-toolbar="customToolbar"
16
16
  use-custom-image-handler
17
- @text-change="onEditorChange"
17
+ @text-change="onRichTextEditorChanged"
18
18
  @image-added="uploadImage"
19
+ :editorOptions="editorSettings"
19
20
  />
20
21
  <!-- Hide these fields but don't remove them because these are the values that will get submitted. -->
21
22
  <div :style="{ display: rawMode ? 'block' : 'none' }">
22
23
  <v-textarea
23
24
  id="raw-editor"
24
- v-model="producedValue"
25
- :name="spec.name"
25
+ v-model="rawEditorValue"
26
26
  :style="$styles()"
27
27
  :class="$classes()"
28
28
  :outlined="$classes().includes('outlined')"
29
- @input="onCodeChange"
29
+ @input="onRawTextEditorChanged"
30
30
  ></v-textarea>
31
31
  <v-text-field
32
32
  v-for="(imageKey, index) in imageKeys"
@@ -39,6 +39,7 @@
39
39
  :value="images[imageKey]"
40
40
  />
41
41
  </div>
42
+ <input type="hidden" :name="spec.name" :value="producedValue" />
42
43
  </div>
43
44
  </template>
44
45
 
@@ -47,29 +48,156 @@ import Uploader from "../../utils/uploader";
47
48
  import { VueEditor, Quill } from "vue2-editor";
48
49
  import TurndownService from "turndown";
49
50
  import { gfm } from "turndown-plugin-gfm";
51
+ import eventFiltering from "../../utils/eventFiltering";
52
+ import QuillImageDropAndPaste from "quill-image-drop-and-paste";
53
+ import bus from "../../utils/eventBus";
54
+
55
+ Quill.register("modules/imageDropAndPaste", QuillImageDropAndPaste);
56
+
57
+ var ImageBlot = Quill.import("formats/image");
58
+ ImageBlot.sanitize = function (url) {
59
+ return url;
60
+ };
61
+
62
+ class Parser {
63
+ static markdownToHtml(data) {
64
+ return Utils.format.markdownForEditor(data);
65
+ }
66
+
67
+ static htmlToMarkdown(data) {
68
+ const turndownService = new TurndownService({ headingStyle: "atx" });
69
+ turndownService.use(gfm);
70
+ turndownService.addRule("strikethrough", {
71
+ filter: ["del", "s", "strike"],
72
+ replacement: function (content) {
73
+ return "~~" + content + "~~";
74
+ },
75
+ });
76
+
77
+ turndownService.addRule("codeblock", {
78
+ filter: ["pre"],
79
+ replacement: function (content) {
80
+ return "```\n" + content + "```";
81
+ },
82
+ });
83
+ return turndownService.turndown(data);
84
+ }
85
+ }
86
+
87
+ class TextEditor {
88
+ constructor(context) {
89
+ this.context = context;
90
+ }
91
+
92
+ // input and output should be either 'html' or 'markdown'
93
+ producedValue(data, input, output) {
94
+ if (output == "markdown") {
95
+ return this.markdownValue(this.replaceWithFakeImage(data), input);
96
+ } else if (output == "html") {
97
+ return this.replaceWithFakeImage(this.htmlValue(data, input));
98
+ }
99
+ }
100
+
101
+ markdownValue(data, input = "html") {
102
+ if (input == "html") {
103
+ return Parser.htmlToMarkdown(data);
104
+ } else if (input == "markdown") {
105
+ return data;
106
+ }
107
+ }
108
+
109
+ htmlValue(data, input) {
110
+ if (input == "html") {
111
+ return data;
112
+ } else if (input == "markdown") {
113
+ return Parser.markdownToHtml(data);
114
+ }
115
+ }
116
+
117
+ markdownValueWithRealImage(data, input) {
118
+ return this.markdownValue(this.replaceWithRealImage(data), input);
119
+ }
120
+
121
+ htmlValueWithRealImage(data, input) {
122
+ return this.htmlValue(this.replaceWithRealImage(data), input);
123
+ }
124
+
125
+ // replace {{image1}} to real image1 url
126
+ replaceWithRealImage(html) {
127
+ const vm = this.context;
128
+ return html.replace(/\{\{image([0-9]+)\}\}/g, function (_, index) {
129
+ const image = vm.spec.images[index - 1];
130
+ if (
131
+ image &&
132
+ vm.$type.isString(image.value) &&
133
+ vm.$type.isString(image.fileUrl)
134
+ ) {
135
+ const url = image.fileUrl;
136
+ const key = url.hashCode().toString();
137
+ vm.images[key] = image.value;
138
+ return url;
139
+ }
140
+ return "{{IMAGE_NOT_FOUND}}";
141
+ });
142
+ }
143
+
144
+ // replace image1 url with {{image1}}
145
+ replaceWithFakeImage(html) {
146
+ const vm = this.context;
147
+ let index = 0;
148
+ vm.imageKeys.clear();
149
+ return html.replace(/src="([^"]+)"|\!\[\]\((.+)\)/g, function (_, g1, g2) {
150
+ var imageValue = g1 || g2;
151
+ // It seems that quill encodes '&' in the URL to '&amp;' which would screw up key matching.
152
+ var decodedValue = imageValue.replace(/&amp;/g, "&");
153
+ const key = decodedValue.hashCode().toString();
154
+ vm.imageKeys.push(key);
155
+ if (g1) {
156
+ return `src="{{image${++index}}}"`;
157
+ } else {
158
+ return `{{image${++index}}}`;
159
+ }
160
+ });
161
+ }
162
+ }
50
163
 
51
164
  export default {
52
165
  components: { VueEditor },
53
166
  props: {
54
- spec: { type: Object, required: true }
167
+ spec: { type: Object, required: true },
55
168
  },
56
169
  data: () => ({
57
170
  customToolbar: [
58
171
  ["bold", "italic", "strike"],
59
172
  [{ header: 1 }, { header: 2 }, { header: 3 }],
60
173
  [{ list: "ordered" }, { list: "bullet" }],
61
- ["image", "link"]
174
+ ["image", "link"],
62
175
  ],
63
- htmlValue: "",
64
- cleanValue: null,
176
+ editorSettings: {
177
+ modules: {
178
+ imageDropAndPaste: {
179
+ // add an custom image handler
180
+ handler: function (imageDataUrl, type, imageData) {
181
+ bus.$emit("richText/dropOrPaste", {
182
+ file: imageData.toFile(),
183
+ editor: this.quill,
184
+ cursorLocation: this.getIndex(),
185
+ });
186
+ },
187
+ },
188
+ },
189
+ },
190
+ richEditorValue: "",
191
+ rawEditorValue: "",
65
192
  producedValue: "",
66
193
  images: {},
67
194
  imageKeys: [],
68
195
  progress: { value: -1 },
69
196
  imageUploader: {},
70
- produce: null,
197
+ textEditor: null,
71
198
  mode: null,
72
- turndownService: new TurndownService({ headingStyle: "atx" })
199
+ produce: null,
200
+ accept: null,
73
201
  }),
74
202
  computed: {
75
203
  showProgress() {
@@ -77,88 +205,37 @@ export default {
77
205
  },
78
206
  rawMode() {
79
207
  return this.mode == 1;
80
- }
81
- },
82
- watch: {
83
- cleanValue(val, oldVal) {
84
- if (oldVal == null) {
85
- // Don't update `producedValue` if this is first-time initialization to preserve the original value.
86
- return;
87
- }
88
- switch (this.produce) {
89
- case "html":
90
- this.producedValue = val;
91
- break;
92
- case "markdown":
93
- this.producedValue = this.turndownService.turndown(val);
94
- break;
95
- default:
96
- console.log(`Unsupported format: ${this.produce}`);
97
- }
98
208
  },
99
- producedValue(val) {
100
- switch (this.produce) {
101
- case "html":
102
- this.htmlValue = val;
103
- break;
104
- case "markdown":
105
- this.htmlValue = this.toHtmlValue(val);
106
- break;
107
- default:
108
- console.log(`Unsupported format: ${this.produce}`);
109
- }
110
- }
111
209
  },
210
+ watch: {},
112
211
  mounted() {
113
- this.registerScrollEvent();
212
+ bus.$on("richText/dropOrPaste", ({ file, editor, cursorLocation }) =>
213
+ this.uploadImage(file, editor, cursorLocation)
214
+ );
114
215
  },
115
216
  methods: {
116
217
  $ready() {
117
218
  this.produce = this.spec.produce || "markdown";
219
+ this.accept = this.spec.accept || "markdown";
118
220
 
119
- this.turndownService.use(gfm);
120
- this.turndownService.addRule("strikethrough", {
121
- filter: ["del", "s", "strike"],
122
- replacement: function(content) {
123
- return "~~" + content + "~~";
124
- }
125
- });
126
-
127
- this.turndownService.addRule("codeblock", {
128
- filter: ["pre"],
129
- replacement: function(content) {
130
- return "```\n" + content + "```";
131
- }
132
- });
133
-
221
+ this.textEditor = new TextEditor(this);
134
222
  this.imageUploader = this.spec.imageUploader;
135
223
 
136
- // Convert initial markdown value to html for displaying.
137
- this.producedValue = this.spec.value || "";
138
- this.htmlValue = this.toHtmlValue(this.producedValue);
139
- },
140
- toHtmlValue(producedValue) {
141
- const vm = this;
142
- var value = producedValue.replace(/\{\{image([0-9]+)\}\}/g, function(
143
- _,
144
- index
145
- ) {
146
- const image = vm.spec.images[index - 1];
147
- if (
148
- image &&
149
- vm.$type.isString(image.value) &&
150
- vm.$type.isString(image.fileUrl)
151
- ) {
152
- const url = image.fileUrl;
153
- const key = url.hashCode().toString();
154
- vm.images[key] = image.value;
155
- return url;
156
- }
157
- return "{{IMAGE_NOT_FOUND}}";
158
- });
159
- return this.produce == "markdown" ? Utils.format.markdown(value) : value;
224
+ this.richEditorValue = this.textEditor.htmlValueWithRealImage(
225
+ this.spec.value,
226
+ this.accept
227
+ );
228
+ this.rawEditorValue = this.textEditor.markdownValueWithRealImage(
229
+ this.spec.value,
230
+ this.accept
231
+ );
232
+ this.producedValue = this.textEditor.producedValue(
233
+ this.spec.value,
234
+ this.accept,
235
+ this.produce
236
+ );
160
237
  },
161
- uploadImage: function(file, editor, cursorLocation) {
238
+ uploadImage: function (file, editor, cursorLocation) {
162
239
  let vm = this;
163
240
  const uploaderSpec = this.imageUploader;
164
241
  // const input = this.$refs.directUploadFile
@@ -175,6 +252,7 @@ export default {
175
252
  upload.start((error, blob) => {
176
253
  if (error) {
177
254
  // Handle the error
255
+ console.error(error);
178
256
  } else {
179
257
  vm.insertImage(file, editor, cursorLocation, blob);
180
258
  }
@@ -184,17 +262,43 @@ export default {
184
262
  });
185
263
  }
186
264
  },
187
- onEditorChange() {
188
- this.separateOutImages();
189
- this.onCodeChange();
265
+ onRichTextClicked() {
266
+ this.richEditorValue = this.textEditor.htmlValue(
267
+ this.rawEditorValue,
268
+ "markdown"
269
+ );
270
+ },
271
+ onRawTextClicked() {
272
+ this.rawEditorValue = this.textEditor.markdownValue(
273
+ this.richEditorValue,
274
+ "html"
275
+ );
190
276
  },
191
- onCodeChange() {
192
- Utils.type.ifObject(this.spec.onChange, onChange => {
277
+ onRichTextEditorChanged: eventFiltering.debounce(function () {
278
+ this.producedValue = this.textEditor.producedValue(
279
+ this.richEditorValue,
280
+ "html",
281
+ this.produce
282
+ );
283
+
284
+ this.onChange(this.producedValue);
285
+ }),
286
+ onRawTextEditorChanged: eventFiltering.debounce(function () {
287
+ this.producedValue = this.textEditor.producedValue(
288
+ this.rawEditorValue,
289
+ "markdown",
290
+ this.produce
291
+ );
292
+
293
+ this.onChange(this.producedValue);
294
+ }),
295
+ onChange(producedValue) {
296
+ Utils.type.ifObject(this.spec.onChange, (onChange) => {
193
297
  this.$nextTick(() => {
194
298
  const params = {
195
299
  [this.spec.paramNameForFormData || "formData"]: {
196
- [this.fieldName]: this.fieldModel
197
- }
300
+ [this.fieldName]: producedValue,
301
+ },
198
302
  };
199
303
 
200
304
  const data = Object.assign({}, onChange, params);
@@ -202,32 +306,16 @@ export default {
202
306
  });
203
307
  });
204
308
  },
205
- separateOutImages: function() {
206
- const vm = this;
207
- var index = 0;
208
- vm.imageKeys.clear();
209
- // TODO: Fix to avoid replacing <video src="">
210
- this.cleanValue = this.htmlValue.replace(/src="([^"]+)"/g, function(
211
- _,
212
- imageValue
213
- ) {
214
- // It seems that quill encodes '&' in the URL to '&amp;' which would screw up key matching.
215
- var decodedValue = imageValue.replace(/&amp;/g, "&");
216
- const key = decodedValue.hashCode().toString();
217
- vm.imageKeys.push(key);
218
- return `src="{{image${++index}}}"`;
219
- });
220
- },
221
- insertImage: function(file, Editor, cursorLocation, blob) {
309
+ insertImage: function (file, Editor, cursorLocation, blob) {
222
310
  let vm = this;
223
311
  var reader = new FileReader();
224
- reader.onload = function(e) {
312
+ reader.onload = function (e) {
225
313
  // vm.fileUrl = e.target.result;
226
314
  if (file.type.indexOf("image") !== -1) {
227
315
  var image = new Image();
228
- image.src = e.target.result;
316
+ image.src = URL.createObjectURL(file);
229
317
 
230
- image.onload = function() {
318
+ image.onload = function () {
231
319
  Editor.insertEmbed(cursorLocation, "image", image.src);
232
320
  };
233
321
 
@@ -238,7 +326,7 @@ export default {
238
326
  reader.readAsDataURL(file);
239
327
  vm.progress.value = -1;
240
328
  },
241
- updateToolbar: function(wrapper, toolbar, container) {
329
+ updateToolbar: function (wrapper, toolbar, container) {
242
330
  if (wrapper.scrollTop >= container.offsetTop) {
243
331
  toolbar.classList.add("sticky");
244
332
  toolbar.style.top = `${wrapper.offsetTop}px`;
@@ -251,7 +339,7 @@ export default {
251
339
  toolbar.style.width = "auto";
252
340
  }
253
341
  },
254
- registerScrollEvent: function() {
342
+ registerScrollEvent: function () {
255
343
  const wrapper = document.querySelector(".v-dialog") || window;
256
344
  const toolbar = this.$el.querySelector(".ql-toolbar");
257
345
  const container = this.$el.querySelector(".ql-container");
@@ -264,8 +352,8 @@ export default {
264
352
  this.updateToolbar(wrapper, toolbar, container)
265
353
  );
266
354
  }
267
- }
268
- }
355
+ },
356
+ },
269
357
  };
270
358
  </script>
271
359
 
File without changes
File without changes
package/components/hr.vue CHANGED
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
package/components/p.vue CHANGED
File without changes
package/keys.js CHANGED
File without changes
File without changes
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "glib-web",
3
- "version": "2.3.0",
3
+ "version": "2.3.1",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -21,6 +21,7 @@
21
21
  "marked": "^4.0.0",
22
22
  "phoenix": "^1.5.3",
23
23
  "push.js": "^1.0.12",
24
+ "quill-image-drop-and-paste": "^1.2.14",
24
25
  "turndown": "^7.1.1",
25
26
  "turndown-plugin-gfm": "^1.0.2",
26
27
  "vue": "2.6.14",
@@ -29,8 +30,8 @@
29
30
  "vue-social-sharing": "^3.0.9",
30
31
  "vue-youtube": "^1.4.0",
31
32
  "vue2-editor": "^2.9.1",
32
- "vue2-google-maps": "^0.10.6",
33
33
  "vue2-gmap-custom-marker": "^6.1.1",
34
+ "vue2-google-maps": "^0.10.6",
34
35
  "vuedraggable": "^2.24.1",
35
36
  "vuetify": "2.3.9"
36
37
  },
@@ -43,6 +44,7 @@
43
44
  "eslint-plugin-prettier": "^3.1.1",
44
45
  "eslint-plugin-vue": "^5.2.3",
45
46
  "eslint-plugin-vuetify": "^1.0.0-beta.3",
46
- "prettier": "^1.18.2"
47
+ "prettier": "^1.18.2",
48
+ "typescript": "^4.9.5"
47
49
  }
48
50
  }
File without changes
package/styles/test.sass CHANGED
File without changes
package/styles/test.scss CHANGED
File without changes
File without changes
package/tsconfig.json ADDED
@@ -0,0 +1,103 @@
1
+ {
2
+ "compilerOptions": {
3
+ /* Visit https://aka.ms/tsconfig to read more about this file */
4
+
5
+ /* Projects */
6
+ // "incremental": true, /* Save .tsbuildinfo files to allow for incremental compilation of projects. */
7
+ // "composite": true, /* Enable constraints that allow a TypeScript project to be used with project references. */
8
+ // "tsBuildInfoFile": "./.tsbuildinfo", /* Specify the path to .tsbuildinfo incremental compilation file. */
9
+ // "disableSourceOfProjectReferenceRedirect": true, /* Disable preferring source files instead of declaration files when referencing composite projects. */
10
+ // "disableSolutionSearching": true, /* Opt a project out of multi-project reference checking when editing. */
11
+ // "disableReferencedProjectLoad": true, /* Reduce the number of projects loaded automatically by TypeScript. */
12
+
13
+ /* Language and Environment */
14
+ "target": "es2016", /* Set the JavaScript language version for emitted JavaScript and include compatible library declarations. */
15
+ // "lib": [], /* Specify a set of bundled library declaration files that describe the target runtime environment. */
16
+ // "jsx": "preserve", /* Specify what JSX code is generated. */
17
+ // "experimentalDecorators": true, /* Enable experimental support for TC39 stage 2 draft decorators. */
18
+ // "emitDecoratorMetadata": true, /* Emit design-type metadata for decorated declarations in source files. */
19
+ // "jsxFactory": "", /* Specify the JSX factory function used when targeting React JSX emit, e.g. 'React.createElement' or 'h'. */
20
+ // "jsxFragmentFactory": "", /* Specify the JSX Fragment reference used for fragments when targeting React JSX emit e.g. 'React.Fragment' or 'Fragment'. */
21
+ // "jsxImportSource": "", /* Specify module specifier used to import the JSX factory functions when using 'jsx: react-jsx*'. */
22
+ // "reactNamespace": "", /* Specify the object invoked for 'createElement'. This only applies when targeting 'react' JSX emit. */
23
+ // "noLib": true, /* Disable including any library files, including the default lib.d.ts. */
24
+ // "useDefineForClassFields": true, /* Emit ECMAScript-standard-compliant class fields. */
25
+ // "moduleDetection": "auto", /* Control what method is used to detect module-format JS files. */
26
+
27
+ /* Modules */
28
+ "module": "commonjs", /* Specify what module code is generated. */
29
+ // "rootDir": "./", /* Specify the root folder within your source files. */
30
+ // "moduleResolution": "node", /* Specify how TypeScript looks up a file from a given module specifier. */
31
+ // "baseUrl": "./", /* Specify the base directory to resolve non-relative module names. */
32
+ // "paths": {}, /* Specify a set of entries that re-map imports to additional lookup locations. */
33
+ // "rootDirs": [], /* Allow multiple folders to be treated as one when resolving modules. */
34
+ // "typeRoots": [], /* Specify multiple folders that act like './node_modules/@types'. */
35
+ // "types": [], /* Specify type package names to be included without being referenced in a source file. */
36
+ // "allowUmdGlobalAccess": true, /* Allow accessing UMD globals from modules. */
37
+ // "moduleSuffixes": [], /* List of file name suffixes to search when resolving a module. */
38
+ // "resolveJsonModule": true, /* Enable importing .json files. */
39
+ // "noResolve": true, /* Disallow 'import's, 'require's or '<reference>'s from expanding the number of files TypeScript should add to a project. */
40
+
41
+ /* JavaScript Support */
42
+ // "allowJs": true, /* Allow JavaScript files to be a part of your program. Use the 'checkJS' option to get errors from these files. */
43
+ // "checkJs": true, /* Enable error reporting in type-checked JavaScript files. */
44
+ // "maxNodeModuleJsDepth": 1, /* Specify the maximum folder depth used for checking JavaScript files from 'node_modules'. Only applicable with 'allowJs'. */
45
+
46
+ /* Emit */
47
+ // "declaration": true, /* Generate .d.ts files from TypeScript and JavaScript files in your project. */
48
+ // "declarationMap": true, /* Create sourcemaps for d.ts files. */
49
+ // "emitDeclarationOnly": true, /* Only output d.ts files and not JavaScript files. */
50
+ // "sourceMap": true, /* Create source map files for emitted JavaScript files. */
51
+ // "outFile": "./", /* Specify a file that bundles all outputs into one JavaScript file. If 'declaration' is true, also designates a file that bundles all .d.ts output. */
52
+ // "outDir": "./", /* Specify an output folder for all emitted files. */
53
+ // "removeComments": true, /* Disable emitting comments. */
54
+ // "noEmit": true, /* Disable emitting files from a compilation. */
55
+ // "importHelpers": true, /* Allow importing helper functions from tslib once per project, instead of including them per-file. */
56
+ // "importsNotUsedAsValues": "remove", /* Specify emit/checking behavior for imports that are only used for types. */
57
+ // "downlevelIteration": true, /* Emit more compliant, but verbose and less performant JavaScript for iteration. */
58
+ // "sourceRoot": "", /* Specify the root path for debuggers to find the reference source code. */
59
+ // "mapRoot": "", /* Specify the location where debugger should locate map files instead of generated locations. */
60
+ // "inlineSourceMap": true, /* Include sourcemap files inside the emitted JavaScript. */
61
+ // "inlineSources": true, /* Include source code in the sourcemaps inside the emitted JavaScript. */
62
+ // "emitBOM": true, /* Emit a UTF-8 Byte Order Mark (BOM) in the beginning of output files. */
63
+ // "newLine": "crlf", /* Set the newline character for emitting files. */
64
+ // "stripInternal": true, /* Disable emitting declarations that have '@internal' in their JSDoc comments. */
65
+ // "noEmitHelpers": true, /* Disable generating custom helper functions like '__extends' in compiled output. */
66
+ // "noEmitOnError": true, /* Disable emitting files if any type checking errors are reported. */
67
+ // "preserveConstEnums": true, /* Disable erasing 'const enum' declarations in generated code. */
68
+ // "declarationDir": "./", /* Specify the output directory for generated declaration files. */
69
+ // "preserveValueImports": true, /* Preserve unused imported values in the JavaScript output that would otherwise be removed. */
70
+
71
+ /* Interop Constraints */
72
+ // "isolatedModules": true, /* Ensure that each file can be safely transpiled without relying on other imports. */
73
+ // "allowSyntheticDefaultImports": true, /* Allow 'import x from y' when a module doesn't have a default export. */
74
+ "esModuleInterop": true, /* Emit additional JavaScript to ease support for importing CommonJS modules. This enables 'allowSyntheticDefaultImports' for type compatibility. */
75
+ // "preserveSymlinks": true, /* Disable resolving symlinks to their realpath. This correlates to the same flag in node. */
76
+ "forceConsistentCasingInFileNames": true, /* Ensure that casing is correct in imports. */
77
+
78
+ /* Type Checking */
79
+ "strict": true, /* Enable all strict type-checking options. */
80
+ // "noImplicitAny": true, /* Enable error reporting for expressions and declarations with an implied 'any' type. */
81
+ // "strictNullChecks": true, /* When type checking, take into account 'null' and 'undefined'. */
82
+ // "strictFunctionTypes": true, /* When assigning functions, check to ensure parameters and the return values are subtype-compatible. */
83
+ // "strictBindCallApply": true, /* Check that the arguments for 'bind', 'call', and 'apply' methods match the original function. */
84
+ // "strictPropertyInitialization": true, /* Check for class properties that are declared but not set in the constructor. */
85
+ // "noImplicitThis": true, /* Enable error reporting when 'this' is given the type 'any'. */
86
+ // "useUnknownInCatchVariables": true, /* Default catch clause variables as 'unknown' instead of 'any'. */
87
+ // "alwaysStrict": true, /* Ensure 'use strict' is always emitted. */
88
+ // "noUnusedLocals": true, /* Enable error reporting when local variables aren't read. */
89
+ // "noUnusedParameters": true, /* Raise an error when a function parameter isn't read. */
90
+ // "exactOptionalPropertyTypes": true, /* Interpret optional property types as written, rather than adding 'undefined'. */
91
+ // "noImplicitReturns": true, /* Enable error reporting for codepaths that do not explicitly return in a function. */
92
+ // "noFallthroughCasesInSwitch": true, /* Enable error reporting for fallthrough cases in switch statements. */
93
+ // "noUncheckedIndexedAccess": true, /* Add 'undefined' to a type when accessed using an index. */
94
+ // "noImplicitOverride": true, /* Ensure overriding members in derived classes are marked with an override modifier. */
95
+ // "noPropertyAccessFromIndexSignature": true, /* Enforces using indexed accessors for keys declared using an indexed type. */
96
+ // "allowUnusedLabels": true, /* Disable error reporting for unused labels. */
97
+ // "allowUnreachableCode": true, /* Disable error reporting for unreachable code. */
98
+
99
+ /* Completeness */
100
+ // "skipDefaultLibCheck": true, /* Skip type checking .d.ts files that are included with TypeScript. */
101
+ "skipLibCheck": true /* Skip type checking all .d.ts files. */
102
+ }
103
+ }
package/utils/dom.js CHANGED
File without changes
package/utils/format.js CHANGED
@@ -1,8 +1,30 @@
1
1
  import { marked } from "marked";
2
2
 
3
3
  export default class {
4
+ static markdownForEditor(text) {
5
+
6
+ const renderer = {
7
+ listitem(text, task, checked) {
8
+ return `<li>${text.replace(/\<p\>|\<\/p\>/g, "")}</li>`
9
+ },
10
+ list(body, ordered, start) {
11
+ if (ordered) {
12
+ return `<ol>${body}</ol>`
13
+ } else {
14
+ return `<ul>${body}</ul>`
15
+ }
16
+ }
17
+ };
18
+
19
+ marked.use({ renderer });
20
+
21
+ return marked.parse(
22
+ text, { break: true }
23
+ );
24
+ }
25
+
4
26
  static markdown(text) {
5
- return marked(text);
27
+ return marked.parse(text)
6
28
  }
7
29
 
8
30
  static local_iso8601(date) {
package/utils/public.js CHANGED
File without changes
package/utils/settings.js CHANGED
File without changes
package/utils/storage.js CHANGED
File without changes
package/utils/url.js CHANGED
File without changes