roosterjs-content-model-plugins 0.21.0 → 0.21.2
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.
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.keyboardInput = void 0;
|
|
4
4
|
var roosterjs_content_model_core_1 = require("roosterjs-content-model-core");
|
|
5
|
+
var roosterjs_content_model_dom_1 = require("roosterjs-content-model-dom");
|
|
5
6
|
/**
|
|
6
7
|
* @internal
|
|
7
8
|
*/
|
|
@@ -20,6 +21,7 @@ function keyboardInput(editor, rawEvent) {
|
|
|
20
21
|
if (result.deleteResult == 'range') {
|
|
21
22
|
// We have deleted something, next input should inherit the segment format from deleted content, so set pending format here
|
|
22
23
|
context.newPendingFormat = (_a = result.insertPoint) === null || _a === void 0 ? void 0 : _a.marker.format;
|
|
24
|
+
(0, roosterjs_content_model_dom_1.normalizeContentModel)(model);
|
|
23
25
|
// Do not preventDefault since we still want browser to handle the final input for now
|
|
24
26
|
return true;
|
|
25
27
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"keyboardInput.js","sourceRoot":"","sources":["../../../../packages-content-model/roosterjs-content-model-plugins/lib/edit/keyboardInput.ts"],"names":[],"mappings":";;;AAAA,6EAA8E;
|
|
1
|
+
{"version":3,"file":"keyboardInput.js","sourceRoot":"","sources":["../../../../packages-content-model/roosterjs-content-model-plugins/lib/edit/keyboardInput.ts"],"names":[],"mappings":";;;AAAA,6EAA8E;AAC9E,2EAAoE;AAIpE;;GAEG;AACH,SAAgB,aAAa,CAAC,MAA2B,EAAE,QAAuB;IAC9E,IAAM,SAAS,GAAG,MAAM,CAAC,eAAe,EAAE,CAAC;IAE3C,IAAI,2BAA2B,CAAC,SAAS,EAAE,QAAQ,CAAC,EAAE;QAClD,MAAM,CAAC,eAAe,EAAE,CAAC;QAEzB,MAAM,CAAC,kBAAkB,CACrB,UAAC,KAAK,EAAE,OAAO;;YACX,IAAM,MAAM,GAAG,IAAA,8CAAe,EAAC,KAAK,EAAE,EAAE,EAAE,OAAO,CAAC,CAAC;YAEnD,0EAA0E;YAC1E,qFAAqF;YACrF,OAAO,CAAC,eAAe,GAAG,IAAI,CAAC;YAE/B,oJAAoJ;YACpJ,OAAO,CAAC,gBAAgB,GAAG,IAAI,CAAC;YAEhC,IAAI,MAAM,CAAC,YAAY,IAAI,OAAO,EAAE;gBAChC,2HAA2H;gBAC3H,OAAO,CAAC,gBAAgB,GAAG,MAAA,MAAM,CAAC,WAAW,0CAAE,MAAM,CAAC,MAAM,CAAC;gBAE7D,IAAA,mDAAqB,EAAC,KAAK,CAAC,CAAC;gBAE7B,sFAAsF;gBACtF,OAAO,IAAI,CAAC;aACf;iBAAM;gBACH,OAAO,KAAK,CAAC;aAChB;QACL,CAAC,EACD;YACI,QAAQ,UAAA;SACX,CACJ,CAAC;QAEF,OAAO,IAAI,CAAC;KACf;AACL,CAAC;AApCD,sCAoCC;AAED,SAAS,2BAA2B,CAAC,SAA8B,EAAE,QAAuB;IACxF,IAAI,CAAC,SAAS,EAAE;QACZ,OAAO,KAAK,CAAC,CAAC,oBAAoB;KACrC;SAAM,IACH,CAAC,IAAA,4CAAa,EAAC,QAAQ,CAAC;QACxB,CAAC,QAAQ,CAAC,GAAG,IAAI,OAAO,IAAI,QAAQ,CAAC,GAAG,IAAI,OAAO,IAAI,QAAQ,CAAC,GAAG,CAAC,MAAM,IAAI,CAAC,CAAC,EAClF;QACE,OAAO,SAAS,CAAC,IAAI,IAAI,OAAO,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC,0DAA0D;KAC7H;SAAM;QACH,OAAO,KAAK,CAAC;KAChB;AACL,CAAC","sourcesContent":["import { deleteSelection, isModifierKey } from 'roosterjs-content-model-core';\nimport { normalizeContentModel } from 'roosterjs-content-model-dom';\nimport type { IContentModelEditor } from 'roosterjs-content-model-editor';\nimport type { DOMSelection } from 'roosterjs-content-model-types';\n\n/**\n * @internal\n */\nexport function keyboardInput(editor: IContentModelEditor, rawEvent: KeyboardEvent) {\n const selection = editor.getDOMSelection();\n\n if (shouldInputWithContentModel(selection, rawEvent)) {\n editor.addUndoSnapshot();\n\n editor.formatContentModel(\n (model, context) => {\n const result = deleteSelection(model, [], context);\n\n // We have deleted selection then we will let browser to handle the input.\n // With this combined operation, we don't wan to mass up the cached model so clear it\n context.clearModelCache = true;\n\n // Skip undo snapshot here and add undo snapshot before the operation so that we don't add another undo snapshot in middle of this replace operation\n context.skipUndoSnapshot = true;\n\n if (result.deleteResult == 'range') {\n // We have deleted something, next input should inherit the segment format from deleted content, so set pending format here\n context.newPendingFormat = result.insertPoint?.marker.format;\n\n normalizeContentModel(model);\n\n // Do not preventDefault since we still want browser to handle the final input for now\n return true;\n } else {\n return false;\n }\n },\n {\n rawEvent,\n }\n );\n\n return true;\n }\n}\n\nfunction shouldInputWithContentModel(selection: DOMSelection | null, rawEvent: KeyboardEvent) {\n if (!selection) {\n return false; // Nothing to delete\n } else if (\n !isModifierKey(rawEvent) &&\n (rawEvent.key == 'Enter' || rawEvent.key == 'Space' || rawEvent.key.length == 1)\n ) {\n return selection.type != 'range' || !selection.range.collapsed; // TODO: Also handle Enter key even selection is collapsed\n } else {\n return false;\n }\n}\n"]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
define(["require", "exports", "roosterjs-content-model-core"], function (require, exports, roosterjs_content_model_core_1) {
|
|
1
|
+
define(["require", "exports", "roosterjs-content-model-core", "roosterjs-content-model-dom"], function (require, exports, roosterjs_content_model_core_1, roosterjs_content_model_dom_1) {
|
|
2
2
|
"use strict";
|
|
3
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
4
|
exports.keyboardInput = void 0;
|
|
@@ -20,6 +20,7 @@ define(["require", "exports", "roosterjs-content-model-core"], function (require
|
|
|
20
20
|
if (result.deleteResult == 'range') {
|
|
21
21
|
// We have deleted something, next input should inherit the segment format from deleted content, so set pending format here
|
|
22
22
|
context.newPendingFormat = (_a = result.insertPoint) === null || _a === void 0 ? void 0 : _a.marker.format;
|
|
23
|
+
(0, roosterjs_content_model_dom_1.normalizeContentModel)(model);
|
|
23
24
|
// Do not preventDefault since we still want browser to handle the final input for now
|
|
24
25
|
return true;
|
|
25
26
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"keyboardInput.js","sourceRoot":"","sources":["../../../../packages-content-model/roosterjs-content-model-plugins/lib/edit/keyboardInput.ts"],"names":[],"mappings":";;;;
|
|
1
|
+
{"version":3,"file":"keyboardInput.js","sourceRoot":"","sources":["../../../../packages-content-model/roosterjs-content-model-plugins/lib/edit/keyboardInput.ts"],"names":[],"mappings":";;;;IAKA;;OAEG;IACH,SAAgB,aAAa,CAAC,MAA2B,EAAE,QAAuB;QAC9E,IAAM,SAAS,GAAG,MAAM,CAAC,eAAe,EAAE,CAAC;QAE3C,IAAI,2BAA2B,CAAC,SAAS,EAAE,QAAQ,CAAC,EAAE;YAClD,MAAM,CAAC,eAAe,EAAE,CAAC;YAEzB,MAAM,CAAC,kBAAkB,CACrB,UAAC,KAAK,EAAE,OAAO;;gBACX,IAAM,MAAM,GAAG,IAAA,8CAAe,EAAC,KAAK,EAAE,EAAE,EAAE,OAAO,CAAC,CAAC;gBAEnD,0EAA0E;gBAC1E,qFAAqF;gBACrF,OAAO,CAAC,eAAe,GAAG,IAAI,CAAC;gBAE/B,oJAAoJ;gBACpJ,OAAO,CAAC,gBAAgB,GAAG,IAAI,CAAC;gBAEhC,IAAI,MAAM,CAAC,YAAY,IAAI,OAAO,EAAE;oBAChC,2HAA2H;oBAC3H,OAAO,CAAC,gBAAgB,GAAG,MAAA,MAAM,CAAC,WAAW,0CAAE,MAAM,CAAC,MAAM,CAAC;oBAE7D,IAAA,mDAAqB,EAAC,KAAK,CAAC,CAAC;oBAE7B,sFAAsF;oBACtF,OAAO,IAAI,CAAC;iBACf;qBAAM;oBACH,OAAO,KAAK,CAAC;iBAChB;YACL,CAAC,EACD;gBACI,QAAQ,UAAA;aACX,CACJ,CAAC;YAEF,OAAO,IAAI,CAAC;SACf;IACL,CAAC;IApCD,sCAoCC;IAED,SAAS,2BAA2B,CAAC,SAA8B,EAAE,QAAuB;QACxF,IAAI,CAAC,SAAS,EAAE;YACZ,OAAO,KAAK,CAAC,CAAC,oBAAoB;SACrC;aAAM,IACH,CAAC,IAAA,4CAAa,EAAC,QAAQ,CAAC;YACxB,CAAC,QAAQ,CAAC,GAAG,IAAI,OAAO,IAAI,QAAQ,CAAC,GAAG,IAAI,OAAO,IAAI,QAAQ,CAAC,GAAG,CAAC,MAAM,IAAI,CAAC,CAAC,EAClF;YACE,OAAO,SAAS,CAAC,IAAI,IAAI,OAAO,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC,0DAA0D;SAC7H;aAAM;YACH,OAAO,KAAK,CAAC;SAChB;IACL,CAAC","sourcesContent":["import { deleteSelection, isModifierKey } from 'roosterjs-content-model-core';\nimport { normalizeContentModel } from 'roosterjs-content-model-dom';\nimport type { IContentModelEditor } from 'roosterjs-content-model-editor';\nimport type { DOMSelection } from 'roosterjs-content-model-types';\n\n/**\n * @internal\n */\nexport function keyboardInput(editor: IContentModelEditor, rawEvent: KeyboardEvent) {\n const selection = editor.getDOMSelection();\n\n if (shouldInputWithContentModel(selection, rawEvent)) {\n editor.addUndoSnapshot();\n\n editor.formatContentModel(\n (model, context) => {\n const result = deleteSelection(model, [], context);\n\n // We have deleted selection then we will let browser to handle the input.\n // With this combined operation, we don't wan to mass up the cached model so clear it\n context.clearModelCache = true;\n\n // Skip undo snapshot here and add undo snapshot before the operation so that we don't add another undo snapshot in middle of this replace operation\n context.skipUndoSnapshot = true;\n\n if (result.deleteResult == 'range') {\n // We have deleted something, next input should inherit the segment format from deleted content, so set pending format here\n context.newPendingFormat = result.insertPoint?.marker.format;\n\n normalizeContentModel(model);\n\n // Do not preventDefault since we still want browser to handle the final input for now\n return true;\n } else {\n return false;\n }\n },\n {\n rawEvent,\n }\n );\n\n return true;\n }\n}\n\nfunction shouldInputWithContentModel(selection: DOMSelection | null, rawEvent: KeyboardEvent) {\n if (!selection) {\n return false; // Nothing to delete\n } else if (\n !isModifierKey(rawEvent) &&\n (rawEvent.key == 'Enter' || rawEvent.key == 'Space' || rawEvent.key.length == 1)\n ) {\n return selection.type != 'range' || !selection.range.collapsed; // TODO: Also handle Enter key even selection is collapsed\n } else {\n return false;\n }\n}\n"]}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { deleteSelection, isModifierKey } from 'roosterjs-content-model-core';
|
|
2
|
+
import { normalizeContentModel } from 'roosterjs-content-model-dom';
|
|
2
3
|
/**
|
|
3
4
|
* @internal
|
|
4
5
|
*/
|
|
@@ -17,6 +18,7 @@ export function keyboardInput(editor, rawEvent) {
|
|
|
17
18
|
if (result.deleteResult == 'range') {
|
|
18
19
|
// We have deleted something, next input should inherit the segment format from deleted content, so set pending format here
|
|
19
20
|
context.newPendingFormat = (_a = result.insertPoint) === null || _a === void 0 ? void 0 : _a.marker.format;
|
|
21
|
+
normalizeContentModel(model);
|
|
20
22
|
// Do not preventDefault since we still want browser to handle the final input for now
|
|
21
23
|
return true;
|
|
22
24
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"keyboardInput.js","sourceRoot":"","sources":["../../../../packages-content-model/roosterjs-content-model-plugins/lib/edit/keyboardInput.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,aAAa,EAAE,MAAM,8BAA8B,CAAC;
|
|
1
|
+
{"version":3,"file":"keyboardInput.js","sourceRoot":"","sources":["../../../../packages-content-model/roosterjs-content-model-plugins/lib/edit/keyboardInput.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,aAAa,EAAE,MAAM,8BAA8B,CAAC;AAC9E,OAAO,EAAE,qBAAqB,EAAE,MAAM,6BAA6B,CAAC;AAIpE;;GA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,CAAC,CAAC,0DAA0D;KAC7H;SAAM;QACH,OAAO,KAAK,CAAC;KAChB;AACL,CAAC","sourcesContent":["import { deleteSelection, isModifierKey } from 'roosterjs-content-model-core';\nimport { normalizeContentModel } from 'roosterjs-content-model-dom';\nimport type { IContentModelEditor } from 'roosterjs-content-model-editor';\nimport type { DOMSelection } from 'roosterjs-content-model-types';\n\n/**\n * @internal\n */\nexport function keyboardInput(editor: IContentModelEditor, rawEvent: KeyboardEvent) {\n const selection = editor.getDOMSelection();\n\n if (shouldInputWithContentModel(selection, rawEvent)) {\n editor.addUndoSnapshot();\n\n editor.formatContentModel(\n (model, context) => {\n const result = deleteSelection(model, [], context);\n\n // We have deleted selection then we will let browser to handle the input.\n // With this combined operation, we don't wan to mass up the cached model so clear it\n context.clearModelCache = true;\n\n // Skip undo snapshot here and add undo snapshot before the operation so that we don't add another undo snapshot in middle of this replace operation\n context.skipUndoSnapshot = true;\n\n if (result.deleteResult == 'range') {\n // We have deleted something, next input should inherit the segment format from deleted content, so set pending format here\n context.newPendingFormat = result.insertPoint?.marker.format;\n\n normalizeContentModel(model);\n\n // Do not preventDefault since we still want browser to handle the final input for now\n return true;\n } else {\n return false;\n }\n },\n {\n rawEvent,\n }\n );\n\n return true;\n }\n}\n\nfunction shouldInputWithContentModel(selection: DOMSelection | null, rawEvent: KeyboardEvent) {\n if (!selection) {\n return false; // Nothing to delete\n } else if (\n !isModifierKey(rawEvent) &&\n (rawEvent.key == 'Enter' || rawEvent.key == 'Space' || rawEvent.key.length == 1)\n ) {\n return selection.type != 'range' || !selection.range.collapsed; // TODO: Also handle Enter key even selection is collapsed\n } else {\n return false;\n }\n}\n"]}
|
package/package.json
CHANGED
|
@@ -5,12 +5,12 @@
|
|
|
5
5
|
"tslib": "^2.3.1",
|
|
6
6
|
"roosterjs-editor-types": "^8.59.0",
|
|
7
7
|
"roosterjs-editor-dom": "^8.59.0",
|
|
8
|
-
"roosterjs-content-model-core": "^0.21.
|
|
9
|
-
"roosterjs-content-model-editor": "^0.21.
|
|
10
|
-
"roosterjs-content-model-dom": "^0.21.
|
|
11
|
-
"roosterjs-content-model-types": "^0.21.
|
|
8
|
+
"roosterjs-content-model-core": "^0.21.2",
|
|
9
|
+
"roosterjs-content-model-editor": "^0.21.2",
|
|
10
|
+
"roosterjs-content-model-dom": "^0.21.2",
|
|
11
|
+
"roosterjs-content-model-types": "^0.21.2"
|
|
12
12
|
},
|
|
13
|
-
"version": "0.21.
|
|
13
|
+
"version": "0.21.2",
|
|
14
14
|
"main": "./lib/index.js",
|
|
15
15
|
"typings": "./lib/index.d.ts",
|
|
16
16
|
"module": "./lib-mjs/index.js",
|