@standardnotes/markdown-minimal 1.2.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/.babelrc +3 -0
- package/CHANGELOG.md +63 -0
- package/Gruntfile.js +125 -0
- package/README.md +26 -0
- package/dist/app.css +143 -0
- package/dist/app.css.map +1 -0
- package/dist/app.js +118 -0
- package/dist/app.js.map +1 -0
- package/dist/dist.css +490 -0
- package/dist/dist.js +11214 -0
- package/dist/lib.js +11096 -0
- package/dist/sn-codemirror-search/dialog/dialog.css +46 -0
- package/dist/sn-codemirror-search/dialog/dialog.js +161 -0
- package/dist/sn-codemirror-search/search.js +258 -0
- package/dist/sn-codemirror-search/searchcursor.js +293 -0
- package/ext.json +8 -0
- package/index.html +23 -0
- package/min-markdown.jpg +0 -0
- package/package.json +41 -0
- package/src/main.js +110 -0
- package/src/main.scss +151 -0
- package/vendor/addon/modes/overlay.js +90 -0
- package/vendor/mark-selection.js +119 -0
- package/vendor/modes/gfm/gfm.js +130 -0
- package/vendor/modes/markdown/markdown.js +884 -0
package/.babelrc
ADDED
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
# Change Log
|
|
2
|
+
|
|
3
|
+
All notable changes to this project will be documented in this file.
|
|
4
|
+
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
|
+
|
|
6
|
+
## [1.2.1](https://github.com/standardnotes/plugins/compare/@sncommunity/markdown-minimal@1.2.0...@sncommunity/markdown-minimal@1.2.1) (2022-11-04)
|
|
7
|
+
|
|
8
|
+
**Note:** Version bump only for package @sncommunity/markdown-minimal
|
|
9
|
+
|
|
10
|
+
# [1.2.0](https://github.com/standardnotes/plugins/compare/@sncommunity/markdown-minimal@1.1.1...@sncommunity/markdown-minimal@1.2.0) (2022-10-04)
|
|
11
|
+
|
|
12
|
+
### Features
|
|
13
|
+
|
|
14
|
+
* add advanced checklist editor ([#3](https://github.com/standardnotes/plugins/issues/3)) ([71ae54d](https://github.com/standardnotes/plugins/commit/71ae54de2b1563c39a885d1ae6d3b30c0ba72eae))
|
|
15
|
+
|
|
16
|
+
## [1.1.1](https://github.com/standardnotes/plugins/compare/@sncommunity/markdown-minimal@1.1.0...@sncommunity/markdown-minimal@1.1.1) (2022-07-01)
|
|
17
|
+
|
|
18
|
+
**Note:** Version bump only for package @sncommunity/markdown-minimal
|
|
19
|
+
|
|
20
|
+
# 1.1.0 (2022-07-01)
|
|
21
|
+
|
|
22
|
+
### Features
|
|
23
|
+
|
|
24
|
+
* individual package entries ([8405d41](https://github.com/standardnotes/plugins/commit/8405d418f5110dd54310d180ffe7c319e61300bd))
|
|
25
|
+
* initial commit ([cf09e92](https://github.com/standardnotes/plugins/commit/cf09e925f915349a64c16905140a2b7b50d1b69b))
|
|
26
|
+
|
|
27
|
+
## [1.3.13](https://github.com/standardnotes/app/compare/@standardnotes/markdown-minimal@1.3.13-alpha.0...@standardnotes/markdown-minimal@1.3.13) (2022-06-22)
|
|
28
|
+
|
|
29
|
+
**Note:** Version bump only for package @standardnotes/markdown-minimal
|
|
30
|
+
|
|
31
|
+
## [1.3.13-alpha.0](https://github.com/standardnotes/app/compare/@standardnotes/markdown-minimal@1.3.12...@standardnotes/markdown-minimal@1.3.13-alpha.0) (2022-06-22)
|
|
32
|
+
|
|
33
|
+
### Bug Fixes
|
|
34
|
+
|
|
35
|
+
* components scripts ([#1136](https://github.com/standardnotes/app/issues/1136)) ([e80b4d0](https://github.com/standardnotes/app/commit/e80b4d0ffad495c758b593c30e1c4c754dda9b7e))
|
|
36
|
+
|
|
37
|
+
## 1.3.12 (2022-06-16)
|
|
38
|
+
|
|
39
|
+
**Note:** Version bump only for package @standardnotes/markdown-minimal
|
|
40
|
+
|
|
41
|
+
## 1.3.11 (2022-06-16)
|
|
42
|
+
|
|
43
|
+
**Note:** Version bump only for package @standardnotes/markdown-minimal
|
|
44
|
+
|
|
45
|
+
## [1.3.10](https://github.com/standardnotes/app/compare/@standardnotes/markdown-minimal@1.3.10-alpha.3...@standardnotes/markdown-minimal@1.3.10) (2022-06-16)
|
|
46
|
+
|
|
47
|
+
**Note:** Version bump only for package @standardnotes/markdown-minimal
|
|
48
|
+
|
|
49
|
+
## [1.3.10-alpha.3](https://github.com/standardnotes/app/compare/@standardnotes/markdown-minimal@1.3.10-alpha.2...@standardnotes/markdown-minimal@1.3.10-alpha.3) (2022-06-16)
|
|
50
|
+
|
|
51
|
+
**Note:** Version bump only for package @standardnotes/markdown-minimal
|
|
52
|
+
|
|
53
|
+
## 1.3.10-alpha.2 (2022-06-16)
|
|
54
|
+
|
|
55
|
+
**Note:** Version bump only for package @standardnotes/markdown-minimal
|
|
56
|
+
|
|
57
|
+
## 1.3.10-alpha.1 (2022-06-16)
|
|
58
|
+
|
|
59
|
+
**Note:** Version bump only for package @standardnotes/markdown-minimal
|
|
60
|
+
|
|
61
|
+
## 1.3.10-alpha.0 (2022-06-15)
|
|
62
|
+
|
|
63
|
+
**Note:** Version bump only for package @standardnotes/markdown-minimal
|
package/Gruntfile.js
ADDED
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
const path = require('path')
|
|
2
|
+
|
|
3
|
+
module.exports = function (grunt) {
|
|
4
|
+
grunt.initConfig({
|
|
5
|
+
watch: {
|
|
6
|
+
js: {
|
|
7
|
+
files: ['src/**/*.js'],
|
|
8
|
+
tasks: ['concat:app', 'babel', 'browserify', 'concat:lib', 'concat:dist'],
|
|
9
|
+
options: {
|
|
10
|
+
spawn: false,
|
|
11
|
+
},
|
|
12
|
+
},
|
|
13
|
+
css: {
|
|
14
|
+
files: ['src/main.scss'],
|
|
15
|
+
tasks: ['sass', 'concat:css'],
|
|
16
|
+
options: {
|
|
17
|
+
spawn: false,
|
|
18
|
+
},
|
|
19
|
+
},
|
|
20
|
+
},
|
|
21
|
+
|
|
22
|
+
sass: {
|
|
23
|
+
dist: {
|
|
24
|
+
options: {
|
|
25
|
+
style: 'expanded',
|
|
26
|
+
sourceMap: false,
|
|
27
|
+
},
|
|
28
|
+
files: {
|
|
29
|
+
'dist/app.css': 'src/main.scss',
|
|
30
|
+
},
|
|
31
|
+
},
|
|
32
|
+
},
|
|
33
|
+
|
|
34
|
+
babel: {
|
|
35
|
+
options: {
|
|
36
|
+
sourceMap: true,
|
|
37
|
+
presets: ['@babel/preset-env'],
|
|
38
|
+
},
|
|
39
|
+
app: {
|
|
40
|
+
files: {
|
|
41
|
+
'dist/app.js': ['dist/app.js'],
|
|
42
|
+
},
|
|
43
|
+
},
|
|
44
|
+
},
|
|
45
|
+
|
|
46
|
+
browserify: {
|
|
47
|
+
dist: {
|
|
48
|
+
files: {
|
|
49
|
+
'dist/app.js': 'dist/app.js',
|
|
50
|
+
},
|
|
51
|
+
},
|
|
52
|
+
},
|
|
53
|
+
|
|
54
|
+
concat: {
|
|
55
|
+
options: {
|
|
56
|
+
separator: ';',
|
|
57
|
+
},
|
|
58
|
+
|
|
59
|
+
app: {
|
|
60
|
+
src: ['src/**/*.js'],
|
|
61
|
+
dest: 'dist/app.js',
|
|
62
|
+
},
|
|
63
|
+
|
|
64
|
+
lib: {
|
|
65
|
+
src: [
|
|
66
|
+
require.resolve('codemirror/lib/codemirror.js'),
|
|
67
|
+
require.resolve('@standardnotes/component-relay/dist/dist.js'),
|
|
68
|
+
'vendor/modes/markdown/markdown.js',
|
|
69
|
+
'vendor/addon/modes/overlay.js',
|
|
70
|
+
'vendor/modes/gfm/gfm.js',
|
|
71
|
+
'vendor/mark-selection.js',
|
|
72
|
+
],
|
|
73
|
+
dest: 'dist/lib.js',
|
|
74
|
+
},
|
|
75
|
+
|
|
76
|
+
dist: {
|
|
77
|
+
src: ['dist/lib.js', 'dist/app.js'],
|
|
78
|
+
dest: 'dist/dist.js',
|
|
79
|
+
},
|
|
80
|
+
|
|
81
|
+
css: {
|
|
82
|
+
options: {
|
|
83
|
+
separator: '',
|
|
84
|
+
},
|
|
85
|
+
src: [
|
|
86
|
+
require.resolve('codemirror/lib/codemirror.css'),
|
|
87
|
+
require.resolve('sn-stylekit/dist/stylekit.css'),
|
|
88
|
+
'dist/app.css',
|
|
89
|
+
],
|
|
90
|
+
dest: 'dist/dist.css',
|
|
91
|
+
},
|
|
92
|
+
},
|
|
93
|
+
copy: {
|
|
94
|
+
main: {
|
|
95
|
+
files: [
|
|
96
|
+
{
|
|
97
|
+
expand: true,
|
|
98
|
+
cwd: path.dirname(require.resolve('sn-codemirror-search')),
|
|
99
|
+
src: ['**', '!package.json'],
|
|
100
|
+
dest: 'dist/sn-codemirror-search',
|
|
101
|
+
},
|
|
102
|
+
],
|
|
103
|
+
},
|
|
104
|
+
},
|
|
105
|
+
})
|
|
106
|
+
|
|
107
|
+
grunt.loadNpmTasks('grunt-newer')
|
|
108
|
+
grunt.loadNpmTasks('grunt-contrib-watch')
|
|
109
|
+
grunt.loadNpmTasks('grunt-babel')
|
|
110
|
+
grunt.loadNpmTasks('grunt-browserify')
|
|
111
|
+
grunt.loadNpmTasks('grunt-contrib-concat')
|
|
112
|
+
grunt.loadNpmTasks('grunt-contrib-sass')
|
|
113
|
+
grunt.loadNpmTasks('grunt-contrib-copy')
|
|
114
|
+
|
|
115
|
+
grunt.registerTask('default', [
|
|
116
|
+
'concat:app',
|
|
117
|
+
'babel',
|
|
118
|
+
'browserify',
|
|
119
|
+
'concat:lib',
|
|
120
|
+
'concat:dist',
|
|
121
|
+
'sass',
|
|
122
|
+
'concat:css',
|
|
123
|
+
'copy',
|
|
124
|
+
])
|
|
125
|
+
}
|
package/README.md
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
# Minimal Markdown Editor
|
|
2
|
+
|
|
3
|
+
A minimal Markdown editor with inline style support. Derived from [CodeMirror](https://github.com/codemirror/codemirror).
|
|
4
|
+
|
|
5
|
+

|
|
6
|
+
|
|
7
|
+
## Setup
|
|
8
|
+
|
|
9
|
+
*Note for Windows and Linux users: remove `fsevents` from `package.json`*
|
|
10
|
+
|
|
11
|
+
1. `npm i`
|
|
12
|
+
|
|
13
|
+
1. `grunt`
|
|
14
|
+
|
|
15
|
+
1. https://docs.standardnotes.org/extensions/local-setup/
|
|
16
|
+
|
|
17
|
+
## Support
|
|
18
|
+
|
|
19
|
+
Please open a new issue and the Standard Notes team will take a look as soon as we can. For more information on editors, refer to the following link:
|
|
20
|
+
|
|
21
|
+
- Standard Notes Help: [What are editors?](https://standardnotes.org/help/77/what-are-editors)
|
|
22
|
+
|
|
23
|
+
## License
|
|
24
|
+
|
|
25
|
+
[GNU AGPL v3.0](https://choosealicense.com/licenses/agpl-3.0/)
|
|
26
|
+
|
package/dist/app.css
ADDED
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
body,
|
|
2
|
+
html {
|
|
3
|
+
font-family: sans-serif;
|
|
4
|
+
font-size: var(--sn-stylekit-base-font-size);
|
|
5
|
+
height: 100%;
|
|
6
|
+
margin: 0;
|
|
7
|
+
background-color: transparent;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
* {
|
|
11
|
+
-webkit-tap-highlight-color: rgba(0, 0, 0, 0);
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
#wrapper {
|
|
15
|
+
display: flex;
|
|
16
|
+
flex-direction: column;
|
|
17
|
+
position: relative;
|
|
18
|
+
height: 100%;
|
|
19
|
+
overflow: hidden;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
.CodeMirror-scroll {
|
|
23
|
+
padding: 8px;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
.CodeMirror {
|
|
27
|
+
background-color: var(--sn-stylekit-editor-background-color) !important;
|
|
28
|
+
color: var(--sn-stylekit-editor-foreground-color) !important;
|
|
29
|
+
border: 0 !important;
|
|
30
|
+
font-family: sans-serif;
|
|
31
|
+
-webkit-overflow-scrolling: touch;
|
|
32
|
+
flex: 1 1 auto;
|
|
33
|
+
height: 100%;
|
|
34
|
+
resize: none;
|
|
35
|
+
font-size: var(--sn-stylekit-font-size-editor);
|
|
36
|
+
padding: 0;
|
|
37
|
+
}
|
|
38
|
+
.CodeMirror .CodeMirror-code .cm-comment {
|
|
39
|
+
background: var(--sn-stylekit-contrast-background-color);
|
|
40
|
+
color: var(--sn-stylekit-info-color);
|
|
41
|
+
font-family: Consolas, monaco, "Ubuntu Mono", courier, monospace !important;
|
|
42
|
+
font-size: 90%;
|
|
43
|
+
}
|
|
44
|
+
.CodeMirror .CodeMirror-code .cm-comment.CodeMirror-selectedtext {
|
|
45
|
+
color: var(--sn-stylekit-info-contrast-color) !important;
|
|
46
|
+
background: var(--sn-stylekit-info-color) !important;
|
|
47
|
+
}
|
|
48
|
+
.CodeMirror .cm-header {
|
|
49
|
+
color: var(--sn-stylekit-editor-foreground-color);
|
|
50
|
+
}
|
|
51
|
+
.CodeMirror .cm-header.CodeMirror-selectedtext {
|
|
52
|
+
color: var(--sn-stylekit-info-contrast-color) !important;
|
|
53
|
+
background: var(--sn-stylekit-info-color) !important;
|
|
54
|
+
}
|
|
55
|
+
.CodeMirror .cm-formatting-header,
|
|
56
|
+
.CodeMirror .cm-formatting-strong,
|
|
57
|
+
.CodeMirror .cm-formatting-em {
|
|
58
|
+
opacity: 0.2;
|
|
59
|
+
}
|
|
60
|
+
.CodeMirror .cm-variable-2, .CodeMirror .cm-variable-3 {
|
|
61
|
+
color: var(--sn-stylekit-editor-foreground-color) !important;
|
|
62
|
+
}
|
|
63
|
+
.CodeMirror .cm-variable-2.CodeMirror-selectedtext, .CodeMirror .cm-variable-3.CodeMirror-selectedtext {
|
|
64
|
+
color: var(--sn-stylekit-info-contrast-color) !important;
|
|
65
|
+
background: transparent;
|
|
66
|
+
}
|
|
67
|
+
.CodeMirror .cm-variable-3 {
|
|
68
|
+
color: var(--sn-stylekit-editor-foreground-color) !important;
|
|
69
|
+
}
|
|
70
|
+
.CodeMirror .cm-variable-3.CodeMirror-selectedtext {
|
|
71
|
+
color: var(--sn-stylekit-info-contrast-color) !important;
|
|
72
|
+
background: transparent;
|
|
73
|
+
}
|
|
74
|
+
.CodeMirror .cm-link,
|
|
75
|
+
.CodeMirror .cm-string {
|
|
76
|
+
color: var(--sn-stylekit-info-color) !important;
|
|
77
|
+
}
|
|
78
|
+
.CodeMirror .cm-link.CodeMirror-selectedtext,
|
|
79
|
+
.CodeMirror .cm-string.CodeMirror-selectedtext {
|
|
80
|
+
color: var(--sn-stylekit-info-contrast-color) !important;
|
|
81
|
+
background: var(--sn-stylekit-info-color) !important;
|
|
82
|
+
}
|
|
83
|
+
.CodeMirror .CodeMirror-linenumber {
|
|
84
|
+
color: gray !important;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
.CodeMirror-cursor {
|
|
88
|
+
border-color: var(--sn-stylekit-editor-foreground-color);
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
.CodeMirror-selected {
|
|
92
|
+
background: var(--sn-stylekit-info-color) !important;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
.CodeMirror-selectedtext {
|
|
96
|
+
color: var(--sn-stylekit-info-contrast-color) !important;
|
|
97
|
+
background: var(--sn-stylekit-info-color) !important;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
.CodeMirror-gutters {
|
|
101
|
+
background-color: var(--sn-stylekit-background-color) !important;
|
|
102
|
+
color: var(--sn-stylekit-editor-foreground-color) !important;
|
|
103
|
+
border-color: var(--sn-stylekit-border-color) !important;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
.cm-header-1 {
|
|
107
|
+
font-size: 150%;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
.cm-header-2 {
|
|
111
|
+
font-size: 130%;
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
.cm-header-3 {
|
|
115
|
+
font-size: 120%;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
.cm-header-4 {
|
|
119
|
+
font-size: 110%;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
.cm-header-5 {
|
|
123
|
+
font-size: 100%;
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
.cm-header-6 {
|
|
127
|
+
font-size: 90%;
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
.CodeMirror .cm-quote {
|
|
131
|
+
color: var(--sn-stylekit-foreground-color);
|
|
132
|
+
opacity: 0.6;
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
.cm-s-default .cm-variable-3, .cm-s-default .cm-type {
|
|
136
|
+
color: var(--sn-stylekit-success-color) !important;
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
.CodeMirror .cm-link, .CodeMirror .cm-string, .CodeMirror .cm-keyword {
|
|
140
|
+
color: var(--sn-stylekit-info-color);
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
/*# sourceMappingURL=app.css.map */
|
package/dist/app.css.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sourceRoot":"","sources":["../src/main.scss"],"names":[],"mappings":"AAAA;AAAA;EAEE;EACA;EACA;EACA;EACA;;;AAGF;EAEE;;;AAGF;EACE;EACA;EACA;EACA;EACA;;;AAIF;EACE;;;AAGF;EACE;EACA;EACA;EACA;EAEA;EAEA;EACA;EACA;EACA;EACA;;AAEA;EACE;EACA;EACA;EACA;;AAEA;EACE;EACA;;AAIJ;EACE;;AAEA;EACE;EACA;;AAKJ;AAAA;AAAA;EAGE;;AAGF;EACE;;AAEA;EACE;EACA;;AAGJ;EACE;;AAEA;EACE;EACA;;AAIJ;AAAA;EAEE;;AAEA;AAAA;EACE;EACA;;AAIJ;EACE;;;AAIJ;EACE;;;AAGF;EACE;;;AAGF;EACE;EACA;;;AAGF;EACE;EACA;EACA;;;AAGF;EACE;;;AAEF;EACE;;;AAEF;EACE;;;AAEF;EACE;;;AAEF;EACE;;;AAEF;EACE;;;AAGF;EACE;EACA;;;AAGF;EACE;;;AAGF;EACE","file":"app.css"}
|
package/dist/app.js
ADDED
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
(function(){function r(e,n,t){function o(i,f){if(!n[i]){if(!e[i]){var c="function"==typeof require&&require;if(!f&&c)return c(i,!0);if(u)return u(i,!0);var a=new Error("Cannot find module '"+i+"'");throw a.code="MODULE_NOT_FOUND",a}var p=n[i]={exports:{}};e[i][0].call(p.exports,function(r){var n=e[i][1][r];return o(n||r)},p,p.exports,r,e,n,t)}return n[i].exports}for(var u="function"==typeof require&&require,i=0;i<t.length;i++)o(t[i]);return o}return r})()({1:[function(require,module,exports){
|
|
2
|
+
"use strict";
|
|
3
|
+
|
|
4
|
+
document.addEventListener('DOMContentLoaded', function (event) {
|
|
5
|
+
var componentRelay;
|
|
6
|
+
var workingNote, clientData;
|
|
7
|
+
var lastValue, lastUUID;
|
|
8
|
+
var editor;
|
|
9
|
+
var ignoreTextChange = false;
|
|
10
|
+
var initialLoad = true;
|
|
11
|
+
|
|
12
|
+
function loadComponentRelay() {
|
|
13
|
+
var initialPermissions = [{
|
|
14
|
+
name: 'stream-context-item'
|
|
15
|
+
}];
|
|
16
|
+
componentRelay = new ComponentRelay({
|
|
17
|
+
initialPermissions: initialPermissions,
|
|
18
|
+
targetWindow: window,
|
|
19
|
+
onReady: function onReady() {
|
|
20
|
+
var platform = componentRelay.platform;
|
|
21
|
+
|
|
22
|
+
if (platform) {
|
|
23
|
+
document.body.classList.add(platform);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
loadEditor(); // only use CodeMirror selection color if we're not on mobile.
|
|
27
|
+
|
|
28
|
+
editor.setOption('styleSelectedText', !componentRelay.isMobile);
|
|
29
|
+
},
|
|
30
|
+
handleRequestForContentHeight: function handleRequestForContentHeight() {
|
|
31
|
+
return undefined;
|
|
32
|
+
}
|
|
33
|
+
});
|
|
34
|
+
componentRelay.streamContextItem(function (note) {
|
|
35
|
+
onReceivedNote(note);
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
function saveNote() {
|
|
40
|
+
if (workingNote) {
|
|
41
|
+
// Be sure to capture this object as a variable, as this.note may be reassigned in `streamContextItem`, so by the time
|
|
42
|
+
// you modify it in the presave block, it may not be the same object anymore, so the presave values will not be applied to
|
|
43
|
+
// the right object, and it will save incorrectly.
|
|
44
|
+
var note = workingNote;
|
|
45
|
+
componentRelay.saveItemWithPresave(note, function () {
|
|
46
|
+
lastValue = editor.getValue();
|
|
47
|
+
note.content.text = lastValue;
|
|
48
|
+
note.clientData = clientData; // clear previews
|
|
49
|
+
|
|
50
|
+
note.content.preview_plain = null;
|
|
51
|
+
note.content.preview_html = null;
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
function onReceivedNote(note) {
|
|
57
|
+
if (note.uuid !== lastUUID) {
|
|
58
|
+
// Note changed, reset last values
|
|
59
|
+
lastValue = null;
|
|
60
|
+
initialLoad = true;
|
|
61
|
+
lastUUID = note.uuid;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
workingNote = note; // Only update UI on non-metadata updates.
|
|
65
|
+
|
|
66
|
+
if (note.isMetadataUpdate) {
|
|
67
|
+
return;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
clientData = note.clientData;
|
|
71
|
+
|
|
72
|
+
if (editor) {
|
|
73
|
+
if (note.content.text !== lastValue) {
|
|
74
|
+
ignoreTextChange = true;
|
|
75
|
+
editor.getDoc().setValue(workingNote.content.text);
|
|
76
|
+
ignoreTextChange = false;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
if (initialLoad) {
|
|
80
|
+
initialLoad = false;
|
|
81
|
+
editor.getDoc().clearHistory();
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
editor.setOption('spellcheck', workingNote.content.spellcheck);
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
function loadEditor() {
|
|
89
|
+
editor = CodeMirror.fromTextArea(document.getElementById('code'), {
|
|
90
|
+
mode: 'gfm',
|
|
91
|
+
lineWrapping: true,
|
|
92
|
+
extraKeys: {
|
|
93
|
+
'Alt-F': 'findPersistent'
|
|
94
|
+
},
|
|
95
|
+
inputStyle: getInputStyleForEnvironment()
|
|
96
|
+
});
|
|
97
|
+
editor.setSize(undefined, '100%');
|
|
98
|
+
editor.on('change', function () {
|
|
99
|
+
if (ignoreTextChange) {
|
|
100
|
+
return;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
saveNote();
|
|
104
|
+
});
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
function getInputStyleForEnvironment() {
|
|
108
|
+
var _componentRelay$envir;
|
|
109
|
+
|
|
110
|
+
var environment = (_componentRelay$envir = componentRelay.environment) !== null && _componentRelay$envir !== void 0 ? _componentRelay$envir : 'web';
|
|
111
|
+
return environment === 'mobile' ? 'textarea' : 'contenteditable';
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
loadComponentRelay();
|
|
115
|
+
});
|
|
116
|
+
|
|
117
|
+
|
|
118
|
+
},{}]},{},[1]);
|
package/dist/app.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"app.js","names":["document","addEventListener","event","componentRelay","workingNote","clientData","lastValue","lastUUID","editor","ignoreTextChange","initialLoad","loadComponentRelay","initialPermissions","name","ComponentRelay","targetWindow","window","onReady","platform","body","classList","add","loadEditor","setOption","isMobile","handleRequestForContentHeight","undefined","streamContextItem","note","onReceivedNote","saveNote","saveItemWithPresave","getValue","content","text","preview_plain","preview_html","uuid","isMetadataUpdate","getDoc","setValue","clearHistory","spellcheck","CodeMirror","fromTextArea","getElementById","mode","lineWrapping","extraKeys","inputStyle","getInputStyleForEnvironment","setSize","on","environment"],"sources":["app.js"],"sourcesContent":["document.addEventListener('DOMContentLoaded', function (event) {\n let componentRelay\n let workingNote, clientData\n let lastValue, lastUUID\n let editor\n let ignoreTextChange = false\n let initialLoad = true\n\n function loadComponentRelay() {\n const initialPermissions = [{ name: 'stream-context-item' }]\n componentRelay = new ComponentRelay({\n initialPermissions,\n targetWindow: window,\n onReady: function () {\n const platform = componentRelay.platform\n if (platform) {\n document.body.classList.add(platform)\n }\n\n loadEditor()\n\n // only use CodeMirror selection color if we're not on mobile.\n editor.setOption('styleSelectedText', !componentRelay.isMobile)\n },\n handleRequestForContentHeight: () => {\n return undefined\n },\n })\n\n componentRelay.streamContextItem((note) => {\n onReceivedNote(note)\n })\n }\n\n function saveNote() {\n if (workingNote) {\n // Be sure to capture this object as a variable, as this.note may be reassigned in `streamContextItem`, so by the time\n // you modify it in the presave block, it may not be the same object anymore, so the presave values will not be applied to\n // the right object, and it will save incorrectly.\n let note = workingNote\n\n componentRelay.saveItemWithPresave(note, () => {\n lastValue = editor.getValue()\n note.content.text = lastValue\n note.clientData = clientData\n\n // clear previews\n note.content.preview_plain = null\n note.content.preview_html = null\n })\n }\n }\n\n function onReceivedNote(note) {\n if (note.uuid !== lastUUID) {\n // Note changed, reset last values\n lastValue = null\n initialLoad = true\n lastUUID = note.uuid\n }\n\n workingNote = note\n\n // Only update UI on non-metadata updates.\n if (note.isMetadataUpdate) {\n return\n }\n\n clientData = note.clientData\n\n if (editor) {\n if (note.content.text !== lastValue) {\n ignoreTextChange = true\n editor.getDoc().setValue(workingNote.content.text)\n ignoreTextChange = false\n }\n\n if (initialLoad) {\n initialLoad = false\n editor.getDoc().clearHistory()\n }\n\n editor.setOption('spellcheck', workingNote.content.spellcheck)\n }\n }\n\n function loadEditor() {\n editor = CodeMirror.fromTextArea(document.getElementById('code'), {\n mode: 'gfm',\n lineWrapping: true,\n extraKeys: { 'Alt-F': 'findPersistent' },\n inputStyle: getInputStyleForEnvironment(),\n })\n editor.setSize(undefined, '100%')\n\n editor.on('change', function () {\n if (ignoreTextChange) {\n return\n }\n saveNote()\n })\n }\n\n function getInputStyleForEnvironment() {\n const environment = componentRelay.environment ?? 'web'\n return environment === 'mobile' ? 'textarea' : 'contenteditable'\n }\n\n loadComponentRelay()\n})\n"],"mappings":";;AAAAA,QAAQ,CAACC,gBAAT,CAA0B,kBAA1B,EAA8C,UAAUC,KAAV,EAAiB;EAC7D,IAAIC,cAAJ;EACA,IA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