@standardnotes/markdown-visual 1.3.0 → 1.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/CHANGELOG.md +6 -0
- package/package.json +2 -2
- package/src/index.tsx +19 -11
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,12 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
## [1.3.1](https://github.com/standardnotes/plugins/compare/@standardnotes/markdown-visual@1.3.0...@standardnotes/markdown-visual@1.3.1) (2023-02-13)
|
|
7
|
+
|
|
8
|
+
### Bug Fixes
|
|
9
|
+
|
|
10
|
+
* markdown alternative width issue on mobile ([94a080a](https://github.com/standardnotes/plugins/commit/94a080a381e4e7c1acea95ebe7824e947ce3834b))
|
|
11
|
+
|
|
6
12
|
# [1.3.0](https://github.com/standardnotes/plugins/compare/@standardnotes/markdown-visual@1.2.3...@standardnotes/markdown-visual@1.3.0) (2023-01-20)
|
|
7
13
|
|
|
8
14
|
### Features
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@standardnotes/markdown-visual",
|
|
3
|
-
"version": "1.3.
|
|
3
|
+
"version": "1.3.1",
|
|
4
4
|
"author": "Standard Notes.",
|
|
5
5
|
"description": "A lightweight WYSIWYG markdown editor for Standard Notes, derived from Milkdown.",
|
|
6
6
|
"keywords": [
|
|
@@ -102,5 +102,5 @@
|
|
|
102
102
|
"prettier --write"
|
|
103
103
|
]
|
|
104
104
|
},
|
|
105
|
-
"gitHead": "
|
|
105
|
+
"gitHead": "088dd04552f474d9e0a61cb86f1d75f9d405906e"
|
|
106
106
|
}
|
package/src/index.tsx
CHANGED
|
@@ -20,6 +20,7 @@ enum TextChangeSource {
|
|
|
20
20
|
type AppProps = {}
|
|
21
21
|
type AppState = {
|
|
22
22
|
splitView: boolean
|
|
23
|
+
splitViewDirection: SplitViewDirection
|
|
23
24
|
editable: boolean
|
|
24
25
|
spellcheck: boolean
|
|
25
26
|
isLoading: boolean
|
|
@@ -37,14 +38,22 @@ class AppWrapper extends Component<AppProps, AppState> {
|
|
|
37
38
|
|
|
38
39
|
this.state = {
|
|
39
40
|
splitView: false,
|
|
41
|
+
splitViewDirection: this.getSplitViewDirection(),
|
|
40
42
|
editable: true,
|
|
41
43
|
spellcheck: true,
|
|
42
44
|
isLoading: true,
|
|
43
45
|
}
|
|
46
|
+
|
|
47
|
+
this.handleSplitViewDirectionChange = this.handleSplitViewDirectionChange.bind(this)
|
|
44
48
|
}
|
|
45
49
|
|
|
46
50
|
componentDidMount() {
|
|
47
51
|
this.configureEditorKit()
|
|
52
|
+
window.matchMedia('(max-width: 768px)').addEventListener('change', this.handleSplitViewDirectionChange)
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
componentWillUnmount(): void {
|
|
56
|
+
window.matchMedia('(max-width: 768px)').removeEventListener('change', this.handleSplitViewDirectionChange)
|
|
48
57
|
}
|
|
49
58
|
|
|
50
59
|
private configureEditorKit() {
|
|
@@ -146,13 +155,15 @@ class AppWrapper extends Component<AppProps, AppState> {
|
|
|
146
155
|
})
|
|
147
156
|
}
|
|
148
157
|
|
|
149
|
-
private getSplitViewDirection = (
|
|
150
|
-
const
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
158
|
+
private getSplitViewDirection = (): SplitViewDirection => {
|
|
159
|
+
const isMobile = window.innerWidth < 768
|
|
160
|
+
return isMobile ? SplitViewDirection.Vertical : SplitViewDirection.Horizontal
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
private handleSplitViewDirectionChange = (event: MediaQueryListEvent) => {
|
|
164
|
+
this.setState({
|
|
165
|
+
splitViewDirection: this.getSplitViewDirection(),
|
|
166
|
+
})
|
|
156
167
|
}
|
|
157
168
|
|
|
158
169
|
private truncateString(text: string, limit = 90) {
|
|
@@ -163,15 +174,12 @@ class AppWrapper extends Component<AppProps, AppState> {
|
|
|
163
174
|
}
|
|
164
175
|
|
|
165
176
|
render() {
|
|
166
|
-
const { splitView, editable, spellcheck, isLoading } = this.state
|
|
177
|
+
const { splitView, splitViewDirection, editable, spellcheck, isLoading } = this.state
|
|
167
178
|
|
|
168
179
|
if (isLoading) {
|
|
169
180
|
return null
|
|
170
181
|
}
|
|
171
182
|
|
|
172
|
-
const environment = this.editorKit?.environment ?? 'web'
|
|
173
|
-
const splitViewDirection = this.getSplitViewDirection(environment)
|
|
174
|
-
|
|
175
183
|
const customMenu: MenuConfig = [
|
|
176
184
|
...menuConfig,
|
|
177
185
|
[
|