@manuscripts/body-editor 1.13.4 → 1.13.6

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.
@@ -131,7 +131,7 @@ const AddKeywordInline = ({ viewProps, getUpdatedNode }) => {
131
131
  };
132
132
  const handleAddKeyword = () => {
133
133
  const keyword = (0, transform_1.buildKeyword)(newKeyword);
134
- if (!isExistingKeyword()) {
134
+ if (!isExistingKeyword() && isValidNewKeyword()) {
135
135
  const node = getUpdatedNode();
136
136
  const keywordNode = node.type.schema.nodes.keyword.create({
137
137
  id: keyword._id,
@@ -21,10 +21,12 @@ Object.defineProperty(exports, "__esModule", { value: true });
21
21
  const prosemirror_commands_1 = require("prosemirror-commands");
22
22
  const prosemirror_keymap_1 = require("prosemirror-keymap");
23
23
  const highlight_1 = __importDefault(require("./highlight"));
24
+ const keyword_1 = __importDefault(require("./keyword"));
24
25
  const list_1 = __importDefault(require("./list"));
25
26
  const misc_1 = __importDefault(require("./misc"));
26
27
  const title_1 = __importDefault(require("./title"));
27
28
  exports.default = [
29
+ (0, prosemirror_keymap_1.keymap)(keyword_1.default),
28
30
  (0, prosemirror_keymap_1.keymap)(list_1.default),
29
31
  (0, prosemirror_keymap_1.keymap)(misc_1.default),
30
32
  (0, prosemirror_keymap_1.keymap)(title_1.default),
@@ -0,0 +1,36 @@
1
+ "use strict";
2
+ /*!
3
+ * © 2019 Atypon Systems LLC
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License");
6
+ * you may not use this file except in compliance with the License.
7
+ * You may obtain a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS,
13
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ * See the License for the specific language governing permissions and
15
+ * limitations under the License.
16
+ */
17
+ Object.defineProperty(exports, "__esModule", { value: true });
18
+ const commands_1 = require("../commands");
19
+ const ignoreEnter = (state) => {
20
+ const { selection } = state;
21
+ if (!(0, commands_1.isTextSelection)(selection)) {
22
+ return false;
23
+ }
24
+ const { $from, $to } = selection;
25
+ const startNode = $from.node($from.depth);
26
+ const endNode = $to.node($to.depth);
27
+ if (startNode.type === state.schema.nodes.keyword ||
28
+ endNode.type === state.schema.nodes.keyword) {
29
+ return true;
30
+ }
31
+ return false;
32
+ };
33
+ const keywordKeymap = {
34
+ Enter: ignoreEnter,
35
+ };
36
+ exports.default = keywordKeymap;
@@ -102,7 +102,7 @@ export const AddKeywordInline = ({ viewProps, getUpdatedNode }) => {
102
102
  };
103
103
  const handleAddKeyword = () => {
104
104
  const keyword = buildKeyword(newKeyword);
105
- if (!isExistingKeyword()) {
105
+ if (!isExistingKeyword() && isValidNewKeyword()) {
106
106
  const node = getUpdatedNode();
107
107
  const keywordNode = node.type.schema.nodes.keyword.create({
108
108
  id: keyword._id,
@@ -16,10 +16,12 @@
16
16
  import { baseKeymap } from 'prosemirror-commands';
17
17
  import { keymap } from 'prosemirror-keymap';
18
18
  import highlightKeymap from './highlight';
19
+ import keywordKeymap from './keyword';
19
20
  import listKeymap from './list';
20
21
  import miscKeymap from './misc';
21
22
  import titleKeymap from './title';
22
23
  export default [
24
+ keymap(keywordKeymap),
23
25
  keymap(listKeymap),
24
26
  keymap(miscKeymap),
25
27
  keymap(titleKeymap),
@@ -0,0 +1,34 @@
1
+ /*!
2
+ * © 2019 Atypon Systems LLC
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+ import { isTextSelection } from '../commands';
17
+ const ignoreEnter = (state) => {
18
+ const { selection } = state;
19
+ if (!isTextSelection(selection)) {
20
+ return false;
21
+ }
22
+ const { $from, $to } = selection;
23
+ const startNode = $from.node($from.depth);
24
+ const endNode = $to.node($to.depth);
25
+ if (startNode.type === state.schema.nodes.keyword ||
26
+ endNode.type === state.schema.nodes.keyword) {
27
+ return true;
28
+ }
29
+ return false;
30
+ };
31
+ const keywordKeymap = {
32
+ Enter: ignoreEnter,
33
+ };
34
+ export default keywordKeymap;
@@ -0,0 +1,20 @@
1
+ /*!
2
+ * © 2019 Atypon Systems LLC
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+ import { EditorAction } from '../types';
17
+ declare const keywordKeymap: {
18
+ [key: string]: EditorAction;
19
+ };
20
+ export default keywordKeymap;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@manuscripts/body-editor",
3
3
  "description": "Prosemirror components for editing and viewing manuscripts",
4
- "version": "1.13.4",
4
+ "version": "1.13.6",
5
5
  "repository": "github:Atypon-OpenSource/manuscripts-body-editor",
6
6
  "license": "Apache-2.0",
7
7
  "main": "dist/cjs",
@@ -29,10 +29,10 @@
29
29
  "dependencies": {
30
30
  "@iarna/word-count": "^1.1.2",
31
31
  "@manuscripts/json-schema": "2.2.10",
32
- "@manuscripts/library": "1.3.9",
33
- "@manuscripts/style-guide": "1.13.1",
34
- "@manuscripts/track-changes-plugin": "1.7.13",
35
- "@manuscripts/transform": "2.3.10",
32
+ "@manuscripts/library": "1.3.10",
33
+ "@manuscripts/style-guide": "1.13.4",
34
+ "@manuscripts/track-changes-plugin": "1.7.14",
35
+ "@manuscripts/transform": "2.3.12",
36
36
  "astrocite-eutils": "^0.16.4",
37
37
  "mathjax-full": "^3.2.2",
38
38
  "codemirror": "^5.58.1",