@contentful/field-editor-rich-text 2.0.0-next.32 → 2.0.0-next.35
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/dist/field-editor-rich-text.cjs.development.js +249 -236
- package/dist/field-editor-rich-text.cjs.development.js.map +1 -1
- package/dist/field-editor-rich-text.cjs.production.min.js +1 -1
- package/dist/field-editor-rich-text.cjs.production.min.js.map +1 -1
- package/dist/field-editor-rich-text.esm.js +250 -237
- package/dist/field-editor-rich-text.esm.js.map +1 -1
- package/dist/plugins/Tracking/createTrackingPlugin.d.ts +1 -0
- package/dist/test-utils/jsx.d.ts +1 -1
- package/package.json +1 -1
|
@@ -5443,7 +5443,8 @@ var createSelectOnBackspacePlugin = function createSelectOnBackspacePlugin() {
|
|
|
5443
5443
|
return plateSelect.createSelectOnBackspacePlugin({
|
|
5444
5444
|
options: {
|
|
5445
5445
|
query: {
|
|
5446
|
-
|
|
5446
|
+
// `createTextPlugin` is taking care of block elements
|
|
5447
|
+
allow: [Contentful.INLINES.EMBEDDED_ENTRY]
|
|
5447
5448
|
}
|
|
5448
5449
|
}
|
|
5449
5450
|
});
|
|
@@ -6127,6 +6128,229 @@ var onKeyDownTable = function onKeyDownTable(editor, plugin) {
|
|
|
6127
6128
|
};
|
|
6128
6129
|
};
|
|
6129
6130
|
|
|
6131
|
+
var _extends2, _extends4, _inlines;
|
|
6132
|
+
var inlines = /*#__PURE__*/Object.values(Contentful.INLINES).map(function (type) {
|
|
6133
|
+
return {
|
|
6134
|
+
type: type
|
|
6135
|
+
};
|
|
6136
|
+
});
|
|
6137
|
+
var schema = {
|
|
6138
|
+
document: {
|
|
6139
|
+
nodes: [{
|
|
6140
|
+
types: /*#__PURE__*/Contentful.TOP_LEVEL_BLOCKS.map(function (type) {
|
|
6141
|
+
return {
|
|
6142
|
+
type: type
|
|
6143
|
+
};
|
|
6144
|
+
})
|
|
6145
|
+
}]
|
|
6146
|
+
},
|
|
6147
|
+
blocks: /*#__PURE__*/_extends((_extends2 = {}, _extends2[Contentful.BLOCKS.PARAGRAPH] = {
|
|
6148
|
+
nodes: [{
|
|
6149
|
+
match: /*#__PURE__*/[].concat(inlines, [{
|
|
6150
|
+
object: 'text'
|
|
6151
|
+
}])
|
|
6152
|
+
}]
|
|
6153
|
+
}, _extends2[Contentful.BLOCKS.HEADING_1] = {
|
|
6154
|
+
nodes: [{
|
|
6155
|
+
match: /*#__PURE__*/[].concat(inlines, [{
|
|
6156
|
+
object: 'text'
|
|
6157
|
+
}])
|
|
6158
|
+
}]
|
|
6159
|
+
}, _extends2[Contentful.BLOCKS.HEADING_2] = {
|
|
6160
|
+
nodes: [{
|
|
6161
|
+
match: /*#__PURE__*/[].concat(inlines, [{
|
|
6162
|
+
object: 'text'
|
|
6163
|
+
}])
|
|
6164
|
+
}]
|
|
6165
|
+
}, _extends2[Contentful.BLOCKS.HEADING_3] = {
|
|
6166
|
+
nodes: [{
|
|
6167
|
+
match: /*#__PURE__*/[].concat(inlines, [{
|
|
6168
|
+
object: 'text'
|
|
6169
|
+
}])
|
|
6170
|
+
}]
|
|
6171
|
+
}, _extends2[Contentful.BLOCKS.HEADING_4] = {
|
|
6172
|
+
nodes: [{
|
|
6173
|
+
match: /*#__PURE__*/[].concat(inlines, [{
|
|
6174
|
+
object: 'text'
|
|
6175
|
+
}])
|
|
6176
|
+
}]
|
|
6177
|
+
}, _extends2[Contentful.BLOCKS.HEADING_5] = {
|
|
6178
|
+
nodes: [{
|
|
6179
|
+
match: /*#__PURE__*/[].concat(inlines, [{
|
|
6180
|
+
object: 'text'
|
|
6181
|
+
}])
|
|
6182
|
+
}]
|
|
6183
|
+
}, _extends2[Contentful.BLOCKS.HEADING_6] = {
|
|
6184
|
+
nodes: [{
|
|
6185
|
+
match: /*#__PURE__*/[].concat(inlines, [{
|
|
6186
|
+
object: 'text'
|
|
6187
|
+
}])
|
|
6188
|
+
}]
|
|
6189
|
+
}, _extends2), /*#__PURE__*/Contentful.VOID_BLOCKS.reduce(function (blocks, nodeType) {
|
|
6190
|
+
var _extends3;
|
|
6191
|
+
|
|
6192
|
+
return _extends({}, blocks, (_extends3 = {}, _extends3[nodeType] = {
|
|
6193
|
+
isVoid: true
|
|
6194
|
+
}, _extends3));
|
|
6195
|
+
}, {}), (_extends4 = {}, _extends4[Contentful.BLOCKS.QUOTE] = {
|
|
6196
|
+
nodes: [{
|
|
6197
|
+
match: [/*#__PURE__*/Contentful.CONTAINERS[Contentful.BLOCKS.QUOTE].map(function (type) {
|
|
6198
|
+
return {
|
|
6199
|
+
type: type
|
|
6200
|
+
};
|
|
6201
|
+
})],
|
|
6202
|
+
min: 1
|
|
6203
|
+
}],
|
|
6204
|
+
normalize: function normalize(editor, error) {
|
|
6205
|
+
if (error.code === 'child_type_invalid') {
|
|
6206
|
+
return editor.unwrapBlockByKey(error.node.key, Contentful.BLOCKS.QUOTE);
|
|
6207
|
+
}
|
|
6208
|
+
}
|
|
6209
|
+
}, _extends4)),
|
|
6210
|
+
inlines: (_inlines = {}, _inlines[Contentful.INLINES.HYPERLINK] = {
|
|
6211
|
+
nodes: [{
|
|
6212
|
+
match: [{
|
|
6213
|
+
object: 'text'
|
|
6214
|
+
}]
|
|
6215
|
+
}]
|
|
6216
|
+
}, _inlines[Contentful.INLINES.ENTRY_HYPERLINK] = {
|
|
6217
|
+
nodes: [{
|
|
6218
|
+
match: [{
|
|
6219
|
+
object: 'text'
|
|
6220
|
+
}]
|
|
6221
|
+
}]
|
|
6222
|
+
}, _inlines[Contentful.INLINES.ASSET_HYPERLINK] = {
|
|
6223
|
+
nodes: [{
|
|
6224
|
+
match: [{
|
|
6225
|
+
object: 'text'
|
|
6226
|
+
}]
|
|
6227
|
+
}]
|
|
6228
|
+
}, _inlines[Contentful.INLINES.EMBEDDED_ENTRY] = {
|
|
6229
|
+
isVoid: true
|
|
6230
|
+
}, _inlines)
|
|
6231
|
+
};
|
|
6232
|
+
|
|
6233
|
+
function getCharacterCount(editor) {
|
|
6234
|
+
var document = contentfulSlateJSAdapter.toContentfulDocument({
|
|
6235
|
+
document: editor.children,
|
|
6236
|
+
schema: schema
|
|
6237
|
+
});
|
|
6238
|
+
return richTextPlainTextRenderer.documentToPlainTextString(document).length;
|
|
6239
|
+
}
|
|
6240
|
+
|
|
6241
|
+
var actionOrigin = {
|
|
6242
|
+
TOOLBAR: 'toolbar-icon',
|
|
6243
|
+
SHORTCUT: 'shortcut',
|
|
6244
|
+
VIEWPORT: 'viewport-interaction',
|
|
6245
|
+
COMMAND_PALETTE: 'command-palette'
|
|
6246
|
+
};
|
|
6247
|
+
function getPastingSource(data) {
|
|
6248
|
+
var textHtml = data.getData('text/html');
|
|
6249
|
+
var doc = new DOMParser().parseFromString(textHtml, 'text/html');
|
|
6250
|
+
|
|
6251
|
+
if (doc.querySelector('[id*="docs-internal-guid"]')) {
|
|
6252
|
+
return 'Google Docs';
|
|
6253
|
+
}
|
|
6254
|
+
|
|
6255
|
+
if (doc.querySelector('google-sheets-html-origin') || doc.querySelector('[data-sheets-value]')) {
|
|
6256
|
+
return 'Google Spreadsheets';
|
|
6257
|
+
}
|
|
6258
|
+
|
|
6259
|
+
if (doc.querySelector('meta[content*="Microsoft Excel"]')) {
|
|
6260
|
+
return 'Microsoft Excel';
|
|
6261
|
+
}
|
|
6262
|
+
|
|
6263
|
+
if (doc.querySelector('meta[content*="Microsoft Word"]')) {
|
|
6264
|
+
return 'Microsoft Word';
|
|
6265
|
+
} // TODO: MS Word Online doesn't give us specific tags, we might need to have a closer look at its tracking result since we are using generic values to identify it
|
|
6266
|
+
|
|
6267
|
+
|
|
6268
|
+
if (doc.querySelector('[style*="Arial_MSFontService"]') && (doc.querySelector('.TextRun') || doc.querySelector('.OutlineElement'))) {
|
|
6269
|
+
return 'Microsoft Word Online';
|
|
6270
|
+
}
|
|
6271
|
+
|
|
6272
|
+
if (doc.querySelector('meta[content="Cocoa HTML Writer"]')) {
|
|
6273
|
+
return 'Apple Notes';
|
|
6274
|
+
}
|
|
6275
|
+
|
|
6276
|
+
if (doc.querySelector('[style*="Slack-Lato, Slack-Fractions"]')) {
|
|
6277
|
+
return 'Slack';
|
|
6278
|
+
}
|
|
6279
|
+
|
|
6280
|
+
return 'Unknown';
|
|
6281
|
+
}
|
|
6282
|
+
var createTrackingPlugin = function createTrackingPlugin(onAction) {
|
|
6283
|
+
var trackingActions = {
|
|
6284
|
+
onViewportAction: function onViewportAction(actionName, data) {
|
|
6285
|
+
if (data === void 0) {
|
|
6286
|
+
data = {};
|
|
6287
|
+
}
|
|
6288
|
+
|
|
6289
|
+
return onAction(actionName, _extends({
|
|
6290
|
+
origin: actionOrigin.VIEWPORT
|
|
6291
|
+
}, data));
|
|
6292
|
+
},
|
|
6293
|
+
onShortcutAction: function onShortcutAction(actionName, data) {
|
|
6294
|
+
if (data === void 0) {
|
|
6295
|
+
data = {};
|
|
6296
|
+
}
|
|
6297
|
+
|
|
6298
|
+
return onAction(actionName, _extends({
|
|
6299
|
+
origin: actionOrigin.SHORTCUT
|
|
6300
|
+
}, data));
|
|
6301
|
+
},
|
|
6302
|
+
onToolbarAction: function onToolbarAction(actionName, data) {
|
|
6303
|
+
if (data === void 0) {
|
|
6304
|
+
data = {};
|
|
6305
|
+
}
|
|
6306
|
+
|
|
6307
|
+
return onAction(actionName, _extends({
|
|
6308
|
+
origin: actionOrigin.TOOLBAR
|
|
6309
|
+
}, data));
|
|
6310
|
+
},
|
|
6311
|
+
onCommandPaletteAction: function onCommandPaletteAction(actionName, data) {
|
|
6312
|
+
if (data === void 0) {
|
|
6313
|
+
data = {};
|
|
6314
|
+
}
|
|
6315
|
+
|
|
6316
|
+
return onAction(actionName, _extends({
|
|
6317
|
+
origin: actionOrigin.COMMAND_PALETTE
|
|
6318
|
+
}, data));
|
|
6319
|
+
}
|
|
6320
|
+
};
|
|
6321
|
+
return {
|
|
6322
|
+
key: 'TrackingPlugin',
|
|
6323
|
+
withOverrides: function withOverrides(editor) {
|
|
6324
|
+
var insertData = editor.insertData;
|
|
6325
|
+
editor.tracking = trackingActions;
|
|
6326
|
+
|
|
6327
|
+
editor.insertData = function (data) {
|
|
6328
|
+
var isCopyAndPaste = data.types.length !== 0;
|
|
6329
|
+
|
|
6330
|
+
if (isCopyAndPaste) {
|
|
6331
|
+
var _window$getSelection;
|
|
6332
|
+
|
|
6333
|
+
var characterCountSelection = (_window$getSelection = window.getSelection()) == null ? void 0 : _window$getSelection.toString().length;
|
|
6334
|
+
var characterCountBefore = getCharacterCount(editor);
|
|
6335
|
+
setTimeout(function () {
|
|
6336
|
+
var characterCountAfter = getCharacterCount(editor);
|
|
6337
|
+
trackingActions.onShortcutAction('paste', {
|
|
6338
|
+
characterCountAfter: characterCountAfter,
|
|
6339
|
+
characterCountBefore: characterCountBefore,
|
|
6340
|
+
characterCountSelection: characterCountSelection,
|
|
6341
|
+
source: getPastingSource(data)
|
|
6342
|
+
});
|
|
6343
|
+
});
|
|
6344
|
+
}
|
|
6345
|
+
|
|
6346
|
+
insertData(data);
|
|
6347
|
+
};
|
|
6348
|
+
|
|
6349
|
+
return editor;
|
|
6350
|
+
}
|
|
6351
|
+
};
|
|
6352
|
+
};
|
|
6353
|
+
|
|
6130
6354
|
function hasTables(nodes) {
|
|
6131
6355
|
return nodes.some(function (_ref) {
|
|
6132
6356
|
var type = _ref.type;
|
|
@@ -6168,6 +6392,7 @@ function addTableTrackingEvents(editor) {
|
|
|
6168
6392
|
if (hasTables(markupAfter)) {
|
|
6169
6393
|
editor.tracking.onViewportAction('paste', {
|
|
6170
6394
|
tablePasted: true,
|
|
6395
|
+
source: getPastingSource(data),
|
|
6171
6396
|
hasHeadersOutsideFirstRow: hasHeadersOutsideFirstRow(markupAfter)
|
|
6172
6397
|
});
|
|
6173
6398
|
}
|
|
@@ -6382,11 +6607,11 @@ function createTextPlugin() {
|
|
|
6382
6607
|
deleteBackward = editor.deleteBackward;
|
|
6383
6608
|
|
|
6384
6609
|
editor.deleteBackward = function (unit) {
|
|
6385
|
-
|
|
6610
|
+
deleteEmptyParagraph(unit, editor, deleteBackward);
|
|
6386
6611
|
};
|
|
6387
6612
|
|
|
6388
6613
|
editor.deleteForward = function (unit) {
|
|
6389
|
-
|
|
6614
|
+
deleteEmptyParagraph(unit, editor, deleteForward);
|
|
6390
6615
|
};
|
|
6391
6616
|
|
|
6392
6617
|
return editor;
|
|
@@ -6394,7 +6619,7 @@ function createTextPlugin() {
|
|
|
6394
6619
|
};
|
|
6395
6620
|
}
|
|
6396
6621
|
|
|
6397
|
-
function
|
|
6622
|
+
function deleteEmptyParagraph(unit, editor, deleteFunction) {
|
|
6398
6623
|
var entry = plateCore.getAbove(editor, {
|
|
6399
6624
|
match: {
|
|
6400
6625
|
type: Contentful.TEXT_CONTAINERS
|
|
@@ -6409,10 +6634,29 @@ function deleteFirstEmptyParagraph(unit, editor, deleteFunction) {
|
|
|
6409
6634
|
var isRootLevel = path.length === 1;
|
|
6410
6635
|
var hasSiblings = editor.children.length > 1; // prevent editor from losing focus
|
|
6411
6636
|
|
|
6412
|
-
if (isTextEmpty && isRootLevel &&
|
|
6637
|
+
if (isTextEmpty && isRootLevel && hasSiblings) {
|
|
6413
6638
|
slate.Transforms.removeNodes(editor, {
|
|
6414
6639
|
at: path
|
|
6415
6640
|
});
|
|
6641
|
+
var prevNode = slate.Editor.before(editor, editor.selection, {
|
|
6642
|
+
unit: unit
|
|
6643
|
+
});
|
|
6644
|
+
|
|
6645
|
+
if (prevNode) {
|
|
6646
|
+
var _Editor$nodes = slate.Editor.nodes(editor, {
|
|
6647
|
+
match: function match(node) {
|
|
6648
|
+
return plateCore.queryNode([node, prevNode.path], {
|
|
6649
|
+
allow: [Contentful.BLOCKS.EMBEDDED_ASSET, Contentful.BLOCKS.EMBEDDED_ENTRY, Contentful.BLOCKS.HR]
|
|
6650
|
+
});
|
|
6651
|
+
},
|
|
6652
|
+
at: prevNode
|
|
6653
|
+
}),
|
|
6654
|
+
prevCell = _Editor$nodes[0];
|
|
6655
|
+
|
|
6656
|
+
if (prevCell) {
|
|
6657
|
+
slate.Transforms.select(editor, prevNode);
|
|
6658
|
+
}
|
|
6659
|
+
}
|
|
6416
6660
|
} else {
|
|
6417
6661
|
deleteFunction(unit);
|
|
6418
6662
|
}
|
|
@@ -6421,237 +6665,6 @@ function deleteFirstEmptyParagraph(unit, editor, deleteFunction) {
|
|
|
6421
6665
|
}
|
|
6422
6666
|
}
|
|
6423
6667
|
|
|
6424
|
-
var _extends2, _extends4, _inlines;
|
|
6425
|
-
var inlines = /*#__PURE__*/Object.values(Contentful.INLINES).map(function (type) {
|
|
6426
|
-
return {
|
|
6427
|
-
type: type
|
|
6428
|
-
};
|
|
6429
|
-
});
|
|
6430
|
-
var schema = {
|
|
6431
|
-
document: {
|
|
6432
|
-
nodes: [{
|
|
6433
|
-
types: /*#__PURE__*/Contentful.TOP_LEVEL_BLOCKS.map(function (type) {
|
|
6434
|
-
return {
|
|
6435
|
-
type: type
|
|
6436
|
-
};
|
|
6437
|
-
})
|
|
6438
|
-
}]
|
|
6439
|
-
},
|
|
6440
|
-
blocks: /*#__PURE__*/_extends((_extends2 = {}, _extends2[Contentful.BLOCKS.PARAGRAPH] = {
|
|
6441
|
-
nodes: [{
|
|
6442
|
-
match: /*#__PURE__*/[].concat(inlines, [{
|
|
6443
|
-
object: 'text'
|
|
6444
|
-
}])
|
|
6445
|
-
}]
|
|
6446
|
-
}, _extends2[Contentful.BLOCKS.HEADING_1] = {
|
|
6447
|
-
nodes: [{
|
|
6448
|
-
match: /*#__PURE__*/[].concat(inlines, [{
|
|
6449
|
-
object: 'text'
|
|
6450
|
-
}])
|
|
6451
|
-
}]
|
|
6452
|
-
}, _extends2[Contentful.BLOCKS.HEADING_2] = {
|
|
6453
|
-
nodes: [{
|
|
6454
|
-
match: /*#__PURE__*/[].concat(inlines, [{
|
|
6455
|
-
object: 'text'
|
|
6456
|
-
}])
|
|
6457
|
-
}]
|
|
6458
|
-
}, _extends2[Contentful.BLOCKS.HEADING_3] = {
|
|
6459
|
-
nodes: [{
|
|
6460
|
-
match: /*#__PURE__*/[].concat(inlines, [{
|
|
6461
|
-
object: 'text'
|
|
6462
|
-
}])
|
|
6463
|
-
}]
|
|
6464
|
-
}, _extends2[Contentful.BLOCKS.HEADING_4] = {
|
|
6465
|
-
nodes: [{
|
|
6466
|
-
match: /*#__PURE__*/[].concat(inlines, [{
|
|
6467
|
-
object: 'text'
|
|
6468
|
-
}])
|
|
6469
|
-
}]
|
|
6470
|
-
}, _extends2[Contentful.BLOCKS.HEADING_5] = {
|
|
6471
|
-
nodes: [{
|
|
6472
|
-
match: /*#__PURE__*/[].concat(inlines, [{
|
|
6473
|
-
object: 'text'
|
|
6474
|
-
}])
|
|
6475
|
-
}]
|
|
6476
|
-
}, _extends2[Contentful.BLOCKS.HEADING_6] = {
|
|
6477
|
-
nodes: [{
|
|
6478
|
-
match: /*#__PURE__*/[].concat(inlines, [{
|
|
6479
|
-
object: 'text'
|
|
6480
|
-
}])
|
|
6481
|
-
}]
|
|
6482
|
-
}, _extends2), /*#__PURE__*/Contentful.VOID_BLOCKS.reduce(function (blocks, nodeType) {
|
|
6483
|
-
var _extends3;
|
|
6484
|
-
|
|
6485
|
-
return _extends({}, blocks, (_extends3 = {}, _extends3[nodeType] = {
|
|
6486
|
-
isVoid: true
|
|
6487
|
-
}, _extends3));
|
|
6488
|
-
}, {}), (_extends4 = {}, _extends4[Contentful.BLOCKS.QUOTE] = {
|
|
6489
|
-
nodes: [{
|
|
6490
|
-
match: [/*#__PURE__*/Contentful.CONTAINERS[Contentful.BLOCKS.QUOTE].map(function (type) {
|
|
6491
|
-
return {
|
|
6492
|
-
type: type
|
|
6493
|
-
};
|
|
6494
|
-
})],
|
|
6495
|
-
min: 1
|
|
6496
|
-
}],
|
|
6497
|
-
normalize: function normalize(editor, error) {
|
|
6498
|
-
if (error.code === 'child_type_invalid') {
|
|
6499
|
-
return editor.unwrapBlockByKey(error.node.key, Contentful.BLOCKS.QUOTE);
|
|
6500
|
-
}
|
|
6501
|
-
}
|
|
6502
|
-
}, _extends4)),
|
|
6503
|
-
inlines: (_inlines = {}, _inlines[Contentful.INLINES.HYPERLINK] = {
|
|
6504
|
-
nodes: [{
|
|
6505
|
-
match: [{
|
|
6506
|
-
object: 'text'
|
|
6507
|
-
}]
|
|
6508
|
-
}]
|
|
6509
|
-
}, _inlines[Contentful.INLINES.ENTRY_HYPERLINK] = {
|
|
6510
|
-
nodes: [{
|
|
6511
|
-
match: [{
|
|
6512
|
-
object: 'text'
|
|
6513
|
-
}]
|
|
6514
|
-
}]
|
|
6515
|
-
}, _inlines[Contentful.INLINES.ASSET_HYPERLINK] = {
|
|
6516
|
-
nodes: [{
|
|
6517
|
-
match: [{
|
|
6518
|
-
object: 'text'
|
|
6519
|
-
}]
|
|
6520
|
-
}]
|
|
6521
|
-
}, _inlines[Contentful.INLINES.EMBEDDED_ENTRY] = {
|
|
6522
|
-
isVoid: true
|
|
6523
|
-
}, _inlines)
|
|
6524
|
-
};
|
|
6525
|
-
|
|
6526
|
-
function getCharacterCount(editor) {
|
|
6527
|
-
var document = contentfulSlateJSAdapter.toContentfulDocument({
|
|
6528
|
-
document: editor.children,
|
|
6529
|
-
schema: schema
|
|
6530
|
-
});
|
|
6531
|
-
return richTextPlainTextRenderer.documentToPlainTextString(document).length;
|
|
6532
|
-
}
|
|
6533
|
-
|
|
6534
|
-
var actionOrigin = {
|
|
6535
|
-
TOOLBAR: 'toolbar-icon',
|
|
6536
|
-
SHORTCUT: 'shortcut',
|
|
6537
|
-
VIEWPORT: 'viewport-interaction',
|
|
6538
|
-
COMMAND_PALETTE: 'command-palette'
|
|
6539
|
-
};
|
|
6540
|
-
|
|
6541
|
-
function getPastingSource(data) {
|
|
6542
|
-
var textHtml = data.getData('text/html');
|
|
6543
|
-
var doc = new DOMParser().parseFromString(textHtml, 'text/html');
|
|
6544
|
-
|
|
6545
|
-
if (doc.querySelector('[id*="docs-internal-guid"]')) {
|
|
6546
|
-
return 'Google Docs';
|
|
6547
|
-
}
|
|
6548
|
-
|
|
6549
|
-
if (doc.querySelector('google-sheets-html-origin') || doc.querySelector('[data-sheets-value]')) {
|
|
6550
|
-
return 'Google Spreadsheets';
|
|
6551
|
-
}
|
|
6552
|
-
|
|
6553
|
-
if (doc.querySelector('meta[content*="Microsoft Excel"]')) {
|
|
6554
|
-
return 'Microsoft Excel';
|
|
6555
|
-
}
|
|
6556
|
-
|
|
6557
|
-
if (doc.querySelector('meta[content*="Microsoft Word"]')) {
|
|
6558
|
-
return 'Microsoft Word';
|
|
6559
|
-
} // TODO: MS Word Online doesn't give us specific tags, we might need to have a closer look at its tracking result since we are using generic values to identify it
|
|
6560
|
-
|
|
6561
|
-
|
|
6562
|
-
if (doc.querySelector('[style*="Arial_MSFontService"]') && (doc.querySelector('.TextRun') || doc.querySelector('.OutlineElement'))) {
|
|
6563
|
-
return 'Microsoft Word Online';
|
|
6564
|
-
}
|
|
6565
|
-
|
|
6566
|
-
if (doc.querySelector('meta[content="Cocoa HTML Writer"]')) {
|
|
6567
|
-
return 'Apple Notes';
|
|
6568
|
-
}
|
|
6569
|
-
|
|
6570
|
-
if (doc.querySelector('[style*="Slack-Lato, Slack-Fractions"]')) {
|
|
6571
|
-
return 'Slack';
|
|
6572
|
-
}
|
|
6573
|
-
|
|
6574
|
-
return '';
|
|
6575
|
-
}
|
|
6576
|
-
|
|
6577
|
-
var createTrackingPlugin = function createTrackingPlugin(onAction) {
|
|
6578
|
-
var trackingActions = {
|
|
6579
|
-
onViewportAction: function onViewportAction(actionName, data) {
|
|
6580
|
-
if (data === void 0) {
|
|
6581
|
-
data = {};
|
|
6582
|
-
}
|
|
6583
|
-
|
|
6584
|
-
return onAction(actionName, _extends({
|
|
6585
|
-
origin: actionOrigin.VIEWPORT
|
|
6586
|
-
}, data));
|
|
6587
|
-
},
|
|
6588
|
-
onShortcutAction: function onShortcutAction(actionName, data) {
|
|
6589
|
-
if (data === void 0) {
|
|
6590
|
-
data = {};
|
|
6591
|
-
}
|
|
6592
|
-
|
|
6593
|
-
return onAction(actionName, _extends({
|
|
6594
|
-
origin: actionOrigin.SHORTCUT
|
|
6595
|
-
}, data));
|
|
6596
|
-
},
|
|
6597
|
-
onToolbarAction: function onToolbarAction(actionName, data) {
|
|
6598
|
-
if (data === void 0) {
|
|
6599
|
-
data = {};
|
|
6600
|
-
}
|
|
6601
|
-
|
|
6602
|
-
return onAction(actionName, _extends({
|
|
6603
|
-
origin: actionOrigin.TOOLBAR
|
|
6604
|
-
}, data));
|
|
6605
|
-
},
|
|
6606
|
-
onCommandPaletteAction: function onCommandPaletteAction(actionName, data) {
|
|
6607
|
-
if (data === void 0) {
|
|
6608
|
-
data = {};
|
|
6609
|
-
}
|
|
6610
|
-
|
|
6611
|
-
return onAction(actionName, _extends({
|
|
6612
|
-
origin: actionOrigin.COMMAND_PALETTE
|
|
6613
|
-
}, data));
|
|
6614
|
-
}
|
|
6615
|
-
};
|
|
6616
|
-
return {
|
|
6617
|
-
key: 'TrackingPlugin',
|
|
6618
|
-
withOverrides: function withOverrides(editor) {
|
|
6619
|
-
var insertData = editor.insertData;
|
|
6620
|
-
editor.tracking = trackingActions;
|
|
6621
|
-
|
|
6622
|
-
editor.insertData = function (data) {
|
|
6623
|
-
var isCopyAndPaste = data.types.length !== 0;
|
|
6624
|
-
|
|
6625
|
-
if (isCopyAndPaste) {
|
|
6626
|
-
var _window$getSelection;
|
|
6627
|
-
|
|
6628
|
-
var characterCountSelection = (_window$getSelection = window.getSelection()) == null ? void 0 : _window$getSelection.toString().length;
|
|
6629
|
-
var characterCountBefore = getCharacterCount(editor);
|
|
6630
|
-
setTimeout(function () {
|
|
6631
|
-
var characterCountAfter = getCharacterCount(editor);
|
|
6632
|
-
var payload = {
|
|
6633
|
-
characterCountAfter: characterCountAfter,
|
|
6634
|
-
characterCountBefore: characterCountBefore,
|
|
6635
|
-
characterCountSelection: characterCountSelection
|
|
6636
|
-
};
|
|
6637
|
-
var source = getPastingSource(data);
|
|
6638
|
-
|
|
6639
|
-
if (source) {
|
|
6640
|
-
payload.source = source;
|
|
6641
|
-
}
|
|
6642
|
-
|
|
6643
|
-
trackingActions.onShortcutAction('paste', payload);
|
|
6644
|
-
});
|
|
6645
|
-
}
|
|
6646
|
-
|
|
6647
|
-
insertData(data);
|
|
6648
|
-
};
|
|
6649
|
-
|
|
6650
|
-
return editor;
|
|
6651
|
-
}
|
|
6652
|
-
};
|
|
6653
|
-
};
|
|
6654
|
-
|
|
6655
6668
|
var createTrailingParagraphPlugin = function createTrailingParagraphPlugin() {
|
|
6656
6669
|
return plateTrailingBlock.createTrailingBlockPlugin({
|
|
6657
6670
|
options: {
|