@textbus/platform-browser 3.0.0-alpha.40 → 3.0.0-alpha.42

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.
@@ -52,5 +52,4 @@ export declare class Parser {
52
52
  private readComponent;
53
53
  private readFormats;
54
54
  private readSlot;
55
- private applyFormats;
56
55
  }
@@ -1250,11 +1250,9 @@ let Parser = Parser_1 = class Parser {
1250
1250
  }
1251
1251
  parse(html, rootSlot) {
1252
1252
  const element = Parser_1.parseHTML(html);
1253
- const formatItems = this.readFormats(element, rootSlot, []);
1254
- this.applyFormats(rootSlot, formatItems);
1255
- return rootSlot;
1253
+ return this.readFormats(element, rootSlot);
1256
1254
  }
1257
- readComponent(el, slot, formatItems) {
1255
+ readComponent(el, slot) {
1258
1256
  if (el.nodeType === Node.ELEMENT_NODE) {
1259
1257
  if (el.tagName === 'BR') {
1260
1258
  slot.insert('\n');
@@ -1273,7 +1271,7 @@ let Parser = Parser_1 = class Parser {
1273
1271
  return;
1274
1272
  }
1275
1273
  }
1276
- this.readFormats(el, slot, formatItems);
1274
+ this.readFormats(el, slot);
1277
1275
  }
1278
1276
  else if (el.nodeType === Node.TEXT_NODE) {
1279
1277
  const textContent = el.textContent;
@@ -1283,26 +1281,21 @@ let Parser = Parser_1 = class Parser {
1283
1281
  slot.insert(textContent);
1284
1282
  }
1285
1283
  }
1286
- readFormats(el, slot, formatItems) {
1287
- const formats = this.formatLoaders.filter(f => {
1284
+ readFormats(el, slot) {
1285
+ this.formatLoaders.filter(f => {
1288
1286
  return f.match(el);
1289
- }).map(f => {
1290
- return f.read(el);
1287
+ }).forEach(f => {
1288
+ const v = f.read(el);
1289
+ slot.applyFormat(v.formatter, {
1290
+ startIndex: 0,
1291
+ endIndex: slot.length,
1292
+ value: v.value
1293
+ });
1291
1294
  });
1292
- const startIndex = slot.index;
1293
1295
  Array.from(el.childNodes).forEach(child => {
1294
- this.readComponent(child, slot, formatItems);
1296
+ this.readComponent(child, slot);
1295
1297
  });
1296
- const endIndex = slot.index;
1297
- formatItems.unshift(...formats.map(i => {
1298
- return {
1299
- formatter: i.formatter,
1300
- value: i.value,
1301
- startIndex,
1302
- endIndex
1303
- };
1304
- }));
1305
- return formatItems;
1298
+ return slot;
1306
1299
  }
1307
1300
  readSlot(childSlot, slotRootElement, slotContentElement) {
1308
1301
  this.attributeLoaders.filter(a => {
@@ -1311,15 +1304,7 @@ let Parser = Parser_1 = class Parser {
1311
1304
  const r = a.read(slotRootElement);
1312
1305
  childSlot.setAttribute(r.attribute, r.value);
1313
1306
  });
1314
- const childFormatItems = this.readFormats(slotContentElement, childSlot, []);
1315
- this.applyFormats(childSlot, childFormatItems);
1316
- return childSlot;
1317
- }
1318
- applyFormats(slot, formatItems) {
1319
- formatItems.forEach(i => {
1320
- slot.retain(i.startIndex);
1321
- slot.retain(i.endIndex - i.startIndex, i.formatter, i.value);
1322
- });
1307
+ return this.readFormats(slotContentElement, childSlot);
1323
1308
  }
1324
1309
  };
1325
1310
  Parser = Parser_1 = __decorate([
@@ -2199,142 +2184,140 @@ OutputTranslator = OutputTranslator_1 = __decorate([
2199
2184
  /**
2200
2185
  * Textbus PC 端默认按键绑定
2201
2186
  */
2202
- class DefaultShortcut {
2203
- setup(injector) {
2204
- const selection = injector.get(Selection);
2205
- const keyboard = injector.get(Keyboard);
2206
- const history = injector.get(History);
2207
- const commander = injector.get(Commander);
2208
- keyboard.addShortcut({
2209
- keymap: {
2210
- key: 'Enter'
2211
- },
2212
- action: () => {
2213
- commander.break();
2214
- }
2215
- });
2216
- keyboard.addShortcut({
2217
- keymap: {
2218
- key: 'Enter',
2219
- shiftKey: true
2220
- },
2221
- action: () => {
2222
- const startOffset = selection.startOffset;
2223
- const startSlot = selection.startSlot;
2224
- const isToEnd = startOffset === startSlot.length || startSlot.isEmpty;
2225
- const content = isToEnd ? '\n\n' : '\n';
2226
- const isInserted = commander.insert(content);
2227
- if (isInserted && isToEnd) {
2228
- selection.setPosition(startSlot, startOffset + 1);
2229
- }
2230
- }
2231
- });
2232
- keyboard.addShortcut({
2233
- keymap: {
2234
- key: ['Delete', 'Backspace']
2235
- },
2236
- action: (key) => {
2237
- commander.delete(key === 'Backspace');
2238
- }
2239
- });
2240
- keyboard.addShortcut({
2241
- keymap: {
2242
- key: ['ArrowLeft', 'ArrowRight', 'ArrowUp', 'ArrowDown']
2243
- },
2244
- action: (key) => {
2245
- switch (key) {
2246
- case 'ArrowLeft':
2247
- selection.toPrevious();
2248
- break;
2249
- case 'ArrowRight':
2250
- selection.toNext();
2251
- break;
2252
- case 'ArrowUp':
2253
- selection.toPreviousLine();
2254
- break;
2255
- case 'ArrowDown':
2256
- selection.toNextLine();
2257
- break;
2258
- }
2259
- }
2260
- });
2261
- keyboard.addShortcut({
2262
- keymap: {
2263
- key: ['ArrowLeft', 'ArrowRight', 'ArrowUp', 'ArrowDown'],
2264
- shiftKey: true
2265
- },
2266
- action: (key) => {
2267
- switch (key) {
2268
- case 'ArrowLeft':
2269
- selection.wrapToBefore();
2270
- break;
2271
- case 'ArrowRight':
2272
- selection.wrapToAfter();
2273
- break;
2274
- case 'ArrowUp':
2275
- selection.wrapToPreviousLine();
2276
- break;
2277
- case 'ArrowDown':
2278
- selection.wrapToNextLine();
2279
- break;
2280
- }
2281
- }
2282
- });
2283
- keyboard.addShortcut({
2284
- keymap: {
2285
- key: 'Tab'
2286
- },
2287
- action: () => {
2288
- commander.insert(' ');
2289
- }
2290
- });
2291
- keyboard.addShortcut({
2292
- keymap: {
2293
- key: 'a',
2294
- ctrlKey: true
2295
- },
2296
- action: () => {
2297
- selection.selectAll();
2298
- }
2299
- });
2300
- keyboard.addShortcut({
2301
- keymap: {
2302
- key: 'c',
2303
- ctrlKey: true
2304
- },
2305
- action: () => {
2306
- commander.copy();
2307
- }
2308
- });
2309
- keyboard.addShortcut({
2310
- keymap: {
2311
- key: 'x',
2312
- ctrlKey: true
2313
- },
2314
- action: () => {
2315
- commander.cut();
2316
- }
2317
- });
2318
- keyboard.addShortcut({
2319
- keymap: {
2320
- key: 'z',
2321
- ctrlKey: true
2322
- },
2323
- action: () => {
2324
- history.back();
2325
- }
2326
- });
2327
- keyboard.addShortcut({
2328
- keymap: {
2329
- key: 'z',
2330
- ctrlKey: true,
2331
- shiftKey: true
2332
- },
2333
- action: () => {
2334
- history.forward();
2335
- }
2336
- });
2337
- }
2187
+ function setDefaultShortcut(injector) {
2188
+ const selection = injector.get(Selection);
2189
+ const keyboard = injector.get(Keyboard);
2190
+ const history = injector.get(History);
2191
+ const commander = injector.get(Commander);
2192
+ keyboard.addShortcut({
2193
+ keymap: {
2194
+ key: 'Enter'
2195
+ },
2196
+ action: () => {
2197
+ commander.break();
2198
+ }
2199
+ });
2200
+ keyboard.addShortcut({
2201
+ keymap: {
2202
+ key: 'Enter',
2203
+ shiftKey: true
2204
+ },
2205
+ action: () => {
2206
+ const startOffset = selection.startOffset;
2207
+ const startSlot = selection.startSlot;
2208
+ const isToEnd = startOffset === startSlot.length || startSlot.isEmpty;
2209
+ const content = isToEnd ? '\n\n' : '\n';
2210
+ const isInserted = commander.insert(content);
2211
+ if (isInserted && isToEnd) {
2212
+ selection.setPosition(startSlot, startOffset + 1);
2213
+ }
2214
+ }
2215
+ });
2216
+ keyboard.addShortcut({
2217
+ keymap: {
2218
+ key: ['Delete', 'Backspace']
2219
+ },
2220
+ action: (key) => {
2221
+ commander.delete(key === 'Backspace');
2222
+ }
2223
+ });
2224
+ keyboard.addShortcut({
2225
+ keymap: {
2226
+ key: ['ArrowLeft', 'ArrowRight', 'ArrowUp', 'ArrowDown']
2227
+ },
2228
+ action: (key) => {
2229
+ switch (key) {
2230
+ case 'ArrowLeft':
2231
+ selection.toPrevious();
2232
+ break;
2233
+ case 'ArrowRight':
2234
+ selection.toNext();
2235
+ break;
2236
+ case 'ArrowUp':
2237
+ selection.toPreviousLine();
2238
+ break;
2239
+ case 'ArrowDown':
2240
+ selection.toNextLine();
2241
+ break;
2242
+ }
2243
+ }
2244
+ });
2245
+ keyboard.addShortcut({
2246
+ keymap: {
2247
+ key: ['ArrowLeft', 'ArrowRight', 'ArrowUp', 'ArrowDown'],
2248
+ shiftKey: true
2249
+ },
2250
+ action: (key) => {
2251
+ switch (key) {
2252
+ case 'ArrowLeft':
2253
+ selection.wrapToBefore();
2254
+ break;
2255
+ case 'ArrowRight':
2256
+ selection.wrapToAfter();
2257
+ break;
2258
+ case 'ArrowUp':
2259
+ selection.wrapToPreviousLine();
2260
+ break;
2261
+ case 'ArrowDown':
2262
+ selection.wrapToNextLine();
2263
+ break;
2264
+ }
2265
+ }
2266
+ });
2267
+ keyboard.addShortcut({
2268
+ keymap: {
2269
+ key: 'Tab'
2270
+ },
2271
+ action: () => {
2272
+ commander.insert(' ');
2273
+ }
2274
+ });
2275
+ keyboard.addShortcut({
2276
+ keymap: {
2277
+ key: 'a',
2278
+ ctrlKey: true
2279
+ },
2280
+ action: () => {
2281
+ selection.selectAll();
2282
+ }
2283
+ });
2284
+ keyboard.addShortcut({
2285
+ keymap: {
2286
+ key: 'c',
2287
+ ctrlKey: true
2288
+ },
2289
+ action: () => {
2290
+ commander.copy();
2291
+ }
2292
+ });
2293
+ keyboard.addShortcut({
2294
+ keymap: {
2295
+ key: 'x',
2296
+ ctrlKey: true
2297
+ },
2298
+ action: () => {
2299
+ commander.cut();
2300
+ }
2301
+ });
2302
+ keyboard.addShortcut({
2303
+ keymap: {
2304
+ key: 'z',
2305
+ ctrlKey: true
2306
+ },
2307
+ action: () => {
2308
+ history.back();
2309
+ }
2310
+ });
2311
+ keyboard.addShortcut({
2312
+ keymap: {
2313
+ key: 'z',
2314
+ ctrlKey: true,
2315
+ shiftKey: true
2316
+ },
2317
+ action: () => {
2318
+ history.forward();
2319
+ }
2320
+ });
2338
2321
  }
2339
2322
 
2340
2323
  const editorError = makeError('CoreEditor');
@@ -2370,7 +2353,7 @@ class Viewer extends Starter {
2370
2353
  provide: Viewer,
2371
2354
  useFactory: () => this
2372
2355
  }];
2373
- super(Object.assign(Object.assign({}, options), { plugins: [...(options.plugins || []), () => new DefaultShortcut()], providers: [
2356
+ super(Object.assign(Object.assign({}, options), { plugins: options.plugins || [], providers: [
2374
2357
  ...(options.providers || []),
2375
2358
  ...staticProviders,
2376
2359
  DomRenderer,
@@ -2441,6 +2424,7 @@ class Viewer extends Starter {
2441
2424
  this.saveEvent.next();
2442
2425
  }
2443
2426
  });
2427
+ setDefaultShortcut(this);
2444
2428
  let component;
2445
2429
  const content = this.options.content;
2446
2430
  if (content) {
@@ -2688,4 +2672,4 @@ class Viewer extends Starter {
2688
2672
  }
2689
2673
  }
2690
2674
 
2691
- export { CollaborateCursor, CollaborateSelectionAwarenessDelegate, DefaultShortcut, DomRenderer, EDITOR_OPTIONS, Input, MagicInput, NativeInput, OutputTranslator, Parser, SelectionBridge, VIEW_CONTAINER, VIEW_DOCUMENT, VIEW_MASK, Viewer, createElement, createTextNode, getLayoutRectByRange, isMac, isSafari, isWindows };
2675
+ export { CollaborateCursor, CollaborateSelectionAwarenessDelegate, DomRenderer, EDITOR_OPTIONS, Input, MagicInput, NativeInput, OutputTranslator, Parser, SelectionBridge, VIEW_CONTAINER, VIEW_DOCUMENT, VIEW_MASK, Viewer, createElement, createTextNode, getLayoutRectByRange, isMac, isSafari, isWindows, setDefaultShortcut };
package/bundles/index.js CHANGED
@@ -1252,11 +1252,9 @@ exports.Parser = Parser_1 = class Parser {
1252
1252
  }
1253
1253
  parse(html, rootSlot) {
1254
1254
  const element = Parser_1.parseHTML(html);
1255
- const formatItems = this.readFormats(element, rootSlot, []);
1256
- this.applyFormats(rootSlot, formatItems);
1257
- return rootSlot;
1255
+ return this.readFormats(element, rootSlot);
1258
1256
  }
1259
- readComponent(el, slot, formatItems) {
1257
+ readComponent(el, slot) {
1260
1258
  if (el.nodeType === Node.ELEMENT_NODE) {
1261
1259
  if (el.tagName === 'BR') {
1262
1260
  slot.insert('\n');
@@ -1275,7 +1273,7 @@ exports.Parser = Parser_1 = class Parser {
1275
1273
  return;
1276
1274
  }
1277
1275
  }
1278
- this.readFormats(el, slot, formatItems);
1276
+ this.readFormats(el, slot);
1279
1277
  }
1280
1278
  else if (el.nodeType === Node.TEXT_NODE) {
1281
1279
  const textContent = el.textContent;
@@ -1285,26 +1283,21 @@ exports.Parser = Parser_1 = class Parser {
1285
1283
  slot.insert(textContent);
1286
1284
  }
1287
1285
  }
1288
- readFormats(el, slot, formatItems) {
1289
- const formats = this.formatLoaders.filter(f => {
1286
+ readFormats(el, slot) {
1287
+ this.formatLoaders.filter(f => {
1290
1288
  return f.match(el);
1291
- }).map(f => {
1292
- return f.read(el);
1289
+ }).forEach(f => {
1290
+ const v = f.read(el);
1291
+ slot.applyFormat(v.formatter, {
1292
+ startIndex: 0,
1293
+ endIndex: slot.length,
1294
+ value: v.value
1295
+ });
1293
1296
  });
1294
- const startIndex = slot.index;
1295
1297
  Array.from(el.childNodes).forEach(child => {
1296
- this.readComponent(child, slot, formatItems);
1298
+ this.readComponent(child, slot);
1297
1299
  });
1298
- const endIndex = slot.index;
1299
- formatItems.unshift(...formats.map(i => {
1300
- return {
1301
- formatter: i.formatter,
1302
- value: i.value,
1303
- startIndex,
1304
- endIndex
1305
- };
1306
- }));
1307
- return formatItems;
1300
+ return slot;
1308
1301
  }
1309
1302
  readSlot(childSlot, slotRootElement, slotContentElement) {
1310
1303
  this.attributeLoaders.filter(a => {
@@ -1313,15 +1306,7 @@ exports.Parser = Parser_1 = class Parser {
1313
1306
  const r = a.read(slotRootElement);
1314
1307
  childSlot.setAttribute(r.attribute, r.value);
1315
1308
  });
1316
- const childFormatItems = this.readFormats(slotContentElement, childSlot, []);
1317
- this.applyFormats(childSlot, childFormatItems);
1318
- return childSlot;
1319
- }
1320
- applyFormats(slot, formatItems) {
1321
- formatItems.forEach(i => {
1322
- slot.retain(i.startIndex);
1323
- slot.retain(i.endIndex - i.startIndex, i.formatter, i.value);
1324
- });
1309
+ return this.readFormats(slotContentElement, childSlot);
1325
1310
  }
1326
1311
  };
1327
1312
  exports.Parser = Parser_1 = __decorate([
@@ -2201,142 +2186,140 @@ exports.OutputTranslator = OutputTranslator_1 = __decorate([
2201
2186
  /**
2202
2187
  * Textbus PC 端默认按键绑定
2203
2188
  */
2204
- class DefaultShortcut {
2205
- setup(injector) {
2206
- const selection = injector.get(core.Selection);
2207
- const keyboard = injector.get(core.Keyboard);
2208
- const history = injector.get(core.History);
2209
- const commander = injector.get(core.Commander);
2210
- keyboard.addShortcut({
2211
- keymap: {
2212
- key: 'Enter'
2213
- },
2214
- action: () => {
2215
- commander.break();
2216
- }
2217
- });
2218
- keyboard.addShortcut({
2219
- keymap: {
2220
- key: 'Enter',
2221
- shiftKey: true
2222
- },
2223
- action: () => {
2224
- const startOffset = selection.startOffset;
2225
- const startSlot = selection.startSlot;
2226
- const isToEnd = startOffset === startSlot.length || startSlot.isEmpty;
2227
- const content = isToEnd ? '\n\n' : '\n';
2228
- const isInserted = commander.insert(content);
2229
- if (isInserted && isToEnd) {
2230
- selection.setPosition(startSlot, startOffset + 1);
2231
- }
2232
- }
2233
- });
2234
- keyboard.addShortcut({
2235
- keymap: {
2236
- key: ['Delete', 'Backspace']
2237
- },
2238
- action: (key) => {
2239
- commander.delete(key === 'Backspace');
2240
- }
2241
- });
2242
- keyboard.addShortcut({
2243
- keymap: {
2244
- key: ['ArrowLeft', 'ArrowRight', 'ArrowUp', 'ArrowDown']
2245
- },
2246
- action: (key) => {
2247
- switch (key) {
2248
- case 'ArrowLeft':
2249
- selection.toPrevious();
2250
- break;
2251
- case 'ArrowRight':
2252
- selection.toNext();
2253
- break;
2254
- case 'ArrowUp':
2255
- selection.toPreviousLine();
2256
- break;
2257
- case 'ArrowDown':
2258
- selection.toNextLine();
2259
- break;
2260
- }
2261
- }
2262
- });
2263
- keyboard.addShortcut({
2264
- keymap: {
2265
- key: ['ArrowLeft', 'ArrowRight', 'ArrowUp', 'ArrowDown'],
2266
- shiftKey: true
2267
- },
2268
- action: (key) => {
2269
- switch (key) {
2270
- case 'ArrowLeft':
2271
- selection.wrapToBefore();
2272
- break;
2273
- case 'ArrowRight':
2274
- selection.wrapToAfter();
2275
- break;
2276
- case 'ArrowUp':
2277
- selection.wrapToPreviousLine();
2278
- break;
2279
- case 'ArrowDown':
2280
- selection.wrapToNextLine();
2281
- break;
2282
- }
2283
- }
2284
- });
2285
- keyboard.addShortcut({
2286
- keymap: {
2287
- key: 'Tab'
2288
- },
2289
- action: () => {
2290
- commander.insert(' ');
2291
- }
2292
- });
2293
- keyboard.addShortcut({
2294
- keymap: {
2295
- key: 'a',
2296
- ctrlKey: true
2297
- },
2298
- action: () => {
2299
- selection.selectAll();
2300
- }
2301
- });
2302
- keyboard.addShortcut({
2303
- keymap: {
2304
- key: 'c',
2305
- ctrlKey: true
2306
- },
2307
- action: () => {
2308
- commander.copy();
2309
- }
2310
- });
2311
- keyboard.addShortcut({
2312
- keymap: {
2313
- key: 'x',
2314
- ctrlKey: true
2315
- },
2316
- action: () => {
2317
- commander.cut();
2318
- }
2319
- });
2320
- keyboard.addShortcut({
2321
- keymap: {
2322
- key: 'z',
2323
- ctrlKey: true
2324
- },
2325
- action: () => {
2326
- history.back();
2327
- }
2328
- });
2329
- keyboard.addShortcut({
2330
- keymap: {
2331
- key: 'z',
2332
- ctrlKey: true,
2333
- shiftKey: true
2334
- },
2335
- action: () => {
2336
- history.forward();
2337
- }
2338
- });
2339
- }
2189
+ function setDefaultShortcut(injector) {
2190
+ const selection = injector.get(core.Selection);
2191
+ const keyboard = injector.get(core.Keyboard);
2192
+ const history = injector.get(core.History);
2193
+ const commander = injector.get(core.Commander);
2194
+ keyboard.addShortcut({
2195
+ keymap: {
2196
+ key: 'Enter'
2197
+ },
2198
+ action: () => {
2199
+ commander.break();
2200
+ }
2201
+ });
2202
+ keyboard.addShortcut({
2203
+ keymap: {
2204
+ key: 'Enter',
2205
+ shiftKey: true
2206
+ },
2207
+ action: () => {
2208
+ const startOffset = selection.startOffset;
2209
+ const startSlot = selection.startSlot;
2210
+ const isToEnd = startOffset === startSlot.length || startSlot.isEmpty;
2211
+ const content = isToEnd ? '\n\n' : '\n';
2212
+ const isInserted = commander.insert(content);
2213
+ if (isInserted && isToEnd) {
2214
+ selection.setPosition(startSlot, startOffset + 1);
2215
+ }
2216
+ }
2217
+ });
2218
+ keyboard.addShortcut({
2219
+ keymap: {
2220
+ key: ['Delete', 'Backspace']
2221
+ },
2222
+ action: (key) => {
2223
+ commander.delete(key === 'Backspace');
2224
+ }
2225
+ });
2226
+ keyboard.addShortcut({
2227
+ keymap: {
2228
+ key: ['ArrowLeft', 'ArrowRight', 'ArrowUp', 'ArrowDown']
2229
+ },
2230
+ action: (key) => {
2231
+ switch (key) {
2232
+ case 'ArrowLeft':
2233
+ selection.toPrevious();
2234
+ break;
2235
+ case 'ArrowRight':
2236
+ selection.toNext();
2237
+ break;
2238
+ case 'ArrowUp':
2239
+ selection.toPreviousLine();
2240
+ break;
2241
+ case 'ArrowDown':
2242
+ selection.toNextLine();
2243
+ break;
2244
+ }
2245
+ }
2246
+ });
2247
+ keyboard.addShortcut({
2248
+ keymap: {
2249
+ key: ['ArrowLeft', 'ArrowRight', 'ArrowUp', 'ArrowDown'],
2250
+ shiftKey: true
2251
+ },
2252
+ action: (key) => {
2253
+ switch (key) {
2254
+ case 'ArrowLeft':
2255
+ selection.wrapToBefore();
2256
+ break;
2257
+ case 'ArrowRight':
2258
+ selection.wrapToAfter();
2259
+ break;
2260
+ case 'ArrowUp':
2261
+ selection.wrapToPreviousLine();
2262
+ break;
2263
+ case 'ArrowDown':
2264
+ selection.wrapToNextLine();
2265
+ break;
2266
+ }
2267
+ }
2268
+ });
2269
+ keyboard.addShortcut({
2270
+ keymap: {
2271
+ key: 'Tab'
2272
+ },
2273
+ action: () => {
2274
+ commander.insert(' ');
2275
+ }
2276
+ });
2277
+ keyboard.addShortcut({
2278
+ keymap: {
2279
+ key: 'a',
2280
+ ctrlKey: true
2281
+ },
2282
+ action: () => {
2283
+ selection.selectAll();
2284
+ }
2285
+ });
2286
+ keyboard.addShortcut({
2287
+ keymap: {
2288
+ key: 'c',
2289
+ ctrlKey: true
2290
+ },
2291
+ action: () => {
2292
+ commander.copy();
2293
+ }
2294
+ });
2295
+ keyboard.addShortcut({
2296
+ keymap: {
2297
+ key: 'x',
2298
+ ctrlKey: true
2299
+ },
2300
+ action: () => {
2301
+ commander.cut();
2302
+ }
2303
+ });
2304
+ keyboard.addShortcut({
2305
+ keymap: {
2306
+ key: 'z',
2307
+ ctrlKey: true
2308
+ },
2309
+ action: () => {
2310
+ history.back();
2311
+ }
2312
+ });
2313
+ keyboard.addShortcut({
2314
+ keymap: {
2315
+ key: 'z',
2316
+ ctrlKey: true,
2317
+ shiftKey: true
2318
+ },
2319
+ action: () => {
2320
+ history.forward();
2321
+ }
2322
+ });
2340
2323
  }
2341
2324
 
2342
2325
  const editorError = core.makeError('CoreEditor');
@@ -2372,7 +2355,7 @@ class Viewer extends core.Starter {
2372
2355
  provide: Viewer,
2373
2356
  useFactory: () => this
2374
2357
  }];
2375
- super(Object.assign(Object.assign({}, options), { plugins: [...(options.plugins || []), () => new DefaultShortcut()], providers: [
2358
+ super(Object.assign(Object.assign({}, options), { plugins: options.plugins || [], providers: [
2376
2359
  ...(options.providers || []),
2377
2360
  ...staticProviders,
2378
2361
  exports.DomRenderer,
@@ -2443,6 +2426,7 @@ class Viewer extends core.Starter {
2443
2426
  this.saveEvent.next();
2444
2427
  }
2445
2428
  });
2429
+ setDefaultShortcut(this);
2446
2430
  let component;
2447
2431
  const content = this.options.content;
2448
2432
  if (content) {
@@ -2691,7 +2675,6 @@ class Viewer extends core.Starter {
2691
2675
  }
2692
2676
 
2693
2677
  exports.CollaborateSelectionAwarenessDelegate = CollaborateSelectionAwarenessDelegate;
2694
- exports.DefaultShortcut = DefaultShortcut;
2695
2678
  exports.EDITOR_OPTIONS = EDITOR_OPTIONS;
2696
2679
  exports.Input = Input;
2697
2680
  exports.VIEW_CONTAINER = VIEW_CONTAINER;
@@ -2704,3 +2687,4 @@ exports.getLayoutRectByRange = getLayoutRectByRange;
2704
2687
  exports.isMac = isMac;
2705
2688
  exports.isSafari = isSafari;
2706
2689
  exports.isWindows = isWindows;
2690
+ exports.setDefaultShortcut = setDefaultShortcut;
@@ -1,8 +1,5 @@
1
1
  import { Injector } from '@tanbo/di';
2
- import { Plugin } from '@textbus/core';
3
2
  /**
4
3
  * Textbus PC 端默认按键绑定
5
4
  */
6
- export declare class DefaultShortcut implements Plugin {
7
- setup(injector: Injector): void;
8
- }
5
+ export declare function setDefaultShortcut(injector: Injector): void;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@textbus/platform-browser",
3
- "version": "3.0.0-alpha.40",
3
+ "version": "3.0.0-alpha.42",
4
4
  "description": "Textbus is a rich text editor and framework that is highly customizable and extensible to achieve rich wysiwyg effects.",
5
5
  "main": "./bundles/index.js",
6
6
  "module": "./bundles/index.esm.js",
@@ -48,5 +48,5 @@
48
48
  "bugs": {
49
49
  "url": "https://github.com/textbus/textbus.git/issues"
50
50
  },
51
- "gitHead": "7f1b573782e02a5e840d3a30507add78235c08c1"
51
+ "gitHead": "5ac4dfb4ae18393afc93ffac9df4012d68adeffa"
52
52
  }