easy-email-extensions 3.1.39 → 3.1.41

Sign up to get free protection for your applications and to get access to all the features.
package/License ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2021-2022 AfterShip
2
+
3
+ Permission is hereby granted, free of charge, to any person
4
+ obtaining a copy of this software and associated documentation
5
+ files (the "Software"), to deal in the Software without
6
+ restriction, including without limitation the rights to use,
7
+ copy, modify, merge, publish, distribute, sublicense, and/or sell
8
+ copies of the Software, and to permit persons to whom the
9
+ Software is furnished to do so, subject to the following
10
+ conditions:
11
+
12
+ The above copyright notice and this permission notice shall be
13
+ included in all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
16
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
17
+ OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
18
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
19
+ HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
20
+ WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
21
+ FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
22
+ OTHER DEALINGS IN THE SOFTWARE.
package/lib/index2.js CHANGED
@@ -38305,12 +38305,17 @@ const PresetColorsProvider = (props) => {
38305
38305
  setCurrentColors(newColors);
38306
38306
  }
38307
38307
  }, [currentColors, setCurrentColors]);
38308
- return /* @__PURE__ */ React__default.createElement(PresetColorsContext.Provider, {
38309
- value: {
38308
+ const value = useMemo(() => {
38309
+ return {
38310
38310
  colors: currentColors,
38311
38311
  addCurrentColor
38312
- }
38313
- }, props.children);
38312
+ };
38313
+ }, [addCurrentColor, currentColors]);
38314
+ return useMemo(() => {
38315
+ return /* @__PURE__ */ React__default.createElement(PresetColorsContext.Provider, {
38316
+ value
38317
+ }, props.children);
38318
+ }, [props.children, value]);
38314
38319
  };
38315
38320
  function ColorPicker(props) {
38316
38321
  const { colors: presetColors, addCurrentColor } = useContext(PresetColorsContext);
@@ -40265,7 +40270,6 @@ const MergeTags = React__default.memo((props) => {
40265
40270
  const value = lodash.exports.get(contextMergeTags, key);
40266
40271
  if (lodash.exports.isObject(value)) {
40267
40272
  setExpandedKeys((keys2) => {
40268
- console.log("keys", keys2, key);
40269
40273
  if (keys2.includes(key)) {
40270
40274
  return keys2.filter((k) => k !== key);
40271
40275
  } else {
@@ -40274,7 +40278,7 @@ const MergeTags = React__default.memo((props) => {
40274
40278
  });
40275
40279
  return;
40276
40280
  }
40277
- return props.onChange(mergeTagGenerate(value));
40281
+ return props.onChange(mergeTagGenerate(key));
40278
40282
  }, [contextMergeTags, props, mergeTagGenerate]);
40279
40283
  const mergeTagContent = useMemo(() => renderMergeTagContent ? renderMergeTagContent({
40280
40284
  onChange: props.onChange,
@@ -41315,6 +41319,40 @@ class BlockAttributeConfigurationManager {
41315
41319
  }
41316
41320
  }
41317
41321
  __publicField(BlockAttributeConfigurationManager, "map", __spreadValues({}, blocks));
41322
+ const SelectionRangeContext = React__default.createContext({
41323
+ selectionRange: null,
41324
+ setSelectionRange: () => {
41325
+ }
41326
+ });
41327
+ const SelectionRangeProvider = (props) => {
41328
+ const [selectionRange, setSelectionRange] = useState(null);
41329
+ useEffect(() => {
41330
+ const onSelectionChange = () => {
41331
+ try {
41332
+ const range2 = getShadowRoot().getSelection().getRangeAt(0);
41333
+ if (range2) {
41334
+ setSelectionRange(range2);
41335
+ }
41336
+ } catch (error2) {
41337
+ }
41338
+ };
41339
+ document.addEventListener("selectionchange", onSelectionChange);
41340
+ return () => {
41341
+ document.removeEventListener("selectionchange", onSelectionChange);
41342
+ };
41343
+ }, []);
41344
+ const value = useMemo(() => {
41345
+ return {
41346
+ selectionRange,
41347
+ setSelectionRange
41348
+ };
41349
+ }, [selectionRange]);
41350
+ return useMemo(() => {
41351
+ return /* @__PURE__ */ React__default.createElement(SelectionRangeContext.Provider, {
41352
+ value
41353
+ }, props.children);
41354
+ }, [props.children, value]);
41355
+ };
41318
41356
  function AttributePanel() {
41319
41357
  const { values: values2, focusBlock: focusBlock2 } = useBlock();
41320
41358
  const { initialized } = useEditorContext();
@@ -41324,7 +41362,7 @@ function AttributePanel() {
41324
41362
  const shadowRoot = getShadowRoot();
41325
41363
  if (!value || !initialized)
41326
41364
  return null;
41327
- return /* @__PURE__ */ React__default.createElement(PresetColorsProvider, null, Com ? /* @__PURE__ */ React__default.createElement(Com, {
41365
+ return /* @__PURE__ */ React__default.createElement(SelectionRangeProvider, null, /* @__PURE__ */ React__default.createElement(PresetColorsProvider, null, Com ? /* @__PURE__ */ React__default.createElement(Com, {
41328
41366
  key: focusIdx2
41329
41367
  }) : /* @__PURE__ */ React__default.createElement("div", {
41330
41368
  style: { marginTop: 200, padding: "0 50px" }
@@ -41340,27 +41378,10 @@ function AttributePanel() {
41340
41378
  outline: none;
41341
41379
  cursor: text;
41342
41380
  }
41343
- `), shadowRoot));
41381
+ `), shadowRoot)));
41344
41382
  }
41345
- function Tools(props) {
41346
- const { container: container2 } = props;
41347
- const { mergeTags: mergeTags2 } = useEditorProps();
41348
- const [selectionRange, setSelectionRange] = useState(null);
41349
- useEffect(() => {
41350
- const onSelectionChange = () => {
41351
- try {
41352
- const range2 = getShadowRoot().getSelection().getRangeAt(0);
41353
- if (range2) {
41354
- setSelectionRange(range2);
41355
- }
41356
- } catch (error2) {
41357
- }
41358
- };
41359
- document.addEventListener("selectionchange", onSelectionChange);
41360
- return () => {
41361
- document.removeEventListener("selectionchange", onSelectionChange);
41362
- };
41363
- }, []);
41383
+ function useSelectionRange() {
41384
+ const { selectionRange, setSelectionRange } = useContext(SelectionRangeContext);
41364
41385
  const restoreRange = useCallback((range2) => {
41365
41386
  const selection = getShadowRoot().getSelection();
41366
41387
  selection.removeAllRanges();
@@ -41369,6 +41390,16 @@ function Tools(props) {
41369
41390
  newRange.setEnd(range2.endContainer, range2.endOffset);
41370
41391
  selection.addRange(newRange);
41371
41392
  }, []);
41393
+ return {
41394
+ selectionRange,
41395
+ setSelectionRange,
41396
+ restoreRange
41397
+ };
41398
+ }
41399
+ function Tools(props) {
41400
+ const { container: container2 } = props;
41401
+ const { mergeTags: mergeTags2 } = useEditorProps();
41402
+ const { selectionRange, restoreRange } = useSelectionRange();
41372
41403
  const execCommand = (cmd, val) => {
41373
41404
  if (!container2) {
41374
41405
  console.error("No container");