@worktile/theia 17.3.2 → 17.4.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.
- package/components/text/text.component.d.ts +2 -2
- package/editor.component.d.ts +3 -6
- package/esm2022/components/text/text.component.mjs +7 -8
- package/esm2022/core/with-theia.mjs +1 -1
- package/esm2022/editor.component.mjs +10 -25
- package/esm2022/interfaces/editor.mjs +1 -1
- package/esm2022/interfaces/plugins/index.mjs +2 -2
- package/esm2022/plugins/code/code.component.mjs +2 -2
- package/esm2022/plugins/code/code.plugin.mjs +7 -6
- package/esm2022/plugins/common/insert-data-by-invalid-type.mjs +6 -6
- package/esm2022/plugins/deserialize/deserialize-html.plugin.mjs +20 -18
- package/esm2022/plugins/deserialize/deserialize-md.plugin.mjs +10 -10
- package/esm2022/plugins/image/image.component.mjs +2 -3
- package/esm2022/plugins/image/image.plugin.mjs +5 -4
- package/esm2022/plugins/index.mjs +2 -2
- package/esm2022/plugins/link/link.plugin.mjs +28 -13
- package/esm2022/plugins/list/list.plugin.mjs +17 -27
- package/esm2022/plugins/public-api.mjs +2 -1
- package/esm2022/plugins/quick-insert/index.mjs +4 -0
- package/esm2022/plugins/table/components/toolbar/table-toolbar.component.mjs +1 -1
- package/esm2022/plugins/table/table.plugin.mjs +48 -54
- package/esm2022/utils/copy-node.mjs +29 -34
- package/esm2022/utils/fragment.mjs +11 -11
- package/fesm2022/worktile-theia.mjs +311 -333
- package/fesm2022/worktile-theia.mjs.map +1 -1
- package/interfaces/editor.d.ts +5 -7
- package/interfaces/plugins/index.d.ts +1 -1
- package/package.json +2 -1
- package/plugins/public-api.d.ts +1 -0
- package/plugins/quick-insert/index.d.ts +3 -0
- package/utils/copy-node.d.ts +4 -3
- package/utils/fragment.d.ts +1 -1
|
@@ -10,7 +10,7 @@ import { cloneDeep, map, assign, defaults, groupBy, uniq, isEqual } from 'lodash
|
|
|
10
10
|
export { assign, cloneDeep, debounce, defaults, groupBy, isEqual, map, uniq } from 'lodash';
|
|
11
11
|
import { Editor, Element, Span, Range, Path, Node, Point, Text, Transforms, Operation, createEditor } from 'slate';
|
|
12
12
|
import * as i4 from 'slate-angular';
|
|
13
|
-
import { NODE_TO_PARENT, NODE_TO_INDEX, AngularEditor, hotkeys,
|
|
13
|
+
import { NODE_TO_PARENT, NODE_TO_INDEX, getClipboardData, AngularEditor, hotkeys, getPlainText as getPlainText$1, createClipboardData, setClipboardData, BaseElementComponent, IS_SAFARI, ELEMENT_TO_COMPONENT, BaseTextComponent, SlateModule, hasBlockCard, isCardLeft, FAKE_RIGHT_BLOCK_CARD_OFFSET, SlateChildrenOutlet, EDITOR_TO_ELEMENT, defaultScrollSelectionIntoView, getDataTransferClipboard, withAngular } from 'slate-angular';
|
|
14
14
|
import { HistoryEditor, withHistory } from 'slate-history';
|
|
15
15
|
import { TheiaConverter } from '@atinc/selene';
|
|
16
16
|
import { isObject, isArray, isString, isUndefined } from 'ngx-tethys/util';
|
|
@@ -46,6 +46,7 @@ import { ThySwitch } from 'ngx-tethys/switch';
|
|
|
46
46
|
import * as i1$1 from 'ngx-tethys/notify';
|
|
47
47
|
import { ThyProgress } from 'ngx-tethys/progress';
|
|
48
48
|
import { ThyUploadStatus } from 'ngx-tethys/upload';
|
|
49
|
+
import getUrls from 'get-urls';
|
|
49
50
|
import { ThyButton } from 'ngx-tethys/button';
|
|
50
51
|
import { ThyFormDirective, ThyFormGroup, ThyFormSubmitDirective, ThyFormGroupFooter } from 'ngx-tethys/form';
|
|
51
52
|
import { PortalInjector, ComponentPortal } from '@angular/cdk/portal';
|
|
@@ -1288,19 +1289,18 @@ const getEndBlock = (editor, fragment) => {
|
|
|
1288
1289
|
}
|
|
1289
1290
|
return fragment;
|
|
1290
1291
|
};
|
|
1291
|
-
const extractFragment = (data, deleteKey = ELEMENT_UNIQUE_ID) => {
|
|
1292
|
-
const
|
|
1293
|
-
|
|
1294
|
-
|
|
1295
|
-
|
|
1296
|
-
|
|
1297
|
-
nodes = [nodes];
|
|
1292
|
+
const extractFragment = async (data, deleteKey = ELEMENT_UNIQUE_ID) => {
|
|
1293
|
+
const clipboardData = await getClipboardData(data);
|
|
1294
|
+
let elements = clipboardData?.elements;
|
|
1295
|
+
if (elements) {
|
|
1296
|
+
if (!Array.isArray(elements)) {
|
|
1297
|
+
elements = [elements];
|
|
1298
1298
|
}
|
|
1299
1299
|
// delete key to avoid duplicate keys
|
|
1300
1300
|
if (deleteKey) {
|
|
1301
|
-
deleteElementKey(
|
|
1301
|
+
deleteElementKey(elements, deleteKey);
|
|
1302
1302
|
}
|
|
1303
|
-
return
|
|
1303
|
+
return elements;
|
|
1304
1304
|
}
|
|
1305
1305
|
return null;
|
|
1306
1306
|
};
|
|
@@ -1715,37 +1715,31 @@ const isDirectionKeydown = (event) => {
|
|
|
1715
1715
|
return isMoveUp || isMoveDown || isMoveBackward || isMoveForward;
|
|
1716
1716
|
};
|
|
1717
1717
|
|
|
1718
|
-
|
|
1719
|
-
|
|
1720
|
-
|
|
1721
|
-
|
|
1722
|
-
|
|
1723
|
-
|
|
1724
|
-
|
|
1725
|
-
|
|
1726
|
-
|
|
1727
|
-
|
|
1728
|
-
|
|
1729
|
-
const
|
|
1730
|
-
|
|
1731
|
-
|
|
1732
|
-
|
|
1733
|
-
|
|
1734
|
-
|
|
1735
|
-
|
|
1736
|
-
|
|
1737
|
-
|
|
1738
|
-
|
|
1739
|
-
|
|
1740
|
-
|
|
1741
|
-
|
|
1742
|
-
|
|
1743
|
-
const selection = window.getSelection();
|
|
1744
|
-
const currentElement = AngularEditor.toDOMNode(editor, element);
|
|
1745
|
-
const range = document.createRange();
|
|
1746
|
-
selection.removeAllRanges();
|
|
1747
|
-
range.selectNode(currentElement);
|
|
1748
|
-
selection.addRange(range);
|
|
1718
|
+
const setClipboardDataByDom = async (e, fragment, data) => {
|
|
1719
|
+
const nodes = Array.isArray(fragment) ? fragment : [fragment];
|
|
1720
|
+
const htmlString = TheiaConverter.convertToHtml(nodes);
|
|
1721
|
+
const domRange = AngularEditor.toDOMRange(e, e.selection);
|
|
1722
|
+
const contents = domRange.cloneContents();
|
|
1723
|
+
const div = document.createElement('div');
|
|
1724
|
+
div.appendChild(contents);
|
|
1725
|
+
div.setAttribute('hidden', 'true');
|
|
1726
|
+
div.innerHTML = htmlString;
|
|
1727
|
+
document.body.appendChild(div);
|
|
1728
|
+
const attach = div.childNodes[0];
|
|
1729
|
+
const plainText = getPlainText$1(div);
|
|
1730
|
+
const clipboardData = createClipboardData(htmlString, nodes, plainText, []);
|
|
1731
|
+
await setClipboardData(clipboardData, div, attach, data);
|
|
1732
|
+
document.body.removeChild(div);
|
|
1733
|
+
};
|
|
1734
|
+
function copyNode(e, element, thyNotifyService) {
|
|
1735
|
+
const fragment = cloneDeep(element);
|
|
1736
|
+
return setClipboardDataByDom(e, fragment)
|
|
1737
|
+
.then(() => {
|
|
1738
|
+
thyNotifyService.success('复制成功');
|
|
1739
|
+
})
|
|
1740
|
+
.catch(() => {
|
|
1741
|
+
thyNotifyService.error('复制失败');
|
|
1742
|
+
});
|
|
1749
1743
|
}
|
|
1750
1744
|
|
|
1751
1745
|
function idCreator(length = 5) {
|
|
@@ -1797,6 +1791,25 @@ const THE_MODE_PROVIDER = {
|
|
|
1797
1791
|
|
|
1798
1792
|
const THE_UPLOAD_SERVICE_TOKEN = new InjectionToken('THE_UPLOAD_SERVICE_TOKEN');
|
|
1799
1793
|
|
|
1794
|
+
const ThePluginMenu = {
|
|
1795
|
+
isMenuGroup(value) {
|
|
1796
|
+
if (value instanceof Object && !value.key) {
|
|
1797
|
+
return true;
|
|
1798
|
+
}
|
|
1799
|
+
else {
|
|
1800
|
+
return false;
|
|
1801
|
+
}
|
|
1802
|
+
},
|
|
1803
|
+
isMenuItem(value) {
|
|
1804
|
+
if (value?.key) {
|
|
1805
|
+
return true;
|
|
1806
|
+
}
|
|
1807
|
+
else {
|
|
1808
|
+
return false;
|
|
1809
|
+
}
|
|
1810
|
+
}
|
|
1811
|
+
};
|
|
1812
|
+
|
|
1800
1813
|
var PluginKeys;
|
|
1801
1814
|
(function (PluginKeys) {
|
|
1802
1815
|
PluginKeys["list"] = "list";
|
|
@@ -1839,25 +1852,6 @@ var PluginKeys;
|
|
|
1839
1852
|
PluginKeys["internalCommon"] = "internalCommon";
|
|
1840
1853
|
})(PluginKeys || (PluginKeys = {}));
|
|
1841
1854
|
|
|
1842
|
-
const ThePluginMenu = {
|
|
1843
|
-
isMenuGroup(value) {
|
|
1844
|
-
if (value instanceof Object && !value.key) {
|
|
1845
|
-
return true;
|
|
1846
|
-
}
|
|
1847
|
-
else {
|
|
1848
|
-
return false;
|
|
1849
|
-
}
|
|
1850
|
-
},
|
|
1851
|
-
isMenuItem(value) {
|
|
1852
|
-
if (value?.key) {
|
|
1853
|
-
return true;
|
|
1854
|
-
}
|
|
1855
|
-
else {
|
|
1856
|
-
return false;
|
|
1857
|
-
}
|
|
1858
|
-
}
|
|
1859
|
-
};
|
|
1860
|
-
|
|
1861
1855
|
const THE_PRESET_CONFIG_TOKEN = new InjectionToken('the-preset');
|
|
1862
1856
|
|
|
1863
1857
|
const inValidTypes = [
|
|
@@ -6867,6 +6861,123 @@ const InlineCodeEditor = {
|
|
|
6867
6861
|
}
|
|
6868
6862
|
};
|
|
6869
6863
|
|
|
6864
|
+
class TheQuickInsert {
|
|
6865
|
+
handleMousedownNativeElement(event) {
|
|
6866
|
+
event.preventDefault();
|
|
6867
|
+
event.stopPropagation();
|
|
6868
|
+
}
|
|
6869
|
+
constructor(renderer, elementRef, cdr) {
|
|
6870
|
+
this.renderer = renderer;
|
|
6871
|
+
this.elementRef = elementRef;
|
|
6872
|
+
this.cdr = cdr;
|
|
6873
|
+
this.className = 'the-quick-insert';
|
|
6874
|
+
this.isVisible = false;
|
|
6875
|
+
this.defaultIconName = 'plus-circle-thin';
|
|
6876
|
+
this.iconNameFill = 'plus-circle-thin-fill';
|
|
6877
|
+
this.displayIconName = this.defaultIconName;
|
|
6878
|
+
}
|
|
6879
|
+
ngOnInit() {
|
|
6880
|
+
const { onChange } = this.editor;
|
|
6881
|
+
this.editor.onChange = () => {
|
|
6882
|
+
onChange();
|
|
6883
|
+
if (this.editor && this.editor.options && !this.editor.options.readonly) {
|
|
6884
|
+
// wait isOpenedMenu is updated
|
|
6885
|
+
setTimeout(() => {
|
|
6886
|
+
this.updateIconDisplay();
|
|
6887
|
+
}, 0);
|
|
6888
|
+
}
|
|
6889
|
+
};
|
|
6890
|
+
this.updateIconDisplay();
|
|
6891
|
+
}
|
|
6892
|
+
ngOnChanges(changes) {
|
|
6893
|
+
if (changes.isVisible && !changes.isVisible.firstChange) {
|
|
6894
|
+
this.updateIconDisplay();
|
|
6895
|
+
}
|
|
6896
|
+
}
|
|
6897
|
+
updateIconDisplay() {
|
|
6898
|
+
const { editor } = this;
|
|
6899
|
+
if (this.isVisible &&
|
|
6900
|
+
!QuickInsertEditor.isOpenedMenu(editor) &&
|
|
6901
|
+
isCleanEmptyParagraph(editor) &&
|
|
6902
|
+
!this.hasExcludeAttribute() &&
|
|
6903
|
+
!this.isRichMediaScope()) {
|
|
6904
|
+
const block = Node.ancestor(editor, [editor?.selection?.anchor.path[0]]);
|
|
6905
|
+
const rootNode = AngularEditor.toDOMNode(editor, block);
|
|
6906
|
+
this.updatePosition(rootNode.offsetLeft, rootNode.offsetTop);
|
|
6907
|
+
return;
|
|
6908
|
+
}
|
|
6909
|
+
this.addHiddenClass();
|
|
6910
|
+
}
|
|
6911
|
+
addHiddenClass() {
|
|
6912
|
+
this.elementRef.nativeElement.classList.add('d-none');
|
|
6913
|
+
}
|
|
6914
|
+
removeHiddenClass() {
|
|
6915
|
+
this.elementRef.nativeElement.classList.remove('d-none');
|
|
6916
|
+
}
|
|
6917
|
+
isRichMediaScope() {
|
|
6918
|
+
const { editor } = this;
|
|
6919
|
+
if (editor?.selection) {
|
|
6920
|
+
const block = Node.ancestor(editor, [editor?.selection?.anchor.path[0]]);
|
|
6921
|
+
const rootElement = AngularEditor.toDOMNode(editor, block);
|
|
6922
|
+
const leafElement = rootElement.querySelector('[data-slate-leaf="true"]');
|
|
6923
|
+
const rootElementRect = rootElement.getBoundingClientRect();
|
|
6924
|
+
const leafElementRect = leafElement.getBoundingClientRect();
|
|
6925
|
+
return leafElementRect?.x !== rootElementRect?.x;
|
|
6926
|
+
}
|
|
6927
|
+
return false;
|
|
6928
|
+
}
|
|
6929
|
+
hasExcludeAttribute() {
|
|
6930
|
+
const marks = getSelectionMarks(this.editor);
|
|
6931
|
+
const fontSizeMark = marks[MarkTypes.fontSize];
|
|
6932
|
+
return fontSizeMark;
|
|
6933
|
+
}
|
|
6934
|
+
updatePosition(left, top) {
|
|
6935
|
+
this.renderer.setStyle(this.elementRef.nativeElement, 'top', `${top}px`);
|
|
6936
|
+
this.renderer.setStyle(this.elementRef.nativeElement, 'left', `${left}px`);
|
|
6937
|
+
this.removeHiddenClass();
|
|
6938
|
+
}
|
|
6939
|
+
mouseEnter(event) {
|
|
6940
|
+
this.displayIconName = this.iconNameFill;
|
|
6941
|
+
this.cdr.markForCheck();
|
|
6942
|
+
}
|
|
6943
|
+
mouseLeave(event) {
|
|
6944
|
+
this.displayIconName = this.defaultIconName;
|
|
6945
|
+
this.cdr.markForCheck();
|
|
6946
|
+
}
|
|
6947
|
+
handleClick(event) {
|
|
6948
|
+
event.stopPropagation();
|
|
6949
|
+
event.preventDefault();
|
|
6950
|
+
// avoid popover is closed immediately
|
|
6951
|
+
setTimeout(() => {
|
|
6952
|
+
QuickInsertEditor.openMenu(this.editor)
|
|
6953
|
+
.afterClosed()
|
|
6954
|
+
.subscribe(() => {
|
|
6955
|
+
this.updateIconDisplay();
|
|
6956
|
+
});
|
|
6957
|
+
this.updateIconDisplay();
|
|
6958
|
+
}, 100);
|
|
6959
|
+
}
|
|
6960
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.4", ngImport: i0, type: TheQuickInsert, deps: [{ token: i0.Renderer2 }, { token: i0.ElementRef }, { token: i0.ChangeDetectorRef }], target: i0.ɵɵFactoryTarget.Component }); }
|
|
6961
|
+
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "17.3.4", type: TheQuickInsert, isStandalone: true, selector: "[theQuickInsert]", inputs: { editor: "editor", isVisible: "isVisible" }, host: { listeners: { "mousedown": "handleMousedownNativeElement($event)" }, properties: { "class": "this.className" } }, viewQueries: [{ propertyName: "iconElement", first: true, predicate: ["iconElement"], descendants: true, read: ElementRef }], usesOnChanges: true, ngImport: i0, template: "<thy-icon\n #iconElement\n [thyIconName]=\"displayIconName\"\n class=\"quick-insert-icon text-desc font-size-xlg\"\n (mouseenter)=\"mouseEnter($event)\"\n (mouseleave)=\"mouseLeave($event)\"\n (mousedown)=\"handleClick($event)\"\n></thy-icon>\n", dependencies: [{ kind: "component", type: ThyIcon, selector: "thy-icon, [thy-icon]", inputs: ["thyIconType", "thyTwotoneColor", "thyIconName", "thyIconRotate", "thyIconSet", "thyIconLegging", "thyIconLinearGradient"] }] }); }
|
|
6962
|
+
}
|
|
6963
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.4", ngImport: i0, type: TheQuickInsert, decorators: [{
|
|
6964
|
+
type: Component,
|
|
6965
|
+
args: [{ selector: '[theQuickInsert]', standalone: true, imports: [ThyIcon], template: "<thy-icon\n #iconElement\n [thyIconName]=\"displayIconName\"\n class=\"quick-insert-icon text-desc font-size-xlg\"\n (mouseenter)=\"mouseEnter($event)\"\n (mouseleave)=\"mouseLeave($event)\"\n (mousedown)=\"handleClick($event)\"\n></thy-icon>\n" }]
|
|
6966
|
+
}], ctorParameters: () => [{ type: i0.Renderer2 }, { type: i0.ElementRef }, { type: i0.ChangeDetectorRef }], propDecorators: { className: [{
|
|
6967
|
+
type: HostBinding,
|
|
6968
|
+
args: ['class']
|
|
6969
|
+
}], editor: [{
|
|
6970
|
+
type: Input
|
|
6971
|
+
}], isVisible: [{
|
|
6972
|
+
type: Input
|
|
6973
|
+
}], iconElement: [{
|
|
6974
|
+
type: ViewChild,
|
|
6975
|
+
args: ['iconElement', { read: ElementRef, static: false }]
|
|
6976
|
+
}], handleMousedownNativeElement: [{
|
|
6977
|
+
type: HostListener,
|
|
6978
|
+
args: ['mousedown', ['$event']]
|
|
6979
|
+
}] } });
|
|
6980
|
+
|
|
6870
6981
|
class TheTableSelect {
|
|
6871
6982
|
constructor(popoverRef) {
|
|
6872
6983
|
this.popoverRef = popoverRef;
|
|
@@ -7267,6 +7378,10 @@ class TheText extends BaseTextComponent {
|
|
|
7267
7378
|
this.excludes = ['color', 'font-size', 'background-color', 'text'];
|
|
7268
7379
|
this.attributes = [];
|
|
7269
7380
|
}
|
|
7381
|
+
onContextChange() {
|
|
7382
|
+
super.onContextChange();
|
|
7383
|
+
this.applyTextMark();
|
|
7384
|
+
}
|
|
7270
7385
|
applyTextMark() {
|
|
7271
7386
|
this.attributes.forEach(attr => {
|
|
7272
7387
|
this.renderer2.removeAttribute(this.elementRef.nativeElement, attr);
|
|
@@ -7294,10 +7409,6 @@ class TheText extends BaseTextComponent {
|
|
|
7294
7409
|
this.renderer2.removeStyle(this.elementRef.nativeElement, 'background-color');
|
|
7295
7410
|
}
|
|
7296
7411
|
}
|
|
7297
|
-
onContextChange() {
|
|
7298
|
-
super.onContextChange();
|
|
7299
|
-
this.applyTextMark();
|
|
7300
|
-
}
|
|
7301
7412
|
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.4", ngImport: i0, type: TheText, deps: [{ token: i0.ElementRef }, { token: i0.Renderer2 }, { token: i0.ChangeDetectorRef }], target: i0.ɵɵFactoryTarget.Component }); }
|
|
7302
7413
|
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "17.3.4", type: TheText, isStandalone: true, selector: "span[theText]", host: { attributes: { "data-slate-node": "text" } }, usesInheritance: true, ngImport: i0, template: ``, isInline: true }); }
|
|
7303
7414
|
}
|
|
@@ -7309,8 +7420,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.4", ngImpor
|
|
|
7309
7420
|
host: {
|
|
7310
7421
|
'data-slate-node': 'text'
|
|
7311
7422
|
},
|
|
7312
|
-
standalone: true
|
|
7313
|
-
imports: [SlateLeaves]
|
|
7423
|
+
standalone: true
|
|
7314
7424
|
}]
|
|
7315
7425
|
}], ctorParameters: () => [{ type: i0.ElementRef }, { type: i0.Renderer2 }, { type: i0.ChangeDetectorRef }] });
|
|
7316
7426
|
|
|
@@ -7443,20 +7553,20 @@ const closeConversionHint = (editor) => {
|
|
|
7443
7553
|
}
|
|
7444
7554
|
};
|
|
7445
7555
|
const withDeserializeMd = (editor) => {
|
|
7446
|
-
const {
|
|
7556
|
+
const { insertFragmentData, onKeydown } = editor;
|
|
7447
7557
|
editor.onKeydown = (event) => {
|
|
7448
7558
|
closeConversionHint(editor);
|
|
7449
7559
|
onKeydown(event);
|
|
7450
7560
|
};
|
|
7451
|
-
editor.
|
|
7561
|
+
editor.insertFragmentData = async (data) => {
|
|
7452
7562
|
const popover = editor.injector.get(ThyPopover);
|
|
7453
7563
|
const viewContainerRef = editor.injector.get(ViewContainerRef);
|
|
7454
7564
|
const cdr = editor.injector.get(ChangeDetectorRef);
|
|
7455
|
-
const plainFragment = data.getData('text/plain');
|
|
7456
|
-
const slateFragment = data.getData(`application/${CLIPBOARD_FORMAT_KEY}`);
|
|
7457
7565
|
const oldRange = editor.selection;
|
|
7566
|
+
const clipboardData = await getClipboardData(data);
|
|
7567
|
+
const plainFragment = clipboardData?.text;
|
|
7458
7568
|
closeConversionHint(editor);
|
|
7459
|
-
if (plainFragment && isMarkdownSyntax(plainFragment) && !
|
|
7569
|
+
if (plainFragment && isMarkdownSyntax(plainFragment) && !clipboardData?.elements) {
|
|
7460
7570
|
setTimeout(() => {
|
|
7461
7571
|
const overlay = editor.injector.get(Overlay);
|
|
7462
7572
|
const bodyElement = document.body;
|
|
@@ -7493,7 +7603,7 @@ const withDeserializeMd = (editor) => {
|
|
|
7493
7603
|
Transforms.insertFragment(editor, fragment);
|
|
7494
7604
|
AngularEditor.focus(editor);
|
|
7495
7605
|
});
|
|
7496
|
-
return;
|
|
7606
|
+
return true;
|
|
7497
7607
|
}
|
|
7498
7608
|
else {
|
|
7499
7609
|
closeConversionHint(editor);
|
|
@@ -7519,7 +7629,7 @@ const withDeserializeMd = (editor) => {
|
|
|
7519
7629
|
cdr.markForCheck();
|
|
7520
7630
|
});
|
|
7521
7631
|
}
|
|
7522
|
-
|
|
7632
|
+
return insertFragmentData(data);
|
|
7523
7633
|
};
|
|
7524
7634
|
return editor;
|
|
7525
7635
|
};
|
|
@@ -8728,7 +8838,7 @@ class TheCode extends TheBaseElement {
|
|
|
8728
8838
|
}
|
|
8729
8839
|
onCopy(event) {
|
|
8730
8840
|
event.preventDefault();
|
|
8731
|
-
copyNode(this.editor, this.element, this.thyNotifyService
|
|
8841
|
+
copyNode(this.editor, this.element, this.thyNotifyService);
|
|
8732
8842
|
}
|
|
8733
8843
|
focusChange(codeMirrorFocused) {
|
|
8734
8844
|
if (codeMirrorFocused) {
|
|
@@ -8827,15 +8937,15 @@ const withCode = (editor) => {
|
|
|
8827
8937
|
}
|
|
8828
8938
|
return renderElement(element);
|
|
8829
8939
|
};
|
|
8830
|
-
editor.setFragmentData =
|
|
8831
|
-
setFragmentData(unit);
|
|
8940
|
+
editor.setFragmentData = (data, originEvent) => {
|
|
8832
8941
|
const { selection } = editor;
|
|
8833
8942
|
const [start] = Editor.edges(editor, selection);
|
|
8834
8943
|
if (isNodeTypeIn(editor, [ElementKinds.code], { at: start })) {
|
|
8835
8944
|
const [codeNode] = getAboveByType(editor, ElementKinds.code);
|
|
8836
|
-
|
|
8837
|
-
return
|
|
8945
|
+
setClipboardDataByDom(editor, codeNode, data);
|
|
8946
|
+
return;
|
|
8838
8947
|
}
|
|
8948
|
+
setFragmentData(data, originEvent);
|
|
8839
8949
|
};
|
|
8840
8950
|
return editor;
|
|
8841
8951
|
};
|
|
@@ -8973,25 +9083,6 @@ const createColorPlugin = createPluginFactory({
|
|
|
8973
9083
|
}
|
|
8974
9084
|
});
|
|
8975
9085
|
|
|
8976
|
-
const withInsertDataByInvalidType = (editor) => {
|
|
8977
|
-
const { insertData } = editor;
|
|
8978
|
-
editor.insertData = (data) => {
|
|
8979
|
-
const fragment = extractFragment(data);
|
|
8980
|
-
if (fragment) {
|
|
8981
|
-
const isContinue = insertDataByInvalidType(editor, fragment);
|
|
8982
|
-
if (!isContinue) {
|
|
8983
|
-
return;
|
|
8984
|
-
}
|
|
8985
|
-
}
|
|
8986
|
-
insertData(data);
|
|
8987
|
-
};
|
|
8988
|
-
return editor;
|
|
8989
|
-
};
|
|
8990
|
-
const createInsertDataByInvalidTypePlugin = createPluginFactory({
|
|
8991
|
-
key: PluginKeys.insertDataByInvalidType,
|
|
8992
|
-
withOverrides: withInsertDataByInvalidType
|
|
8993
|
-
});
|
|
8994
|
-
|
|
8995
9086
|
const withBlockCard = (editor) => {
|
|
8996
9087
|
const { insertBreak, deleteBackward, onKeydown, deleteForward, insertData, insertText, mousedown } = editor;
|
|
8997
9088
|
editor.insertBreak = () => {
|
|
@@ -9405,6 +9496,25 @@ const createTheHistoryPlugin = createPluginFactory({
|
|
|
9405
9496
|
withOverrides: withTheHistory
|
|
9406
9497
|
});
|
|
9407
9498
|
|
|
9499
|
+
const withInsertDataByInvalidType = (editor) => {
|
|
9500
|
+
const { insertFragmentData } = editor;
|
|
9501
|
+
editor.insertFragmentData = async (data) => {
|
|
9502
|
+
const fragment = await extractFragment(data);
|
|
9503
|
+
if (fragment) {
|
|
9504
|
+
const isContinue = insertDataByInvalidType(editor, fragment);
|
|
9505
|
+
if (!isContinue) {
|
|
9506
|
+
return true;
|
|
9507
|
+
}
|
|
9508
|
+
}
|
|
9509
|
+
return insertFragmentData(data);
|
|
9510
|
+
};
|
|
9511
|
+
return editor;
|
|
9512
|
+
};
|
|
9513
|
+
const createInsertDataByInvalidTypePlugin = createPluginFactory({
|
|
9514
|
+
key: PluginKeys.insertDataByInvalidType,
|
|
9515
|
+
withOverrides: withInsertDataByInvalidType
|
|
9516
|
+
});
|
|
9517
|
+
|
|
9408
9518
|
const isInline = (editor, path) => {
|
|
9409
9519
|
const [inlineNode] = Editor.nodes(editor, {
|
|
9410
9520
|
at: path ? path : editor.selection?.anchor.path,
|
|
@@ -9648,23 +9758,24 @@ const createResetTypePlugin = createPluginFactory({
|
|
|
9648
9758
|
});
|
|
9649
9759
|
|
|
9650
9760
|
const withDeserializeHTML = (editor) => {
|
|
9651
|
-
const {
|
|
9652
|
-
editor.
|
|
9653
|
-
const
|
|
9654
|
-
|
|
9655
|
-
|
|
9656
|
-
const htmlDom = new DOMParser().parseFromString(html, 'text/html');
|
|
9761
|
+
const { insertFragmentData } = editor;
|
|
9762
|
+
editor.insertFragmentData = async (data) => {
|
|
9763
|
+
const clipboardData = await getClipboardData(data);
|
|
9764
|
+
if (!clipboardData?.elements && clipboardData?.html) {
|
|
9765
|
+
const htmlDom = new DOMParser().parseFromString(clipboardData?.html, 'text/html');
|
|
9657
9766
|
const fragment = TheiaConverter.convertToTheia(Array.from(htmlDom.body.children));
|
|
9767
|
+
// 识别粘贴的 HTML 只有纯链接, 跳至 link
|
|
9768
|
+
if (fragment.length === 1 && fragment.every(block => isUrl(block?.children?.[0]?.['text']))) {
|
|
9769
|
+
return insertFragmentData(data);
|
|
9770
|
+
}
|
|
9658
9771
|
// 无法识别HTML内容时后退一下:识别纯文本
|
|
9659
9772
|
if (fragment.every(block => block.type === ElementKinds.paragraph && isLogicEmptyParagraphElement(editor, block))) {
|
|
9660
|
-
|
|
9661
|
-
return;
|
|
9773
|
+
return insertFragmentData(data);
|
|
9662
9774
|
}
|
|
9663
9775
|
// 识出纯图片并且粘贴板中存在文件则不进行处理, hook 直接右键复制图片的场景,流转到上传图片流程
|
|
9664
9776
|
// 后续需要做识别html图片后自动上传处理
|
|
9665
9777
|
if (fragment.length === 1 && fragment[0].type === ElementKinds.image && data.files.length > 0) {
|
|
9666
|
-
|
|
9667
|
-
return;
|
|
9778
|
+
return insertFragmentData(data);
|
|
9668
9779
|
}
|
|
9669
9780
|
// 过滤 text 节点的 color/background-color 属性
|
|
9670
9781
|
fragment.forEach(node => filterTextFormat(node));
|
|
@@ -9683,12 +9794,12 @@ const withDeserializeHTML = (editor) => {
|
|
|
9683
9794
|
});
|
|
9684
9795
|
const isContinue = insertDataByInvalidType(editor, fragment);
|
|
9685
9796
|
if (!isContinue) {
|
|
9686
|
-
return;
|
|
9797
|
+
return true;
|
|
9687
9798
|
}
|
|
9688
9799
|
Transforms.insertFragment(editor, fragment);
|
|
9689
|
-
return;
|
|
9800
|
+
return true;
|
|
9690
9801
|
}
|
|
9691
|
-
|
|
9802
|
+
return insertFragmentData(data);
|
|
9692
9803
|
};
|
|
9693
9804
|
return editor;
|
|
9694
9805
|
};
|
|
@@ -10415,7 +10526,6 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.4", ngImpor
|
|
|
10415
10526
|
NgFor,
|
|
10416
10527
|
NgStyle,
|
|
10417
10528
|
NgTemplateOutlet,
|
|
10418
|
-
SlateChildren,
|
|
10419
10529
|
ThyIcon,
|
|
10420
10530
|
ThyImageDirective,
|
|
10421
10531
|
ThyAction,
|
|
@@ -10446,8 +10556,9 @@ const withImage = (editor) => {
|
|
|
10446
10556
|
editor.isVoid = (element) => {
|
|
10447
10557
|
return element.type === ElementKinds.image || isVoid(element);
|
|
10448
10558
|
};
|
|
10449
|
-
editor.insertData = (data) => {
|
|
10450
|
-
|
|
10559
|
+
editor.insertData = async (data) => {
|
|
10560
|
+
const clipboardData = await getClipboardData(data);
|
|
10561
|
+
if (clipboardData?.files?.length) {
|
|
10451
10562
|
const imageFiles = [];
|
|
10452
10563
|
const imageTypes = getPluginOptions(editor, PluginKeys.image)?.imageTypes;
|
|
10453
10564
|
for (const file of data.files) {
|
|
@@ -11009,7 +11120,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.4", ngImpor
|
|
|
11009
11120
|
}] } });
|
|
11010
11121
|
|
|
11011
11122
|
const withLink = (editor) => {
|
|
11012
|
-
const {
|
|
11123
|
+
const { insertText, isInline, insertFragmentData, renderElement } = editor;
|
|
11013
11124
|
editor.isInline = (element) => {
|
|
11014
11125
|
return element.type === ElementKinds.link ? true : isInline(element);
|
|
11015
11126
|
};
|
|
@@ -11022,16 +11133,28 @@ const withLink = (editor) => {
|
|
|
11022
11133
|
insertText(text);
|
|
11023
11134
|
}
|
|
11024
11135
|
};
|
|
11025
|
-
editor.
|
|
11026
|
-
const
|
|
11027
|
-
const
|
|
11028
|
-
if (text && isUrl(text)
|
|
11029
|
-
|
|
11030
|
-
|
|
11031
|
-
|
|
11032
|
-
|
|
11033
|
-
|
|
11136
|
+
editor.insertFragmentData = async (data) => {
|
|
11137
|
+
const clipboardData = await getClipboardData(data);
|
|
11138
|
+
const text = clipboardData?.text;
|
|
11139
|
+
if (!clipboardData?.elements && text && isUrl(text)) {
|
|
11140
|
+
const urls = Array.from(getUrls(text, { stripWWW: false }));
|
|
11141
|
+
if (urls.length) {
|
|
11142
|
+
let str = cloneDeep(text);
|
|
11143
|
+
urls.forEach((url, index) => {
|
|
11144
|
+
const parts = str.split(url);
|
|
11145
|
+
const beforeUrl = parts[0];
|
|
11146
|
+
insertText(beforeUrl);
|
|
11147
|
+
LinkEditor.wrapLink(editor, url, url);
|
|
11148
|
+
Transforms.move(editor, { distance: 1, unit: 'offset' });
|
|
11149
|
+
str = parts[1];
|
|
11150
|
+
if (index === urls.length - 1) {
|
|
11151
|
+
insertText(str);
|
|
11152
|
+
}
|
|
11153
|
+
});
|
|
11154
|
+
return true;
|
|
11155
|
+
}
|
|
11034
11156
|
}
|
|
11157
|
+
return insertFragmentData(data);
|
|
11035
11158
|
};
|
|
11036
11159
|
editor.renderElement = (element) => {
|
|
11037
11160
|
if (element.type === ElementKinds.link) {
|
|
@@ -11800,7 +11923,7 @@ const unwrapList = (editor) => {
|
|
|
11800
11923
|
};
|
|
11801
11924
|
|
|
11802
11925
|
const withList = (editor) => {
|
|
11803
|
-
const { insertBreak, deleteBackward, onKeydown, insertData, setFragmentData, renderElement } = editor;
|
|
11926
|
+
const { insertBreak, deleteBackward, onKeydown, insertData, insertFragmentData, setFragmentData, renderElement } = editor;
|
|
11804
11927
|
const validLiChildrenTypes = getPluginOptions(editor, PluginKeys.list)?.validLiChildrenTypes ?? [];
|
|
11805
11928
|
const resetBlockTypesListRule = {
|
|
11806
11929
|
types: [ElementKinds.listItem],
|
|
@@ -11877,7 +12000,7 @@ const withList = (editor) => {
|
|
|
11877
12000
|
}
|
|
11878
12001
|
insertBreak();
|
|
11879
12002
|
};
|
|
11880
|
-
editor.setFragmentData =
|
|
12003
|
+
editor.setFragmentData = (data, originEvent) => {
|
|
11881
12004
|
const { selection } = editor;
|
|
11882
12005
|
const [start] = Editor.edges(editor, selection);
|
|
11883
12006
|
if (isInList(editor, start)) {
|
|
@@ -11897,22 +12020,13 @@ const withList = (editor) => {
|
|
|
11897
12020
|
fragmentNodes = children[0].children;
|
|
11898
12021
|
}
|
|
11899
12022
|
const fragment = fragmentNodes.concat(fragmentData.slice(1));
|
|
11900
|
-
|
|
11901
|
-
|
|
11902
|
-
|
|
11903
|
-
|
|
11904
|
-
unit.setData(`application/${CLIPBOARD_FORMAT_KEY}`, encoded);
|
|
11905
|
-
const div = document.createElement('div');
|
|
11906
|
-
div.appendChild(contents);
|
|
11907
|
-
div.setAttribute('hidden', 'true');
|
|
11908
|
-
document.body.appendChild(div);
|
|
11909
|
-
unit.setData('text/html', div.innerHTML);
|
|
11910
|
-
unit.setData('text/plain', getPlainText$1(div));
|
|
11911
|
-
document.body.removeChild(div);
|
|
11912
|
-
return;
|
|
12023
|
+
if (fragment) {
|
|
12024
|
+
setClipboardDataByDom(editor, fragment, data);
|
|
12025
|
+
return;
|
|
12026
|
+
}
|
|
11913
12027
|
}
|
|
11914
12028
|
}
|
|
11915
|
-
setFragmentData(
|
|
12029
|
+
setFragmentData(data, originEvent);
|
|
11916
12030
|
};
|
|
11917
12031
|
editor.deleteBackward = unit => {
|
|
11918
12032
|
const res = getListItemEntry(editor, {});
|
|
@@ -11976,13 +12090,12 @@ const withList = (editor) => {
|
|
|
11976
12090
|
}
|
|
11977
12091
|
deleteBackward(unit);
|
|
11978
12092
|
};
|
|
11979
|
-
editor.
|
|
11980
|
-
const
|
|
11981
|
-
const fragment = extractFragment(data);
|
|
11982
|
-
const aboveEntry = Editor.above(editor, {
|
|
11983
|
-
match: n => Element.isElement(n) && Editor.isBlock(editor, n) && n.type === ElementKinds.listItem
|
|
11984
|
-
});
|
|
12093
|
+
editor.insertFragmentData = async (data) => {
|
|
12094
|
+
const fragment = await extractFragment(data);
|
|
11985
12095
|
if (fragment) {
|
|
12096
|
+
const aboveEntry = Editor.above(editor, {
|
|
12097
|
+
match: n => Element.isElement(n) && Editor.isBlock(editor, n) && n.type === ElementKinds.listItem
|
|
12098
|
+
});
|
|
11986
12099
|
const res = getListItemEntry(editor, {});
|
|
11987
12100
|
if (fragment.length === 1 &&
|
|
11988
12101
|
isList(fragment[0]) &&
|
|
@@ -11990,10 +12103,10 @@ const withList = (editor) => {
|
|
|
11990
12103
|
!isSingleListItem(fragment[0]) &&
|
|
11991
12104
|
hasStableListItem(res.listItem[0])) {
|
|
11992
12105
|
insertListData(editor, { fromList: fragment[0], toListItemEntry: aboveEntry });
|
|
11993
|
-
return;
|
|
12106
|
+
return true;
|
|
11994
12107
|
}
|
|
11995
12108
|
}
|
|
11996
|
-
|
|
12109
|
+
return insertFragmentData(data);
|
|
11997
12110
|
};
|
|
11998
12111
|
editor.onKeydown = (event) => {
|
|
11999
12112
|
const isContinue = !onKeyDownList(event, editor);
|
|
@@ -15742,7 +15855,7 @@ const normalizeTable = (table) => {
|
|
|
15742
15855
|
};
|
|
15743
15856
|
|
|
15744
15857
|
const withTable = (editor) => {
|
|
15745
|
-
const { deleteBackward, deleteForward, onKeydown, setFragmentData,
|
|
15858
|
+
const { deleteBackward, deleteForward, onKeydown, setFragmentData, insertFragmentData, normalizeNode, isBlockCard, renderElement, deleteCutData, isContainer, onChange, onClick, mousedown } = editor;
|
|
15746
15859
|
editor.deleteBackward = unit => {
|
|
15747
15860
|
const opts = new TableOptions();
|
|
15748
15861
|
if (!isSelectionInTable(opts, editor)) {
|
|
@@ -15944,62 +16057,54 @@ const withTable = (editor) => {
|
|
|
15944
16057
|
onKeydown(event);
|
|
15945
16058
|
return;
|
|
15946
16059
|
};
|
|
15947
|
-
editor.setFragmentData =
|
|
16060
|
+
editor.setFragmentData = (data, originEvent) => {
|
|
15948
16061
|
const opts = new TableOptions();
|
|
15949
|
-
if (
|
|
15950
|
-
|
|
15951
|
-
|
|
15952
|
-
|
|
15953
|
-
|
|
15954
|
-
|
|
15955
|
-
|
|
15956
|
-
|
|
15957
|
-
|
|
15958
|
-
|
|
15959
|
-
|
|
15960
|
-
...tablePosition.table,
|
|
15961
|
-
children: rows
|
|
15962
|
-
};
|
|
15963
|
-
}
|
|
15964
|
-
else if (selectedCellPositions.length > 0) {
|
|
15965
|
-
const tempRows = {};
|
|
15966
|
-
for (const cell of selectedCellPositions) {
|
|
15967
|
-
const { row, col } = cell;
|
|
15968
|
-
const cellPath = [...tablePosition.tableEntry[1], row, col];
|
|
15969
|
-
const cellNode = Node.get(editor, cellPath);
|
|
15970
|
-
if (!tempRows[row]) {
|
|
15971
|
-
tempRows[row] = [];
|
|
15972
|
-
}
|
|
15973
|
-
tempRows[row].push(cellNode);
|
|
16062
|
+
if (isSelectionInTable(opts, editor)) {
|
|
16063
|
+
const tablePosition = createTablePosition(editor);
|
|
16064
|
+
const tableComponent = ELEMENT_TO_COMPONENT.get(tablePosition.table);
|
|
16065
|
+
const selectedCellPositions = tableComponent.tableStore.getSelectedCellPositions();
|
|
16066
|
+
let tableFragment = null;
|
|
16067
|
+
if (tableComponent.tableStore.selectedRowsIndex.length > 0) {
|
|
16068
|
+
const rows = tablePosition.table.children.slice(tableComponent.tableStore.selectedRowsIndex[0], tableComponent.tableStore.selectedRowsIndex[tableComponent.tableStore.selectedRowsIndex.length - 1] + 1);
|
|
16069
|
+
tableFragment = {
|
|
16070
|
+
...tablePosition.table,
|
|
16071
|
+
children: rows
|
|
16072
|
+
};
|
|
15974
16073
|
}
|
|
15975
|
-
|
|
15976
|
-
|
|
15977
|
-
|
|
15978
|
-
|
|
16074
|
+
else if (selectedCellPositions.length > 0) {
|
|
16075
|
+
const tempRows = {};
|
|
16076
|
+
for (const cell of selectedCellPositions) {
|
|
16077
|
+
const { row, col } = cell;
|
|
16078
|
+
const cellPath = [...tablePosition.tableEntry[1], row, col];
|
|
16079
|
+
const cellNode = Node.get(editor, cellPath);
|
|
16080
|
+
if (!tempRows[row]) {
|
|
16081
|
+
tempRows[row] = [];
|
|
16082
|
+
}
|
|
16083
|
+
tempRows[row].push(cellNode);
|
|
16084
|
+
}
|
|
16085
|
+
const rows = Object.values(tempRows).map((item) => {
|
|
16086
|
+
return {
|
|
16087
|
+
type: ElementKinds.tableRow,
|
|
16088
|
+
children: item
|
|
16089
|
+
};
|
|
16090
|
+
});
|
|
16091
|
+
tableFragment = {
|
|
16092
|
+
type: ElementKinds.table,
|
|
16093
|
+
children: rows
|
|
15979
16094
|
};
|
|
15980
|
-
}
|
|
15981
|
-
tableFragment
|
|
15982
|
-
|
|
15983
|
-
|
|
15984
|
-
|
|
15985
|
-
|
|
15986
|
-
if (tableFragment) {
|
|
15987
|
-
tableFragment = normalizeTable(cloneDeep(tableFragment));
|
|
15988
|
-
const plainText = Node.string(tableFragment);
|
|
15989
|
-
tableFragment = [tableFragment];
|
|
15990
|
-
const stringObj = JSON.stringify(tableFragment);
|
|
15991
|
-
const encoded = window.btoa(encodeURIComponent(stringObj));
|
|
15992
|
-
unit.setData(`application/${CLIPBOARD_FORMAT_KEY}`, encoded);
|
|
15993
|
-
unit.setData('text/plain', plainText);
|
|
15994
|
-
return;
|
|
16095
|
+
}
|
|
16096
|
+
if (tableFragment) {
|
|
16097
|
+
tableFragment = normalizeTable(cloneDeep(tableFragment));
|
|
16098
|
+
setClipboardDataByDom(editor, tableFragment, data);
|
|
16099
|
+
return;
|
|
16100
|
+
}
|
|
15995
16101
|
}
|
|
15996
|
-
setFragmentData(
|
|
16102
|
+
setFragmentData(data, originEvent);
|
|
15997
16103
|
};
|
|
15998
|
-
editor.
|
|
15999
|
-
const fragment = extractFragment(data);
|
|
16104
|
+
editor.insertFragmentData = async (data) => {
|
|
16105
|
+
const fragment = await extractFragment(data);
|
|
16000
16106
|
if (fragment) {
|
|
16001
16107
|
const opts = new TableOptions();
|
|
16002
|
-
const { selection } = editor;
|
|
16003
16108
|
if (isSelectionInTable(opts, editor) &&
|
|
16004
16109
|
fragment.length === 1 &&
|
|
16005
16110
|
Element.isElement(fragment[0]) &&
|
|
@@ -16069,8 +16174,10 @@ const withTable = (editor) => {
|
|
|
16069
16174
|
});
|
|
16070
16175
|
});
|
|
16071
16176
|
}
|
|
16177
|
+
Transforms.insertFragment(editor, fragment);
|
|
16178
|
+
return true;
|
|
16072
16179
|
}
|
|
16073
|
-
|
|
16180
|
+
return insertFragmentData(data);
|
|
16074
16181
|
};
|
|
16075
16182
|
editor.normalizeNode = ([node, path]) => {
|
|
16076
16183
|
if (Element.isElement(node) && node.type === ElementKinds.table) {
|
|
@@ -16452,123 +16559,6 @@ const internalPlugins = () => [
|
|
|
16452
16559
|
createMentionPlugin()
|
|
16453
16560
|
];
|
|
16454
16561
|
|
|
16455
|
-
class TheQuickInsert {
|
|
16456
|
-
handleMousedownNativeElement(event) {
|
|
16457
|
-
event.preventDefault();
|
|
16458
|
-
event.stopPropagation();
|
|
16459
|
-
}
|
|
16460
|
-
constructor(renderer, elementRef, cdr) {
|
|
16461
|
-
this.renderer = renderer;
|
|
16462
|
-
this.elementRef = elementRef;
|
|
16463
|
-
this.cdr = cdr;
|
|
16464
|
-
this.className = 'the-quick-insert';
|
|
16465
|
-
this.isVisible = false;
|
|
16466
|
-
this.defaultIconName = 'plus-circle-thin';
|
|
16467
|
-
this.iconNameFill = 'plus-circle-thin-fill';
|
|
16468
|
-
this.displayIconName = this.defaultIconName;
|
|
16469
|
-
}
|
|
16470
|
-
ngOnInit() {
|
|
16471
|
-
const { onChange } = this.editor;
|
|
16472
|
-
this.editor.onChange = () => {
|
|
16473
|
-
onChange();
|
|
16474
|
-
if (this.editor && this.editor.options && !this.editor.options.readonly) {
|
|
16475
|
-
// wait isOpenedMenu is updated
|
|
16476
|
-
setTimeout(() => {
|
|
16477
|
-
this.updateIconDisplay();
|
|
16478
|
-
}, 0);
|
|
16479
|
-
}
|
|
16480
|
-
};
|
|
16481
|
-
this.updateIconDisplay();
|
|
16482
|
-
}
|
|
16483
|
-
ngOnChanges(changes) {
|
|
16484
|
-
if (changes.isVisible && !changes.isVisible.firstChange) {
|
|
16485
|
-
this.updateIconDisplay();
|
|
16486
|
-
}
|
|
16487
|
-
}
|
|
16488
|
-
updateIconDisplay() {
|
|
16489
|
-
const { editor } = this;
|
|
16490
|
-
if (this.isVisible &&
|
|
16491
|
-
!QuickInsertEditor.isOpenedMenu(editor) &&
|
|
16492
|
-
isCleanEmptyParagraph(editor) &&
|
|
16493
|
-
!this.hasExcludeAttribute() &&
|
|
16494
|
-
!this.isRichMediaScope()) {
|
|
16495
|
-
const block = Node.ancestor(editor, [editor?.selection?.anchor.path[0]]);
|
|
16496
|
-
const rootNode = AngularEditor.toDOMNode(editor, block);
|
|
16497
|
-
this.updatePosition(rootNode.offsetLeft, rootNode.offsetTop);
|
|
16498
|
-
return;
|
|
16499
|
-
}
|
|
16500
|
-
this.addHiddenClass();
|
|
16501
|
-
}
|
|
16502
|
-
addHiddenClass() {
|
|
16503
|
-
this.elementRef.nativeElement.classList.add('d-none');
|
|
16504
|
-
}
|
|
16505
|
-
removeHiddenClass() {
|
|
16506
|
-
this.elementRef.nativeElement.classList.remove('d-none');
|
|
16507
|
-
}
|
|
16508
|
-
isRichMediaScope() {
|
|
16509
|
-
const { editor } = this;
|
|
16510
|
-
if (editor?.selection) {
|
|
16511
|
-
const block = Node.ancestor(editor, [editor?.selection?.anchor.path[0]]);
|
|
16512
|
-
const rootElement = AngularEditor.toDOMNode(editor, block);
|
|
16513
|
-
const leafElement = rootElement.querySelector('[data-slate-leaf="true"]');
|
|
16514
|
-
const rootElementRect = rootElement.getBoundingClientRect();
|
|
16515
|
-
const leafElementRect = leafElement.getBoundingClientRect();
|
|
16516
|
-
return leafElementRect?.x !== rootElementRect?.x;
|
|
16517
|
-
}
|
|
16518
|
-
return false;
|
|
16519
|
-
}
|
|
16520
|
-
hasExcludeAttribute() {
|
|
16521
|
-
const marks = getSelectionMarks(this.editor);
|
|
16522
|
-
const fontSizeMark = marks[MarkTypes.fontSize];
|
|
16523
|
-
return fontSizeMark;
|
|
16524
|
-
}
|
|
16525
|
-
updatePosition(left, top) {
|
|
16526
|
-
this.renderer.setStyle(this.elementRef.nativeElement, 'top', `${top}px`);
|
|
16527
|
-
this.renderer.setStyle(this.elementRef.nativeElement, 'left', `${left}px`);
|
|
16528
|
-
this.removeHiddenClass();
|
|
16529
|
-
}
|
|
16530
|
-
mouseEnter(event) {
|
|
16531
|
-
this.displayIconName = this.iconNameFill;
|
|
16532
|
-
this.cdr.markForCheck();
|
|
16533
|
-
}
|
|
16534
|
-
mouseLeave(event) {
|
|
16535
|
-
this.displayIconName = this.defaultIconName;
|
|
16536
|
-
this.cdr.markForCheck();
|
|
16537
|
-
}
|
|
16538
|
-
handleClick(event) {
|
|
16539
|
-
event.stopPropagation();
|
|
16540
|
-
event.preventDefault();
|
|
16541
|
-
// avoid popover is closed immediately
|
|
16542
|
-
setTimeout(() => {
|
|
16543
|
-
QuickInsertEditor.openMenu(this.editor)
|
|
16544
|
-
.afterClosed()
|
|
16545
|
-
.subscribe(() => {
|
|
16546
|
-
this.updateIconDisplay();
|
|
16547
|
-
});
|
|
16548
|
-
this.updateIconDisplay();
|
|
16549
|
-
}, 100);
|
|
16550
|
-
}
|
|
16551
|
-
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.4", ngImport: i0, type: TheQuickInsert, deps: [{ token: i0.Renderer2 }, { token: i0.ElementRef }, { token: i0.ChangeDetectorRef }], target: i0.ɵɵFactoryTarget.Component }); }
|
|
16552
|
-
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "17.3.4", type: TheQuickInsert, isStandalone: true, selector: "[theQuickInsert]", inputs: { editor: "editor", isVisible: "isVisible" }, host: { listeners: { "mousedown": "handleMousedownNativeElement($event)" }, properties: { "class": "this.className" } }, viewQueries: [{ propertyName: "iconElement", first: true, predicate: ["iconElement"], descendants: true, read: ElementRef }], usesOnChanges: true, ngImport: i0, template: "<thy-icon\n #iconElement\n [thyIconName]=\"displayIconName\"\n class=\"quick-insert-icon text-desc font-size-xlg\"\n (mouseenter)=\"mouseEnter($event)\"\n (mouseleave)=\"mouseLeave($event)\"\n (mousedown)=\"handleClick($event)\"\n></thy-icon>\n", dependencies: [{ kind: "component", type: ThyIcon, selector: "thy-icon, [thy-icon]", inputs: ["thyIconType", "thyTwotoneColor", "thyIconName", "thyIconRotate", "thyIconSet", "thyIconLegging", "thyIconLinearGradient"] }] }); }
|
|
16553
|
-
}
|
|
16554
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.4", ngImport: i0, type: TheQuickInsert, decorators: [{
|
|
16555
|
-
type: Component,
|
|
16556
|
-
args: [{ selector: '[theQuickInsert]', standalone: true, imports: [ThyIcon], template: "<thy-icon\n #iconElement\n [thyIconName]=\"displayIconName\"\n class=\"quick-insert-icon text-desc font-size-xlg\"\n (mouseenter)=\"mouseEnter($event)\"\n (mouseleave)=\"mouseLeave($event)\"\n (mousedown)=\"handleClick($event)\"\n></thy-icon>\n" }]
|
|
16557
|
-
}], ctorParameters: () => [{ type: i0.Renderer2 }, { type: i0.ElementRef }, { type: i0.ChangeDetectorRef }], propDecorators: { className: [{
|
|
16558
|
-
type: HostBinding,
|
|
16559
|
-
args: ['class']
|
|
16560
|
-
}], editor: [{
|
|
16561
|
-
type: Input
|
|
16562
|
-
}], isVisible: [{
|
|
16563
|
-
type: Input
|
|
16564
|
-
}], iconElement: [{
|
|
16565
|
-
type: ViewChild,
|
|
16566
|
-
args: ['iconElement', { read: ElementRef, static: false }]
|
|
16567
|
-
}], handleMousedownNativeElement: [{
|
|
16568
|
-
type: HostListener,
|
|
16569
|
-
args: ['mousedown', ['$event']]
|
|
16570
|
-
}] } });
|
|
16571
|
-
|
|
16572
16562
|
const HOTKEYS = {
|
|
16573
16563
|
'mod+b': MarkTypes.bold,
|
|
16574
16564
|
'mod+i': MarkTypes.italic,
|
|
@@ -16677,22 +16667,22 @@ class TheEditorComponent {
|
|
|
16677
16667
|
});
|
|
16678
16668
|
};
|
|
16679
16669
|
this.onSlaPaste = (event) => {
|
|
16670
|
+
const clipboardData = getDataTransferClipboard(event.clipboardData);
|
|
16680
16671
|
this.theOnDOMEvent.emit({
|
|
16681
|
-
data:
|
|
16682
|
-
...this.getTextAndJSON(event.clipboardData)
|
|
16683
|
-
},
|
|
16672
|
+
data: clipboardData,
|
|
16684
16673
|
nativeEvent: event
|
|
16685
16674
|
});
|
|
16686
16675
|
};
|
|
16687
|
-
this.onSlaBeforeInput = (event) => {
|
|
16676
|
+
this.onSlaBeforeInput = async (event) => {
|
|
16688
16677
|
let data = {
|
|
16689
16678
|
inputType: event.inputType,
|
|
16690
16679
|
text: (event.data || event.dataTransfer)
|
|
16691
16680
|
};
|
|
16692
16681
|
if (event.inputType === 'insertFromPaste') {
|
|
16682
|
+
const clipboardData = getDataTransferClipboard(event.dataTransfer);
|
|
16693
16683
|
data = {
|
|
16694
16684
|
...data,
|
|
16695
|
-
...
|
|
16685
|
+
...clipboardData
|
|
16696
16686
|
};
|
|
16697
16687
|
}
|
|
16698
16688
|
this.theOnDOMEvent.emit({
|
|
@@ -16985,18 +16975,6 @@ class TheEditorComponent {
|
|
|
16985
16975
|
event.preventDefault();
|
|
16986
16976
|
return;
|
|
16987
16977
|
}
|
|
16988
|
-
getTextAndJSON(data) {
|
|
16989
|
-
const fragment = data.getData(`application/${CLIPBOARD_FORMAT_KEY}`);
|
|
16990
|
-
let json = [];
|
|
16991
|
-
if (fragment) {
|
|
16992
|
-
json = JSON.parse(decodeURIComponent(window.atob(fragment)));
|
|
16993
|
-
}
|
|
16994
|
-
const text = data.getData('text/plain');
|
|
16995
|
-
return {
|
|
16996
|
-
json,
|
|
16997
|
-
text
|
|
16998
|
-
};
|
|
16999
|
-
}
|
|
17000
16978
|
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.4", ngImport: i0, type: TheEditorComponent, deps: [{ token: i0.ChangeDetectorRef }, { token: i0.DestroyRef }, { token: i0.ElementRef }, { token: i0.Injector }, { token: i0.NgZone }, { token: i0.ViewContainerRef }, { token: TheContextService }, { token: i2$2.ThyIconRegistry }, { token: THE_PRESET_CONFIG_TOKEN, optional: true }], target: i0.ɵɵFactoryTarget.Component }); }
|
|
17001
16979
|
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "17.3.4", type: TheEditorComponent, isStandalone: true, selector: "the-editor, theEditor", inputs: { theOptions: "theOptions", thePlugins: "thePlugins", theGlobalToolbar: "theGlobalToolbar", theDecorate: "theDecorate", theOnError: "theOnError" }, outputs: { theOnSave: "theOnSave", theOnDOMEvent: "theOnDOMEvent", theEditorCreated: "theEditorCreated", theUploadingStatus: "theUploadingStatus" }, host: { properties: { "class.the-editor-readonly": "editor.options?.readonly", "class.the-mobile-editor": "isMobileMode" }, classAttribute: "the-editor" }, providers: [
|
|
17002
16980
|
TheContextService,
|
|
@@ -17346,5 +17324,5 @@ const withTestPlugin = (plugins, initValue) => {
|
|
|
17346
17324
|
* Generated bundle index. Do not edit.
|
|
17347
17325
|
*/
|
|
17348
17326
|
|
|
17349
|
-
export { ALIGN_BLOCK_TYPES, A_TAG_REL_ATTR, AlignEditor, Alignment, BLOCK_DELETE_BACKWARD_TYPES, BasicTest, BlockquoteEditor, CLIPBOARD_FORMAT_KEY, CODEMIRROR_PADDING_TOP, CODE_MODES, CONTAINER_BLOCKS, CONTROL_KEY, CodeEditor, ColorEditor, ColumnResizeNotifierSource, ColumnResizingStore, DEFAULT_LANGUAGE, DEFAULT_SCROLL_CONTAINER, DISABLED_OPERATE_TYPES, DataTransferFaker, DefaultElementOptions, DefaultGlobalToolbarDefinition, DefaultInlineToolbarDefinition, DefaultPluginMenu, DropdownMode, ELEMENT_UNIQUE_ID, EditorPresetConfigFactoryMock, ElementKinds, ErrorCodes, FontSizeTypes, FontSizes, HEADING_TYPES, HeadingEditor, HoveredCellInfo, HrEditor, IS_MAC, ImageEditor, IndentEditor, Indents, InlineCodeEditor, LINK_DEFAULT_TEXT, LIST_BLOCK_TYPES, LayoutTypes, LinkEditor, ListEditor, MarkEditor, MarkProps, MarkTypes, MentionEditor, PICTURE_ACCEPTED_UPLOAD_MIME, PICTURE_ACCEPTED_UPLOAD_SIZE, PluginKeys, PluginMenuIcons, PluginMenuSvgs, Position, QuickInsertEditor, ResizeRef, SLA_TABLE_CELL_SELECTOR, SLA_TABLE_SELECTOR, STANDARD_HEADING_TYPES, ScrollDirection, SpecialBackgroundColor, TAB_SPACE, THE_EDITOR_BG_COLOR, THE_EDITOR_COLOR, THE_EDITOR_CONVERSION_HINT_REF, THE_EDITOR_ORIGIN_ANCHOR, THE_EDITOR_POPOVER_REF, THE_EDITOR_PREVIOUS_SELECTION, THE_EDITOR_UUID, THE_LISTBOX_PARENT_GROUP_TOKEN, THE_LISTBOX_PARENT_OPTION_TOKEN, THE_LISTBOX_TOKEN, THE_MODE_PROVIDER, THE_MODE_TOKEN, THE_PLUGIN_MENU_REF, THE_PRESET_CONFIG_TOKEN, THE_UPLOAD_SERVICE_TOKEN, TableCellEventDispatcher, TableEditor, TableHeaderBackgroundColor, TablePosition, TheBaseElement, TheBaseSuggestion, TheBaseToolbarDropdown, TheBaseToolbarItem, TheColumnResizeDirective, TheColumnResizeOverlayHandle, TheContextMenu, TheContextService, TheConversionHint, TheDataMode, TheDefaultElement, TheEditor, TheEditorComponent, TheEditorModule, TheImage, TheInlineToolbar, TheListboxDirective, TheListboxGroupDirective, TheListboxOptionDirective, TheMode, TheModeConfig, ThePluginMenu, ThePluginMenuComponent, ThePluginMenuItemType, ThePreventDefaultDirective, index$1 as TheQueries, TheTableSelect, TheTemplate, TheText, TheToolbarComponent, TheToolbarDropdown, TheToolbarGroup, TheToolbarGroupToken, TheToolbarItem, TheToolbarService, index as TheTransforms, TodoItemEditor, ToolbarActionTypes, ToolbarAlignment, ToolbarItemType, ToolbarMoreGroup, VOID_BLOCK_TYPES, VerticalAlignEditor, VerticalAlignment, ZERO_WIDTH_CHAR, autoFocus, base64toBlob, bottomLeftPosition, buildPluginMenu, buildPluginMenuItemMap, buildQuickInsertMenus, calcPrintColumnWidth, calcSpanForColumn, calcSpanForRow, calculateHeaderRowHeight, calculateRowControls, coercePixelsFromCssValue, combinePlugins, copyNode,
|
|
17327
|
+
export { ALIGN_BLOCK_TYPES, A_TAG_REL_ATTR, AlignEditor, Alignment, BLOCK_DELETE_BACKWARD_TYPES, BasicTest, BlockquoteEditor, CLIPBOARD_FORMAT_KEY, CODEMIRROR_PADDING_TOP, CODE_MODES, CONTAINER_BLOCKS, CONTROL_KEY, CodeEditor, ColorEditor, ColumnResizeNotifierSource, ColumnResizingStore, DEFAULT_LANGUAGE, DEFAULT_SCROLL_CONTAINER, DISABLED_OPERATE_TYPES, DataTransferFaker, DefaultElementOptions, DefaultGlobalToolbarDefinition, DefaultInlineToolbarDefinition, DefaultPluginMenu, DropdownMode, ELEMENT_UNIQUE_ID, EditorPresetConfigFactoryMock, ElementKinds, ErrorCodes, FontSizeTypes, FontSizes, HEADING_TYPES, HeadingEditor, HoveredCellInfo, HrEditor, IS_MAC, ImageEditor, IndentEditor, Indents, InlineCodeEditor, LINK_DEFAULT_TEXT, LIST_BLOCK_TYPES, LayoutTypes, LinkEditor, ListEditor, MarkEditor, MarkProps, MarkTypes, MentionEditor, PICTURE_ACCEPTED_UPLOAD_MIME, PICTURE_ACCEPTED_UPLOAD_SIZE, PluginKeys, PluginMenuIcons, PluginMenuSvgs, Position, QuickInsertEditor, ResizeRef, SLA_TABLE_CELL_SELECTOR, SLA_TABLE_SELECTOR, STANDARD_HEADING_TYPES, ScrollDirection, SpecialBackgroundColor, TAB_SPACE, THE_EDITOR_BG_COLOR, THE_EDITOR_COLOR, THE_EDITOR_CONVERSION_HINT_REF, THE_EDITOR_ORIGIN_ANCHOR, THE_EDITOR_POPOVER_REF, THE_EDITOR_PREVIOUS_SELECTION, THE_EDITOR_UUID, THE_LISTBOX_PARENT_GROUP_TOKEN, THE_LISTBOX_PARENT_OPTION_TOKEN, THE_LISTBOX_TOKEN, THE_MODE_PROVIDER, THE_MODE_TOKEN, THE_PLUGIN_MENU_REF, THE_PRESET_CONFIG_TOKEN, THE_UPLOAD_SERVICE_TOKEN, TableCellEventDispatcher, TableEditor, TableHeaderBackgroundColor, TablePosition, TheBaseElement, TheBaseSuggestion, TheBaseToolbarDropdown, TheBaseToolbarItem, TheColumnResizeDirective, TheColumnResizeOverlayHandle, TheContextMenu, TheContextService, TheConversionHint, TheDataMode, TheDefaultElement, TheEditor, TheEditorComponent, TheEditorModule, TheImage, TheInlineToolbar, TheListboxDirective, TheListboxGroupDirective, TheListboxOptionDirective, TheMode, TheModeConfig, ThePluginMenu, ThePluginMenuComponent, ThePluginMenuItemType, ThePreventDefaultDirective, index$1 as TheQueries, TheQuickInsert, TheTableSelect, TheTemplate, TheText, TheToolbarComponent, TheToolbarDropdown, TheToolbarGroup, TheToolbarGroupToken, TheToolbarItem, TheToolbarService, index as TheTransforms, TodoItemEditor, ToolbarActionTypes, ToolbarAlignment, ToolbarItemType, ToolbarMoreGroup, VOID_BLOCK_TYPES, VerticalAlignEditor, VerticalAlignment, ZERO_WIDTH_CHAR, autoFocus, base64toBlob, bottomLeftPosition, buildPluginMenu, buildPluginMenuItemMap, buildQuickInsertMenus, calcPrintColumnWidth, calcSpanForColumn, calcSpanForRow, calculateHeaderRowHeight, calculateRowControls, coercePixelsFromCssValue, combinePlugins, copyNode, createCell, createEmptyContent, createEmptyParagraph, createMentionPlugin, createPluginFactory, createRow, createTable, createTablePosition, createTest1Plugin, createTestPlugin, createToolbar, createVerticalAlignPlugin, customPluginMock, customPluginMockKey, dataDeserialize, dataSerializing, deleteElementKey, errorImageUrlMock, extractFragment, filterTextFormat, fixBlockWithoutParagraph, fixBlockWithoutText, flattenDeepPlugins, getCellPositionsFromRange, getColsTotalWidth, getColumnsWidth, getDirtyElements, getEditorScrollContainer, getEditorUUID, getElementClassByPrefix, getElementHeight, getElementWidth, getEndBlock, getGridColumns, getMode, getNextCell, getOriginCell, getPlugin, getPluginOptions, getPlugins, getRowsTotalHeight, getSelectCellNode, getSelectedCellPositions, getStartBlock, getTableByCell, getTableByRow, getToolbarClass, hasHeaderRow, headingOptions, htmlToTheia, idCreator, inValidTypes, initializeDefaultMenuIcons, insertDataByInvalidType, internalPlugins, isCleanEmptyParagraph, isColorIndicator, isColorInput, isColorPanel, isDirectionKeydown, isInside, isMobileMode, isPrintMode, isPureEmptyParagraph, isRangeInTable, isRectangularInTableCells, isSelectedAllCell, isSelectionInTable, isVirtualKey, matchOptions, mergeArray, mergeDeepPlugins, mergeElementOptions, mergeOptions, nestedStructureByKey, normalizeValue, originOptions, plainToTheia, pluginKey, pluginKey1, pluginsByKey, reSelection, recursionNodes, refocus, scrollIntoView, setClipboardDataByDom, setEditorUUID, theTethysIconRegistryFaker, topLeftPosition, uniqueCellPosition, updatePopoverPosition, useElementStyle, withMention, withTestPlugin, withTheia };
|
|
17350
17328
|
//# sourceMappingURL=worktile-theia.mjs.map
|