roosterjs-content-model-plugins 9.30.0 → 9.32.0

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.
@@ -23,7 +23,7 @@ function keyboardEnter(editor, rawEvent, handleNormalEnter) {
23
23
  var steps = rawEvent.shiftKey
24
24
  ? []
25
25
  : [handleAutoLink_1.handleAutoLink, handleEnterOnList_1.handleEnterOnList, deleteEmptyQuote_1.deleteEmptyQuote];
26
- if (handleNormalEnter || hasEnterForEntity((_a = result.insertPoint) === null || _a === void 0 ? void 0 : _a.paragraph)) {
26
+ if (handleNormalEnter || handleEnterForEntity((_a = result.insertPoint) === null || _a === void 0 ? void 0 : _a.paragraph)) {
27
27
  steps.push(handleEnterOnParagraph_1.handleEnterOnParagraph);
28
28
  }
29
29
  (0, roosterjs_content_model_dom_1.runEditSteps)(steps, result);
@@ -47,8 +47,8 @@ function keyboardEnter(editor, rawEvent, handleNormalEnter) {
47
47
  });
48
48
  }
49
49
  exports.keyboardEnter = keyboardEnter;
50
- function hasEnterForEntity(paragraph) {
50
+ function handleEnterForEntity(paragraph) {
51
51
  return (paragraph &&
52
- (paragraph.isImplicit || paragraph.segments.some(function (x) { return x.segmentType == 'SelectionMarker'; })));
52
+ (paragraph.isImplicit || paragraph.segments.some(function (x) { return x.segmentType == 'Entity'; })));
53
53
  }
54
54
  //# sourceMappingURL=keyboardEnter.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"keyboardEnter.js","sourceRoot":"","sources":["../../../../packages/roosterjs-content-model-plugins/lib/edit/keyboardEnter.ts"],"names":[],"mappings":";;;AAAA,mEAAkE;AAClE,8DAA6D;AAC7D,oEAAmE;AACnE,8EAA6E;AAC7E,2EAKqC;AAGrC;;GAEG;AACH,SAAgB,aAAa,CACzB,MAAe,EACf,QAAuB,EACvB,iBAA0B;IAE1B,IAAM,SAAS,GAAG,MAAM,CAAC,eAAe,EAAE,CAAC;IAE3C,MAAM,CAAC,kBAAkB,CACrB,UA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AC,UAAU,IAAI,SAAS,CAAC,QAAQ,CAAC,IAAI,CAAC,UAAA,CAAC,IAAI,OAAA,CAAC,CAAC,WAAW,IAAI,iBAAiB,EAAlC,CAAkC,CAAC,CAAC,CAC7F,CAAC;AACN,CAAC","sourcesContent":["import { deleteEmptyQuote } from './deleteSteps/deleteEmptyQuote';\nimport { handleAutoLink } from './inputSteps/handleAutoLink';\nimport { handleEnterOnList } from './inputSteps/handleEnterOnList';\nimport { handleEnterOnParagraph } from './inputSteps/handleEnterOnParagraph';\nimport {\n ChangeSource,\n deleteSelection,\n normalizeContentModel,\n runEditSteps,\n} from 'roosterjs-content-model-dom';\nimport type { IEditor, ReadonlyContentModelParagraph } from 'roosterjs-content-model-types';\n\n/**\n * @internal\n */\nexport function keyboardEnter(\n editor: IEditor,\n rawEvent: KeyboardEvent,\n handleNormalEnter: boolean\n) {\n const selection = editor.getDOMSelection();\n\n editor.formatContentModel(\n (model, context) => {\n // 1. delete the expanded selection if any, then merge paragraph\n const result = deleteSelection(model, [], context);\n\n // 2. Add line break\n if (selection && selection.type != 'table') {\n // For ENTER key, although we may have deleted something, since we still need to split the line, we always treat it as not delete\n // so further delete steps can keep working\n result.deleteResult = 'notDeleted';\n\n const steps = rawEvent.shiftKey\n ? []\n : [handleAutoLink, handleEnterOnList, deleteEmptyQuote];\n\n if (handleNormalEnter || hasEnterForEntity(result.insertPoint?.paragraph)) {\n steps.push(handleEnterOnParagraph);\n }\n\n runEditSteps(steps, result);\n }\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 rawEvent.preventDefault();\n return true;\n } else {\n return false;\n }\n },\n {\n rawEvent,\n scrollCaretIntoView: true,\n changeSource: ChangeSource.Keyboard,\n getChangeData: () => rawEvent.which,\n apiName: 'handleEnterKey',\n }\n );\n}\n\nfunction hasEnterForEntity(paragraph: ReadonlyContentModelParagraph | undefined) {\n return (\n paragraph &&\n (paragraph.isImplicit || paragraph.segments.some(x => x.segmentType == 'SelectionMarker'))\n );\n}\n"]}
1
+ {"version":3,"file":"keyboardEnter.js","sourceRoot":"","sources":["../../../../packages/roosterjs-content-model-plugins/lib/edit/keyboardEnter.ts"],"names":[],"mappings":";;;AAAA,mEAAkE;AAClE,8DAA6D;AAC7D,oEAAmE;AACnE,8EAA6E;AAC7E,2EAKqC;AAGrC;;GAEG;AACH,SAAgB,aAAa,CACzB,MAAe,EACf,QAAuB,EACvB,iBAA0B;IAE1B,IAAM,SAAS,GAAG,MAAM,CAAC,eAAe,EAAE,CAAC;IAE3C,MAAM,CAAC,kBAAkB,CACrB,UAAC,KAAK,EAAE,OAAO;;QACX,gEAAgE;QAChE,IAAM,MAAM,GAAG,IAAA,6CAAe,EAAC,KAAK,EAAE,EAAE,EAAE,OAAO,CAAC,CAAC;QAEnD,oBAAoB;QACpB,IAAI,SAAS,IAAI,SAAS,CAAC,IAAI,IAAI,OAAO,EAAE;YACxC,iIAAiI;YACjI,2CAA2C;YAC3C,MAAM,CAAC,YAAY,GAAG,YAAY,CAAC;YAEnC,IAAM,KAAK,GAAG,QAAQ,CAAC,QAAQ;gBAC3B,CAAC,CAAC,EAAE;gBACJ,CAAC,CAAC,CAAC,+BAAc,EAAE,qCAAiB,EAAE,mCAAgB,CAAC,CAAC;YAE5D,IAAI,iBAAiB,IAAI,oBAAoB,CAAC,MAAA,MAAM,CAAC,WAAW,0CAAE,SAAS,CAAC,EAAE;gBAC1E,KAAK,CAAC,IAAI,CAAC,+CAAsB,CAAC,CAAC;aACtC;YAED,IAAA,0CAAY,EAAC,KAAK,EAAE,MAAM,CAAC,CAAC;SAC/B;QAED,IAAI,MAAM,CAAC,YAAY,IAAI,OAAO,EAAE;YAChC,2HAA2H;YAC3H,OAAO,CAAC,gBAAgB,GAAG,MAAA,MAAM,CAAC,WAAW,0CAAE,MAAM,CAAC,MAAM,CAAC;YAE7D,IAAA,mDAAqB,EAAC,KAAK,CAAC,CAAC;YAE7B,QAAQ,CAAC,cAAc,EAAE,CAAC;YAC1B,OAAO,IAAI,CAAC;SACf;aAAM;YACH,OAAO,KAAK,CAAC;SAChB;IACL,CAAC,EACD;QACI,QAAQ,UAAA;QACR,mBAAmB,EAAE,IAAI;QACzB,YAAY,EAAE,0CAAY,CAAC,QAAQ;QACnC,aAAa,EAAE,cAAM,OAAA,QAAQ,CAAC,KAAK,EAAd,CAAc;QACnC,OAAO,EAAE,gBAAgB;KAC5B,CACJ,CAAC;AACN,CAAC;AAjDD,sCAiDC;AAED,SAAS,oBAAoB,CAAC,SAAoD;IAC9E,OAAO,CACH,SAAS;QACT,CAAC,SAAS,CAAC,UAAU,IAAI,SAAS,CAAC,QAAQ,CAAC,IAAI,CAAC,UAAA,CAAC,IAAI,OAAA,CAAC,CAAC,WAAW,IAAI,QAAQ,EAAzB,CAAyB,CAAC,CAAC,CACpF,CAAC;AACN,CAAC","sourcesContent":["import { deleteEmptyQuote } from './deleteSteps/deleteEmptyQuote';\nimport { handleAutoLink } from './inputSteps/handleAutoLink';\nimport { handleEnterOnList } from './inputSteps/handleEnterOnList';\nimport { handleEnterOnParagraph } from './inputSteps/handleEnterOnParagraph';\nimport {\n ChangeSource,\n deleteSelection,\n normalizeContentModel,\n runEditSteps,\n} from 'roosterjs-content-model-dom';\nimport type { IEditor, ReadonlyContentModelParagraph } from 'roosterjs-content-model-types';\n\n/**\n * @internal\n */\nexport function keyboardEnter(\n editor: IEditor,\n rawEvent: KeyboardEvent,\n handleNormalEnter: boolean\n) {\n const selection = editor.getDOMSelection();\n\n editor.formatContentModel(\n (model, context) => {\n // 1. delete the expanded selection if any, then merge paragraph\n const result = deleteSelection(model, [], context);\n\n // 2. Add line break\n if (selection && selection.type != 'table') {\n // For ENTER key, although we may have deleted something, since we still need to split the line, we always treat it as not delete\n // so further delete steps can keep working\n result.deleteResult = 'notDeleted';\n\n const steps = rawEvent.shiftKey\n ? []\n : [handleAutoLink, handleEnterOnList, deleteEmptyQuote];\n\n if (handleNormalEnter || handleEnterForEntity(result.insertPoint?.paragraph)) {\n steps.push(handleEnterOnParagraph);\n }\n\n runEditSteps(steps, result);\n }\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 rawEvent.preventDefault();\n return true;\n } else {\n return false;\n }\n },\n {\n rawEvent,\n scrollCaretIntoView: true,\n changeSource: ChangeSource.Keyboard,\n getChangeData: () => rawEvent.which,\n apiName: 'handleEnterKey',\n }\n );\n}\n\nfunction handleEnterForEntity(paragraph: ReadonlyContentModelParagraph | undefined) {\n return (\n paragraph &&\n (paragraph.isImplicit || paragraph.segments.some(x => x.segmentType == 'Entity'))\n );\n}\n"]}
@@ -19,7 +19,7 @@ define(["require", "exports", "./deleteSteps/deleteEmptyQuote", "./inputSteps/ha
19
19
  var steps = rawEvent.shiftKey
20
20
  ? []
21
21
  : [handleAutoLink_1.handleAutoLink, handleEnterOnList_1.handleEnterOnList, deleteEmptyQuote_1.deleteEmptyQuote];
22
- if (handleNormalEnter || hasEnterForEntity((_a = result.insertPoint) === null || _a === void 0 ? void 0 : _a.paragraph)) {
22
+ if (handleNormalEnter || handleEnterForEntity((_a = result.insertPoint) === null || _a === void 0 ? void 0 : _a.paragraph)) {
23
23
  steps.push(handleEnterOnParagraph_1.handleEnterOnParagraph);
24
24
  }
25
25
  (0, roosterjs_content_model_dom_1.runEditSteps)(steps, result);
@@ -43,9 +43,9 @@ define(["require", "exports", "./deleteSteps/deleteEmptyQuote", "./inputSteps/ha
43
43
  });
44
44
  }
45
45
  exports.keyboardEnter = keyboardEnter;
46
- function hasEnterForEntity(paragraph) {
46
+ function handleEnterForEntity(paragraph) {
47
47
  return (paragraph &&
48
- (paragraph.isImplicit || paragraph.segments.some(function (x) { return x.segmentType == 'SelectionMarker'; })));
48
+ (paragraph.isImplicit || paragraph.segments.some(function (x) { return x.segmentType == 'Entity'; })));
49
49
  }
50
50
  });
51
51
  //# sourceMappingURL=keyboardEnter.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"keyboardEnter.js","sourceRoot":"","sources":["../../../../packages/roosterjs-content-model-plugins/lib/edit/keyboardEnter.ts"],"names":[],"mappings":";;;;IAYA;;OAEG;IACH,SAAgB,aAAa,CACzB,MAAe,EACf,QAAuB,EACvB,iBAA0B;QAE1B,IAAM,SAAS,GAAG,MAAM,CAAC,eAAe,EAAE,CAAC;QAE3C,MAAM,CAAC,kBAAkB,CACrB,UAAC,KAAK,EAAE,OAAO;;YACX,gEAAgE;YAChE,IAAM,MAAM,GAAG,IAAA,6CAAe,EAAC,KAAK,EAAE,EAAE,EAAE,OAAO,CAAC,CAAC;YAEnD,oBAAoB;YACpB,IAAI,SAAS,IAAI,SAAS,CAAC,IAAI,IAAI,OAAO,EAAE;gBACxC,iIAAiI;gBACjI,2CAA2C;gBAC3C,MAAM,CAAC,YAAY,GAAG,YAAY,CAAC;gBAEnC,IAAM,KAAK,GAAG,QAAQ,CAAC,QAAQ;oBAC3B,CAAC,CAAC,EAAE;oBACJ,CAAC,CAAC,CAAC,+BAAc,EAAE,qCAAiB,EAAE,mCAAgB,CAAC,CAAC;gBAE5D,IAAI,iBAAiB,IAAI,iBAAiB,CAAC,MAAA,MAAM,CAAC,WAAW,0CAAE,SAAS,CAAC,EAAE;oBACvE,KAAK,CAAC,IAAI,CAAC,+CAAsB,CAAC,CAAC;iBACtC;gBAED,IAAA,0CAAY,EAAC,KAAK,EAAE,MAAM,CAAC,CAAC;aAC/B;YAED,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,QAAQ,CAAC,cAAc,EAAE,CAAC;gBAC1B,OAAO,IAAI,CAAC;aACf;iBAAM;gBACH,OAAO,KAAK,CAAC;aAChB;QACL,CAAC,EACD;YACI,QAAQ,UAAA;YACR,mBAAmB,EAAE,IAAI;YACzB,YAAY,EAAE,0CAAY,CAAC,QAAQ;YACnC,aAAa,EAAE,cAAM,OAAA,QAAQ,CAAC,KAAK,EAAd,CAAc;YACnC,OAAO,EAAE,gBAAgB;SAC5B,CACJ,CAAC;IACN,CAAC;IAjDD,sCAiDC;IAED,SAAS,iBAAiB,CAAC,SAAoD;QAC3E,OAAO,CACH,SAAS;YACT,CAAC,SAAS,CAAC,UAAU,IAAI,SAAS,CAAC,QAAQ,CAAC,IAAI,CAAC,UAAA,CAAC,IAAI,OAAA,CAAC,CAAC,WAAW,IAAI,iBAAiB,EAAlC,CAAkC,CAAC,CAAC,CAC7F,CAAC;IACN,CAAC","sourcesContent":["import { deleteEmptyQuote } from './deleteSteps/deleteEmptyQuote';\nimport { handleAutoLink } from './inputSteps/handleAutoLink';\nimport { handleEnterOnList } from './inputSteps/handleEnterOnList';\nimport { handleEnterOnParagraph } from './inputSteps/handleEnterOnParagraph';\nimport {\n ChangeSource,\n deleteSelection,\n normalizeContentModel,\n runEditSteps,\n} from 'roosterjs-content-model-dom';\nimport type { IEditor, ReadonlyContentModelParagraph } from 'roosterjs-content-model-types';\n\n/**\n * @internal\n */\nexport function keyboardEnter(\n editor: IEditor,\n rawEvent: KeyboardEvent,\n handleNormalEnter: boolean\n) {\n const selection = editor.getDOMSelection();\n\n editor.formatContentModel(\n (model, context) => {\n // 1. delete the expanded selection if any, then merge paragraph\n const result = deleteSelection(model, [], context);\n\n // 2. Add line break\n if (selection && selection.type != 'table') {\n // For ENTER key, although we may have deleted something, since we still need to split the line, we always treat it as not delete\n // so further delete steps can keep working\n result.deleteResult = 'notDeleted';\n\n const steps = rawEvent.shiftKey\n ? []\n : [handleAutoLink, handleEnterOnList, deleteEmptyQuote];\n\n if (handleNormalEnter || hasEnterForEntity(result.insertPoint?.paragraph)) {\n steps.push(handleEnterOnParagraph);\n }\n\n runEditSteps(steps, result);\n }\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 rawEvent.preventDefault();\n return true;\n } else {\n return false;\n }\n },\n {\n rawEvent,\n scrollCaretIntoView: true,\n changeSource: ChangeSource.Keyboard,\n getChangeData: () => rawEvent.which,\n apiName: 'handleEnterKey',\n }\n );\n}\n\nfunction hasEnterForEntity(paragraph: ReadonlyContentModelParagraph | undefined) {\n return (\n paragraph &&\n (paragraph.isImplicit || paragraph.segments.some(x => x.segmentType == 'SelectionMarker'))\n );\n}\n"]}
1
+ {"version":3,"file":"keyboardEnter.js","sourceRoot":"","sources":["../../../../packages/roosterjs-content-model-plugins/lib/edit/keyboardEnter.ts"],"names":[],"mappings":";;;;IAYA;;OAEG;IACH,SAAgB,aAAa,CACzB,MAAe,EACf,QAAuB,EACvB,iBAA0B;QAE1B,IAAM,SAAS,GAAG,MAAM,CAAC,eAAe,EAAE,CAAC;QAE3C,MAAM,CAAC,kBAAkB,CACrB,UAAC,KAAK,EAAE,OAAO;;YACX,gEAAgE;YAChE,IAAM,MAAM,GAAG,IAAA,6CAAe,EAAC,KAAK,EAAE,EAAE,EAAE,OAAO,CAAC,CAAC;YAEnD,oBAAoB;YACpB,IAAI,SAAS,IAAI,SAAS,CAAC,IAAI,IAAI,OAAO,EAAE;gBACxC,iIAAiI;gBACjI,2CAA2C;gBAC3C,MAAM,CAAC,YAAY,GAAG,YAAY,CAAC;gBAEnC,IAAM,KAAK,GAAG,QAAQ,CAAC,QAAQ;oBAC3B,CAAC,CAAC,EAAE;oBACJ,CAAC,CAAC,CAAC,+BAAc,EAAE,qCAAiB,EAAE,mCAAgB,CAAC,CAAC;gBAE5D,IAAI,iBAAiB,IAAI,oBAAoB,CAAC,MAAA,MAAM,CAAC,WAAW,0CAAE,SAAS,CAAC,EAAE;oBAC1E,KAAK,CAAC,IAAI,CAAC,+CAAsB,CAAC,CAAC;iBACtC;gBAED,IAAA,0CAAY,EAAC,KAAK,EAAE,MAAM,CAAC,CAAC;aAC/B;YAED,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,QAAQ,CAAC,cAAc,EAAE,CAAC;gBAC1B,OAAO,IAAI,CAAC;aACf;iBAAM;gBACH,OAAO,KAAK,CAAC;aAChB;QACL,CAAC,EACD;YACI,QAAQ,UAAA;YACR,mBAAmB,EAAE,IAAI;YACzB,YAAY,EAAE,0CAAY,CAAC,QAAQ;YACnC,aAAa,EAAE,cAAM,OAAA,QAAQ,CAAC,KAAK,EAAd,CAAc;YACnC,OAAO,EAAE,gBAAgB;SAC5B,CACJ,CAAC;IACN,CAAC;IAjDD,sCAiDC;IAED,SAAS,oBAAoB,CAAC,SAAoD;QAC9E,OAAO,CACH,SAAS;YACT,CAAC,SAAS,CAAC,UAAU,IAAI,SAAS,CAAC,QAAQ,CAAC,IAAI,CAAC,UAAA,CAAC,IAAI,OAAA,CAAC,CAAC,WAAW,IAAI,QAAQ,EAAzB,CAAyB,CAAC,CAAC,CACpF,CAAC;IACN,CAAC","sourcesContent":["import { deleteEmptyQuote } from './deleteSteps/deleteEmptyQuote';\nimport { handleAutoLink } from './inputSteps/handleAutoLink';\nimport { handleEnterOnList } from './inputSteps/handleEnterOnList';\nimport { handleEnterOnParagraph } from './inputSteps/handleEnterOnParagraph';\nimport {\n ChangeSource,\n deleteSelection,\n normalizeContentModel,\n runEditSteps,\n} from 'roosterjs-content-model-dom';\nimport type { IEditor, ReadonlyContentModelParagraph } from 'roosterjs-content-model-types';\n\n/**\n * @internal\n */\nexport function keyboardEnter(\n editor: IEditor,\n rawEvent: KeyboardEvent,\n handleNormalEnter: boolean\n) {\n const selection = editor.getDOMSelection();\n\n editor.formatContentModel(\n (model, context) => {\n // 1. delete the expanded selection if any, then merge paragraph\n const result = deleteSelection(model, [], context);\n\n // 2. Add line break\n if (selection && selection.type != 'table') {\n // For ENTER key, although we may have deleted something, since we still need to split the line, we always treat it as not delete\n // so further delete steps can keep working\n result.deleteResult = 'notDeleted';\n\n const steps = rawEvent.shiftKey\n ? []\n : [handleAutoLink, handleEnterOnList, deleteEmptyQuote];\n\n if (handleNormalEnter || handleEnterForEntity(result.insertPoint?.paragraph)) {\n steps.push(handleEnterOnParagraph);\n }\n\n runEditSteps(steps, result);\n }\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 rawEvent.preventDefault();\n return true;\n } else {\n return false;\n }\n },\n {\n rawEvent,\n scrollCaretIntoView: true,\n changeSource: ChangeSource.Keyboard,\n getChangeData: () => rawEvent.which,\n apiName: 'handleEnterKey',\n }\n );\n}\n\nfunction handleEnterForEntity(paragraph: ReadonlyContentModelParagraph | undefined) {\n return (\n paragraph &&\n (paragraph.isImplicit || paragraph.segments.some(x => x.segmentType == 'Entity'))\n );\n}\n"]}
@@ -20,7 +20,7 @@ export function keyboardEnter(editor, rawEvent, handleNormalEnter) {
20
20
  var steps = rawEvent.shiftKey
21
21
  ? []
22
22
  : [handleAutoLink, handleEnterOnList, deleteEmptyQuote];
23
- if (handleNormalEnter || hasEnterForEntity((_a = result.insertPoint) === null || _a === void 0 ? void 0 : _a.paragraph)) {
23
+ if (handleNormalEnter || handleEnterForEntity((_a = result.insertPoint) === null || _a === void 0 ? void 0 : _a.paragraph)) {
24
24
  steps.push(handleEnterOnParagraph);
25
25
  }
26
26
  runEditSteps(steps, result);
@@ -43,8 +43,8 @@ export function keyboardEnter(editor, rawEvent, handleNormalEnter) {
43
43
  apiName: 'handleEnterKey',
44
44
  });
45
45
  }
46
- function hasEnterForEntity(paragraph) {
46
+ function handleEnterForEntity(paragraph) {
47
47
  return (paragraph &&
48
- (paragraph.isImplicit || paragraph.segments.some(function (x) { return x.segmentType == 'SelectionMarker'; })));
48
+ (paragraph.isImplicit || paragraph.segments.some(function (x) { return x.segmentType == 'Entity'; })));
49
49
  }
50
50
  //# sourceMappingURL=keyboardEnter.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"keyboardEnter.js","sourceRoot":"","sources":["../../../../packages/roosterjs-content-model-plugins/lib/edit/keyboardEnter.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,gCAAgC,CAAC;AAClE,OAAO,EAAE,cAAc,EAAE,MAAM,6BAA6B,CAAC;AAC7D,OAAO,EAAE,iBAAiB,EAAE,MAAM,gCAAgC,CAAC;AACnE,OAAO,EAAE,sBAAsB,EAAE,MAAM,qCAAqC,CAAC;AAC7E,OAAO,EACH,YAAY,EACZ,eAAe,EACf,qBAAqB,EACrB,YAAY,GACf,MAAM,6BAA6B,CAAC;AAGrC;;GAEG;AACH,MAAM,UAAU,aAAa,CACzB,MAAe,EACf,QAAuB,EACvB,iBAA0B;IAE1B,IAAM,SAAS,GAAG,MAAM,CAAC,eAAe,EAAE,CAAC;IAE3C,MAAM,CAAC,kBAAkB,CACrB,UAAC,KAAK,EAAE,OAAO;;QACX,gEAAgE;QAChE,IAAM,MAAM,GAAG,eAAe,CAAC,KAAK,EAAE,EAAE,EAAE,OAAO,CAAC,CAAC;QAEnD,oBAAoB;QACpB,IAAI,SAAS,IAAI,SAAS,CAAC,IAAI,IAAI,OAAO,EAAE;YACxC,iIAAiI;YACjI,2CAA2C;YAC3C,MAAM,CAAC,YAAY,GAAG,YAAY,CAAC;YAEnC,IAAM,KAAK,GAAG,QAAQ,CAAC,QAAQ;gBAC3B,CAAC,CAAC,EAAE;gBACJ,CAAC,CAAC,CAAC,cAAc,EAAE,iBAAiB,EAAE,gBAAgB,CAAC,CAAC;YAE5D,IAAI,iBAAiB,IAAI,iBAAiB,CAAC,MAAA,MAAM,CAAC,WAAW,0CAAE,SAAS,CAAC,EAAE;gBACvE,KAAK,CAAC,IAAI,CAAC,sBAAsB,CAAC,CAAC;aACtC;YAED,YAAY,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC;SAC/B;QAED,IAAI,MAAM,CAAC,YAAY,IAAI,OAAO,EAAE;YAChC,2HAA2H;YAC3H,OAAO,CAAC,gBAAgB,GAAG,MAAA,MAAM,CAAC,WAAW,0CAAE,MAAM,CAAC,MAAM,CAAC;YAE7D,qBAAqB,CAAC,KAAK,CAAC,CAAC;YAE7B,QAAQ,CAAC,cAAc,EAAE,CAAC;YAC1B,OAAO,IAAI,CAAC;SACf;aAAM;YACH,OAAO,KAAK,CAAC;SAChB;IACL,CAAC,EACD;QACI,QAAQ,UAAA;QACR,mBAAmB,EAAE,IAAI;QACzB,YAAY,EAAE,YAAY,CAAC,QAAQ;QACnC,aAAa,EAAE,cAAM,OAAA,QAAQ,CAAC,KAAK,EAAd,CAAc;QACnC,OAAO,EAAE,gBAAgB;KAC5B,CACJ,CAAC;AACN,CAAC;AAED,SAAS,iBAAiB,CAAC,SAAoD;IAC3E,OAAO,CACH,SAAS;QACT,CAAC,SAAS,CAAC,UAAU,IAAI,SAAS,CAAC,QAAQ,CAAC,IAAI,CAAC,UAAA,CAAC,IAAI,OAAA,CAAC,CAAC,WAAW,IAAI,iBAAiB,EAAlC,CAAkC,CAAC,CAAC,CAC7F,CAAC;AACN,CAAC","sourcesContent":["import { deleteEmptyQuote } from './deleteSteps/deleteEmptyQuote';\nimport { handleAutoLink } from './inputSteps/handleAutoLink';\nimport { handleEnterOnList } from './inputSteps/handleEnterOnList';\nimport { handleEnterOnParagraph } from './inputSteps/handleEnterOnParagraph';\nimport {\n ChangeSource,\n deleteSelection,\n normalizeContentModel,\n runEditSteps,\n} from 'roosterjs-content-model-dom';\nimport type { IEditor, ReadonlyContentModelParagraph } from 'roosterjs-content-model-types';\n\n/**\n * @internal\n */\nexport function keyboardEnter(\n editor: IEditor,\n rawEvent: KeyboardEvent,\n handleNormalEnter: boolean\n) {\n const selection = editor.getDOMSelection();\n\n editor.formatContentModel(\n (model, context) => {\n // 1. delete the expanded selection if any, then merge paragraph\n const result = deleteSelection(model, [], context);\n\n // 2. Add line break\n if (selection && selection.type != 'table') {\n // For ENTER key, although we may have deleted something, since we still need to split the line, we always treat it as not delete\n // so further delete steps can keep working\n result.deleteResult = 'notDeleted';\n\n const steps = rawEvent.shiftKey\n ? []\n : [handleAutoLink, handleEnterOnList, deleteEmptyQuote];\n\n if (handleNormalEnter || hasEnterForEntity(result.insertPoint?.paragraph)) {\n steps.push(handleEnterOnParagraph);\n }\n\n runEditSteps(steps, result);\n }\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 rawEvent.preventDefault();\n return true;\n } else {\n return false;\n }\n },\n {\n rawEvent,\n scrollCaretIntoView: true,\n changeSource: ChangeSource.Keyboard,\n getChangeData: () => rawEvent.which,\n apiName: 'handleEnterKey',\n }\n );\n}\n\nfunction hasEnterForEntity(paragraph: ReadonlyContentModelParagraph | undefined) {\n return (\n paragraph &&\n (paragraph.isImplicit || paragraph.segments.some(x => x.segmentType == 'SelectionMarker'))\n );\n}\n"]}
1
+ {"version":3,"file":"keyboardEnter.js","sourceRoot":"","sources":["../../../../packages/roosterjs-content-model-plugins/lib/edit/keyboardEnter.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,gCAAgC,CAAC;AAClE,OAAO,EAAE,cAAc,EAAE,MAAM,6BAA6B,CAAC;AAC7D,OAAO,EAAE,iBAAiB,EAAE,MAAM,gCAAgC,CAAC;AACnE,OAAO,EAAE,sBAAsB,EAAE,MAAM,qCAAqC,CAAC;AAC7E,OAAO,EACH,YAAY,EACZ,eAAe,EACf,qB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AM,OAAA,QAAQ,CAAC,KAAK,EAAd,CAAc;QACnC,OAAO,EAAE,gBAAgB;KAC5B,CACJ,CAAC;AACN,CAAC;AAED,SAAS,oBAAoB,CAAC,SAAoD;IAC9E,OAAO,CACH,SAAS;QACT,CAAC,SAAS,CAAC,UAAU,IAAI,SAAS,CAAC,QAAQ,CAAC,IAAI,CAAC,UAAA,CAAC,IAAI,OAAA,CAAC,CAAC,WAAW,IAAI,QAAQ,EAAzB,CAAyB,CAAC,CAAC,CACpF,CAAC;AACN,CAAC","sourcesContent":["import { deleteEmptyQuote } from './deleteSteps/deleteEmptyQuote';\nimport { handleAutoLink } from './inputSteps/handleAutoLink';\nimport { handleEnterOnList } from './inputSteps/handleEnterOnList';\nimport { handleEnterOnParagraph } from './inputSteps/handleEnterOnParagraph';\nimport {\n ChangeSource,\n deleteSelection,\n normalizeContentModel,\n runEditSteps,\n} from 'roosterjs-content-model-dom';\nimport type { IEditor, ReadonlyContentModelParagraph } from 'roosterjs-content-model-types';\n\n/**\n * @internal\n */\nexport function keyboardEnter(\n editor: IEditor,\n rawEvent: KeyboardEvent,\n handleNormalEnter: boolean\n) {\n const selection = editor.getDOMSelection();\n\n editor.formatContentModel(\n (model, context) => {\n // 1. delete the expanded selection if any, then merge paragraph\n const result = deleteSelection(model, [], context);\n\n // 2. Add line break\n if (selection && selection.type != 'table') {\n // For ENTER key, although we may have deleted something, since we still need to split the line, we always treat it as not delete\n // so further delete steps can keep working\n result.deleteResult = 'notDeleted';\n\n const steps = rawEvent.shiftKey\n ? []\n : [handleAutoLink, handleEnterOnList, deleteEmptyQuote];\n\n if (handleNormalEnter || handleEnterForEntity(result.insertPoint?.paragraph)) {\n steps.push(handleEnterOnParagraph);\n }\n\n runEditSteps(steps, result);\n }\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 rawEvent.preventDefault();\n return true;\n } else {\n return false;\n }\n },\n {\n rawEvent,\n scrollCaretIntoView: true,\n changeSource: ChangeSource.Keyboard,\n getChangeData: () => rawEvent.which,\n apiName: 'handleEnterKey',\n }\n );\n}\n\nfunction handleEnterForEntity(paragraph: ReadonlyContentModelParagraph | undefined) {\n return (\n paragraph &&\n (paragraph.isImplicit || paragraph.segments.some(x => x.segmentType == 'Entity'))\n );\n}\n"]}
package/package.json CHANGED
@@ -3,12 +3,12 @@
3
3
  "description": "Plugins for roosterjs",
4
4
  "dependencies": {
5
5
  "tslib": "^2.3.1",
6
- "roosterjs-content-model-core": "^9.30.0",
7
- "roosterjs-content-model-dom": "^9.30.0",
8
- "roosterjs-content-model-types": "^9.30.0",
9
- "roosterjs-content-model-api": "^9.30.0"
6
+ "roosterjs-content-model-core": "^9.32.0",
7
+ "roosterjs-content-model-dom": "^9.32.0",
8
+ "roosterjs-content-model-types": "^9.32.0",
9
+ "roosterjs-content-model-api": "^9.32.0"
10
10
  },
11
- "version": "9.30.0",
11
+ "version": "9.32.0",
12
12
  "main": "./lib/index.js",
13
13
  "typings": "./lib/index.d.ts",
14
14
  "module": "./lib-mjs/index.js",