@knime/kds-rich-text-editor 1.3.1 → 2.0.1

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/CHANGELOG.md CHANGED
@@ -1,5 +1,30 @@
1
1
  # @knime/kds-rich-text-editor
2
2
 
3
+ ## 2.0.1
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated dependencies [d8bb77a]
8
+ - @knime/kds-styles@2.0.1
9
+ - @knime/kds-components@2.0.1
10
+
11
+ ## 2.0.0
12
+
13
+ ### Patch Changes
14
+
15
+ - Updated dependencies [b698be1]
16
+ - Updated dependencies [7d7918f]
17
+ - Updated dependencies [d6af8e5]
18
+ - Updated dependencies [d6af8e5]
19
+ - Updated dependencies [d6af8e5]
20
+ - Updated dependencies [c2d135a]
21
+ - Updated dependencies [2779db1]
22
+ - Updated dependencies [e774645]
23
+ - Updated dependencies [c2d135a]
24
+ - @knime/kds-styles@2.0.0
25
+ - @knime/kds-components@2.0.0
26
+ - @knime/utils@1.12.0
27
+
3
28
  ## 1.3.1
4
29
 
5
30
  ### Patch Changes
package/dist/index.css CHANGED
@@ -19,7 +19,7 @@
19
19
  gap: var(--kds-spacing-container-0-5x);
20
20
  }
21
21
 
22
- .tools[data-v-0163d303] {
22
+ .tools[data-v-b3a757e3] {
23
23
  display: flex;
24
24
  gap: var(--kds-spacing-container-0-25x);
25
25
  align-items: center;
@@ -27,7 +27,7 @@
27
27
  }
28
28
 
29
29
  .editor-wrapper {
30
- &[data-v-7342ae63] {
30
+ &[data-v-2bc5f7d4] {
31
31
  /* Fixed 44px toolbar height per the design (28px content + 8px padding on
32
32
  * each side); the small toolbar buttons (24px) center within the content
33
33
  * area. */
@@ -39,16 +39,16 @@
39
39
  position: relative;
40
40
  isolation: isolate;
41
41
  }
42
- &.disabled[data-v-7342ae63] {
42
+ &.disabled[data-v-2bc5f7d4] {
43
43
  color: var(--kds-color-text-and-icon-disabled);
44
44
  }
45
45
  }
46
46
 
47
47
  /* stylelint-disable selector-class-pattern */
48
48
  .rich-text-editor {
49
- &[data-v-7342ae63] {
49
+ &[data-v-2bc5f7d4] {
50
50
  height: 100%;
51
- max-height: var(--v688daf92);
51
+ max-height: var(--b5683582);
52
52
  padding: var(--kds-spacing-container-0-5x);
53
53
  overflow-y: auto;
54
54
 
@@ -56,15 +56,15 @@
56
56
  /* stylelint-enable selector-class-pattern */
57
57
  }
58
58
  &.editable {
59
- &[data-v-7342ae63] {
59
+ &[data-v-2bc5f7d4] {
60
60
  cursor: text;
61
61
  background: var(--kds-color-background-input-initial);
62
62
  }
63
- &[data-v-7342ae63] .ProseMirror {
64
- min-height: var(--v1a3e32ee);
63
+ &[data-v-2bc5f7d4] .ProseMirror {
64
+ min-height: var(--v6718b8de);
65
65
  }
66
66
  }
67
- &[data-v-7342ae63] .ProseMirror {
67
+ &[data-v-2bc5f7d4] .ProseMirror {
68
68
  height: 100%;
69
69
  font: var(--kds-font-base-body-small);
70
70
 
@@ -175,7 +175,7 @@ a {
175
175
  margin-left: var(--kds-spacing-container-0-12x);
176
176
  content: "";
177
177
  background-color: var(--link-color);
178
- mask-image: var(--v7ae662d6);
178
+ mask-image: var(--v6389a4c6);
179
179
  mask-repeat: no-repeat;
180
180
  mask-size: contain;
181
181
  }
@@ -224,34 +224,34 @@ td {
224
224
  }
225
225
  }
226
226
  }
227
- &[data-v-7342ae63] .ProseMirror:focus-visible,
228
- &[data-v-7342ae63] .ProseMirror:focus {
227
+ &[data-v-2bc5f7d4] .ProseMirror:focus-visible,
228
+ &[data-v-2bc5f7d4] .ProseMirror:focus {
229
229
  outline: transparent;
230
230
  }
231
231
  }
232
232
  .editor-wrapper.with-border {
233
- &[data-v-7342ae63] {
233
+ &[data-v-2bc5f7d4] {
234
234
  border: var(--kds-border-action-input);
235
235
  border-radius: var(--kds-border-radius-container-0-37x);
236
236
  }
237
- &.disabled[data-v-7342ae63] {
237
+ &.disabled[data-v-2bc5f7d4] {
238
238
  border: var(--kds-border-action-disabled);
239
239
  }
240
- & .toolbar-wrapper[data-v-7342ae63] {
240
+ & .toolbar-wrapper[data-v-2bc5f7d4] {
241
241
  border-top-left-radius: var(--kds-border-radius-container-0-37x);
242
242
  border-top-right-radius: var(--kds-border-radius-container-0-37x);
243
243
  }
244
- & .rich-text-editor[data-v-7342ae63] {
244
+ & .rich-text-editor[data-v-2bc5f7d4] {
245
245
  border-bottom-right-radius: var(--kds-border-radius-container-0-37x);
246
246
  border-bottom-left-radius: var(--kds-border-radius-container-0-37x);
247
247
  }
248
248
  }
249
- .editor-wrapper.show-focus-ring[data-v-7342ae63] {
249
+ .editor-wrapper.show-focus-ring[data-v-2bc5f7d4] {
250
250
  outline: var(--kds-border-action-focused);
251
251
  outline-offset: var(--kds-spacing-offset-focus);
252
252
  }
253
253
  .embedded-toolbar {
254
- &[data-v-7342ae63] {
254
+ &[data-v-2bc5f7d4] {
255
255
  height: var(--toolbar-height);
256
256
  padding: var(--kds-spacing-container-0-5x);
257
257
  overflow-x: auto;
@@ -262,7 +262,7 @@ td {
262
262
  border-bottom: var(--kds-border-base-muted);
263
263
  -ms-overflow-style: none; /* needed to hide scroll bar in edge */
264
264
  }
265
- &[data-v-7342ae63]::-webkit-scrollbar {
265
+ &[data-v-2bc5f7d4]::-webkit-scrollbar {
266
266
  display: none;
267
267
  }
268
268
  }
package/dist/index.js CHANGED
@@ -2323,15 +2323,6 @@ const modeDefinitions = [
2323
2323
  }
2324
2324
  ];
2325
2325
  Object.assign({}, ...modeDefinitions.map((obj) => ({ [obj.id]: obj })));
2326
-
2327
- const isMac = () => navigator?.userAgent?.toLowerCase()?.includes("mac");
2328
- const isWindows = () => navigator?.userAgent?.toLowerCase()?.includes("windows");
2329
-
2330
- const navigator$1 = /*#__PURE__*/Object.freeze(/*#__PURE__*/Object.defineProperty({
2331
- __proto__: null,
2332
- isMac,
2333
- isWindows
2334
- }, Symbol.toStringTag, { value: 'Module' }));
2335
2326
  const yearsPart = "(\\d+)\\s*y(?:ears?)?";
2336
2327
  const monthsPart = "(\\d+)\\s*m(?:o(?:nths?)?)?";
2337
2328
  const weeksPart = "(\\d+)\\s*w(?:eeks?)?";
@@ -2355,10 +2346,60 @@ new RegExp(
2355
2346
  `^\\s*-\\s*\\(\\s*${humanReadableDurationRegex.source.replace(/[$^]/g, "")}\\s*\\)\\s*$`,
2356
2347
  "i"
2357
2348
  );
2349
+
2350
+ const hotkeyPlatform = {
2351
+ MAC_OS: "macOS"};
2352
+
2353
+ const isMac = () => navigator?.userAgent?.toLowerCase()?.includes("mac");
2354
+ const isWindows = () => navigator?.userAgent?.toLowerCase()?.includes("windows");
2355
+
2356
+ const navigator$1 = /*#__PURE__*/Object.freeze(/*#__PURE__*/Object.defineProperty({
2357
+ __proto__: null,
2358
+ isMac,
2359
+ isWindows
2360
+ }, Symbol.toStringTag, { value: 'Module' }));
2361
+
2362
+ const globalKeyMap = {
2363
+ ArrowUp: "↑",
2364
+ ArrowDown: "↓",
2365
+ ArrowLeft: "←",
2366
+ ArrowRight: "→",
2367
+ Enter: "↵",
2368
+ " ": "Space",
2369
+ // we use event.key and there space is an actual space not the code "Space"
2370
+ CtrlOrCmd: "Ctrl"
2371
+ };
2372
+ const MacOSkeyMap = {
2373
+ Shift: "⇧",
2374
+ Delete: "⌫",
2375
+ CtrlOrCmd: "⌘",
2376
+ Ctrl: "⌃",
2377
+ Alt: "⌥",
2378
+ Enter: "↩"
2379
+ };
2380
+ const formatHotkey = (hotkey, platform) => {
2381
+ const mapSymbols = (formatMap) => (key) => formatMap[key] ?? key;
2382
+ const pipe = (...fns) => fns.reduce(
2383
+ (f, g) => (arg) => g(f(arg)),
2384
+ (arg) => arg
2385
+ );
2386
+ const macKeyFormatter = pipe(
2387
+ mapSymbols(MacOSkeyMap),
2388
+ mapSymbols(globalKeyMap)
2389
+ );
2390
+ const generalKeyFormatter = mapSymbols(globalKeyMap);
2391
+ const useMacFormatter = platform === void 0 ? isMac() : platform === hotkeyPlatform.MAC_OS;
2392
+ return useMacFormatter ? macKeyFormatter(hotkey) : generalKeyFormatter(hotkey);
2393
+ };
2394
+ const getDefaultSeparator = () => isMac() ? " " : "+";
2395
+ const formatHotkeys = (hotkeys, getSeparator = getDefaultSeparator) => hotkeys.map((hotkey) => formatHotkey(hotkey)).join(getSeparator());
2358
2396
  const getMetaOrCtrlKey = () => {
2359
2397
  return isMac() ? "metaKey" : "ctrlKey";
2360
2398
  };
2361
2399
 
2400
+ const hotkeys = {
2401
+ formatHotkeys};
2402
+
2362
2403
  const ExternalLinkIconUrl = "data:image/svg+xml,%3csvg%20xmlns='http://www.w3.org/2000/svg'%20fill='none'%20stroke='currentColor'%20stroke-linecap='round'%20stroke-linejoin='round'%20viewBox='0%200%2012%2012'%3e%3cpath%20d='M5.5%201.5h-3a1%201%200%200%200-1%201v7a1%201%200%200%200%201%201h7a1%201%200%200%200%201-1v-3m0-5L6%205.892M10.5%201.5v2.75m0-2.75H7.75'%20vector-effect='non-scaling-stroke'/%3e%3c/svg%3e";
2363
2404
 
2364
2405
  const kdsCharacterCountDisplay = {
@@ -2505,7 +2546,7 @@ const clearHeading = (editor) => {
2505
2546
  const getHeadingOptionChild = (level, getEditor) => ({
2506
2547
  id: `${level}`,
2507
2548
  text: `Heading ${level}`,
2508
- hotkey: ["Ctrl", "Alt", `${level}`],
2549
+ hotkey: ["CtrlOrCmd", "Alt", `${level}`],
2509
2550
  active: () => getEditor().isActive("heading", { level }),
2510
2551
  handler: () => {
2511
2552
  const editor = getEditor();
@@ -2522,7 +2563,7 @@ const getParagraphTextStyleTool = (getEditor) => {
2522
2563
  {
2523
2564
  id: "standard",
2524
2565
  text: "Standard",
2525
- hotkey: ["Ctrl", "Alt", "0"],
2566
+ hotkey: ["CtrlOrCmd", "Alt", "0"],
2526
2567
  handler: () => {
2527
2568
  const editor = getEditor();
2528
2569
  clearHeading(editor);
@@ -2532,7 +2573,7 @@ const getParagraphTextStyleTool = (getEditor) => {
2532
2573
  {
2533
2574
  id: "small",
2534
2575
  text: "Small text",
2535
- hotkey: ["Ctrl", "Alt", "−"],
2576
+ hotkey: ["CtrlOrCmd", "Alt", "−"],
2536
2577
  // this is a wider minus character for aesthetic reasons
2537
2578
  active: () => getEditor().isActive({ smallText: true }),
2538
2579
  handler: () => {
@@ -2694,7 +2735,7 @@ const _sfc_main$3 = /* @__PURE__ */ defineComponent({
2694
2735
  id: "bold",
2695
2736
  type: "primary",
2696
2737
  text: "Bold",
2697
- hotkey: ["Ctrl", "B"],
2738
+ hotkey: ["CtrlOrCmd", "B"],
2698
2739
  icon: "bold",
2699
2740
  active: () => props.editor.isActive("bold"),
2700
2741
  handler: () => props.editor.chain().focus().toggleBold().run()
@@ -2704,7 +2745,7 @@ const _sfc_main$3 = /* @__PURE__ */ defineComponent({
2704
2745
  type: "primary",
2705
2746
  text: "Italic",
2706
2747
  icon: "italic",
2707
- hotkey: ["Ctrl", "I"],
2748
+ hotkey: ["CtrlOrCmd", "I"],
2708
2749
  active: () => props.editor.isActive("italic"),
2709
2750
  handler: () => props.editor.chain().focus().toggleItalic().run()
2710
2751
  }),
@@ -2713,7 +2754,7 @@ const _sfc_main$3 = /* @__PURE__ */ defineComponent({
2713
2754
  type: "primary",
2714
2755
  text: "Underline",
2715
2756
  icon: "underline",
2716
- hotkey: ["Ctrl", "U"],
2757
+ hotkey: ["CtrlOrCmd", "U"],
2717
2758
  active: () => props.editor.isActive("underline"),
2718
2759
  handler: () => props.editor.chain().focus().toggleUnderline().run()
2719
2760
  }),
@@ -2722,7 +2763,7 @@ const _sfc_main$3 = /* @__PURE__ */ defineComponent({
2722
2763
  type: "primary",
2723
2764
  text: "Bullet list",
2724
2765
  icon: "list-bulletpoint",
2725
- hotkey: ["Ctrl", "Shift", "8"],
2766
+ hotkey: ["CtrlOrCmd", "Shift", "8"],
2726
2767
  active: () => props.editor.isActive("bulletList"),
2727
2768
  handler: () => {
2728
2769
  const commandChain = props.editor.chain().focus();
@@ -2737,7 +2778,7 @@ const _sfc_main$3 = /* @__PURE__ */ defineComponent({
2737
2778
  type: "primary",
2738
2779
  text: "Ordered list",
2739
2780
  icon: "list-number",
2740
- hotkey: ["Ctrl", "Shift", "7"],
2781
+ hotkey: ["CtrlOrCmd", "Shift", "7"],
2741
2782
  active: () => props.editor.isActive("orderedList"),
2742
2783
  handler: () => {
2743
2784
  const commandChain = props.editor.chain().focus();
@@ -2752,7 +2793,7 @@ const _sfc_main$3 = /* @__PURE__ */ defineComponent({
2752
2793
  type: "primary",
2753
2794
  icon: "left-aligned",
2754
2795
  text: "Align left",
2755
- hotkey: ["Ctrl", "Shift", "L"],
2796
+ hotkey: ["CtrlOrCmd", "Shift", "L"],
2756
2797
  active: () => !isListActive() && props.editor.isActive({ textAlign: "left" }),
2757
2798
  handler: () => props.editor.chain().focus().setTextAlign("left").run(),
2758
2799
  disabled: () => isListActive()
@@ -2762,7 +2803,7 @@ const _sfc_main$3 = /* @__PURE__ */ defineComponent({
2762
2803
  type: "primary",
2763
2804
  icon: "center-aligned",
2764
2805
  text: "Align center",
2765
- hotkey: ["Ctrl", "Shift", "E"],
2806
+ hotkey: ["CtrlOrCmd", "Shift", "E"],
2766
2807
  active: () => !isListActive() && props.editor.isActive({ textAlign: "center" }),
2767
2808
  handler: () => props.editor.chain().focus().setTextAlign("center").run(),
2768
2809
  disabled: () => isListActive()
@@ -2772,7 +2813,7 @@ const _sfc_main$3 = /* @__PURE__ */ defineComponent({
2772
2813
  type: "primary",
2773
2814
  icon: "right-aligned",
2774
2815
  text: "Align right",
2775
- hotkey: ["Ctrl", "Shift", "R"],
2816
+ hotkey: ["CtrlOrCmd", "Shift", "R"],
2776
2817
  active: () => !isListActive() && props.editor.isActive({ textAlign: "right" }),
2777
2818
  handler: () => props.editor.chain().focus().setTextAlign("right").run(),
2778
2819
  disabled: () => isListActive()
@@ -2782,7 +2823,7 @@ const _sfc_main$3 = /* @__PURE__ */ defineComponent({
2782
2823
  type: "primary",
2783
2824
  icon: "link",
2784
2825
  text: "Link",
2785
- hotkey: ["Ctrl", "K"],
2826
+ hotkey: ["CtrlOrCmd", "K"],
2786
2827
  active: () => props.editor.isActive("link"),
2787
2828
  handler: () => linkTool?.onLinkToolClick()
2788
2829
  }),
@@ -2803,7 +2844,7 @@ const _sfc_main$3 = /* @__PURE__ */ defineComponent({
2803
2844
  type: "secondary",
2804
2845
  icon: "code-block",
2805
2846
  text: "Code block",
2806
- hotkey: ["Ctrl", "Alt", "C"],
2847
+ hotkey: ["CtrlOrCmd", "Alt", "C"],
2807
2848
  active: () => props.editor.isActive("codeBlock"),
2808
2849
  handler: () => props.editor.chain().focus().toggleCodeBlock().run()
2809
2850
  }),
@@ -2812,7 +2853,7 @@ const _sfc_main$3 = /* @__PURE__ */ defineComponent({
2812
2853
  type: "secondary",
2813
2854
  icon: "strikethrough",
2814
2855
  text: "Strikethrough",
2815
- hotkey: ["Ctrl", "Shift", "X"],
2856
+ hotkey: ["CtrlOrCmd", "Shift", "X"],
2816
2857
  active: () => props.editor.isActive("strike"),
2817
2858
  handler: () => props.editor.chain().focus().toggleStrike().run()
2818
2859
  }),
@@ -2860,7 +2901,7 @@ const _sfc_main$2 = /* @__PURE__ */ defineComponent({
2860
2901
  id: tool.id,
2861
2902
  text: tool.text,
2862
2903
  disabled: tool.disabled?.(),
2863
- shortcut: props.hotkeyFormatter(tool.hotkey ?? []),
2904
+ shortcut: tool.hotkey ?? [],
2864
2905
  accessory: {
2865
2906
  type: "icon",
2866
2907
  name: tool.icon
@@ -2873,7 +2914,7 @@ const _sfc_main$2 = /* @__PURE__ */ defineComponent({
2873
2914
  return {
2874
2915
  id: toolChild.id,
2875
2916
  text: toolChild.text,
2876
- shortcut: props.hotkeyFormatter(toolChild.hotkey ?? []),
2917
+ shortcut: toolChild.hotkey ?? [],
2877
2918
  handler: () => toolChild.handler(toolChild.id)
2878
2919
  };
2879
2920
  })
@@ -2917,7 +2958,7 @@ const _sfc_main$2 = /* @__PURE__ */ defineComponent({
2917
2958
  }
2918
2959
  });
2919
2960
 
2920
- const RichTextEditorToolbar = /* @__PURE__ */ _export_sfc(_sfc_main$2, [["__scopeId", "data-v-0163d303"]]);
2961
+ const RichTextEditorToolbar = /* @__PURE__ */ _export_sfc(_sfc_main$2, [["__scopeId", "data-v-b3a757e3"]]);
2921
2962
 
2922
2963
  const CustomEscape = Extension.create({
2923
2964
  name: "OverrideEscape",
@@ -3053,16 +3094,7 @@ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
3053
3094
  minHeight: { default: null },
3054
3095
  maxHeight: { default: null },
3055
3096
  baseExtensions: { default: () => ({}) },
3056
- hotkeyFormatter: { type: Function, default: (hotkey) => {
3057
- const MacOSkeyMap = {
3058
- Shift: "⇧",
3059
- Ctrl: "⌘",
3060
- Alt: "⌥"
3061
- };
3062
- const mapSymbols = (key) => MacOSkeyMap[key] || key;
3063
- const identityFn = (value) => value;
3064
- return hotkey.map(navigator$1.isMac() ? mapSymbols : identityFn).join(" ");
3065
- } },
3097
+ hotkeyFormatter: { type: Function, default: hotkeys.formatHotkeys },
3066
3098
  customExtensions: { default: () => [] },
3067
3099
  autofocus: { type: Boolean, default: false },
3068
3100
  withBorder: { type: Boolean, default: true },
@@ -3084,9 +3116,9 @@ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
3084
3116
  emits: /* @__PURE__ */ mergeModels(["blur"], ["update:modelValue"]),
3085
3117
  setup(__props, { expose: __expose, emit: __emit }) {
3086
3118
  useCssVars((_ctx) => ({
3087
- "v688daf92": maxHeightStyle.value,
3088
- "v1a3e32ee": minHeightStyle.value,
3089
- "v7ae662d6": externalIcon
3119
+ "b5683582": maxHeightStyle.value,
3120
+ "v6718b8de": minHeightStyle.value,
3121
+ "v6389a4c6": externalIcon
3090
3122
  }));
3091
3123
  const hardCharacterLimit = Math.max(
3092
3124
  __props.characterLimit.maxCharacters ?? 1e3,
@@ -3295,7 +3327,7 @@ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
3295
3327
  }
3296
3328
  });
3297
3329
 
3298
- const KdsRichTextEditor = /* @__PURE__ */ _export_sfc(_sfc_main$1, [["__scopeId", "data-v-7342ae63"]]);
3330
+ const KdsRichTextEditor = /* @__PURE__ */ _export_sfc(_sfc_main$1, [["__scopeId", "data-v-2bc5f7d4"]]);
3299
3331
 
3300
3332
  const _sfc_main = /* @__PURE__ */ defineComponent({
3301
3333
  __name: "KdsRichTextInput",