@worktile/theia 2.2.4 → 2.2.5

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.
@@ -7172,10 +7172,35 @@
7172
7172
  }
7173
7173
  i1.AngularEditor.focus(this.editor);
7174
7174
  slate.Transforms.select(this.editor, i1.AngularEditor.findPath(this.editor, this.element));
7175
- document.execCommand('copy');
7176
- this.thyNotifyService.success('复制成功');
7175
+ if (i1.IS_SAFARI) {
7176
+ this.safariCopy();
7177
+ return;
7178
+ }
7179
+ document.execCommand('copy') ? this.thyNotifyService.success('复制成功') : this.thyNotifyService.error('复制失败');
7177
7180
  i1.AngularEditor.deselect(this.editor);
7178
7181
  };
7182
+ TheCodeComponent.prototype.safariCopy = function () {
7183
+ var currentElement = i1.AngularEditor.toDOMNode(this.editor, this.element);
7184
+ var blockCard = currentElement.closest('.slate-block-card');
7185
+ var span = document.createElement('pre');
7186
+ span.appendChild(blockCard.cloneNode(true));
7187
+ span.textContent = this.element.content;
7188
+ span.setAttribute('data-language', this.element.language);
7189
+ span.setAttribute('data-auto-wrap', String(this.element.autoWrap));
7190
+ span.setAttribute('data-height', String(this.element.height));
7191
+ document.body.appendChild(span);
7192
+ var selection = window.getSelection();
7193
+ var range = document.createRange();
7194
+ if (selection) {
7195
+ selection.removeAllRanges();
7196
+ range.selectNode(span);
7197
+ selection.addRange(range);
7198
+ document.execCommand('copy') ? this.thyNotifyService.success('复制成功') : this.thyNotifyService.error('复制失败');
7199
+ selection.removeAllRanges();
7200
+ document.body.removeChild(span);
7201
+ i1.AngularEditor.deselect(this.editor);
7202
+ }
7203
+ };
7179
7204
  TheCodeComponent.prototype.focusChange = function (codeMirrorFocused) {
7180
7205
  if (codeMirrorFocused) {
7181
7206
  this.isHightLight = false;