123b3eb3cSopenharmony_ci/*
223b3eb3cSopenharmony_ci * Copyright (c) 2023-2023 Huawei Device Co., Ltd.
323b3eb3cSopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License");
423b3eb3cSopenharmony_ci * you may not use this file except in compliance with the License.
523b3eb3cSopenharmony_ci * You may obtain a copy of the License at
623b3eb3cSopenharmony_ci *
723b3eb3cSopenharmony_ci *     http://www.apache.org/licenses/LICENSE-2.0
823b3eb3cSopenharmony_ci *
923b3eb3cSopenharmony_ci * Unless required by applicable law or agreed to in writing, software
1023b3eb3cSopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS,
1123b3eb3cSopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1223b3eb3cSopenharmony_ci * See the License for the specific language governing permissions and
1323b3eb3cSopenharmony_ci * limitations under the License.
1423b3eb3cSopenharmony_ci */
1523b3eb3cSopenharmony_ciconst pasteboard = requireNapi('pasteboard');
1623b3eb3cSopenharmony_ciconst hilog = requireNapi('hilog');
1723b3eb3cSopenharmony_ci
1823b3eb3cSopenharmony_ciif (!('finalizeConstruction' in ViewPU.prototype)) {
1923b3eb3cSopenharmony_ci    Reflect.set(ViewPU.prototype, 'finalizeConstruction', () => {
2023b3eb3cSopenharmony_ci    });
2123b3eb3cSopenharmony_ci}
2223b3eb3cSopenharmony_ci
2323b3eb3cSopenharmony_ciconst WITHOUT_BUILDER = -2;
2423b3eb3cSopenharmony_ciconst defaultTheme = {
2523b3eb3cSopenharmony_ci    imageSize: 24,
2623b3eb3cSopenharmony_ci    buttonSize: 48,
2723b3eb3cSopenharmony_ci    menuSpacing: 8,
2823b3eb3cSopenharmony_ci    editorOptionMargin: 1,
2923b3eb3cSopenharmony_ci    expandedOptionPadding: 3,
3023b3eb3cSopenharmony_ci    defaultMenuWidth: 256,
3123b3eb3cSopenharmony_ci    imageFillColor: {
3223b3eb3cSopenharmony_ci        'id': -1,
3323b3eb3cSopenharmony_ci        'type': 10001,
3423b3eb3cSopenharmony_ci        params: ['sys.color.ohos_id_color_primary'],
3523b3eb3cSopenharmony_ci        'bundleName': '__harDefaultBundleName__',
3623b3eb3cSopenharmony_ci        'moduleName': '__harDefaultModuleName__'
3723b3eb3cSopenharmony_ci    },
3823b3eb3cSopenharmony_ci    backGroundColor: {
3923b3eb3cSopenharmony_ci        'id': -1,
4023b3eb3cSopenharmony_ci        'type': 10001,
4123b3eb3cSopenharmony_ci        params: ['sys.color.ohos_id_color_dialog_bg'],
4223b3eb3cSopenharmony_ci        'bundleName': '__harDefaultBundleName__',
4323b3eb3cSopenharmony_ci        'moduleName': '__harDefaultModuleName__'
4423b3eb3cSopenharmony_ci    },
4523b3eb3cSopenharmony_ci    iconBorderRadius: {
4623b3eb3cSopenharmony_ci        'id': -1,
4723b3eb3cSopenharmony_ci        'type': 10002,
4823b3eb3cSopenharmony_ci        params: ['sys.float.ohos_id_corner_radius_default_m'],
4923b3eb3cSopenharmony_ci        'bundleName': '__harDefaultBundleName__',
5023b3eb3cSopenharmony_ci        'moduleName': '__harDefaultModuleName__'
5123b3eb3cSopenharmony_ci    },
5223b3eb3cSopenharmony_ci    containerBorderRadius: {
5323b3eb3cSopenharmony_ci        'id': -1,
5423b3eb3cSopenharmony_ci        'type': 10002,
5523b3eb3cSopenharmony_ci        params: ['sys.float.ohos_id_corner_radius_card'],
5623b3eb3cSopenharmony_ci        'bundleName': '__harDefaultBundleName__',
5723b3eb3cSopenharmony_ci        'moduleName': '__harDefaultModuleName__'
5823b3eb3cSopenharmony_ci    },
5923b3eb3cSopenharmony_ci    cutIcon: {
6023b3eb3cSopenharmony_ci        'id': -1,
6123b3eb3cSopenharmony_ci        'type': 20000,
6223b3eb3cSopenharmony_ci        params: ['sys.media.ohos_ic_public_cut'],
6323b3eb3cSopenharmony_ci        'bundleName': '__harDefaultBundleName__',
6423b3eb3cSopenharmony_ci        'moduleName': '__harDefaultModuleName__'
6523b3eb3cSopenharmony_ci    },
6623b3eb3cSopenharmony_ci    copyIcon: {
6723b3eb3cSopenharmony_ci        'id': -1,
6823b3eb3cSopenharmony_ci        'type': 20000,
6923b3eb3cSopenharmony_ci        params: ['sys.media.ohos_ic_public_copy'],
7023b3eb3cSopenharmony_ci        'bundleName': '__harDefaultBundleName__',
7123b3eb3cSopenharmony_ci        'moduleName': '__harDefaultModuleName__'
7223b3eb3cSopenharmony_ci    },
7323b3eb3cSopenharmony_ci    pasteIcon: {
7423b3eb3cSopenharmony_ci        'id': -1,
7523b3eb3cSopenharmony_ci        'type': 20000,
7623b3eb3cSopenharmony_ci        params: ['sys.media.ohos_ic_public_paste'],
7723b3eb3cSopenharmony_ci        'bundleName': '__harDefaultBundleName__',
7823b3eb3cSopenharmony_ci        'moduleName': '__harDefaultModuleName__'
7923b3eb3cSopenharmony_ci    },
8023b3eb3cSopenharmony_ci    selectAllIcon: {
8123b3eb3cSopenharmony_ci        'id': -1,
8223b3eb3cSopenharmony_ci        'type': 20000,
8323b3eb3cSopenharmony_ci        params: ['sys.media.ohos_ic_public_select_all'],
8423b3eb3cSopenharmony_ci        'bundleName': '__harDefaultBundleName__',
8523b3eb3cSopenharmony_ci        'moduleName': '__harDefaultModuleName__'
8623b3eb3cSopenharmony_ci    },
8723b3eb3cSopenharmony_ci    shareIcon: {
8823b3eb3cSopenharmony_ci        'id': -1,
8923b3eb3cSopenharmony_ci        'type': 20000,
9023b3eb3cSopenharmony_ci        params: ['sys.media.ohos_ic_public_share'],
9123b3eb3cSopenharmony_ci        'bundleName': '__harDefaultBundleName__',
9223b3eb3cSopenharmony_ci        'moduleName': '__harDefaultModuleName__'
9323b3eb3cSopenharmony_ci    },
9423b3eb3cSopenharmony_ci    translateIcon: {
9523b3eb3cSopenharmony_ci        'id': -1,
9623b3eb3cSopenharmony_ci        'type': 20000,
9723b3eb3cSopenharmony_ci        params: ['sys.media.ohos_ic_public_translate_c2e'],
9823b3eb3cSopenharmony_ci        'bundleName': '__harDefaultBundleName__',
9923b3eb3cSopenharmony_ci        'moduleName': '__harDefaultModuleName__'
10023b3eb3cSopenharmony_ci    },
10123b3eb3cSopenharmony_ci    searchIcon: {
10223b3eb3cSopenharmony_ci        'id': -1,
10323b3eb3cSopenharmony_ci        'type': 20000,
10423b3eb3cSopenharmony_ci        params: ['sys.media.ohos_ic_public_search_filled'],
10523b3eb3cSopenharmony_ci        'bundleName': '__harDefaultBundleName__',
10623b3eb3cSopenharmony_ci        'moduleName': '__harDefaultModuleName__'
10723b3eb3cSopenharmony_ci    },
10823b3eb3cSopenharmony_ci    arrowDownIcon: {
10923b3eb3cSopenharmony_ci        'id': -1,
11023b3eb3cSopenharmony_ci        'type': 20000,
11123b3eb3cSopenharmony_ci        params: ['sys.media.ohos_ic_public_arrow_down'],
11223b3eb3cSopenharmony_ci        'bundleName': '__harDefaultBundleName__',
11323b3eb3cSopenharmony_ci        'moduleName': '__harDefaultModuleName__'
11423b3eb3cSopenharmony_ci    },
11523b3eb3cSopenharmony_ci    aiWriteIcon: {
11623b3eb3cSopenharmony_ci        'id': -1,
11723b3eb3cSopenharmony_ci        'type': 20000,
11823b3eb3cSopenharmony_ci        params: ['sys.media.ic_public_ai_write'],
11923b3eb3cSopenharmony_ci        'bundleName': '__harDefaultBundleName__',
12023b3eb3cSopenharmony_ci        'moduleName': '__harDefaultModuleName__'
12123b3eb3cSopenharmony_ci    },
12223b3eb3cSopenharmony_ci    iconPanelShadowStyle: ShadowStyle.OUTER_DEFAULT_MD,
12323b3eb3cSopenharmony_ci};
12423b3eb3cSopenharmony_ci
12523b3eb3cSopenharmony_ciclass SelectionMenuComponent extends ViewPU {
12623b3eb3cSopenharmony_ci    constructor(parent, params, __localStorage, elmtId = -1, paramsLambda = undefined, extraInfo) {
12723b3eb3cSopenharmony_ci        super(parent, __localStorage, elmtId, extraInfo);
12823b3eb3cSopenharmony_ci        if (typeof paramsLambda === 'function') {
12923b3eb3cSopenharmony_ci            this.paramsGenerator_ = paramsLambda;
13023b3eb3cSopenharmony_ci        }
13123b3eb3cSopenharmony_ci        this.editorMenuOptions = undefined;
13223b3eb3cSopenharmony_ci        this.expandedMenuOptions = undefined;
13323b3eb3cSopenharmony_ci        this.controller = undefined;
13423b3eb3cSopenharmony_ci        this.onPaste = undefined;
13523b3eb3cSopenharmony_ci        this.onCopy = undefined;
13623b3eb3cSopenharmony_ci        this.onCut = undefined;
13723b3eb3cSopenharmony_ci        this.onSelectAll = undefined;
13823b3eb3cSopenharmony_ci        this.theme = defaultTheme;
13923b3eb3cSopenharmony_ci        this.builder = this.CloserFun;
14023b3eb3cSopenharmony_ci        this.__showExpandedMenuOptions = new ObservedPropertySimplePU(false, this, 'showExpandedMenuOptions');
14123b3eb3cSopenharmony_ci        this.__showCustomerIndex = new ObservedPropertySimplePU(-1, this, 'showCustomerIndex');
14223b3eb3cSopenharmony_ci        this.__customerChange = new ObservedPropertySimplePU(false, this, 'customerChange');
14323b3eb3cSopenharmony_ci        this.__cutAndCopyEnable = new ObservedPropertySimplePU(false, this, 'cutAndCopyEnable');
14423b3eb3cSopenharmony_ci        this.__pasteEnable = new ObservedPropertySimplePU(false, this, 'pasteEnable');
14523b3eb3cSopenharmony_ci        this.__visibilityValue = new ObservedPropertySimplePU(Visibility.Visible, this, 'visibilityValue');
14623b3eb3cSopenharmony_ci        this.__customMenuSize = new ObservedPropertySimplePU('100%', this, 'customMenuSize');
14723b3eb3cSopenharmony_ci        this.customMenuHeight = this.theme.menuSpacing;
14823b3eb3cSopenharmony_ci        this.fontWeightTable = ['100', '200', '300', '400', '500', '600', '700', '800', '900', 'bold', 'normal', 'bolder', 'lighter', 'medium', 'regular'];
14923b3eb3cSopenharmony_ci        this.setInitiallyProvidedValue(params);
15023b3eb3cSopenharmony_ci        this.finalizeConstruction();
15123b3eb3cSopenharmony_ci    }
15223b3eb3cSopenharmony_ci
15323b3eb3cSopenharmony_ci    setInitiallyProvidedValue(params) {
15423b3eb3cSopenharmony_ci        if (params.editorMenuOptions !== undefined) {
15523b3eb3cSopenharmony_ci            this.editorMenuOptions = params.editorMenuOptions;
15623b3eb3cSopenharmony_ci        }
15723b3eb3cSopenharmony_ci        if (params.expandedMenuOptions !== undefined) {
15823b3eb3cSopenharmony_ci            this.expandedMenuOptions = params.expandedMenuOptions;
15923b3eb3cSopenharmony_ci        }
16023b3eb3cSopenharmony_ci        if (params.controller !== undefined) {
16123b3eb3cSopenharmony_ci            this.controller = params.controller;
16223b3eb3cSopenharmony_ci        }
16323b3eb3cSopenharmony_ci        if (params.onPaste !== undefined) {
16423b3eb3cSopenharmony_ci            this.onPaste = params.onPaste;
16523b3eb3cSopenharmony_ci        }
16623b3eb3cSopenharmony_ci        if (params.onCopy !== undefined) {
16723b3eb3cSopenharmony_ci            this.onCopy = params.onCopy;
16823b3eb3cSopenharmony_ci        }
16923b3eb3cSopenharmony_ci        if (params.onCut !== undefined) {
17023b3eb3cSopenharmony_ci            this.onCut = params.onCut;
17123b3eb3cSopenharmony_ci        }
17223b3eb3cSopenharmony_ci        if (params.onSelectAll !== undefined) {
17323b3eb3cSopenharmony_ci            this.onSelectAll = params.onSelectAll;
17423b3eb3cSopenharmony_ci        }
17523b3eb3cSopenharmony_ci        if (params.theme !== undefined) {
17623b3eb3cSopenharmony_ci            this.theme = params.theme;
17723b3eb3cSopenharmony_ci        }
17823b3eb3cSopenharmony_ci        if (params.builder !== undefined) {
17923b3eb3cSopenharmony_ci            this.builder = params.builder;
18023b3eb3cSopenharmony_ci        }
18123b3eb3cSopenharmony_ci        if (params.showExpandedMenuOptions !== undefined) {
18223b3eb3cSopenharmony_ci            this.showExpandedMenuOptions = params.showExpandedMenuOptions;
18323b3eb3cSopenharmony_ci        }
18423b3eb3cSopenharmony_ci        if (params.showCustomerIndex !== undefined) {
18523b3eb3cSopenharmony_ci            this.showCustomerIndex = params.showCustomerIndex;
18623b3eb3cSopenharmony_ci        }
18723b3eb3cSopenharmony_ci        if (params.customerChange !== undefined) {
18823b3eb3cSopenharmony_ci            this.customerChange = params.customerChange;
18923b3eb3cSopenharmony_ci        }
19023b3eb3cSopenharmony_ci        if (params.cutAndCopyEnable !== undefined) {
19123b3eb3cSopenharmony_ci            this.cutAndCopyEnable = params.cutAndCopyEnable;
19223b3eb3cSopenharmony_ci        }
19323b3eb3cSopenharmony_ci        if (params.pasteEnable !== undefined) {
19423b3eb3cSopenharmony_ci            this.pasteEnable = params.pasteEnable;
19523b3eb3cSopenharmony_ci        }
19623b3eb3cSopenharmony_ci        if (params.visibilityValue !== undefined) {
19723b3eb3cSopenharmony_ci            this.visibilityValue = params.visibilityValue;
19823b3eb3cSopenharmony_ci        }
19923b3eb3cSopenharmony_ci        if (params.customMenuSize !== undefined) {
20023b3eb3cSopenharmony_ci            this.customMenuSize = params.customMenuSize;
20123b3eb3cSopenharmony_ci        }
20223b3eb3cSopenharmony_ci        if (params.customMenuHeight !== undefined) {
20323b3eb3cSopenharmony_ci            this.customMenuHeight = params.customMenuHeight;
20423b3eb3cSopenharmony_ci        }
20523b3eb3cSopenharmony_ci        if (params.fontWeightTable !== undefined) {
20623b3eb3cSopenharmony_ci            this.fontWeightTable = params.fontWeightTable;
20723b3eb3cSopenharmony_ci        }
20823b3eb3cSopenharmony_ci    }
20923b3eb3cSopenharmony_ci
21023b3eb3cSopenharmony_ci    updateStateVars(params) {
21123b3eb3cSopenharmony_ci    }
21223b3eb3cSopenharmony_ci
21323b3eb3cSopenharmony_ci    purgeVariableDependenciesOnElmtId(rmElmtId) {
21423b3eb3cSopenharmony_ci        this.__showExpandedMenuOptions.purgeDependencyOnElmtId(rmElmtId);
21523b3eb3cSopenharmony_ci        this.__showCustomerIndex.purgeDependencyOnElmtId(rmElmtId);
21623b3eb3cSopenharmony_ci        this.__customerChange.purgeDependencyOnElmtId(rmElmtId);
21723b3eb3cSopenharmony_ci        this.__cutAndCopyEnable.purgeDependencyOnElmtId(rmElmtId);
21823b3eb3cSopenharmony_ci        this.__pasteEnable.purgeDependencyOnElmtId(rmElmtId);
21923b3eb3cSopenharmony_ci        this.__visibilityValue.purgeDependencyOnElmtId(rmElmtId);
22023b3eb3cSopenharmony_ci        this.__customMenuSize.purgeDependencyOnElmtId(rmElmtId);
22123b3eb3cSopenharmony_ci    }
22223b3eb3cSopenharmony_ci
22323b3eb3cSopenharmony_ci    aboutToBeDeleted() {
22423b3eb3cSopenharmony_ci        this.__showExpandedMenuOptions.aboutToBeDeleted();
22523b3eb3cSopenharmony_ci        this.__showCustomerIndex.aboutToBeDeleted();
22623b3eb3cSopenharmony_ci        this.__customerChange.aboutToBeDeleted();
22723b3eb3cSopenharmony_ci        this.__cutAndCopyEnable.aboutToBeDeleted();
22823b3eb3cSopenharmony_ci        this.__pasteEnable.aboutToBeDeleted();
22923b3eb3cSopenharmony_ci        this.__visibilityValue.aboutToBeDeleted();
23023b3eb3cSopenharmony_ci        this.__customMenuSize.aboutToBeDeleted();
23123b3eb3cSopenharmony_ci        SubscriberManager.Get().delete(this.id__());
23223b3eb3cSopenharmony_ci        this.aboutToBeDeletedInternal();
23323b3eb3cSopenharmony_ci    }
23423b3eb3cSopenharmony_ci
23523b3eb3cSopenharmony_ci    CloserFun(parent = null) {
23623b3eb3cSopenharmony_ci    }
23723b3eb3cSopenharmony_ci
23823b3eb3cSopenharmony_ci    get showExpandedMenuOptions() {
23923b3eb3cSopenharmony_ci        return this.__showExpandedMenuOptions.get();
24023b3eb3cSopenharmony_ci    }
24123b3eb3cSopenharmony_ci
24223b3eb3cSopenharmony_ci    set showExpandedMenuOptions(newValue) {
24323b3eb3cSopenharmony_ci        this.__showExpandedMenuOptions.set(newValue);
24423b3eb3cSopenharmony_ci    }
24523b3eb3cSopenharmony_ci
24623b3eb3cSopenharmony_ci    get showCustomerIndex() {
24723b3eb3cSopenharmony_ci        return this.__showCustomerIndex.get();
24823b3eb3cSopenharmony_ci    }
24923b3eb3cSopenharmony_ci
25023b3eb3cSopenharmony_ci    set showCustomerIndex(newValue) {
25123b3eb3cSopenharmony_ci        this.__showCustomerIndex.set(newValue);
25223b3eb3cSopenharmony_ci    }
25323b3eb3cSopenharmony_ci
25423b3eb3cSopenharmony_ci    get customerChange() {
25523b3eb3cSopenharmony_ci        return this.__customerChange.get();
25623b3eb3cSopenharmony_ci    }
25723b3eb3cSopenharmony_ci
25823b3eb3cSopenharmony_ci    set customerChange(newValue) {
25923b3eb3cSopenharmony_ci        this.__customerChange.set(newValue);
26023b3eb3cSopenharmony_ci    }
26123b3eb3cSopenharmony_ci
26223b3eb3cSopenharmony_ci    get cutAndCopyEnable() {
26323b3eb3cSopenharmony_ci        return this.__cutAndCopyEnable.get();
26423b3eb3cSopenharmony_ci    }
26523b3eb3cSopenharmony_ci
26623b3eb3cSopenharmony_ci    set cutAndCopyEnable(newValue) {
26723b3eb3cSopenharmony_ci        this.__cutAndCopyEnable.set(newValue);
26823b3eb3cSopenharmony_ci    }
26923b3eb3cSopenharmony_ci
27023b3eb3cSopenharmony_ci    get pasteEnable() {
27123b3eb3cSopenharmony_ci        return this.__pasteEnable.get();
27223b3eb3cSopenharmony_ci    }
27323b3eb3cSopenharmony_ci
27423b3eb3cSopenharmony_ci    set pasteEnable(newValue) {
27523b3eb3cSopenharmony_ci        this.__pasteEnable.set(newValue);
27623b3eb3cSopenharmony_ci    }
27723b3eb3cSopenharmony_ci
27823b3eb3cSopenharmony_ci    get visibilityValue() {
27923b3eb3cSopenharmony_ci        return this.__visibilityValue.get();
28023b3eb3cSopenharmony_ci    }
28123b3eb3cSopenharmony_ci
28223b3eb3cSopenharmony_ci    set visibilityValue(newValue) {
28323b3eb3cSopenharmony_ci        this.__visibilityValue.set(newValue);
28423b3eb3cSopenharmony_ci    }
28523b3eb3cSopenharmony_ci
28623b3eb3cSopenharmony_ci    get customMenuSize() {
28723b3eb3cSopenharmony_ci        return this.__customMenuSize.get();
28823b3eb3cSopenharmony_ci    }
28923b3eb3cSopenharmony_ci
29023b3eb3cSopenharmony_ci    set customMenuSize(newValue) {
29123b3eb3cSopenharmony_ci        this.__customMenuSize.set(newValue);
29223b3eb3cSopenharmony_ci    }
29323b3eb3cSopenharmony_ci
29423b3eb3cSopenharmony_ci    aboutToAppear() {
29523b3eb3cSopenharmony_ci        if (this.controller) {
29623b3eb3cSopenharmony_ci            let richEditorSelection = this.controller.getSelection();
29723b3eb3cSopenharmony_ci            let start = richEditorSelection.selection[0];
29823b3eb3cSopenharmony_ci            let end = richEditorSelection.selection[1];
29923b3eb3cSopenharmony_ci            if (start !== end) {
30023b3eb3cSopenharmony_ci                this.cutAndCopyEnable = true;
30123b3eb3cSopenharmony_ci            }
30223b3eb3cSopenharmony_ci            if (start === 0 && this.controller.getSpans({ start: end + 1, end: end + 1 }).length === 0) {
30323b3eb3cSopenharmony_ci                this.visibilityValue = Visibility.None;
30423b3eb3cSopenharmony_ci            }
30523b3eb3cSopenharmony_ci            else {
30623b3eb3cSopenharmony_ci                this.visibilityValue = Visibility.Visible;
30723b3eb3cSopenharmony_ci            }
30823b3eb3cSopenharmony_ci        }
30923b3eb3cSopenharmony_ci        else if (this.expandedMenuOptions && this.expandedMenuOptions.length > 0) {
31023b3eb3cSopenharmony_ci            this.showExpandedMenuOptions = true;
31123b3eb3cSopenharmony_ci        }
31223b3eb3cSopenharmony_ci        let sysBoard = pasteboard.getSystemPasteboard();
31323b3eb3cSopenharmony_ci        if (sysBoard && sysBoard.hasDataSync()) {
31423b3eb3cSopenharmony_ci            this.pasteEnable = true;
31523b3eb3cSopenharmony_ci        }
31623b3eb3cSopenharmony_ci        if (!(this.editorMenuOptions && this.editorMenuOptions.length > 0)) {
31723b3eb3cSopenharmony_ci            this.customMenuHeight = 0;
31823b3eb3cSopenharmony_ci        }
31923b3eb3cSopenharmony_ci    }
32023b3eb3cSopenharmony_ci
32123b3eb3cSopenharmony_ci    initialRender() {
32223b3eb3cSopenharmony_ci        this.observeComponentCreation2((elmtId, isInitialRender) => {
32323b3eb3cSopenharmony_ci            Column.create();
32423b3eb3cSopenharmony_ci            Column.useShadowBatching(true);
32523b3eb3cSopenharmony_ci            Column.flexShrink(1);
32623b3eb3cSopenharmony_ci            Column.height(this.customMenuSize);
32723b3eb3cSopenharmony_ci        }, Column);
32823b3eb3cSopenharmony_ci        this.observeComponentCreation2((elmtId, isInitialRender) => {
32923b3eb3cSopenharmony_ci            If.create();
33023b3eb3cSopenharmony_ci            if (this.editorMenuOptions && this.editorMenuOptions.length > 0) {
33123b3eb3cSopenharmony_ci                this.ifElseBranchUpdateFunction(0, () => {
33223b3eb3cSopenharmony_ci                    this.IconPanel.bind(this)(this);
33323b3eb3cSopenharmony_ci                });
33423b3eb3cSopenharmony_ci            }
33523b3eb3cSopenharmony_ci            else {
33623b3eb3cSopenharmony_ci                this.ifElseBranchUpdateFunction(1, () => {
33723b3eb3cSopenharmony_ci                });
33823b3eb3cSopenharmony_ci            }
33923b3eb3cSopenharmony_ci        }, If);
34023b3eb3cSopenharmony_ci        If.pop();
34123b3eb3cSopenharmony_ci        this.observeComponentCreation2((elmtId, isInitialRender) => {
34223b3eb3cSopenharmony_ci            Scroll.create();
34323b3eb3cSopenharmony_ci            Scroll.backgroundColor(this.theme.backGroundColor);
34423b3eb3cSopenharmony_ci            Scroll.flexShrink(1);
34523b3eb3cSopenharmony_ci            Scroll.shadow(this.theme.iconPanelShadowStyle);
34623b3eb3cSopenharmony_ci            Scroll.borderRadius(this.theme.containerBorderRadius);
34723b3eb3cSopenharmony_ci            Scroll.onAreaChange((oldValue, newValue) => {
34823b3eb3cSopenharmony_ci                let newValueHeight = newValue.height;
34923b3eb3cSopenharmony_ci                let oldValueHeight = oldValue.height;
35023b3eb3cSopenharmony_ci                this.customMenuHeight += newValueHeight - oldValueHeight;
35123b3eb3cSopenharmony_ci                this.customMenuSize = this.customMenuHeight;
35223b3eb3cSopenharmony_ci            });
35323b3eb3cSopenharmony_ci        }, Scroll);
35423b3eb3cSopenharmony_ci        this.SystemMenu.bind(this)(this);
35523b3eb3cSopenharmony_ci        Scroll.pop();
35623b3eb3cSopenharmony_ci        Column.pop();
35723b3eb3cSopenharmony_ci    }
35823b3eb3cSopenharmony_ci
35923b3eb3cSopenharmony_ci    pushDataToPasteboard(richEditorSelection) {
36023b3eb3cSopenharmony_ci        let sysBoard = pasteboard.getSystemPasteboard();
36123b3eb3cSopenharmony_ci        let pasteData = pasteboard.createData(pasteboard.MIMETYPE_TEXT_PLAIN, '');
36223b3eb3cSopenharmony_ci        if (richEditorSelection.spans && richEditorSelection.spans.length > 0) {
36323b3eb3cSopenharmony_ci            let count = richEditorSelection.spans.length;
36423b3eb3cSopenharmony_ci            for (let i = count - 1; i >= 0; i--) {
36523b3eb3cSopenharmony_ci                let item = richEditorSelection.spans[i];
36623b3eb3cSopenharmony_ci                if (item?.textStyle) {
36723b3eb3cSopenharmony_ci                    let span = item;
36823b3eb3cSopenharmony_ci                    let style = span.textStyle;
36923b3eb3cSopenharmony_ci                    let data = pasteboard.createRecord(pasteboard.MIMETYPE_TEXT_PLAIN, span.value.substring(span.offsetInSpan[0], span.offsetInSpan[1]));
37023b3eb3cSopenharmony_ci                    let prop = pasteData.getProperty();
37123b3eb3cSopenharmony_ci                    let temp = {
37223b3eb3cSopenharmony_ci                        'color': style.fontColor,
37323b3eb3cSopenharmony_ci                        'size': style.fontSize,
37423b3eb3cSopenharmony_ci                        'style': style.fontStyle,
37523b3eb3cSopenharmony_ci                        'weight': this.fontWeightTable[style.fontWeight],
37623b3eb3cSopenharmony_ci                        'fontFamily': style.fontFamily,
37723b3eb3cSopenharmony_ci                        'decorationType': style.decoration.type,
37823b3eb3cSopenharmony_ci                        'decorationColor': style.decoration.color
37923b3eb3cSopenharmony_ci                    };
38023b3eb3cSopenharmony_ci                    prop.additions[i] = temp;
38123b3eb3cSopenharmony_ci                    pasteData.addRecord(data);
38223b3eb3cSopenharmony_ci                    pasteData.setProperty(prop);
38323b3eb3cSopenharmony_ci                }
38423b3eb3cSopenharmony_ci            }
38523b3eb3cSopenharmony_ci        }
38623b3eb3cSopenharmony_ci        sysBoard.clearData();
38723b3eb3cSopenharmony_ci        sysBoard.setData(pasteData).then(() => {
38823b3eb3cSopenharmony_ci            hilog.info(0x3900, 'Ace', 'SelectionMenu copy option, Succeeded in setting PasteData.');
38923b3eb3cSopenharmony_ci        }).catch((err) => {
39023b3eb3cSopenharmony_ci            hilog.info(0x3900, 'Ace', 'SelectionMenu copy option, Failed to set PasteData. Cause:' + err.message);
39123b3eb3cSopenharmony_ci        });
39223b3eb3cSopenharmony_ci    }
39323b3eb3cSopenharmony_ci
39423b3eb3cSopenharmony_ci    popDataFromPasteboard(richEditorSelection) {
39523b3eb3cSopenharmony_ci        let start = richEditorSelection.selection[0];
39623b3eb3cSopenharmony_ci        let end = richEditorSelection.selection[1];
39723b3eb3cSopenharmony_ci        if (start === end && this.controller) {
39823b3eb3cSopenharmony_ci            start = this.controller.getCaretOffset();
39923b3eb3cSopenharmony_ci            end = this.controller.getCaretOffset();
40023b3eb3cSopenharmony_ci        }
40123b3eb3cSopenharmony_ci        let moveOffset = 0;
40223b3eb3cSopenharmony_ci        let sysBoard = pasteboard.getSystemPasteboard();
40323b3eb3cSopenharmony_ci        sysBoard.getData((err, data) => {
40423b3eb3cSopenharmony_ci            if (err) {
40523b3eb3cSopenharmony_ci                return;
40623b3eb3cSopenharmony_ci            }
40723b3eb3cSopenharmony_ci            let count = data.getRecordCount();
40823b3eb3cSopenharmony_ci            for (let i = 0; i < count; i++) {
40923b3eb3cSopenharmony_ci                const element = data.getRecord(i);
41023b3eb3cSopenharmony_ci                let tex = {
41123b3eb3cSopenharmony_ci                    fontSize: 16,
41223b3eb3cSopenharmony_ci                    fontColor: Color.Black,
41323b3eb3cSopenharmony_ci                    fontWeight: FontWeight.Normal,
41423b3eb3cSopenharmony_ci                    fontFamily: 'HarmonyOS Sans',
41523b3eb3cSopenharmony_ci                    fontStyle: FontStyle.Normal,
41623b3eb3cSopenharmony_ci                    decoration: { type: TextDecorationType.None, color: '#FF000000' }
41723b3eb3cSopenharmony_ci                };
41823b3eb3cSopenharmony_ci                if (data.getProperty() && data.getProperty().additions[i]) {
41923b3eb3cSopenharmony_ci                    const tmp = data.getProperty().additions[i];
42023b3eb3cSopenharmony_ci                    if (tmp.color) {
42123b3eb3cSopenharmony_ci                        tex.fontColor = tmp.color;
42223b3eb3cSopenharmony_ci                    }
42323b3eb3cSopenharmony_ci                    if (tmp.size) {
42423b3eb3cSopenharmony_ci                        tex.fontSize = tmp.size;
42523b3eb3cSopenharmony_ci                    }
42623b3eb3cSopenharmony_ci                    if (tmp.style) {
42723b3eb3cSopenharmony_ci                        tex.fontStyle = tmp.style;
42823b3eb3cSopenharmony_ci                    }
42923b3eb3cSopenharmony_ci                    if (tmp.weight) {
43023b3eb3cSopenharmony_ci                        tex.fontWeight = tmp.weight;
43123b3eb3cSopenharmony_ci                    }
43223b3eb3cSopenharmony_ci                    if (tmp.fontFamily) {
43323b3eb3cSopenharmony_ci                        tex.fontFamily = tmp.fontFamily;
43423b3eb3cSopenharmony_ci                    }
43523b3eb3cSopenharmony_ci                    if (tmp.decorationType && tex.decoration) {
43623b3eb3cSopenharmony_ci                        tex.decoration.type = tmp.decorationType;
43723b3eb3cSopenharmony_ci                    }
43823b3eb3cSopenharmony_ci                    if (tmp.decorationColor && tex.decoration) {
43923b3eb3cSopenharmony_ci                        tex.decoration.color = tmp.decorationColor;
44023b3eb3cSopenharmony_ci                    }
44123b3eb3cSopenharmony_ci                    if (tex.decoration) {
44223b3eb3cSopenharmony_ci                        tex.decoration = { type: tex.decoration.type, color: tex.decoration.color };
44323b3eb3cSopenharmony_ci                    }
44423b3eb3cSopenharmony_ci                }
44523b3eb3cSopenharmony_ci                if (element && element.plainText && element.mimeType === pasteboard.MIMETYPE_TEXT_PLAIN && this.controller) {
44623b3eb3cSopenharmony_ci                    this.controller.addTextSpan(element.plainText, {
44723b3eb3cSopenharmony_ci                        style: tex,
44823b3eb3cSopenharmony_ci                        offset: start + moveOffset
44923b3eb3cSopenharmony_ci                    });
45023b3eb3cSopenharmony_ci                    moveOffset += element.plainText.length;
45123b3eb3cSopenharmony_ci                }
45223b3eb3cSopenharmony_ci            }
45323b3eb3cSopenharmony_ci            if (this.controller) {
45423b3eb3cSopenharmony_ci                this.controller.setCaretOffset(start + moveOffset);
45523b3eb3cSopenharmony_ci            }
45623b3eb3cSopenharmony_ci            if (start !== end && this.controller) {
45723b3eb3cSopenharmony_ci                this.controller.deleteSpans({ start: start + moveOffset, end: end + moveOffset });
45823b3eb3cSopenharmony_ci            }
45923b3eb3cSopenharmony_ci        });
46023b3eb3cSopenharmony_ci    }
46123b3eb3cSopenharmony_ci
46223b3eb3cSopenharmony_ci    measureButtonWidth() {
46323b3eb3cSopenharmony_ci        if (this.editorMenuOptions && this.editorMenuOptions.length < 5) {
46423b3eb3cSopenharmony_ci            return (this.theme.defaultMenuWidth - this.theme.expandedOptionPadding * 2 -
46523b3eb3cSopenharmony_ci                this.theme.editorOptionMargin * 2 * this.editorMenuOptions.length) / this.editorMenuOptions.length;
46623b3eb3cSopenharmony_ci        }
46723b3eb3cSopenharmony_ci        return this.theme.buttonSize;
46823b3eb3cSopenharmony_ci    }
46923b3eb3cSopenharmony_ci
47023b3eb3cSopenharmony_ci    IconPanel(parent = null) {
47123b3eb3cSopenharmony_ci        this.observeComponentCreation2((elmtId, isInitialRender) => {
47223b3eb3cSopenharmony_ci            Flex.create({ wrap: FlexWrap.Wrap });
47323b3eb3cSopenharmony_ci            Flex.onAreaChange((oldValue, newValue) => {
47423b3eb3cSopenharmony_ci                let newValueHeight = newValue.height;
47523b3eb3cSopenharmony_ci                let oldValueHeight = oldValue.height;
47623b3eb3cSopenharmony_ci                this.customMenuHeight += newValueHeight - oldValueHeight;
47723b3eb3cSopenharmony_ci                this.customMenuSize = this.customMenuHeight;
47823b3eb3cSopenharmony_ci            });
47923b3eb3cSopenharmony_ci            Flex.clip(true);
48023b3eb3cSopenharmony_ci            Flex.width(this.theme.defaultMenuWidth);
48123b3eb3cSopenharmony_ci            Flex.padding(this.theme.expandedOptionPadding);
48223b3eb3cSopenharmony_ci            Flex.borderRadius(this.theme.containerBorderRadius);
48323b3eb3cSopenharmony_ci            Flex.margin({ bottom: this.theme.menuSpacing });
48423b3eb3cSopenharmony_ci            Flex.backgroundColor(this.theme.backGroundColor);
48523b3eb3cSopenharmony_ci            Flex.shadow(this.theme.iconPanelShadowStyle);
48623b3eb3cSopenharmony_ci        }, Flex);
48723b3eb3cSopenharmony_ci        this.observeComponentCreation2((elmtId, isInitialRender) => {
48823b3eb3cSopenharmony_ci            If.create();
48923b3eb3cSopenharmony_ci            if (this.editorMenuOptions) {
49023b3eb3cSopenharmony_ci                this.ifElseBranchUpdateFunction(0, () => {
49123b3eb3cSopenharmony_ci                    this.observeComponentCreation2((elmtId, isInitialRender) => {
49223b3eb3cSopenharmony_ci                        ForEach.create();
49323b3eb3cSopenharmony_ci                        const forEachItemGenFunction = (_item, index) => {
49423b3eb3cSopenharmony_ci                            const item = _item;
49523b3eb3cSopenharmony_ci                            this.observeComponentCreation2((elmtId, isInitialRender) => {
49623b3eb3cSopenharmony_ci                                Button.createWithChild();
49723b3eb3cSopenharmony_ci                                Button.enabled(!(!item.action && !item.builder));
49823b3eb3cSopenharmony_ci                                Button.type(ButtonType.Normal);
49923b3eb3cSopenharmony_ci                                Button.margin(this.theme.editorOptionMargin);
50023b3eb3cSopenharmony_ci                                Button.backgroundColor(this.theme.backGroundColor);
50123b3eb3cSopenharmony_ci                                Button.onClick(() => {
50223b3eb3cSopenharmony_ci                                    if (item.builder) {
50323b3eb3cSopenharmony_ci                                        this.builder = item.builder;
50423b3eb3cSopenharmony_ci                                        this.showCustomerIndex = index;
50523b3eb3cSopenharmony_ci                                        this.showExpandedMenuOptions = false;
50623b3eb3cSopenharmony_ci                                        this.customerChange = !this.customerChange;
50723b3eb3cSopenharmony_ci                                    }
50823b3eb3cSopenharmony_ci                                    else {
50923b3eb3cSopenharmony_ci                                        this.showCustomerIndex = WITHOUT_BUILDER;
51023b3eb3cSopenharmony_ci                                        if (!this.controller) {
51123b3eb3cSopenharmony_ci                                            this.showExpandedMenuOptions = true;
51223b3eb3cSopenharmony_ci                                        }
51323b3eb3cSopenharmony_ci                                    }
51423b3eb3cSopenharmony_ci                                    if (item.action) {
51523b3eb3cSopenharmony_ci                                        item.action();
51623b3eb3cSopenharmony_ci                                    }
51723b3eb3cSopenharmony_ci                                });
51823b3eb3cSopenharmony_ci                                Button.borderRadius(this.theme.iconBorderRadius);
51923b3eb3cSopenharmony_ci                                Button.width(this.measureButtonWidth());
52023b3eb3cSopenharmony_ci                                Button.height(this.theme.buttonSize);
52123b3eb3cSopenharmony_ci                            }, Button);
52223b3eb3cSopenharmony_ci                            this.observeComponentCreation2((elmtId, isInitialRender) => {
52323b3eb3cSopenharmony_ci                                Image.create(item.icon);
52423b3eb3cSopenharmony_ci                                Image.width(this.theme.imageSize);
52523b3eb3cSopenharmony_ci                                Image.height(this.theme.imageSize);
52623b3eb3cSopenharmony_ci                                Image.fillColor(this.theme.imageFillColor);
52723b3eb3cSopenharmony_ci                                Image.focusable(true);
52823b3eb3cSopenharmony_ci                                Image.draggable(false);
52923b3eb3cSopenharmony_ci                            }, Image);
53023b3eb3cSopenharmony_ci                            Button.pop();
53123b3eb3cSopenharmony_ci                        };
53223b3eb3cSopenharmony_ci                        this.forEachUpdateFunction(elmtId, this.editorMenuOptions, forEachItemGenFunction, undefined, true, false);
53323b3eb3cSopenharmony_ci                    }, ForEach);
53423b3eb3cSopenharmony_ci                    ForEach.pop();
53523b3eb3cSopenharmony_ci                });
53623b3eb3cSopenharmony_ci            }
53723b3eb3cSopenharmony_ci            else {
53823b3eb3cSopenharmony_ci                this.ifElseBranchUpdateFunction(1, () => {
53923b3eb3cSopenharmony_ci                });
54023b3eb3cSopenharmony_ci            }
54123b3eb3cSopenharmony_ci        }, If);
54223b3eb3cSopenharmony_ci        If.pop();
54323b3eb3cSopenharmony_ci        Flex.pop();
54423b3eb3cSopenharmony_ci    }
54523b3eb3cSopenharmony_ci
54623b3eb3cSopenharmony_ci    SystemMenu(parent = null) {
54723b3eb3cSopenharmony_ci        this.observeComponentCreation2((elmtId, isInitialRender) => {
54823b3eb3cSopenharmony_ci            Column.create();
54923b3eb3cSopenharmony_ci            Column.width(this.theme.defaultMenuWidth);
55023b3eb3cSopenharmony_ci        }, Column);
55123b3eb3cSopenharmony_ci        this.observeComponentCreation2((elmtId, isInitialRender) => {
55223b3eb3cSopenharmony_ci            If.create();
55323b3eb3cSopenharmony_ci            if (this.showCustomerIndex === -1 &&
55423b3eb3cSopenharmony_ci                (this.controller || (this.expandedMenuOptions && this.expandedMenuOptions.length > 0))) {
55523b3eb3cSopenharmony_ci                this.ifElseBranchUpdateFunction(0, () => {
55623b3eb3cSopenharmony_ci                    this.observeComponentCreation2((elmtId, isInitialRender) => {
55723b3eb3cSopenharmony_ci                        Menu.create();
55823b3eb3cSopenharmony_ci                        Menu.onVisibleAreaChange([0.0, 1.0], () => {
55923b3eb3cSopenharmony_ci                            if (!this.controller) {
56023b3eb3cSopenharmony_ci                                return;
56123b3eb3cSopenharmony_ci                            }
56223b3eb3cSopenharmony_ci                            let richEditorSelection = this.controller.getSelection();
56323b3eb3cSopenharmony_ci                            let start = richEditorSelection.selection[0];
56423b3eb3cSopenharmony_ci                            let end = richEditorSelection.selection[1];
56523b3eb3cSopenharmony_ci                            if (start !== end) {
56623b3eb3cSopenharmony_ci                                this.cutAndCopyEnable = true;
56723b3eb3cSopenharmony_ci                            }
56823b3eb3cSopenharmony_ci                            if (start === 0 && this.controller.getSpans({
56923b3eb3cSopenharmony_ci                                start: end + 1,
57023b3eb3cSopenharmony_ci                                end: end + 1
57123b3eb3cSopenharmony_ci                            }).length === 0) {
57223b3eb3cSopenharmony_ci                                this.visibilityValue = Visibility.None;
57323b3eb3cSopenharmony_ci                            }
57423b3eb3cSopenharmony_ci                            else {
57523b3eb3cSopenharmony_ci                                this.visibilityValue = Visibility.Visible;
57623b3eb3cSopenharmony_ci                            }
57723b3eb3cSopenharmony_ci                        });
57823b3eb3cSopenharmony_ci                        Menu.radius(this.theme.containerBorderRadius);
57923b3eb3cSopenharmony_ci                        Menu.clip(true);
58023b3eb3cSopenharmony_ci                        Menu.width(this.theme.defaultMenuWidth);
58123b3eb3cSopenharmony_ci                    }, Menu);
58223b3eb3cSopenharmony_ci                    this.observeComponentCreation2((elmtId, isInitialRender) => {
58323b3eb3cSopenharmony_ci                        If.create();
58423b3eb3cSopenharmony_ci                        if (this.controller) {
58523b3eb3cSopenharmony_ci                            this.ifElseBranchUpdateFunction(0, () => {
58623b3eb3cSopenharmony_ci                                this.observeComponentCreation2((elmtId, isInitialRender) => {
58723b3eb3cSopenharmony_ci                                    MenuItemGroup.create();
58823b3eb3cSopenharmony_ci                                }, MenuItemGroup);
58923b3eb3cSopenharmony_ci                                this.observeComponentCreation2((elmtId, isInitialRender) => {
59023b3eb3cSopenharmony_ci                                    MenuItem.create({
59123b3eb3cSopenharmony_ci                                        startIcon: this.theme.cutIcon,
59223b3eb3cSopenharmony_ci                                        content: '剪切',
59323b3eb3cSopenharmony_ci                                        labelInfo: 'Ctrl+X'
59423b3eb3cSopenharmony_ci                                    });
59523b3eb3cSopenharmony_ci                                    MenuItem.enabled(this.cutAndCopyEnable);
59623b3eb3cSopenharmony_ci                                    MenuItem.onClick(() => {
59723b3eb3cSopenharmony_ci                                        if (!this.controller) {
59823b3eb3cSopenharmony_ci                                            return;
59923b3eb3cSopenharmony_ci                                        }
60023b3eb3cSopenharmony_ci                                        let richEditorSelection = this.controller.getSelection();
60123b3eb3cSopenharmony_ci                                        if (this.onCut) {
60223b3eb3cSopenharmony_ci                                            this.onCut({ content: richEditorSelection });
60323b3eb3cSopenharmony_ci                                        }
60423b3eb3cSopenharmony_ci                                        else {
60523b3eb3cSopenharmony_ci                                            this.pushDataToPasteboard(richEditorSelection);
60623b3eb3cSopenharmony_ci                                            this.controller.deleteSpans({
60723b3eb3cSopenharmony_ci                                                start: richEditorSelection.selection[0],
60823b3eb3cSopenharmony_ci                                                end: richEditorSelection.selection[1]
60923b3eb3cSopenharmony_ci                                            });
61023b3eb3cSopenharmony_ci                                        }
61123b3eb3cSopenharmony_ci                                    });
61223b3eb3cSopenharmony_ci                                }, MenuItem);
61323b3eb3cSopenharmony_ci                                MenuItem.pop();
61423b3eb3cSopenharmony_ci                                this.observeComponentCreation2((elmtId, isInitialRender) => {
61523b3eb3cSopenharmony_ci                                    MenuItem.create({
61623b3eb3cSopenharmony_ci                                        startIcon: this.theme.copyIcon,
61723b3eb3cSopenharmony_ci                                        content: '复制',
61823b3eb3cSopenharmony_ci                                        labelInfo: 'Ctrl+C'
61923b3eb3cSopenharmony_ci                                    });
62023b3eb3cSopenharmony_ci                                    MenuItem.enabled(this.cutAndCopyEnable);
62123b3eb3cSopenharmony_ci                                    MenuItem.onClick(() => {
62223b3eb3cSopenharmony_ci                                        if (!this.controller) {
62323b3eb3cSopenharmony_ci                                            return;
62423b3eb3cSopenharmony_ci                                        }
62523b3eb3cSopenharmony_ci                                        let richEditorSelection = this.controller.getSelection();
62623b3eb3cSopenharmony_ci                                        if (this.onCopy) {
62723b3eb3cSopenharmony_ci                                            this.onCopy({ content: richEditorSelection });
62823b3eb3cSopenharmony_ci                                        }
62923b3eb3cSopenharmony_ci                                        else {
63023b3eb3cSopenharmony_ci                                            this.pushDataToPasteboard(richEditorSelection);
63123b3eb3cSopenharmony_ci                                            this.controller.closeSelectionMenu();
63223b3eb3cSopenharmony_ci                                        }
63323b3eb3cSopenharmony_ci                                    });
63423b3eb3cSopenharmony_ci                                }, MenuItem);
63523b3eb3cSopenharmony_ci                                MenuItem.pop();
63623b3eb3cSopenharmony_ci                                this.observeComponentCreation2((elmtId, isInitialRender) => {
63723b3eb3cSopenharmony_ci                                    MenuItem.create({
63823b3eb3cSopenharmony_ci                                        startIcon: this.theme.pasteIcon,
63923b3eb3cSopenharmony_ci                                        content: '粘贴',
64023b3eb3cSopenharmony_ci                                        labelInfo: 'Ctrl+V'
64123b3eb3cSopenharmony_ci                                    });
64223b3eb3cSopenharmony_ci                                    MenuItem.enabled(this.pasteEnable);
64323b3eb3cSopenharmony_ci                                    MenuItem.onClick(() => {
64423b3eb3cSopenharmony_ci                                        if (!this.controller) {
64523b3eb3cSopenharmony_ci                                            return;
64623b3eb3cSopenharmony_ci                                        }
64723b3eb3cSopenharmony_ci                                        let richEditorSelection = this.controller.getSelection();
64823b3eb3cSopenharmony_ci                                        if (this.onPaste) {
64923b3eb3cSopenharmony_ci                                            this.onPaste({ content: richEditorSelection });
65023b3eb3cSopenharmony_ci                                        }
65123b3eb3cSopenharmony_ci                                        else {
65223b3eb3cSopenharmony_ci                                            this.popDataFromPasteboard(richEditorSelection);
65323b3eb3cSopenharmony_ci                                            this.controller.closeSelectionMenu();
65423b3eb3cSopenharmony_ci                                        }
65523b3eb3cSopenharmony_ci                                    });
65623b3eb3cSopenharmony_ci                                }, MenuItem);
65723b3eb3cSopenharmony_ci                                MenuItem.pop();
65823b3eb3cSopenharmony_ci                                this.observeComponentCreation2((elmtId, isInitialRender) => {
65923b3eb3cSopenharmony_ci                                    MenuItem.create({
66023b3eb3cSopenharmony_ci                                        startIcon: this.theme.selectAllIcon,
66123b3eb3cSopenharmony_ci                                        content: '全选',
66223b3eb3cSopenharmony_ci                                        labelInfo: 'Ctrl+A'
66323b3eb3cSopenharmony_ci                                    });
66423b3eb3cSopenharmony_ci                                    MenuItem.visibility(this.visibilityValue);
66523b3eb3cSopenharmony_ci                                    MenuItem.onClick(() => {
66623b3eb3cSopenharmony_ci                                        if (!this.controller) {
66723b3eb3cSopenharmony_ci                                            return;
66823b3eb3cSopenharmony_ci                                        }
66923b3eb3cSopenharmony_ci                                        if (this.onSelectAll) {
67023b3eb3cSopenharmony_ci                                            let richEditorSelection = this.controller.getSelection();
67123b3eb3cSopenharmony_ci                                            this.onSelectAll({ content: richEditorSelection });
67223b3eb3cSopenharmony_ci                                        }
67323b3eb3cSopenharmony_ci                                        else {
67423b3eb3cSopenharmony_ci                                            this.controller.setSelection(-1, -1);
67523b3eb3cSopenharmony_ci                                            this.visibilityValue = Visibility.None;
67623b3eb3cSopenharmony_ci                                        }
67723b3eb3cSopenharmony_ci                                        this.controller.closeSelectionMenu();
67823b3eb3cSopenharmony_ci                                    });
67923b3eb3cSopenharmony_ci                                }, MenuItem);
68023b3eb3cSopenharmony_ci                                MenuItem.pop();
68123b3eb3cSopenharmony_ci                                MenuItemGroup.pop();
68223b3eb3cSopenharmony_ci                            });
68323b3eb3cSopenharmony_ci                        }
68423b3eb3cSopenharmony_ci                        else {
68523b3eb3cSopenharmony_ci                            this.ifElseBranchUpdateFunction(1, () => {
68623b3eb3cSopenharmony_ci                            });
68723b3eb3cSopenharmony_ci                        }
68823b3eb3cSopenharmony_ci                    }, If);
68923b3eb3cSopenharmony_ci                    If.pop();
69023b3eb3cSopenharmony_ci                    this.observeComponentCreation2((elmtId, isInitialRender) => {
69123b3eb3cSopenharmony_ci                        If.create();
69223b3eb3cSopenharmony_ci                        if (this.controller && !this.showExpandedMenuOptions && this.expandedMenuOptions && this.expandedMenuOptions.length > 0) {
69323b3eb3cSopenharmony_ci                            this.ifElseBranchUpdateFunction(0, () => {
69423b3eb3cSopenharmony_ci                                this.observeComponentCreation2((elmtId, isInitialRender) => {
69523b3eb3cSopenharmony_ci                                    MenuItem.create({ content: '更多', endIcon: this.theme.arrowDownIcon });
69623b3eb3cSopenharmony_ci                                    MenuItem.onClick(() => {
69723b3eb3cSopenharmony_ci                                        this.showExpandedMenuOptions = true;
69823b3eb3cSopenharmony_ci                                        this.customMenuSize = '100%';
69923b3eb3cSopenharmony_ci                                    });
70023b3eb3cSopenharmony_ci                                }, MenuItem);
70123b3eb3cSopenharmony_ci                                MenuItem.pop();
70223b3eb3cSopenharmony_ci                            });
70323b3eb3cSopenharmony_ci                        }
70423b3eb3cSopenharmony_ci                        else if (this.showExpandedMenuOptions && this.expandedMenuOptions && this.expandedMenuOptions.length > 0) {
70523b3eb3cSopenharmony_ci                            this.ifElseBranchUpdateFunction(1, () => {
70623b3eb3cSopenharmony_ci                                this.observeComponentCreation2((elmtId, isInitialRender) => {
70723b3eb3cSopenharmony_ci                                    ForEach.create();
70823b3eb3cSopenharmony_ci                                    const forEachItemGenFunction = (_item, index) => {
70923b3eb3cSopenharmony_ci                                        const expandedMenuOptionItem = _item;
71023b3eb3cSopenharmony_ci                                        this.observeComponentCreation2((elmtId, isInitialRender) => {
71123b3eb3cSopenharmony_ci                                            MenuItem.create({
71223b3eb3cSopenharmony_ci                                                startIcon: expandedMenuOptionItem.startIcon,
71323b3eb3cSopenharmony_ci                                                content: expandedMenuOptionItem.content,
71423b3eb3cSopenharmony_ci                                                endIcon: expandedMenuOptionItem.endIcon,
71523b3eb3cSopenharmony_ci                                                labelInfo: expandedMenuOptionItem.labelInfo,
71623b3eb3cSopenharmony_ci                                                builder: expandedMenuOptionItem.builder
71723b3eb3cSopenharmony_ci                                            });
71823b3eb3cSopenharmony_ci                                            MenuItem.onClick(() => {
71923b3eb3cSopenharmony_ci                                                if (expandedMenuOptionItem.action) {
72023b3eb3cSopenharmony_ci                                                    expandedMenuOptionItem.action();
72123b3eb3cSopenharmony_ci                                                }
72223b3eb3cSopenharmony_ci                                            });
72323b3eb3cSopenharmony_ci                                        }, MenuItem);
72423b3eb3cSopenharmony_ci                                        MenuItem.pop();
72523b3eb3cSopenharmony_ci                                    };
72623b3eb3cSopenharmony_ci                                    this.forEachUpdateFunction(elmtId, this.expandedMenuOptions, forEachItemGenFunction, undefined, true, false);
72723b3eb3cSopenharmony_ci                                }, ForEach);
72823b3eb3cSopenharmony_ci                                ForEach.pop();
72923b3eb3cSopenharmony_ci                            });
73023b3eb3cSopenharmony_ci                        }
73123b3eb3cSopenharmony_ci                        else {
73223b3eb3cSopenharmony_ci                            this.ifElseBranchUpdateFunction(2, () => {
73323b3eb3cSopenharmony_ci                            });
73423b3eb3cSopenharmony_ci                        }
73523b3eb3cSopenharmony_ci                    }, If);
73623b3eb3cSopenharmony_ci                    If.pop();
73723b3eb3cSopenharmony_ci                    Menu.pop();
73823b3eb3cSopenharmony_ci                });
73923b3eb3cSopenharmony_ci            }
74023b3eb3cSopenharmony_ci            else if (this.showCustomerIndex > -1 && this.builder) {
74123b3eb3cSopenharmony_ci                this.ifElseBranchUpdateFunction(1, () => {
74223b3eb3cSopenharmony_ci                    this.observeComponentCreation2((elmtId, isInitialRender) => {
74323b3eb3cSopenharmony_ci                        If.create();
74423b3eb3cSopenharmony_ci                        if (this.customerChange) {
74523b3eb3cSopenharmony_ci                            this.ifElseBranchUpdateFunction(0, () => {
74623b3eb3cSopenharmony_ci                                this.builder.bind(this)(parent ? parent : this);
74723b3eb3cSopenharmony_ci                            });
74823b3eb3cSopenharmony_ci                        }
74923b3eb3cSopenharmony_ci                        else {
75023b3eb3cSopenharmony_ci                            this.ifElseBranchUpdateFunction(1, () => {
75123b3eb3cSopenharmony_ci                                this.builder.bind(this)(parent ? parent : this);
75223b3eb3cSopenharmony_ci                            });
75323b3eb3cSopenharmony_ci                        }
75423b3eb3cSopenharmony_ci                    }, If);
75523b3eb3cSopenharmony_ci                    If.pop();
75623b3eb3cSopenharmony_ci                });
75723b3eb3cSopenharmony_ci            }
75823b3eb3cSopenharmony_ci            else {
75923b3eb3cSopenharmony_ci                this.ifElseBranchUpdateFunction(2, () => {
76023b3eb3cSopenharmony_ci                });
76123b3eb3cSopenharmony_ci            }
76223b3eb3cSopenharmony_ci        }, If);
76323b3eb3cSopenharmony_ci        If.pop();
76423b3eb3cSopenharmony_ci        Column.pop();
76523b3eb3cSopenharmony_ci    }
76623b3eb3cSopenharmony_ci
76723b3eb3cSopenharmony_ci    rerender() {
76823b3eb3cSopenharmony_ci        this.updateDirtyElements();
76923b3eb3cSopenharmony_ci    }
77023b3eb3cSopenharmony_ci}
77123b3eb3cSopenharmony_ci
77223b3eb3cSopenharmony_ciexport function SelectionMenu(options, parent = null) {
77323b3eb3cSopenharmony_ci    const __options__ = options;
77423b3eb3cSopenharmony_ci    {
77523b3eb3cSopenharmony_ci        (parent ? parent : this).observeComponentCreation2((elmtId, isInitialRender, options = __options__) => {
77623b3eb3cSopenharmony_ci            if (isInitialRender) {
77723b3eb3cSopenharmony_ci                let componentCall = new SelectionMenuComponent(typeof PUV2ViewBase !== 'undefined' && parent instanceof PUV2ViewBase ? parent : this, {
77823b3eb3cSopenharmony_ci                    editorMenuOptions: options.editorMenuOptions,
77923b3eb3cSopenharmony_ci                    expandedMenuOptions: options.expandedMenuOptions,
78023b3eb3cSopenharmony_ci                    controller: options.controller,
78123b3eb3cSopenharmony_ci                    onPaste: options.onPaste,
78223b3eb3cSopenharmony_ci                    onCopy: options.onCopy,
78323b3eb3cSopenharmony_ci                    onCut: options.onCut,
78423b3eb3cSopenharmony_ci                    onSelectAll: options.onSelectAll
78523b3eb3cSopenharmony_ci                }, undefined, elmtId, () => {
78623b3eb3cSopenharmony_ci                }, { page: 'library/src/main/ets/components/mainpage/MainPage.ets', line: 459, col: 3 });
78723b3eb3cSopenharmony_ci                ViewPU.create(componentCall);
78823b3eb3cSopenharmony_ci                let paramsLambda = () => {
78923b3eb3cSopenharmony_ci                    return {
79023b3eb3cSopenharmony_ci                        editorMenuOptions: options.editorMenuOptions,
79123b3eb3cSopenharmony_ci                        expandedMenuOptions: options.expandedMenuOptions,
79223b3eb3cSopenharmony_ci                        controller: options.controller,
79323b3eb3cSopenharmony_ci                        onPaste: options.onPaste,
79423b3eb3cSopenharmony_ci                        onCopy: options.onCopy,
79523b3eb3cSopenharmony_ci                        onCut: options.onCut,
79623b3eb3cSopenharmony_ci                        onSelectAll: options.onSelectAll
79723b3eb3cSopenharmony_ci                    };
79823b3eb3cSopenharmony_ci                };
79923b3eb3cSopenharmony_ci                componentCall.paramsGenerator_ = paramsLambda;
80023b3eb3cSopenharmony_ci            }
80123b3eb3cSopenharmony_ci            else {
80223b3eb3cSopenharmony_ci                (parent ? parent : this).updateStateVarsOfChildByElmtId(elmtId, {});
80323b3eb3cSopenharmony_ci            }
80423b3eb3cSopenharmony_ci        }, { name: 'SelectionMenuComponent' });
80523b3eb3cSopenharmony_ci    }
80623b3eb3cSopenharmony_ci}
80723b3eb3cSopenharmony_ciexport default { SelectionMenu };