@quadrats/common 0.6.7 → 0.7.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.
Files changed (85) hide show
  1. package/blockquote/createBlockquote.d.ts +1 -1
  2. package/blockquote/createBlockquote.js +33 -33
  3. package/blockquote/index.cjs.js +32 -34
  4. package/bold/createBold.d.ts +2 -1
  5. package/bold/createBold.js +6 -4
  6. package/bold/index.cjs.js +6 -6
  7. package/divider/createDivider.d.ts +1 -1
  8. package/divider/createDivider.js +29 -29
  9. package/divider/index.cjs.js +29 -31
  10. package/embed/createEmbed.js +40 -40
  11. package/embed/deserializeEmbedElementToData.js +6 -6
  12. package/embed/index.cjs.js +54 -56
  13. package/embed/serializeEmbedCode.js +8 -8
  14. package/embed/strategies/facebook/index.cjs.js +45 -47
  15. package/embed/strategies/facebook/index.d.ts +5 -5
  16. package/embed/strategies/facebook/index.js +45 -45
  17. package/embed/strategies/instagram/index.cjs.js +29 -31
  18. package/embed/strategies/instagram/index.d.ts +3 -3
  19. package/embed/strategies/instagram/index.js +29 -29
  20. package/embed/strategies/podcast-apple/index.cjs.js +16 -18
  21. package/embed/strategies/podcast-apple/index.d.ts +4 -4
  22. package/embed/strategies/podcast-apple/index.js +16 -16
  23. package/embed/strategies/spotify/index.cjs.js +14 -16
  24. package/embed/strategies/spotify/index.d.ts +4 -4
  25. package/embed/strategies/spotify/index.js +14 -14
  26. package/embed/strategies/twitter/index.cjs.js +41 -43
  27. package/embed/strategies/twitter/index.d.ts +4 -4
  28. package/embed/strategies/twitter/index.js +41 -41
  29. package/embed/strategies/vimeo/index.cjs.js +14 -16
  30. package/embed/strategies/vimeo/index.d.ts +3 -3
  31. package/embed/strategies/vimeo/index.js +14 -14
  32. package/embed/strategies/youtube/index.cjs.js +14 -16
  33. package/embed/strategies/youtube/index.d.ts +3 -3
  34. package/embed/strategies/youtube/index.js +14 -14
  35. package/embed/typings.d.ts +1 -1
  36. package/file-uploader/_virtual/_tslib.js +3 -1
  37. package/file-uploader/createFileUploader.js +76 -76
  38. package/file-uploader/getFilesFromInput.js +24 -24
  39. package/file-uploader/index.cjs.js +102 -102
  40. package/file-uploader/typings.d.ts +6 -6
  41. package/footnote/createFootnote.d.ts +1 -1
  42. package/footnote/createFootnote.js +65 -65
  43. package/footnote/index.cjs.js +65 -67
  44. package/footnote/typings.d.ts +1 -1
  45. package/heading/constants.js +1 -1
  46. package/heading/createHeading.d.ts +1 -1
  47. package/heading/createHeading.js +45 -45
  48. package/heading/index.cjs.js +46 -48
  49. package/heading/typings.d.ts +1 -1
  50. package/highlight/createHighlight.d.ts +2 -1
  51. package/highlight/createHighlight.js +6 -4
  52. package/highlight/index.cjs.js +6 -6
  53. package/image/constants.js +4 -4
  54. package/image/createImage.js +195 -195
  55. package/image/getImageElementCommonProps.js +6 -6
  56. package/image/getImageFigureElementCommonProps.js +5 -5
  57. package/image/index.cjs.js +211 -213
  58. package/image/isHostingNotRequired.js +2 -2
  59. package/image/typings.d.ts +8 -8
  60. package/input-block/createInputBlock.js +37 -37
  61. package/input-block/index.cjs.js +37 -39
  62. package/input-widget/typings.d.ts +1 -1
  63. package/italic/createItalic.d.ts +2 -1
  64. package/italic/createItalic.js +6 -4
  65. package/italic/index.cjs.js +6 -6
  66. package/link/createLink.js +147 -147
  67. package/link/index.cjs.js +146 -148
  68. package/link/typings.d.ts +2 -2
  69. package/list/constants.js +4 -4
  70. package/list/createList.js +185 -185
  71. package/list/index.cjs.js +188 -190
  72. package/list/typings.d.ts +4 -4
  73. package/package.json +4 -4
  74. package/read-more/createReadMore.d.ts +1 -1
  75. package/read-more/createReadMore.js +51 -51
  76. package/read-more/index.cjs.js +50 -52
  77. package/strikethrough/createStrikethrough.d.ts +2 -1
  78. package/strikethrough/createStrikethrough.js +6 -4
  79. package/strikethrough/index.cjs.js +6 -6
  80. package/toggle-mark/createToggleMarkCreator.d.ts +4 -4
  81. package/toggle-mark/createToggleMarkCreator.js +36 -36
  82. package/toggle-mark/index.cjs.js +36 -38
  83. package/underline/createUnderline.d.ts +2 -1
  84. package/underline/createUnderline.js +6 -4
  85. package/underline/index.cjs.js +6 -6
@@ -1,9 +1,11 @@
1
1
  import { createToggleMarkCreator } from '@quadrats/common/toggle-mark';
2
2
  import { STRIKETHROUGH_TYPE } from './constants.js';
3
3
 
4
- const createStrikethrough = (variant) => createToggleMarkCreator({
5
- type: STRIKETHROUGH_TYPE,
6
- variant,
7
- });
4
+ function createStrikethrough(variant) {
5
+ return createToggleMarkCreator({
6
+ type: STRIKETHROUGH_TYPE,
7
+ variant,
8
+ });
9
+ }
8
10
 
9
11
  export { createStrikethrough };
@@ -1,15 +1,15 @@
1
1
  'use strict';
2
2
 
3
- Object.defineProperty(exports, '__esModule', { value: true });
4
-
5
3
  var toggleMark = require('@quadrats/common/toggle-mark');
6
4
 
7
5
  const STRIKETHROUGH_TYPE = 'strikethrough';
8
6
 
9
- const createStrikethrough = (variant) => toggleMark.createToggleMarkCreator({
10
- type: STRIKETHROUGH_TYPE,
11
- variant,
12
- });
7
+ function createStrikethrough(variant) {
8
+ return toggleMark.createToggleMarkCreator({
9
+ type: STRIKETHROUGH_TYPE,
10
+ variant,
11
+ });
12
+ }
13
13
 
14
14
  exports.STRIKETHROUGH_TYPE = STRIKETHROUGH_TYPE;
15
15
  exports.createStrikethrough = createStrikethrough;
@@ -1,9 +1,9 @@
1
- import { WithMarkType } from '@quadrats/core';
1
+ import { Editor, WithMarkType } from '@quadrats/core';
2
2
  import { ToggleMark } from './typings';
3
- export declare type CreateToggleMarkCreatorOptions = WithMarkType & {
3
+ export type CreateToggleMarkCreatorOptions = WithMarkType & {
4
4
  variant?: string;
5
5
  };
6
- export declare type CreateToggleMarkOptions = Partial<CreateToggleMarkCreatorOptions> & {
6
+ export type CreateToggleMarkOptions = Partial<CreateToggleMarkCreatorOptions> & {
7
7
  variant?: string;
8
8
  };
9
- export declare function createToggleMarkCreator(defaults: CreateToggleMarkCreatorOptions): ({ type, variant }?: CreateToggleMarkOptions) => ToggleMark;
9
+ export declare function createToggleMarkCreator<E extends Editor = Editor>(defaults: CreateToggleMarkCreatorOptions): ({ type, variant }?: CreateToggleMarkOptions) => ToggleMark<E>;
@@ -1,41 +1,41 @@
1
1
  import { getMark } from '@quadrats/core';
2
2
 
3
- function createToggleMarkCreator(defaults) {
4
- return ({ type = defaults.type, variant = defaults.variant } = {}) => {
5
- const isToggleMarkActive = (editor) => {
6
- const mark = getMark(editor, type);
7
- if (mark !== true)
8
- return false;
9
- const nowVariant = getMark(editor, `${type}Variant`) || '';
10
- if (variant) {
11
- return nowVariant === variant;
12
- }
13
- return !nowVariant;
14
- };
15
- const toggleMark = (editor) => {
16
- const isActive = isToggleMarkActive(editor);
17
- if (isActive) {
18
- editor.removeMark(type);
19
- if (variant) {
20
- editor.removeMark(`${type}Variant`);
21
- }
22
- }
23
- else {
24
- editor.addMark(type, true);
25
- if (variant) {
26
- editor.addMark(`${type}Variant`, variant);
27
- }
28
- else {
29
- editor.removeMark(`${type}Variant`);
30
- }
31
- }
32
- };
33
- return {
34
- type,
35
- isToggleMarkActive,
36
- toggleMark,
37
- };
38
- };
3
+ function createToggleMarkCreator(defaults) {
4
+ return ({ type = defaults.type, variant = defaults.variant } = {}) => {
5
+ const isToggleMarkActive = (editor) => {
6
+ const mark = getMark(editor, type);
7
+ if (mark !== true)
8
+ return false;
9
+ const nowVariant = getMark(editor, `${type}Variant`) || '';
10
+ if (variant) {
11
+ return nowVariant === variant;
12
+ }
13
+ return !nowVariant;
14
+ };
15
+ const toggleMark = (editor) => {
16
+ const isActive = isToggleMarkActive(editor);
17
+ if (isActive) {
18
+ editor.removeMark(type);
19
+ if (variant) {
20
+ editor.removeMark(`${type}Variant`);
21
+ }
22
+ }
23
+ else {
24
+ editor.addMark(type, true);
25
+ if (variant) {
26
+ editor.addMark(`${type}Variant`, variant);
27
+ }
28
+ else {
29
+ editor.removeMark(`${type}Variant`);
30
+ }
31
+ }
32
+ };
33
+ return {
34
+ type,
35
+ isToggleMarkActive,
36
+ toggleMark,
37
+ };
38
+ };
39
39
  }
40
40
 
41
41
  export { createToggleMarkCreator };
@@ -1,45 +1,43 @@
1
1
  'use strict';
2
2
 
3
- Object.defineProperty(exports, '__esModule', { value: true });
4
-
5
3
  var core = require('@quadrats/core');
6
4
 
7
- function createToggleMarkCreator(defaults) {
8
- return ({ type = defaults.type, variant = defaults.variant } = {}) => {
9
- const isToggleMarkActive = (editor) => {
10
- const mark = core.getMark(editor, type);
11
- if (mark !== true)
12
- return false;
13
- const nowVariant = core.getMark(editor, `${type}Variant`) || '';
14
- if (variant) {
15
- return nowVariant === variant;
16
- }
17
- return !nowVariant;
18
- };
19
- const toggleMark = (editor) => {
20
- const isActive = isToggleMarkActive(editor);
21
- if (isActive) {
22
- editor.removeMark(type);
23
- if (variant) {
24
- editor.removeMark(`${type}Variant`);
25
- }
26
- }
27
- else {
28
- editor.addMark(type, true);
29
- if (variant) {
30
- editor.addMark(`${type}Variant`, variant);
31
- }
32
- else {
33
- editor.removeMark(`${type}Variant`);
34
- }
35
- }
36
- };
37
- return {
38
- type,
39
- isToggleMarkActive,
40
- toggleMark,
41
- };
42
- };
5
+ function createToggleMarkCreator(defaults) {
6
+ return ({ type = defaults.type, variant = defaults.variant } = {}) => {
7
+ const isToggleMarkActive = (editor) => {
8
+ const mark = core.getMark(editor, type);
9
+ if (mark !== true)
10
+ return false;
11
+ const nowVariant = core.getMark(editor, `${type}Variant`) || '';
12
+ if (variant) {
13
+ return nowVariant === variant;
14
+ }
15
+ return !nowVariant;
16
+ };
17
+ const toggleMark = (editor) => {
18
+ const isActive = isToggleMarkActive(editor);
19
+ if (isActive) {
20
+ editor.removeMark(type);
21
+ if (variant) {
22
+ editor.removeMark(`${type}Variant`);
23
+ }
24
+ }
25
+ else {
26
+ editor.addMark(type, true);
27
+ if (variant) {
28
+ editor.addMark(`${type}Variant`, variant);
29
+ }
30
+ else {
31
+ editor.removeMark(`${type}Variant`);
32
+ }
33
+ }
34
+ };
35
+ return {
36
+ type,
37
+ isToggleMarkActive,
38
+ toggleMark,
39
+ };
40
+ };
43
41
  }
44
42
 
45
43
  exports.createToggleMarkCreator = createToggleMarkCreator;
@@ -1 +1,2 @@
1
- export declare const createUnderline: (variant?: string | undefined) => ({ type, variant }?: import("@quadrats/common/toggle-mark").CreateToggleMarkOptions | undefined) => import("@quadrats/common/toggle-mark").ToggleMark<import("slate").BaseEditor>;
1
+ import { Editor } from '@quadrats/core';
2
+ export declare function createUnderline<E extends Editor = Editor>(variant?: string): ({ type, variant }?: import("@quadrats/common/toggle-mark").CreateToggleMarkOptions | undefined) => import("@quadrats/common/toggle-mark").ToggleMark<E>;
@@ -1,9 +1,11 @@
1
1
  import { createToggleMarkCreator } from '@quadrats/common/toggle-mark';
2
2
  import { UNDERLINE_TYPE } from './constants.js';
3
3
 
4
- const createUnderline = (variant) => createToggleMarkCreator({
5
- type: UNDERLINE_TYPE,
6
- variant,
7
- });
4
+ function createUnderline(variant) {
5
+ return createToggleMarkCreator({
6
+ type: UNDERLINE_TYPE,
7
+ variant,
8
+ });
9
+ }
8
10
 
9
11
  export { createUnderline };
@@ -1,15 +1,15 @@
1
1
  'use strict';
2
2
 
3
- Object.defineProperty(exports, '__esModule', { value: true });
4
-
5
3
  var toggleMark = require('@quadrats/common/toggle-mark');
6
4
 
7
5
  const UNDERLINE_TYPE = 'underline';
8
6
 
9
- const createUnderline = (variant) => toggleMark.createToggleMarkCreator({
10
- type: UNDERLINE_TYPE,
11
- variant,
12
- });
7
+ function createUnderline(variant) {
8
+ return toggleMark.createToggleMarkCreator({
9
+ type: UNDERLINE_TYPE,
10
+ variant,
11
+ });
12
+ }
13
13
 
14
14
  exports.UNDERLINE_TYPE = UNDERLINE_TYPE;
15
15
  exports.createUnderline = createUnderline;