@makeswift/runtime 0.28.8-canary.6 → 0.28.8-canary.8
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/dist/cjs/api/graphql-api-client.js +1 -1
- package/dist/cjs/api/rest-api-client.js +1 -1
- package/dist/cjs/api-handler/handlers/manifest.js +1 -1
- package/dist/cjs/client/index.js +1 -1
- package/dist/cjs/components/builtin/Embed/Embed.js +2 -1
- package/dist/cjs/components/builtin/Embed/Embed.js.map +1 -1
- package/dist/cjs/runtimes/react/controls/rich-text/EditableText/useSyncWithBuilder.js +4 -2
- package/dist/cjs/runtimes/react/controls/rich-text/EditableText/useSyncWithBuilder.js.map +1 -1
- package/dist/cjs/slate/TypographyPlugin/normalizeTypographyUp.js.map +1 -1
- package/dist/cjs/slate/selectors.js.map +1 -1
- package/dist/cjs/utils/intersection.js.map +1 -1
- package/dist/esm/api/graphql-api-client.js +1 -1
- package/dist/esm/api/rest-api-client.js +1 -1
- package/dist/esm/api-handler/handlers/manifest.js +1 -1
- package/dist/esm/client/index.js +1 -1
- package/dist/esm/components/builtin/Embed/Embed.js +3 -2
- package/dist/esm/components/builtin/Embed/Embed.js.map +1 -1
- package/dist/esm/runtimes/react/controls/rich-text/EditableText/useSyncDOMSelection.js.map +0 -1
- package/dist/esm/runtimes/react/controls/rich-text/EditableText/useSyncWithBuilder.js +4 -2
- package/dist/esm/runtimes/react/controls/rich-text/EditableText/useSyncWithBuilder.js.map +0 -1
- package/dist/esm/runtimes/react/controls/rich-text-v2/EditableTextV2/usePresetValue.js.map +0 -1
- package/dist/esm/runtimes/react/controls/rich-text-v2/EditableTextV2/useRemoteChanges.js.map +0 -1
- package/dist/esm/runtimes/react/controls/rich-text-v2/EditableTextV2/useSyncDOMSelection.js.map +0 -1
- package/dist/esm/slate/TypographyPlugin/normalizeTypographyUp.js.map +1 -1
- package/dist/esm/slate/selectors.js.map +1 -1
- package/dist/esm/utils/intersection.js.map +1 -1
- package/dist/types/components/builtin/Embed/Embed.d.ts.map +1 -1
- package/dist/types/runtimes/react/controls/rich-text/EditableText/useSyncWithBuilder.d.ts.map +1 -1
- package/dist/types/slate/selectors.d.ts +2 -2
- package/dist/types/slate/selectors.d.ts.map +1 -1
- package/dist/types/utils/intersection.d.ts +2 -1
- package/dist/types/utils/intersection.d.ts.map +1 -1
- package/package.json +3 -3
- package/dist/cjs/utils/is.js +0 -26
- package/dist/cjs/utils/is.js.map +0 -1
- package/dist/esm/utils/is.js +0 -6
- package/dist/esm/utils/is.js.map +0 -1
- package/dist/types/utils/is.d.ts +0 -3
- package/dist/types/utils/is.d.ts.map +0 -1
|
@@ -27,7 +27,7 @@ class MakeswiftGraphQLApiClient {
|
|
|
27
27
|
graphqlClient;
|
|
28
28
|
constructor({ endpoint }) {
|
|
29
29
|
this.graphqlClient = new import_client.GraphQLClient(endpoint, {
|
|
30
|
-
"makeswift-runtime-version": "0.28.8-canary.
|
|
30
|
+
"makeswift-runtime-version": "0.28.8-canary.8"
|
|
31
31
|
});
|
|
32
32
|
}
|
|
33
33
|
async createTableRecord(tableId, columns) {
|
|
@@ -147,7 +147,7 @@ class MakeswiftRestAPIClient {
|
|
|
147
147
|
const requestHeaders = new Headers({
|
|
148
148
|
"x-api-key": this.apiKey,
|
|
149
149
|
"makeswift-site-api-key": this.apiKey,
|
|
150
|
-
"makeswift-runtime-version": "0.28.8-canary.
|
|
150
|
+
"makeswift-runtime-version": "0.28.8-canary.8"
|
|
151
151
|
});
|
|
152
152
|
if (siteVersion?.token) {
|
|
153
153
|
requestUrl.searchParams.set("version", siteVersion.version);
|
|
@@ -28,7 +28,7 @@ async function manifestHandler(req, { apiKey, manifest }) {
|
|
|
28
28
|
return import_request_response.ApiResponse.json({ message: "Unauthorized" }, { status: 401 });
|
|
29
29
|
}
|
|
30
30
|
return import_request_response.ApiResponse.json({
|
|
31
|
-
version: "0.28.8-canary.
|
|
31
|
+
version: "0.28.8-canary.8",
|
|
32
32
|
interactionMode: true,
|
|
33
33
|
clientSideNavigation: false,
|
|
34
34
|
elementFromPoint: false,
|
package/dist/cjs/client/index.js
CHANGED
|
@@ -689,7 +689,7 @@ Received "${apiKey}" instead.`
|
|
|
689
689
|
headers: {
|
|
690
690
|
"x-api-key": this.apiKey,
|
|
691
691
|
"makeswift-site-api-key": this.apiKey,
|
|
692
|
-
"makeswift-runtime-version": "0.28.8-canary.
|
|
692
|
+
"makeswift-runtime-version": "0.28.8-canary.8",
|
|
693
693
|
"content-type": "application/json"
|
|
694
694
|
},
|
|
695
695
|
body: JSON.stringify({ token }),
|
|
@@ -94,6 +94,7 @@ const Embed = (0, import_react.forwardRef)(function Embed2({ id, width, margin,
|
|
|
94
94
|
});
|
|
95
95
|
}, [container, html]);
|
|
96
96
|
const className = (0, import_use_style.useStyle)({ minHeight: 15 });
|
|
97
|
+
const dangerouslySetInnerHTML = (0, import_react.useMemo)(() => ({ __html: html }), [html]);
|
|
97
98
|
if (shouldRender === false)
|
|
98
99
|
return null;
|
|
99
100
|
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
@@ -102,7 +103,7 @@ const Embed = (0, import_react.forwardRef)(function Embed2({ id, width, margin,
|
|
|
102
103
|
ref: setContainer,
|
|
103
104
|
id,
|
|
104
105
|
className: (0, import_css.cx)(className, width, margin),
|
|
105
|
-
dangerouslySetInnerHTML
|
|
106
|
+
dangerouslySetInnerHTML
|
|
106
107
|
}
|
|
107
108
|
);
|
|
108
109
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../src/components/builtin/Embed/Embed.tsx"],"sourcesContent":["'use client'\n\n/* eslint-env browser */\n\nimport { useState, useEffect, forwardRef, Ref, useImperativeHandle } from 'react'\n\nimport { useIsomorphicLayoutEffect } from '../../hooks/useIsomorphicLayoutEffect'\nimport { useStyle } from '../../../runtimes/react/use-style'\nimport { cx } from '@emotion/css'\n\ntype Props = {\n id?: string\n html?: string\n width?: string\n margin?: string\n}\n\nconst defaultHtml = `<div style=\"padding: 24px; background-color: rgba(161, 168, 194, 0.18); overflow: hidden;\">\n<svg width=\"316\" height=\"168\" viewBox=\"0 0 316 168\" fill=\"none\" xmlns=\"http://www.w3.org/2000/svg\">\n<rect width=\"70\" height=\"8\" rx=\"2\" fill=\"#A1A8C2\" fill-opacity=\"0.5\"/>\n<rect x=\"78\" width=\"30\" height=\"8\" rx=\"2\" fill=\"#A1A8C2\" fill-opacity=\"0.25\"/>\n<rect x=\"116\" width=\"78\" height=\"8\" rx=\"2\" fill=\"#A1A8C2\" fill-opacity=\"0.25\"/>\n<rect y=\"20\" width=\"120\" height=\"8\" rx=\"2\" fill=\"#A1A8C2\" fill-opacity=\"0.5\"/>\n<rect x=\"128\" y=\"20\" width=\"30\" height=\"8\" rx=\"2\" fill=\"#A1A8C2\" fill-opacity=\"0.25\"/>\n<rect x=\"166\" y=\"20\" width=\"78\" height=\"8\" rx=\"2\" fill=\"#A1A8C2\" fill-opacity=\"0.25\"/>\n<rect y=\"60\" width=\"40\" height=\"8\" rx=\"2\" fill=\"#A1A8C2\" fill-opacity=\"0.5\"/>\n<rect x=\"20\" y=\"80\" width=\"40\" height=\"8\" rx=\"2\" fill=\"#A1A8C2\" fill-opacity=\"0.5\"/>\n<rect x=\"40\" y=\"100\" width=\"40\" height=\"8\" rx=\"2\" fill=\"#A1A8C2\" fill-opacity=\"0.5\"/>\n<rect x=\"88\" y=\"100\" width=\"110\" height=\"8\" rx=\"2\" fill=\"#A1A8C2\" fill-opacity=\"0.25\"/>\n<rect x=\"206\" y=\"100\" width=\"24\" height=\"8\" rx=\"2\" fill=\"#A1A8C2\" fill-opacity=\"0.25\"/>\n<rect x=\"238\" y=\"100\" width=\"40\" height=\"8\" rx=\"2\" fill=\"#A1A8C2\" fill-opacity=\"0.5\"/>\n<rect x=\"40\" y=\"120\" width=\"40\" height=\"8\" rx=\"2\" fill=\"#A1A8C2\" fill-opacity=\"0.5\"/>\n<rect x=\"88\" y=\"120\" width=\"50\" height=\"8\" rx=\"2\" fill=\"#A1A8C2\" fill-opacity=\"0.25\"/>\n<rect x=\"146\" y=\"120\" width=\"24\" height=\"8\" rx=\"2\" fill=\"#A1A8C2\" fill-opacity=\"0.25\"/>\n<rect x=\"178\" y=\"120\" width=\"90\" height=\"8\" rx=\"2\" fill=\"#A1A8C2\" fill-opacity=\"0.25\"/>\n<rect x=\"276\" y=\"120\" width=\"40\" height=\"8\" rx=\"2\" fill=\"#A1A8C2\" fill-opacity=\"0.5\"/>\n<rect x=\"20\" y=\"140\" width=\"40\" height=\"8\" rx=\"2\" fill=\"#A1A8C2\" fill-opacity=\"0.5\"/>\n<rect y=\"160\" width=\"40\" height=\"8\" rx=\"2\" fill=\"#A1A8C2\" fill-opacity=\"0.5\"/>\n</svg>\n</div>`\nconst SCRIPT_TAG = 'script'\n\nconst Embed = forwardRef(function Embed(\n { id, width, margin, html = defaultHtml }: Props,\n ref: Ref<HTMLDivElement | null>,\n) {\n const [container, setContainer] = useState<HTMLDivElement | null>(null)\n const [shouldRender, setShouldRender] = useState(false)\n\n useIsomorphicLayoutEffect(() => {\n setShouldRender(true)\n }, [])\n\n useImperativeHandle<HTMLDivElement | null, HTMLDivElement | null>(ref, () => container, [\n container,\n ])\n\n useEffect(() => {\n // TODO: When we SSR the editor, we can remove the editor check\n // and not run this effect on the first render.\n if (!container) return\n\n const walker = container.ownerDocument.createTreeWalker(container, NodeFilter.SHOW_ELEMENT, {\n acceptNode(node: Element) {\n return node.tagName.toLowerCase() === SCRIPT_TAG\n ? NodeFilter.FILTER_ACCEPT\n : NodeFilter.FILTER_REJECT\n },\n })\n\n const nodes: Element[] = []\n\n while (walker.nextNode()) nodes.push(walker.currentNode as Element)\n\n // By default scripts appended dynamically will execute asyncrhonously. Here we ensure that\n // scripts are loaded synchronously since that's what a user usually expects with scripts in\n // embedded in HTML which usually comes from the server.\n //\n // See: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/script#notes\n async function executeScriptsInOrder() {\n for (let i = 0; i < nodes.length; i++) {\n await new Promise<void>(resolve => {\n const node = nodes[i]\n const script = node.ownerDocument.createElement(SCRIPT_TAG)\n\n script.textContent = node.textContent\n Array.from(node.attributes).forEach(({ name, value }) => {\n script.setAttribute(name, value)\n })\n\n script.onload = () => resolve()\n script.onerror = () => resolve()\n\n node.parentNode?.insertBefore(script, node)\n node.parentNode?.removeChild(node)\n\n if (!script.hasAttribute('src')) resolve()\n })\n }\n }\n\n executeScriptsInOrder().catch(error => {\n // Ignore errors from user-provided code\n console.error(error)\n })\n }, [container, html])\n\n const className = useStyle({ minHeight: 15 })\n\n if (shouldRender === false) return null\n\n return (\n <div\n ref={setContainer}\n id={id}\n className={cx(className, width, margin)}\n dangerouslySetInnerHTML={
|
|
1
|
+
{"version":3,"sources":["../../../../../src/components/builtin/Embed/Embed.tsx"],"sourcesContent":["'use client'\n\n/* eslint-env browser */\n\nimport { useState, useEffect, useMemo, forwardRef, Ref, useImperativeHandle } from 'react'\n\nimport { useIsomorphicLayoutEffect } from '../../hooks/useIsomorphicLayoutEffect'\nimport { useStyle } from '../../../runtimes/react/use-style'\nimport { cx } from '@emotion/css'\n\ntype Props = {\n id?: string\n html?: string\n width?: string\n margin?: string\n}\n\nconst defaultHtml = `<div style=\"padding: 24px; background-color: rgba(161, 168, 194, 0.18); overflow: hidden;\">\n<svg width=\"316\" height=\"168\" viewBox=\"0 0 316 168\" fill=\"none\" xmlns=\"http://www.w3.org/2000/svg\">\n<rect width=\"70\" height=\"8\" rx=\"2\" fill=\"#A1A8C2\" fill-opacity=\"0.5\"/>\n<rect x=\"78\" width=\"30\" height=\"8\" rx=\"2\" fill=\"#A1A8C2\" fill-opacity=\"0.25\"/>\n<rect x=\"116\" width=\"78\" height=\"8\" rx=\"2\" fill=\"#A1A8C2\" fill-opacity=\"0.25\"/>\n<rect y=\"20\" width=\"120\" height=\"8\" rx=\"2\" fill=\"#A1A8C2\" fill-opacity=\"0.5\"/>\n<rect x=\"128\" y=\"20\" width=\"30\" height=\"8\" rx=\"2\" fill=\"#A1A8C2\" fill-opacity=\"0.25\"/>\n<rect x=\"166\" y=\"20\" width=\"78\" height=\"8\" rx=\"2\" fill=\"#A1A8C2\" fill-opacity=\"0.25\"/>\n<rect y=\"60\" width=\"40\" height=\"8\" rx=\"2\" fill=\"#A1A8C2\" fill-opacity=\"0.5\"/>\n<rect x=\"20\" y=\"80\" width=\"40\" height=\"8\" rx=\"2\" fill=\"#A1A8C2\" fill-opacity=\"0.5\"/>\n<rect x=\"40\" y=\"100\" width=\"40\" height=\"8\" rx=\"2\" fill=\"#A1A8C2\" fill-opacity=\"0.5\"/>\n<rect x=\"88\" y=\"100\" width=\"110\" height=\"8\" rx=\"2\" fill=\"#A1A8C2\" fill-opacity=\"0.25\"/>\n<rect x=\"206\" y=\"100\" width=\"24\" height=\"8\" rx=\"2\" fill=\"#A1A8C2\" fill-opacity=\"0.25\"/>\n<rect x=\"238\" y=\"100\" width=\"40\" height=\"8\" rx=\"2\" fill=\"#A1A8C2\" fill-opacity=\"0.5\"/>\n<rect x=\"40\" y=\"120\" width=\"40\" height=\"8\" rx=\"2\" fill=\"#A1A8C2\" fill-opacity=\"0.5\"/>\n<rect x=\"88\" y=\"120\" width=\"50\" height=\"8\" rx=\"2\" fill=\"#A1A8C2\" fill-opacity=\"0.25\"/>\n<rect x=\"146\" y=\"120\" width=\"24\" height=\"8\" rx=\"2\" fill=\"#A1A8C2\" fill-opacity=\"0.25\"/>\n<rect x=\"178\" y=\"120\" width=\"90\" height=\"8\" rx=\"2\" fill=\"#A1A8C2\" fill-opacity=\"0.25\"/>\n<rect x=\"276\" y=\"120\" width=\"40\" height=\"8\" rx=\"2\" fill=\"#A1A8C2\" fill-opacity=\"0.5\"/>\n<rect x=\"20\" y=\"140\" width=\"40\" height=\"8\" rx=\"2\" fill=\"#A1A8C2\" fill-opacity=\"0.5\"/>\n<rect y=\"160\" width=\"40\" height=\"8\" rx=\"2\" fill=\"#A1A8C2\" fill-opacity=\"0.5\"/>\n</svg>\n</div>`\nconst SCRIPT_TAG = 'script'\n\nconst Embed = forwardRef(function Embed(\n { id, width, margin, html = defaultHtml }: Props,\n ref: Ref<HTMLDivElement | null>,\n) {\n const [container, setContainer] = useState<HTMLDivElement | null>(null)\n const [shouldRender, setShouldRender] = useState(false)\n\n useIsomorphicLayoutEffect(() => {\n setShouldRender(true)\n }, [])\n\n useImperativeHandle<HTMLDivElement | null, HTMLDivElement | null>(ref, () => container, [\n container,\n ])\n\n useEffect(() => {\n // TODO: When we SSR the editor, we can remove the editor check\n // and not run this effect on the first render.\n if (!container) return\n\n const walker = container.ownerDocument.createTreeWalker(container, NodeFilter.SHOW_ELEMENT, {\n acceptNode(node: Element) {\n return node.tagName.toLowerCase() === SCRIPT_TAG\n ? NodeFilter.FILTER_ACCEPT\n : NodeFilter.FILTER_REJECT\n },\n })\n\n const nodes: Element[] = []\n\n while (walker.nextNode()) nodes.push(walker.currentNode as Element)\n\n // By default scripts appended dynamically will execute asyncrhonously. Here we ensure that\n // scripts are loaded synchronously since that's what a user usually expects with scripts in\n // embedded in HTML which usually comes from the server.\n //\n // See: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/script#notes\n async function executeScriptsInOrder() {\n for (let i = 0; i < nodes.length; i++) {\n await new Promise<void>(resolve => {\n const node = nodes[i]\n const script = node.ownerDocument.createElement(SCRIPT_TAG)\n\n script.textContent = node.textContent\n Array.from(node.attributes).forEach(({ name, value }) => {\n script.setAttribute(name, value)\n })\n\n script.onload = () => resolve()\n script.onerror = () => resolve()\n\n node.parentNode?.insertBefore(script, node)\n node.parentNode?.removeChild(node)\n\n if (!script.hasAttribute('src')) resolve()\n })\n }\n }\n\n executeScriptsInOrder().catch(error => {\n // Ignore errors from user-provided code\n console.error(error)\n })\n }, [container, html])\n\n const className = useStyle({ minHeight: 15 })\n\n // React 19+ resets `innerHTML` whenever the `dangerouslySetInnerHTML`\n // object's identity changes, even if `__html` is the same string. Memoize\n // the object so unrelated re-renders don't wipe out DOM produced by the\n // executed scripts above. See https://github.com/facebook/react/issues/31660\n // and https://github.com/react/react/issues/31600\n const dangerouslySetInnerHTML = useMemo(() => ({ __html: html }), [html])\n\n if (shouldRender === false) return null\n\n return (\n <div\n ref={setContainer}\n id={id}\n className={cx(className, width, margin)}\n dangerouslySetInnerHTML={dangerouslySetInnerHTML}\n />\n )\n})\n\nexport default Embed\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAuHI;AAnHJ,mBAAmF;AAEnF,uCAA0C;AAC1C,uBAAyB;AACzB,iBAAmB;AASnB,MAAM,cAAc;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAuBpB,MAAM,aAAa;AAEnB,MAAM,YAAQ,yBAAW,SAASA,OAChC,EAAE,IAAI,OAAO,QAAQ,OAAO,YAAY,GACxC,KACA;AACA,QAAM,CAAC,WAAW,YAAY,QAAI,uBAAgC,IAAI;AACtE,QAAM,CAAC,cAAc,eAAe,QAAI,uBAAS,KAAK;AAEtD,kEAA0B,MAAM;AAC9B,oBAAgB,IAAI;AAAA,EACtB,GAAG,CAAC,CAAC;AAEL,wCAAkE,KAAK,MAAM,WAAW;AAAA,IACtF;AAAA,EACF,CAAC;AAED,8BAAU,MAAM;AAGd,QAAI,CAAC;AAAW;AAEhB,UAAM,SAAS,UAAU,cAAc,iBAAiB,WAAW,WAAW,cAAc;AAAA,MAC1F,WAAW,MAAe;AACxB,eAAO,KAAK,QAAQ,YAAY,MAAM,aAClC,WAAW,gBACX,WAAW;AAAA,MACjB;AAAA,IACF,CAAC;AAED,UAAM,QAAmB,CAAC;AAE1B,WAAO,OAAO,SAAS;AAAG,YAAM,KAAK,OAAO,WAAsB;AAOlE,mBAAe,wBAAwB;AACrC,eAAS,IAAI,GAAG,IAAI,MAAM,QAAQ,KAAK;AACrC,cAAM,IAAI,QAAc,aAAW;AACjC,gBAAM,OAAO,MAAM,CAAC;AACpB,gBAAM,SAAS,KAAK,cAAc,cAAc,UAAU;AAE1D,iBAAO,cAAc,KAAK;AAC1B,gBAAM,KAAK,KAAK,UAAU,EAAE,QAAQ,CAAC,EAAE,MAAM,MAAM,MAAM;AACvD,mBAAO,aAAa,MAAM,KAAK;AAAA,UACjC,CAAC;AAED,iBAAO,SAAS,MAAM,QAAQ;AAC9B,iBAAO,UAAU,MAAM,QAAQ;AAE/B,eAAK,YAAY,aAAa,QAAQ,IAAI;AAC1C,eAAK,YAAY,YAAY,IAAI;AAEjC,cAAI,CAAC,OAAO,aAAa,KAAK;AAAG,oBAAQ;AAAA,QAC3C,CAAC;AAAA,MACH;AAAA,IACF;AAEA,0BAAsB,EAAE,MAAM,WAAS;AAErC,cAAQ,MAAM,KAAK;AAAA,IACrB,CAAC;AAAA,EACH,GAAG,CAAC,WAAW,IAAI,CAAC;AAEpB,QAAM,gBAAY,2BAAS,EAAE,WAAW,GAAG,CAAC;AAO5C,QAAM,8BAA0B,sBAAQ,OAAO,EAAE,QAAQ,KAAK,IAAI,CAAC,IAAI,CAAC;AAExE,MAAI,iBAAiB;AAAO,WAAO;AAEnC,SACE;AAAA,IAAC;AAAA;AAAA,MACC,KAAK;AAAA,MACL;AAAA,MACA,eAAW,eAAG,WAAW,OAAO,MAAM;AAAA,MACtC;AAAA;AAAA,EACF;AAEJ,CAAC;AAED,IAAO,gBAAQ;","names":["Embed"]}
|
|
@@ -32,6 +32,7 @@ __export(useSyncWithBuilder_exports, {
|
|
|
32
32
|
});
|
|
33
33
|
module.exports = __toCommonJS(useSyncWithBuilder_exports);
|
|
34
34
|
var import_react = require("react");
|
|
35
|
+
var import_slate = require("slate");
|
|
35
36
|
var import_controls = require("@makeswift/controls");
|
|
36
37
|
var import_use_is_in_builder = require("../../../hooks/use-is-in-builder");
|
|
37
38
|
var import_deepEqual = __toESM(require("../../../../../utils/deepEqual"));
|
|
@@ -43,13 +44,14 @@ function useSyncWithBuilder(editor, text) {
|
|
|
43
44
|
if (shouldCommit && text && isInBuilder) {
|
|
44
45
|
const nextValue = (0, import_controls.richTextDTOtoDAO)(text);
|
|
45
46
|
const nextSelection = (0, import_controls.richTextDTOtoSelection)(text);
|
|
46
|
-
|
|
47
|
+
const sameSelection = editor.selection == null || nextSelection == null ? editor.selection == nextSelection : import_slate.Range.equals(editor.selection, nextSelection);
|
|
48
|
+
if (!(0, import_deepEqual.default)(editor.children, nextValue) || !sameSelection) {
|
|
47
49
|
editor.children = nextValue;
|
|
48
50
|
editor.selection = nextSelection;
|
|
49
51
|
editor.onChange();
|
|
50
52
|
}
|
|
51
53
|
}
|
|
52
|
-
}, [editor, shouldCommit, text]);
|
|
54
|
+
}, [editor, isInBuilder, shouldCommit, text]);
|
|
53
55
|
(0, import_react.useEffect)(() => {
|
|
54
56
|
if (shouldCommit)
|
|
55
57
|
return;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../../../src/runtimes/react/controls/rich-text/EditableText/useSyncWithBuilder.tsx"],"sourcesContent":["import { useState, useEffect, useCallback } from 'react'\nimport { Editor } from 'slate'\nimport { type RichTextDTO, richTextDTOtoDAO, richTextDTOtoSelection } from '@makeswift/controls'\n\nimport { useIsInBuilder } from '../../../hooks/use-is-in-builder'\nimport deepEqual from '../../../../../utils/deepEqual'\n\nconst COMMIT_DEBOUNCE_DELAY = 500\n\n/**\n * Compare new prop value with current editor and update editor\n * if the values are not equal.\n */\nexport function useSyncWithBuilder(editor: Editor, text?: RichTextDTO) {\n const [shouldCommit, setShouldCommit] = useState(true)\n const isInBuilder = useIsInBuilder()\n\n useEffect(() => {\n if (shouldCommit && text && isInBuilder) {\n const nextValue = richTextDTOtoDAO(text)\n const nextSelection = richTextDTOtoSelection(text)\n if (!deepEqual(editor.children, nextValue) || !
|
|
1
|
+
{"version":3,"sources":["../../../../../../../src/runtimes/react/controls/rich-text/EditableText/useSyncWithBuilder.tsx"],"sourcesContent":["import { useState, useEffect, useCallback } from 'react'\nimport { Editor, Range } from 'slate'\nimport { type RichTextDTO, richTextDTOtoDAO, richTextDTOtoSelection } from '@makeswift/controls'\n\nimport { useIsInBuilder } from '../../../hooks/use-is-in-builder'\nimport deepEqual from '../../../../../utils/deepEqual'\n\nconst COMMIT_DEBOUNCE_DELAY = 500\n\n/**\n * Compare new prop value with current editor and update editor\n * if the values are not equal.\n */\nexport function useSyncWithBuilder(editor: Editor, text?: RichTextDTO) {\n const [shouldCommit, setShouldCommit] = useState(true)\n const isInBuilder = useIsInBuilder()\n\n useEffect(() => {\n if (shouldCommit && text && isInBuilder) {\n const nextValue = richTextDTOtoDAO(text)\n const nextSelection = richTextDTOtoSelection(text)\n const sameSelection =\n editor.selection == null || nextSelection == null\n ? editor.selection == nextSelection\n : Range.equals(editor.selection, nextSelection)\n\n if (!deepEqual(editor.children, nextValue) || !sameSelection) {\n editor.children = nextValue\n editor.selection = nextSelection\n editor.onChange()\n }\n }\n }, [editor, isInBuilder, shouldCommit, text])\n\n useEffect(() => {\n if (shouldCommit) return\n\n const timeoutId = window.setTimeout(() => {\n setShouldCommit(true)\n }, COMMIT_DEBOUNCE_DELAY)\n\n return () => {\n window.clearTimeout(timeoutId)\n }\n }, [shouldCommit])\n\n return useCallback(() => setShouldCommit(false), [])\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,mBAAiD;AACjD,mBAA8B;AAC9B,sBAA2E;AAE3E,+BAA+B;AAC/B,uBAAsB;AAEtB,MAAM,wBAAwB;AAMvB,SAAS,mBAAmB,QAAgB,MAAoB;AACrE,QAAM,CAAC,cAAc,eAAe,QAAI,uBAAS,IAAI;AACrD,QAAM,kBAAc,yCAAe;AAEnC,8BAAU,MAAM;AACd,QAAI,gBAAgB,QAAQ,aAAa;AACvC,YAAM,gBAAY,kCAAiB,IAAI;AACvC,YAAM,oBAAgB,wCAAuB,IAAI;AACjD,YAAM,gBACJ,OAAO,aAAa,QAAQ,iBAAiB,OACzC,OAAO,aAAa,gBACpB,mBAAM,OAAO,OAAO,WAAW,aAAa;AAElD,UAAI,KAAC,iBAAAA,SAAU,OAAO,UAAU,SAAS,KAAK,CAAC,eAAe;AAC5D,eAAO,WAAW;AAClB,eAAO,YAAY;AACnB,eAAO,SAAS;AAAA,MAClB;AAAA,IACF;AAAA,EACF,GAAG,CAAC,QAAQ,aAAa,cAAc,IAAI,CAAC;AAE5C,8BAAU,MAAM;AACd,QAAI;AAAc;AAElB,UAAM,YAAY,OAAO,WAAW,MAAM;AACxC,sBAAgB,IAAI;AAAA,IACtB,GAAG,qBAAqB;AAExB,WAAO,MAAM;AACX,aAAO,aAAa,SAAS;AAAA,IAC/B;AAAA,EACF,GAAG,CAAC,YAAY,CAAC;AAEjB,aAAO,0BAAY,MAAM,gBAAgB,KAAK,GAAG,CAAC,CAAC;AACrD;","names":["deepEqual"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/slate/TypographyPlugin/normalizeTypographyUp.ts"],"sourcesContent":["import { Editor, Element, NodeEntry, Transforms, Node, Text } from 'slate'\nimport { RichTextTypography } from '@makeswift/controls'\n\nimport { MakeswiftEditor } from '../types'\nimport keys from '../../utils/keys'\nimport deepEqual from '../../utils/deepEqual'\nimport { shallowMergeTypographies } from './normalizeTypographyDown'\n\nfunction shallowAnd<A extends Record<string,
|
|
1
|
+
{"version":3,"sources":["../../../../src/slate/TypographyPlugin/normalizeTypographyUp.ts"],"sourcesContent":["import { Editor, Element, NodeEntry, Transforms, Node, Text } from 'slate'\nimport { type Data, RichTextTypography } from '@makeswift/controls'\n\nimport { MakeswiftEditor } from '../types'\nimport keys from '../../utils/keys'\nimport deepEqual from '../../utils/deepEqual'\nimport { shallowMergeTypographies } from './normalizeTypographyDown'\n\nfunction shallowAnd<A extends Record<string, Data>, B extends Record<string, Data>>(\n a: A,\n b: B,\n): A & B {\n const bKeys = keys(b)\n const aPrime = { ...a } as A & B\n const and = {} as A & B\n\n bKeys.forEach(key => {\n if (deepEqual(aPrime[key], b[key])) and[key] = aPrime[key]\n })\n\n return and\n}\n\nfunction shallowAndTypographies(...typographies: RichTextTypography[]): RichTextTypography {\n return {\n id: typographies.every(typography => typography?.id === typographies.at(0)?.id)\n ? typographies.at(0)?.id\n : undefined,\n style: [\n ...new Set(\n typographies.flatMap(typography => typography?.style.map(node => node.deviceId) ?? []),\n ),\n ].flatMap(deviceId => {\n const stylesForThisDevice = typographies\n .map(typography => typography.style.find(s => s.deviceId === deviceId)?.value)\n .filter((typography): typography is RichTextTypography['style'][number]['value'] =>\n Boolean(typography),\n )\n\n if (typographies.length !== stylesForThisDevice.length) return []\n\n const value = stylesForThisDevice.reduce(\n (acc, curr) => {\n return shallowAnd(acc, curr)\n },\n stylesForThisDevice.at(0) as RichTextTypography['style'][number]['value'],\n )\n\n if (value == null || Object.keys(value).length === 0) {\n return []\n }\n\n return [\n {\n deviceId,\n value,\n },\n ]\n }),\n }\n}\n\nfunction shallowInverseAnd<A extends Record<string, Data>, B extends Record<string, Data>>(\n a: A,\n b: B,\n): A & B {\n const bKeys = Array.from(new Set([...keys(b), ...keys(a)]))\n const aPrime = { ...a } as A & B\n const bPrime = { ...b } as A & B\n const xor = {} as A & B\n\n bKeys.forEach(key => {\n if (!deepEqual(aPrime[key], bPrime[key])) xor[key] = aPrime[key]\n })\n\n return xor\n}\n\nfunction shallowInverseAndTypographies(\n a: RichTextTypography,\n b: RichTextTypography,\n): RichTextTypography {\n const typography = { style: [] } as RichTextTypography\n if (a?.id !== b.id) {\n typography.id = a?.id\n }\n\n if (a && a.style.length > 0) {\n const styles: RichTextTypography['style'] = []\n for (const style of a.style) {\n const bDeviceTypography = b.style.find(s => s.deviceId === style.deviceId)\n if (bDeviceTypography == null) {\n styles.push(style)\n } else {\n const uniquePropertiesOfA = shallowInverseAnd(style.value, bDeviceTypography.value)\n\n if (Object.keys(uniquePropertiesOfA).length > 0) {\n styles.push({\n deviceId: style.deviceId,\n value: uniquePropertiesOfA,\n })\n }\n }\n }\n typography.style = styles\n }\n\n return typography\n}\n\n/**\n * If a text is empty then don't include it in our comparison.\n */\nfunction isException(node: Node): boolean {\n return Text.isText(node) && node.text === ''\n}\n\nexport function normalizeTypographyUp(editor: MakeswiftEditor, entry: NodeEntry): boolean {\n const [node, path] = entry\n if (Element.isElement(node) && node.children.length) {\n const typographiesOfChildren = node.children\n .filter(child => !isException(child))\n .map(child => child.typography)\n\n const definedTypographiesOfChildren = typographiesOfChildren.filter(\n (typography): typography is RichTextTypography => Boolean(typography),\n )\n if (typographiesOfChildren.length === definedTypographiesOfChildren.length) {\n let sharedTypography: RichTextTypography = shallowAndTypographies(\n ...definedTypographiesOfChildren,\n )\n\n if (sharedTypography.style.length > 0 || sharedTypography.id != null) {\n const rootTypography: RichTextTypography = shallowMergeTypographies(\n sharedTypography,\n node.typography,\n )\n Editor.withoutNormalizing(editor, () => {\n Transforms.setNodes(editor, { typography: rootTypography }, { at: path })\n for (let i = 0; i < node.children.length; i++) {\n const typography: RichTextTypography = shallowInverseAndTypographies(\n node.children.at(i)?.typography ?? { style: [] },\n sharedTypography,\n )\n\n Transforms.setNodes(editor, { typography }, { at: [...path, i] })\n }\n })\n return true\n }\n }\n }\n return false\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,mBAAmE;AAInE,kBAAiB;AACjB,uBAAsB;AACtB,qCAAyC;AAEzC,SAAS,WACP,GACA,GACO;AACP,QAAM,YAAQ,YAAAA,SAAK,CAAC;AACpB,QAAM,SAAS,EAAE,GAAG,EAAE;AACtB,QAAM,MAAM,CAAC;AAEb,QAAM,QAAQ,SAAO;AACnB,YAAI,iBAAAC,SAAU,OAAO,GAAG,GAAG,EAAE,GAAG,CAAC;AAAG,UAAI,GAAG,IAAI,OAAO,GAAG;AAAA,EAC3D,CAAC;AAED,SAAO;AACT;AAEA,SA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AAM,qBAAqC;AAAA,UACzC;AAAA,UACA,KAAK;AAAA,QACP;AACA,4BAAO,mBAAmB,QAAQ,MAAM;AACtC,kCAAW,SAAS,QAAQ,EAAE,YAAY,eAAe,GAAG,EAAE,IAAI,KAAK,CAAC;AACxE,mBAAS,IAAI,GAAG,IAAI,KAAK,SAAS,QAAQ,KAAK;AAC7C,kBAAM,aAAiC;AAAA,cACrC,KAAK,SAAS,GAAG,CAAC,GAAG,cAAc,EAAE,OAAO,CAAC,EAAE;AAAA,cAC/C;AAAA,YACF;AAEA,oCAAW,SAAS,QAAQ,EAAE,WAAW,GAAG,EAAE,IAAI,CAAC,GAAG,MAAM,CAAC,EAAE,CAAC;AAAA,UAClE;AAAA,QACF,CAAC;AACD,eAAO;AAAA,MACT;AAAA,IACF;AAAA,EACF;AACA,SAAO;AACT;","names":["keys","deepEqual"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/slate/selectors.ts"],"sourcesContent":["import { Editor, NodeEntry, Range, Text } from 'slate'\nimport {\n type Breakpoints,\n type BreakpointId,\n findBreakpointOverride,\n Slate,\n} from '@makeswift/controls'\n\nimport { EditableBlockKey } from './BlockPlugin/types'\n\nimport unhangRange from './utils/unhangRange'\nimport shallowEqual from '../utils/shallowEqual'\nimport { isNonNullable } from '../utils/isNonNullable'\n\nimport deepEqual from '../utils/deepEqual'\nimport keys from '../utils/keys'\n\nexport function getSelection(editor: Editor): Range {\n if (editor.selection) return unhangRange(editor, editor.selection)\n return {\n anchor: Editor.start(editor, []),\n focus: Editor.end(editor, []),\n }\n}\n\nexport function getBlocksInSelection(editor: Editor): NodeEntry<Slate.RootBlock>[] {\n return Array.from(\n Editor.nodes(editor, {\n at: getSelection(editor),\n match: node => Slate.isRootBlock(node),\n }),\n ).filter((entry): entry is NodeEntry<Slate.RootBlock> => Slate.isRootBlock(entry[0]))\n}\n\nexport function getInlinesInSelection(editor: Editor): NodeEntry<Slate.Inline>[] {\n return Array.from(\n Editor.nodes(editor, {\n at: getSelection(editor),\n match: node => Slate.isInline(node),\n }),\n ).filter((entry): entry is NodeEntry<Slate.Inline> => Slate.isInline(entry[0]))\n}\n\nexport function getActiveBlockType(editor: Editor): Slate.RootBlockType | null {\n const rootBlocks = getBlocksInSelection(editor).map(([node]) => node.type)\n\n return rootBlocks.reduce<Slate.RootBlockType | null>(\n (a, b) => (a === b ? b : null),\n rootBlocks.at(0) ?? null,\n )\n}\n\nexport function getActiveBlockValue(editor: Editor, key: EditableBlockKey) {\n const blocks = getBlocksInSelection(editor)\n\n const active = blocks.map(\n ([block]) => block[key] ?? null,\n ) as (Slate.ResponsiveBlockTextAlignment | null)[]\n\n return active.length === 0 ? null : active.reduce((a, b) => (shallowEqual(a, b) ? b : null))\n}\n\nexport function getActiveBlockDeviceOverrideValue(\n editor: Editor,\n key: EditableBlockKey,\n breakpoints: Breakpoints,\n deviceId: BreakpointId,\n) {\n const active: (Slate.BlockTextAlignment | null)[] = []\n const blocks = getBlocksInSelection(editor)\n\n blocks.forEach(([block]) => {\n const deviceOverride =\n findBreakpointOverride<Slate.BlockTextAlignment>(breakpoints, block[key], deviceId) || null\n active.push(deviceOverride?.value ?? null)\n })\n\n return active.length === 0 ? null : active.reduce((a, b) => (shallowEqual(a, b) ? b : null))\n}\n\n// Typography\n\nconst concat = (a: unknown[], b: unknown[]) => a.concat(b)\n\n// TODO: This is more cruft from trying to remove null from the typography type. This optimization is not worth it.\n/**\n * This is a c/p of the intersection of the utils from the root utils folder.\n * The only change is defaulting to undefined instead of to null.\n */\nexport default function intersection<A extends Record<string,
|
|
1
|
+
{"version":3,"sources":["../../../src/slate/selectors.ts"],"sourcesContent":["import { Editor, NodeEntry, Range, Text } from 'slate'\nimport {\n type Breakpoints,\n type BreakpointId,\n type Data,\n findBreakpointOverride,\n Slate,\n} from '@makeswift/controls'\n\nimport { EditableBlockKey } from './BlockPlugin/types'\n\nimport unhangRange from './utils/unhangRange'\nimport shallowEqual from '../utils/shallowEqual'\nimport { isNonNullable } from '../utils/isNonNullable'\n\nimport deepEqual from '../utils/deepEqual'\nimport keys from '../utils/keys'\n\nexport function getSelection(editor: Editor): Range {\n if (editor.selection) return unhangRange(editor, editor.selection)\n return {\n anchor: Editor.start(editor, []),\n focus: Editor.end(editor, []),\n }\n}\n\nexport function getBlocksInSelection(editor: Editor): NodeEntry<Slate.RootBlock>[] {\n return Array.from(\n Editor.nodes(editor, {\n at: getSelection(editor),\n match: node => Slate.isRootBlock(node),\n }),\n ).filter((entry): entry is NodeEntry<Slate.RootBlock> => Slate.isRootBlock(entry[0]))\n}\n\nexport function getInlinesInSelection(editor: Editor): NodeEntry<Slate.Inline>[] {\n return Array.from(\n Editor.nodes(editor, {\n at: getSelection(editor),\n match: node => Slate.isInline(node),\n }),\n ).filter((entry): entry is NodeEntry<Slate.Inline> => Slate.isInline(entry[0]))\n}\n\nexport function getActiveBlockType(editor: Editor): Slate.RootBlockType | null {\n const rootBlocks = getBlocksInSelection(editor).map(([node]) => node.type)\n\n return rootBlocks.reduce<Slate.RootBlockType | null>(\n (a, b) => (a === b ? b : null),\n rootBlocks.at(0) ?? null,\n )\n}\n\nexport function getActiveBlockValue(editor: Editor, key: EditableBlockKey) {\n const blocks = getBlocksInSelection(editor)\n\n const active = blocks.map(\n ([block]) => block[key] ?? null,\n ) as (Slate.ResponsiveBlockTextAlignment | null)[]\n\n return active.length === 0 ? null : active.reduce((a, b) => (shallowEqual(a, b) ? b : null))\n}\n\nexport function getActiveBlockDeviceOverrideValue(\n editor: Editor,\n key: EditableBlockKey,\n breakpoints: Breakpoints,\n deviceId: BreakpointId,\n) {\n const active: (Slate.BlockTextAlignment | null)[] = []\n const blocks = getBlocksInSelection(editor)\n\n blocks.forEach(([block]) => {\n const deviceOverride =\n findBreakpointOverride<Slate.BlockTextAlignment>(breakpoints, block[key], deviceId) || null\n active.push(deviceOverride?.value ?? null)\n })\n\n return active.length === 0 ? null : active.reduce((a, b) => (shallowEqual(a, b) ? b : null))\n}\n\n// Typography\n\nconst concat = (a: unknown[], b: unknown[]) => a.concat(b)\n\n// TODO: This is more cruft from trying to remove null from the typography type. This optimization is not worth it.\n/**\n * This is a c/p of the intersection of the utils from the root utils folder.\n * The only change is defaulting to undefined instead of to null.\n */\nexport default function intersection<A extends Record<string, Data>, B extends A>(\n a: A,\n b: B,\n isEqual: (a: Data, b: Data) => boolean = deepEqual,\n): { [K in keyof A]: A[K] | undefined } {\n const allKeys = [...new Set([...keys(a), ...keys(b)])] as (keyof A)[]\n\n return allKeys.reduce(\n (acc, k) => {\n if (isEqual(a[k], b[k])) acc[k] = a[k]\n else acc[k] = undefined\n\n return acc\n },\n {} as { [K in keyof A]: A[K] | undefined },\n )\n}\n\nconst fuseTypographyMarks = (\n values: Array<Slate.Typography | null | undefined>,\n breakpoints: Breakpoints,\n): Slate.Typography => {\n const devices = [\n ...new Set(\n values\n .filter(isNonNullable)\n .map(({ style }) => style.map(({ deviceId }) => deviceId))\n .reduce(concat, []),\n ),\n ] as BreakpointId[]\n\n return {\n id: values.map(v => v && v.id).reduce((a, b) => (a === b ? a : undefined)) ?? undefined,\n style: devices.map(deviceId =>\n values\n .map(\n v =>\n (v && findBreakpointOverride(breakpoints, v.style, deviceId)) || {\n deviceId,\n value: {},\n },\n )\n .reduce((acc, { value }) => {\n const a = intersection(acc.value, value)\n return {\n deviceId,\n value: a,\n }\n }),\n ),\n }\n}\n\nexport function getActiveTypographyMark(\n editor: Editor,\n breakpoints: Breakpoints,\n): Slate.Typography {\n const active: Slate.Typography[] = []\n\n const textNodes = Editor.nodes(editor, {\n at: getSelection(editor),\n match: node => Text.isText(node),\n })\n\n for (const [node] of textNodes) {\n if (Text.isText(node) && 'typography' in node && node.typography != undefined) {\n active.push(node.typography)\n }\n }\n return active.length === 0 ? { style: [] } : fuseTypographyMarks(active, breakpoints)\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA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IAAI,OAAK,KAAK,EAAE,EAAE,EAAE,OAAO,CAAC,GAAG,MAAO,MAAM,IAAI,IAAI,MAAU,KAAK;AAAA,IAC9E,OAAO,QAAQ;AAAA,MAAI,cACjB,OACG;AAAA,QACC,OACG,SAAK,wCAAuB,aAAa,EAAE,OAAO,QAAQ,KAAM;AAAA,UAC/D;AAAA,UACA,OAAO,CAAC;AAAA,QACV;AAAA,MACJ,EACC,OAAO,CAAC,KAAK,EAAE,MAAM,MAAM;AAC1B,cAAM,IAAI,aAAa,IAAI,OAAO,KAAK;AACvC,eAAO;AAAA,UACL;AAAA,UACA,OAAO;AAAA,QACT;AAAA,MACF,CAAC;AAAA,IACL;AAAA,EACF;AACF;AAEO,SAAS,wBACd,QACA,aACkB;AAClB,QAAM,SAA6B,CAAC;AAEpC,QAAM,YAAY,oBAAO,MAAM,QAAQ;AAAA,IACrC,IAAI,aAAa,MAAM;AAAA,IACvB,OAAO,UAAQ,kBAAK,OAAO,IAAI;AAAA,EACjC,CAAC;AAED,aAAW,CAAC,IAAI,KAAK,WAAW;AAC9B,QAAI,kBAAK,OAAO,IAAI,KAAK,gBAAgB,QAAQ,KAAK,cAAc,QAAW;AAC7E,aAAO,KAAK,KAAK,UAAU;AAAA,IAC7B;AAAA,EACF;AACA,SAAO,OAAO,WAAW,IAAI,EAAE,OAAO,CAAC,EAAE,IAAI,oBAAoB,QAAQ,WAAW;AACtF;","names":["unhangRange","shallowEqual","deepEqual","keys"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/utils/intersection.ts"],"sourcesContent":["import deepEqual from './deepEqual'\nimport keys from './keys'\n\nexport default function intersection<A extends Record<string,
|
|
1
|
+
{"version":3,"sources":["../../../src/utils/intersection.ts"],"sourcesContent":["import { type Data } from '@makeswift/controls'\n\nimport deepEqual from './deepEqual'\nimport keys from './keys'\n\nexport default function intersection<A extends Record<string, Data>, B extends A>(\n a: A,\n b: B,\n isEqual: (a: Data, b: Data) => boolean = deepEqual,\n): { [K in keyof A]: A[K] | null } {\n const allKeys = [...new Set([...keys(a), ...keys(b)])] as (keyof A)[]\n\n return allKeys.reduce(\n (acc, k) => {\n if (isEqual(a[k], b[k])) acc[k] = a[k]\n else acc[k] = null\n\n return acc\n },\n {} as { [K in keyof A]: A[K] | null },\n )\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAEA,uBAAsB;AACtB,kBAAiB;AAEF,SAAR,aACL,GACA,GACA,UAAyC,iBAAAA,SACR;AACjC,QAAM,UAAU,CAAC,GAAG,oBAAI,IAAI,CAAC,OAAG,YAAAC,SAAK,CAAC,GAAG,OAAG,YAAAA,SAAK,CAAC,CAAC,CAAC,CAAC;AAErD,SAAO,QAAQ;AAAA,IACb,CAAC,KAAK,MAAM;AACV,UAAI,QAAQ,EAAE,CAAC,GAAG,EAAE,CAAC,CAAC;AAAG,YAAI,CAAC,IAAI,EAAE,CAAC;AAAA;AAChC,YAAI,CAAC,IAAI;AAEd,aAAO;AAAA,IACT;AAAA,IACA,CAAC;AAAA,EACH;AACF;","names":["deepEqual","keys"]}
|
|
@@ -9,7 +9,7 @@ class MakeswiftGraphQLApiClient {
|
|
|
9
9
|
graphqlClient;
|
|
10
10
|
constructor({ endpoint }) {
|
|
11
11
|
this.graphqlClient = new GraphQLClient(endpoint, {
|
|
12
|
-
"makeswift-runtime-version": "0.28.8-canary.
|
|
12
|
+
"makeswift-runtime-version": "0.28.8-canary.8"
|
|
13
13
|
});
|
|
14
14
|
}
|
|
15
15
|
async createTableRecord(tableId, columns) {
|
|
@@ -113,7 +113,7 @@ class MakeswiftRestAPIClient {
|
|
|
113
113
|
const requestHeaders = new Headers({
|
|
114
114
|
"x-api-key": this.apiKey,
|
|
115
115
|
"makeswift-site-api-key": this.apiKey,
|
|
116
|
-
"makeswift-runtime-version": "0.28.8-canary.
|
|
116
|
+
"makeswift-runtime-version": "0.28.8-canary.8"
|
|
117
117
|
});
|
|
118
118
|
if (siteVersion?.token) {
|
|
119
119
|
requestUrl.searchParams.set("version", siteVersion.version);
|
|
@@ -8,7 +8,7 @@ async function manifestHandler(req, { apiKey, manifest }) {
|
|
|
8
8
|
return ApiResponse.json({ message: "Unauthorized" }, { status: 401 });
|
|
9
9
|
}
|
|
10
10
|
return ApiResponse.json({
|
|
11
|
-
version: "0.28.8-canary.
|
|
11
|
+
version: "0.28.8-canary.8",
|
|
12
12
|
interactionMode: true,
|
|
13
13
|
clientSideNavigation: false,
|
|
14
14
|
elementFromPoint: false,
|
package/dist/esm/client/index.js
CHANGED
|
@@ -669,7 +669,7 @@ Received "${apiKey}" instead.`
|
|
|
669
669
|
headers: {
|
|
670
670
|
"x-api-key": this.apiKey,
|
|
671
671
|
"makeswift-site-api-key": this.apiKey,
|
|
672
|
-
"makeswift-runtime-version": "0.28.8-canary.
|
|
672
|
+
"makeswift-runtime-version": "0.28.8-canary.8",
|
|
673
673
|
"content-type": "application/json"
|
|
674
674
|
},
|
|
675
675
|
body: JSON.stringify({ token }),
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { jsx } from "react/jsx-runtime";
|
|
3
|
-
import { useState, useEffect, forwardRef, useImperativeHandle } from "react";
|
|
3
|
+
import { useState, useEffect, useMemo, forwardRef, useImperativeHandle } from "react";
|
|
4
4
|
import { useIsomorphicLayoutEffect } from "../../hooks/useIsomorphicLayoutEffect";
|
|
5
5
|
import { useStyle } from "../../../runtimes/react/use-style";
|
|
6
6
|
import { cx } from "@emotion/css";
|
|
@@ -71,6 +71,7 @@ const Embed = forwardRef(function Embed2({ id, width, margin, html = defaultHtml
|
|
|
71
71
|
});
|
|
72
72
|
}, [container, html]);
|
|
73
73
|
const className = useStyle({ minHeight: 15 });
|
|
74
|
+
const dangerouslySetInnerHTML = useMemo(() => ({ __html: html }), [html]);
|
|
74
75
|
if (shouldRender === false)
|
|
75
76
|
return null;
|
|
76
77
|
return /* @__PURE__ */ jsx(
|
|
@@ -79,7 +80,7 @@ const Embed = forwardRef(function Embed2({ id, width, margin, html = defaultHtml
|
|
|
79
80
|
ref: setContainer,
|
|
80
81
|
id,
|
|
81
82
|
className: cx(className, width, margin),
|
|
82
|
-
dangerouslySetInnerHTML
|
|
83
|
+
dangerouslySetInnerHTML
|
|
83
84
|
}
|
|
84
85
|
);
|
|
85
86
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../src/components/builtin/Embed/Embed.tsx"],"sourcesContent":["'use client'\n\n/* eslint-env browser */\n\nimport { useState, useEffect, forwardRef, Ref, useImperativeHandle } from 'react'\n\nimport { useIsomorphicLayoutEffect } from '../../hooks/useIsomorphicLayoutEffect'\nimport { useStyle } from '../../../runtimes/react/use-style'\nimport { cx } from '@emotion/css'\n\ntype Props = {\n id?: string\n html?: string\n width?: string\n margin?: string\n}\n\nconst defaultHtml = `<div style=\"padding: 24px; background-color: rgba(161, 168, 194, 0.18); overflow: hidden;\">\n<svg width=\"316\" height=\"168\" viewBox=\"0 0 316 168\" fill=\"none\" xmlns=\"http://www.w3.org/2000/svg\">\n<rect width=\"70\" height=\"8\" rx=\"2\" fill=\"#A1A8C2\" fill-opacity=\"0.5\"/>\n<rect x=\"78\" width=\"30\" height=\"8\" rx=\"2\" fill=\"#A1A8C2\" fill-opacity=\"0.25\"/>\n<rect x=\"116\" width=\"78\" height=\"8\" rx=\"2\" fill=\"#A1A8C2\" fill-opacity=\"0.25\"/>\n<rect y=\"20\" width=\"120\" height=\"8\" rx=\"2\" fill=\"#A1A8C2\" fill-opacity=\"0.5\"/>\n<rect x=\"128\" y=\"20\" width=\"30\" height=\"8\" rx=\"2\" fill=\"#A1A8C2\" fill-opacity=\"0.25\"/>\n<rect x=\"166\" y=\"20\" width=\"78\" height=\"8\" rx=\"2\" fill=\"#A1A8C2\" fill-opacity=\"0.25\"/>\n<rect y=\"60\" width=\"40\" height=\"8\" rx=\"2\" fill=\"#A1A8C2\" fill-opacity=\"0.5\"/>\n<rect x=\"20\" y=\"80\" width=\"40\" height=\"8\" rx=\"2\" fill=\"#A1A8C2\" fill-opacity=\"0.5\"/>\n<rect x=\"40\" y=\"100\" width=\"40\" height=\"8\" rx=\"2\" fill=\"#A1A8C2\" fill-opacity=\"0.5\"/>\n<rect x=\"88\" y=\"100\" width=\"110\" height=\"8\" rx=\"2\" fill=\"#A1A8C2\" fill-opacity=\"0.25\"/>\n<rect x=\"206\" y=\"100\" width=\"24\" height=\"8\" rx=\"2\" fill=\"#A1A8C2\" fill-opacity=\"0.25\"/>\n<rect x=\"238\" y=\"100\" width=\"40\" height=\"8\" rx=\"2\" fill=\"#A1A8C2\" fill-opacity=\"0.5\"/>\n<rect x=\"40\" y=\"120\" width=\"40\" height=\"8\" rx=\"2\" fill=\"#A1A8C2\" fill-opacity=\"0.5\"/>\n<rect x=\"88\" y=\"120\" width=\"50\" height=\"8\" rx=\"2\" fill=\"#A1A8C2\" fill-opacity=\"0.25\"/>\n<rect x=\"146\" y=\"120\" width=\"24\" height=\"8\" rx=\"2\" fill=\"#A1A8C2\" fill-opacity=\"0.25\"/>\n<rect x=\"178\" y=\"120\" width=\"90\" height=\"8\" rx=\"2\" fill=\"#A1A8C2\" fill-opacity=\"0.25\"/>\n<rect x=\"276\" y=\"120\" width=\"40\" height=\"8\" rx=\"2\" fill=\"#A1A8C2\" fill-opacity=\"0.5\"/>\n<rect x=\"20\" y=\"140\" width=\"40\" height=\"8\" rx=\"2\" fill=\"#A1A8C2\" fill-opacity=\"0.5\"/>\n<rect y=\"160\" width=\"40\" height=\"8\" rx=\"2\" fill=\"#A1A8C2\" fill-opacity=\"0.5\"/>\n</svg>\n</div>`\nconst SCRIPT_TAG = 'script'\n\nconst Embed = forwardRef(function Embed(\n { id, width, margin, html = defaultHtml }: Props,\n ref: Ref<HTMLDivElement | null>,\n) {\n const [container, setContainer] = useState<HTMLDivElement | null>(null)\n const [shouldRender, setShouldRender] = useState(false)\n\n useIsomorphicLayoutEffect(() => {\n setShouldRender(true)\n }, [])\n\n useImperativeHandle<HTMLDivElement | null, HTMLDivElement | null>(ref, () => container, [\n container,\n ])\n\n useEffect(() => {\n // TODO: When we SSR the editor, we can remove the editor check\n // and not run this effect on the first render.\n if (!container) return\n\n const walker = container.ownerDocument.createTreeWalker(container, NodeFilter.SHOW_ELEMENT, {\n acceptNode(node: Element) {\n return node.tagName.toLowerCase() === SCRIPT_TAG\n ? NodeFilter.FILTER_ACCEPT\n : NodeFilter.FILTER_REJECT\n },\n })\n\n const nodes: Element[] = []\n\n while (walker.nextNode()) nodes.push(walker.currentNode as Element)\n\n // By default scripts appended dynamically will execute asyncrhonously. Here we ensure that\n // scripts are loaded synchronously since that's what a user usually expects with scripts in\n // embedded in HTML which usually comes from the server.\n //\n // See: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/script#notes\n async function executeScriptsInOrder() {\n for (let i = 0; i < nodes.length; i++) {\n await new Promise<void>(resolve => {\n const node = nodes[i]\n const script = node.ownerDocument.createElement(SCRIPT_TAG)\n\n script.textContent = node.textContent\n Array.from(node.attributes).forEach(({ name, value }) => {\n script.setAttribute(name, value)\n })\n\n script.onload = () => resolve()\n script.onerror = () => resolve()\n\n node.parentNode?.insertBefore(script, node)\n node.parentNode?.removeChild(node)\n\n if (!script.hasAttribute('src')) resolve()\n })\n }\n }\n\n executeScriptsInOrder().catch(error => {\n // Ignore errors from user-provided code\n console.error(error)\n })\n }, [container, html])\n\n const className = useStyle({ minHeight: 15 })\n\n if (shouldRender === false) return null\n\n return (\n <div\n ref={setContainer}\n id={id}\n className={cx(className, width, margin)}\n dangerouslySetInnerHTML={
|
|
1
|
+
{"version":3,"sources":["../../../../../src/components/builtin/Embed/Embed.tsx"],"sourcesContent":["'use client'\n\n/* eslint-env browser */\n\nimport { useState, useEffect, useMemo, forwardRef, Ref, useImperativeHandle } from 'react'\n\nimport { useIsomorphicLayoutEffect } from '../../hooks/useIsomorphicLayoutEffect'\nimport { useStyle } from '../../../runtimes/react/use-style'\nimport { cx } from '@emotion/css'\n\ntype Props = {\n id?: string\n html?: string\n width?: string\n margin?: string\n}\n\nconst defaultHtml = `<div style=\"padding: 24px; background-color: rgba(161, 168, 194, 0.18); overflow: hidden;\">\n<svg width=\"316\" height=\"168\" viewBox=\"0 0 316 168\" fill=\"none\" xmlns=\"http://www.w3.org/2000/svg\">\n<rect width=\"70\" height=\"8\" rx=\"2\" fill=\"#A1A8C2\" fill-opacity=\"0.5\"/>\n<rect x=\"78\" width=\"30\" height=\"8\" rx=\"2\" fill=\"#A1A8C2\" fill-opacity=\"0.25\"/>\n<rect x=\"116\" width=\"78\" height=\"8\" rx=\"2\" fill=\"#A1A8C2\" fill-opacity=\"0.25\"/>\n<rect y=\"20\" width=\"120\" height=\"8\" rx=\"2\" fill=\"#A1A8C2\" fill-opacity=\"0.5\"/>\n<rect x=\"128\" y=\"20\" width=\"30\" height=\"8\" rx=\"2\" fill=\"#A1A8C2\" fill-opacity=\"0.25\"/>\n<rect x=\"166\" y=\"20\" width=\"78\" height=\"8\" rx=\"2\" fill=\"#A1A8C2\" fill-opacity=\"0.25\"/>\n<rect y=\"60\" width=\"40\" height=\"8\" rx=\"2\" fill=\"#A1A8C2\" fill-opacity=\"0.5\"/>\n<rect x=\"20\" y=\"80\" width=\"40\" height=\"8\" rx=\"2\" fill=\"#A1A8C2\" fill-opacity=\"0.5\"/>\n<rect x=\"40\" y=\"100\" width=\"40\" height=\"8\" rx=\"2\" fill=\"#A1A8C2\" fill-opacity=\"0.5\"/>\n<rect x=\"88\" y=\"100\" width=\"110\" height=\"8\" rx=\"2\" fill=\"#A1A8C2\" fill-opacity=\"0.25\"/>\n<rect x=\"206\" y=\"100\" width=\"24\" height=\"8\" rx=\"2\" fill=\"#A1A8C2\" fill-opacity=\"0.25\"/>\n<rect x=\"238\" y=\"100\" width=\"40\" height=\"8\" rx=\"2\" fill=\"#A1A8C2\" fill-opacity=\"0.5\"/>\n<rect x=\"40\" y=\"120\" width=\"40\" height=\"8\" rx=\"2\" fill=\"#A1A8C2\" fill-opacity=\"0.5\"/>\n<rect x=\"88\" y=\"120\" width=\"50\" height=\"8\" rx=\"2\" fill=\"#A1A8C2\" fill-opacity=\"0.25\"/>\n<rect x=\"146\" y=\"120\" width=\"24\" height=\"8\" rx=\"2\" fill=\"#A1A8C2\" fill-opacity=\"0.25\"/>\n<rect x=\"178\" y=\"120\" width=\"90\" height=\"8\" rx=\"2\" fill=\"#A1A8C2\" fill-opacity=\"0.25\"/>\n<rect x=\"276\" y=\"120\" width=\"40\" height=\"8\" rx=\"2\" fill=\"#A1A8C2\" fill-opacity=\"0.5\"/>\n<rect x=\"20\" y=\"140\" width=\"40\" height=\"8\" rx=\"2\" fill=\"#A1A8C2\" fill-opacity=\"0.5\"/>\n<rect y=\"160\" width=\"40\" height=\"8\" rx=\"2\" fill=\"#A1A8C2\" fill-opacity=\"0.5\"/>\n</svg>\n</div>`\nconst SCRIPT_TAG = 'script'\n\nconst Embed = forwardRef(function Embed(\n { id, width, margin, html = defaultHtml }: Props,\n ref: Ref<HTMLDivElement | null>,\n) {\n const [container, setContainer] = useState<HTMLDivElement | null>(null)\n const [shouldRender, setShouldRender] = useState(false)\n\n useIsomorphicLayoutEffect(() => {\n setShouldRender(true)\n }, [])\n\n useImperativeHandle<HTMLDivElement | null, HTMLDivElement | null>(ref, () => container, [\n container,\n ])\n\n useEffect(() => {\n // TODO: When we SSR the editor, we can remove the editor check\n // and not run this effect on the first render.\n if (!container) return\n\n const walker = container.ownerDocument.createTreeWalker(container, NodeFilter.SHOW_ELEMENT, {\n acceptNode(node: Element) {\n return node.tagName.toLowerCase() === SCRIPT_TAG\n ? NodeFilter.FILTER_ACCEPT\n : NodeFilter.FILTER_REJECT\n },\n })\n\n const nodes: Element[] = []\n\n while (walker.nextNode()) nodes.push(walker.currentNode as Element)\n\n // By default scripts appended dynamically will execute asyncrhonously. Here we ensure that\n // scripts are loaded synchronously since that's what a user usually expects with scripts in\n // embedded in HTML which usually comes from the server.\n //\n // See: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/script#notes\n async function executeScriptsInOrder() {\n for (let i = 0; i < nodes.length; i++) {\n await new Promise<void>(resolve => {\n const node = nodes[i]\n const script = node.ownerDocument.createElement(SCRIPT_TAG)\n\n script.textContent = node.textContent\n Array.from(node.attributes).forEach(({ name, value }) => {\n script.setAttribute(name, value)\n })\n\n script.onload = () => resolve()\n script.onerror = () => resolve()\n\n node.parentNode?.insertBefore(script, node)\n node.parentNode?.removeChild(node)\n\n if (!script.hasAttribute('src')) resolve()\n })\n }\n }\n\n executeScriptsInOrder().catch(error => {\n // Ignore errors from user-provided code\n console.error(error)\n })\n }, [container, html])\n\n const className = useStyle({ minHeight: 15 })\n\n // React 19+ resets `innerHTML` whenever the `dangerouslySetInnerHTML`\n // object's identity changes, even if `__html` is the same string. Memoize\n // the object so unrelated re-renders don't wipe out DOM produced by the\n // executed scripts above. See https://github.com/facebook/react/issues/31660\n // and https://github.com/react/react/issues/31600\n const dangerouslySetInnerHTML = useMemo(() => ({ __html: html }), [html])\n\n if (shouldRender === false) return null\n\n return (\n <div\n ref={setContainer}\n id={id}\n className={cx(className, width, margin)}\n dangerouslySetInnerHTML={dangerouslySetInnerHTML}\n />\n )\n})\n\nexport default Embed\n"],"mappings":";AAuHI;AAnHJ,SAAS,UAAU,WAAW,SAAS,YAAiB,2BAA2B;AAEnF,SAAS,iCAAiC;AAC1C,SAAS,gBAAgB;AACzB,SAAS,UAAU;AASnB,MAAM,cAAc;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAuBpB,MAAM,aAAa;AAEnB,MAAM,QAAQ,WAAW,SAASA,OAChC,EAAE,IAAI,OAAO,QAAQ,OAAO,YAAY,GACxC,KACA;AACA,QAAM,CAAC,WAAW,YAAY,IAAI,SAAgC,IAAI;AACtE,QAAM,C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,KAAK,IAAI,CAAC,IAAI,CAAC;AAExE,MAAI,iBAAiB;AAAO,WAAO;AAEnC,SACE;AAAA,IAAC;AAAA;AAAA,MACC,KAAK;AAAA,MACL;AAAA,MACA,WAAW,GAAG,WAAW,OAAO,MAAM;AAAA,MACtC;AAAA;AAAA,EACF;AAEJ,CAAC;AAED,IAAO,gBAAQ;","names":["Embed"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../../../src/runtimes/react/controls/rich-text/EditableText/useSyncDOMSelection.tsx"],"sourcesContent":["import { ReactEditor } from 'slate-react'\nimport { Editor, Range as SlateRange } from 'slate'\nimport { useIsomorphicLayoutEffect } from '../../../../../components/hooks/useIsomorphicLayoutEffect'\n\n/**\n * Clicking outside of the host blurs our `<Editable />`.\n * `<Editable />` only updates the DOM's selection to match slate when it is focused.\n * In the case of a panel being clicked this hook updates the DOM selection to match slate.\n */\nexport function useSyncDOMSelection(editor: Editor, isEnabled: boolean) {\n useIsomorphicLayoutEffect(() => {\n if (!isEnabled || editor.selection == null || ReactEditor.isFocused(editor)) return\n try {\n const root = ReactEditor.findDocumentOrShadowRoot(editor) as Document\n const domSelection = root.getSelection()\n const newDomRange: Range | null = ReactEditor.toDOMRange(editor, editor.selection)\n\n if (newDomRange) {\n if (SlateRange.isBackward(editor.selection!)) {\n domSelection?.setBaseAndExtent(\n newDomRange.endContainer,\n newDomRange.endOffset,\n newDomRange.startContainer,\n newDomRange.startOffset,\n )\n } else {\n domSelection?.setBaseAndExtent(\n newDomRange.startContainer,\n newDomRange.startOffset,\n newDomRange.endContainer,\n newDomRange.endOffset,\n )\n }\n } else {\n domSelection?.removeAllRanges()\n }\n } catch (e) {\n console.error(e)\n }\n })\n}\n"],"mappings":"AAAA,SAAS,mBAAmB;AAC5B,SAAiB,SAAS,kBAAkB;AAC5C,SAAS,iCAAiC;AAOnC,SAAS,oBAAoB,QAAgB,WAAoB;AACtE,4BAA0B,MAAM;AAC9B,QAAI,CAAC,aAAa,OAAO,aAAa,QAAQ,YAAY,UAAU,MAAM;AAAG;AAC7E,QAAI;AACF,YAAM,OAAO,YAAY,yBAAyB,MAAM;AACxD,YAAM,eAAe,KAAK,aAAa;AACvC,YAAM,cAA4B,YAAY,WAAW,QAAQ,OAAO,SAAS;AAEjF,UAAI,aAAa;AACf,YAAI,WAAW,WAAW,OAAO,SAAU,GAAG;AAC5C,wBAAc;AAAA,YACZ,YAAY;AAAA,YACZ,YAAY;AAAA,YACZ,YAAY;AAAA,YACZ,YAAY;AAAA,UACd;AAAA,QACF,OAAO;AACL,wBAAc;AAAA,YACZ,YAAY;AAAA,YACZ,YAAY;AAAA,YACZ,YAAY;AAAA,YACZ,YAAY;AAAA,UACd;AAAA,QACF;AAAA,MACF,OAAO;AACL,sBAAc,gBAAgB;AAAA,MAChC;AAAA,IACF,SAAS,GAAG;AACV,cAAQ,MAAM,CAAC;AAAA,IACjB;AAAA,EACF,CAAC;AACH;","names":[]}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { useState, useEffect, useCallback } from "react";
|
|
2
|
+
import { Range } from "slate";
|
|
2
3
|
import { richTextDTOtoDAO, richTextDTOtoSelection } from "@makeswift/controls";
|
|
3
4
|
import { useIsInBuilder } from "../../../hooks/use-is-in-builder";
|
|
4
5
|
import deepEqual from "../../../../../utils/deepEqual";
|
|
@@ -10,13 +11,14 @@ function useSyncWithBuilder(editor, text) {
|
|
|
10
11
|
if (shouldCommit && text && isInBuilder) {
|
|
11
12
|
const nextValue = richTextDTOtoDAO(text);
|
|
12
13
|
const nextSelection = richTextDTOtoSelection(text);
|
|
13
|
-
|
|
14
|
+
const sameSelection = editor.selection == null || nextSelection == null ? editor.selection == nextSelection : Range.equals(editor.selection, nextSelection);
|
|
15
|
+
if (!deepEqual(editor.children, nextValue) || !sameSelection) {
|
|
14
16
|
editor.children = nextValue;
|
|
15
17
|
editor.selection = nextSelection;
|
|
16
18
|
editor.onChange();
|
|
17
19
|
}
|
|
18
20
|
}
|
|
19
|
-
}, [editor, shouldCommit, text]);
|
|
21
|
+
}, [editor, isInBuilder, shouldCommit, text]);
|
|
20
22
|
useEffect(() => {
|
|
21
23
|
if (shouldCommit)
|
|
22
24
|
return;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../../../src/runtimes/react/controls/rich-text/EditableText/useSyncWithBuilder.tsx"],"sourcesContent":["import { useState, useEffect, useCallback } from 'react'\nimport { Editor } from 'slate'\nimport { type RichTextDTO, richTextDTOtoDAO, richTextDTOtoSelection } from '@makeswift/controls'\n\nimport { useIsInBuilder } from '../../../hooks/use-is-in-builder'\nimport deepEqual from '../../../../../utils/deepEqual'\n\nconst COMMIT_DEBOUNCE_DELAY = 500\n\n/**\n * Compare new prop value with current editor and update editor\n * if the values are not equal.\n */\nexport function useSyncWithBuilder(editor: Editor, text?: RichTextDTO) {\n const [shouldCommit, setShouldCommit] = useState(true)\n const isInBuilder = useIsInBuilder()\n\n useEffect(() => {\n if (shouldCommit && text && isInBuilder) {\n const nextValue = richTextDTOtoDAO(text)\n const nextSelection = richTextDTOtoSelection(text)\n if (!deepEqual(editor.children, nextValue) || !deepEqual(editor.selection, nextSelection)) {\n editor.children = nextValue\n editor.selection = nextSelection\n editor.onChange()\n }\n }\n }, [editor, shouldCommit, text])\n\n useEffect(() => {\n if (shouldCommit) return\n\n const timeoutId = window.setTimeout(() => {\n setShouldCommit(true)\n }, COMMIT_DEBOUNCE_DELAY)\n\n return () => {\n window.clearTimeout(timeoutId)\n }\n }, [shouldCommit])\n\n return useCallback(() => setShouldCommit(false), [])\n}\n"],"mappings":"AAAA,SAAS,UAAU,WAAW,mBAAmB;AAEjD,SAA2B,kBAAkB,8BAA8B;AAE3E,SAAS,sBAAsB;AAC/B,OAAO,eAAe;AAEtB,MAAM,wBAAwB;AAMvB,SAAS,mBAAmB,QAAgB,MAAoB;AACrE,QAAM,CAAC,cAAc,eAAe,IAAI,SAAS,IAAI;AACrD,QAAM,cAAc,eAAe;AAEnC,YAAU,MAAM;AACd,QAAI,gBAAgB,QAAQ,aAAa;AACvC,YAAM,YAAY,iBAAiB,IAAI;AACvC,YAAM,gBAAgB,uBAAuB,IAAI;AACjD,UAAI,CAAC,UAAU,OAAO,UAAU,SAAS,KAAK,CAAC,UAAU,OAAO,WAAW,aAAa,GAAG;AACzF,eAAO,WAAW;AAClB,eAAO,YAAY;AACnB,eAAO,SAAS;AAAA,MAClB;AAAA,IACF;AAAA,EACF,GAAG,CAAC,QAAQ,cAAc,IAAI,CAAC;AAE/B,YAAU,MAAM;AACd,QAAI;AAAc;AAElB,UAAM,YAAY,OAAO,WAAW,MAAM;AACxC,sBAAgB,IAAI;AAAA,IACtB,GAAG,qBAAqB;AAExB,WAAO,MAAM;AACX,aAAO,aAAa,SAAS;AAAA,IAC/B;AAAA,EACF,GAAG,CAAC,YAAY,CAAC;AAEjB,SAAO,YAAY,MAAM,gBAAgB,KAAK,GAAG,CAAC,CAAC;AACrD;","names":[]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../../../src/runtimes/react/controls/rich-text-v2/EditableTextV2/usePresetValue.tsx"],"sourcesContent":["import { useMemo } from 'react'\nimport { Descendant } from 'slate'\nimport { Slate, getBaseBreakpoint } from '@makeswift/controls'\n\nimport { DefaultBreakpointID } from '../../../../../state/modules/breakpoints'\nimport { useBreakpoints } from '../../../hooks/use-breakpoints'\nimport { RichTextV2Definition, RichText } from '../../../../../controls'\n\nexport function usePresetValue(definition: RichTextV2Definition): Descendant[] {\n const breakpoints = useBreakpoints()\n return useMemo(\n () => [\n {\n type: Slate.BlockType.Default,\n children: [\n {\n text: definition.config.defaultValue ?? '',\n ...(definition.config.mode === RichText.Mode.Inline\n ? {}\n : {\n typography: {\n style: [\n {\n deviceId: getBaseBreakpoint(breakpoints).id,\n value: {\n fontWeight: 400,\n fontSize: { value: 18, unit: 'px' },\n lineHeight: 1.5,\n },\n },\n ...(breakpoints.some(({ id }) => id === DefaultBreakpointID.Mobile)\n ? [\n {\n deviceId: DefaultBreakpointID.Mobile,\n value: { fontSize: { value: 16, unit: 'px' } },\n },\n ]\n : []),\n ],\n },\n }),\n },\n ],\n },\n ],\n [definition.config.mode, definition.config.defaultValue, breakpoints],\n )\n}\n\nexport const defaultValue = [\n {\n type: Slate.BlockType.Default,\n children: [\n {\n text: '',\n },\n ],\n },\n]\n"],"mappings":"AAAA,SAAS,eAAe;AAExB,SAAS,OAAO,yBAAyB;AAEzC,SAAS,2BAA2B;AACpC,SAAS,sBAAsB;AAC/B,SAA+B,gBAAgB;AAExC,SAAS,eAAe,YAAgD;AAC7E,QAAM,cAAc,eAAe;AACnC,SAAO;AAAA,IACL,MAAM;AAAA,MACJ;AAAA,QACE,MAAM,MAAM,UAAU;AAAA,QACtB,UAAU;AAAA,UACR;AAAA,YACE,MAAM,WAAW,OAAO,gBAAgB;AAAA,YACxC,GAAI,WAAW,OAAO,SAAS,SAAS,KAAK,SACzC,CAAC,IACD;AAAA,cACE,YAAY;AAAA,gBACV,OAAO;AAAA,kBACL;AAAA,oBACE,UAAU,kBAAkB,WAAW,EAAE;AAAA,oBACzC,OAAO;AAAA,sBACL,YAAY;AAAA,sBACZ,UAAU,EAAE,OAAO,IAAI,MAAM,KAAK;AAAA,sBAClC,YAAY;AAAA,oBACd;AAAA,kBACF;AAAA,kBACA,GAAI,YAAY,KAAK,CAAC,EAAE,GAAG,MAAM,OAAO,oBAAoB,MAAM,IAC9D;AAAA,oBACE;AAAA,sBACE,UAAU,oBAAoB;AAAA,sBAC9B,OAAO,EAAE,UAAU,EAAE,OAAO,IAAI,MAAM,KAAK,EAAE;AAAA,oBAC/C;AAAA,kBACF,IACA,CAAC;AAAA,gBACP;AAAA,cACF;AAAA,YACF;AAAA,UACN;AAAA,QACF;AAAA,MACF;AAAA,IACF;AAAA,IACA,CAAC,WAAW,OAAO,MAAM,WAAW,OAAO,cAAc,WAAW;AAAA,EACtE;AACF;AAEO,MAAM,eAAe;AAAA,EAC1B;AAAA,IACE,MAAM,MAAM,UAAU;AAAA,IACtB,UAAU;AAAA,MACR;AAAA,QACE,MAAM;AAAA,MACR;AAAA,IACF;AAAA,EACF;AACF;","names":[]}
|
package/dist/esm/runtimes/react/controls/rich-text-v2/EditableTextV2/useRemoteChanges.js.map
CHANGED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../../../src/runtimes/react/controls/rich-text-v2/EditableTextV2/useRemoteChanges.tsx"],"sourcesContent":["import { useEffect } from 'react'\nimport { Editor } from 'slate'\n\nimport { RichText, RichTextDataV2 } from '../../../../../controls/rich-text-v2'\nimport { LocalChange } from '../../../../../slate'\nimport { useIsInBuilder } from '../../../hooks/use-is-in-builder'\n\n// From the component point of view we can't know if the change came from an action or a undo/redo\n// So we diff the time and force updates on actions that occured over a second ago.\nfunction isChangeWithinPreviousSec(change?: LocalChange) {\n return performance.now() - (change?.time ?? 0) < 1000\n}\n\nexport function useSyncRemoteChanges(editor: Editor, data?: RichTextDataV2) {\n const isInBuilder = useIsInBuilder()\n\n useEffect(() => {\n if (\n !isChangeWithinPreviousSec(editor.localChanges.get(data?.key ?? '')) &&\n data &&\n isInBuilder\n ) {\n editor.children = RichText.dataToNodes(data)\n editor.selection = editor?.localChanges.get(data.key)?.selection ?? null\n editor.onChange()\n }\n }, [editor, data])\n}\n"],"mappings":"AAAA,SAAS,iBAAiB;AAG1B,SAAS,gBAAgC;AAEzC,SAAS,sBAAsB;AAI/B,SAAS,0BAA0B,QAAsB;AACvD,SAAO,YAAY,IAAI,KAAK,QAAQ,QAAQ,KAAK;AACnD;AAEO,SAAS,qBAAqB,QAAgB,MAAuB;AAC1E,QAAM,cAAc,eAAe;AAEnC,YAAU,MAAM;AACd,QACE,CAAC,0BAA0B,OAAO,aAAa,IAAI,MAAM,OAAO,EAAE,CAAC,KACnE,QACA,aACA;AACA,aAAO,WAAW,SAAS,YAAY,IAAI;AAC3C,aAAO,YAAY,QAAQ,aAAa,IAAI,KAAK,GAAG,GAAG,aAAa;AACpE,aAAO,SAAS;AAAA,IAClB;AAAA,EACF,GAAG,CAAC,QAAQ,IAAI,CAAC;AACnB;","names":[]}
|
package/dist/esm/runtimes/react/controls/rich-text-v2/EditableTextV2/useSyncDOMSelection.js.map
CHANGED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../../../src/runtimes/react/controls/rich-text-v2/EditableTextV2/useSyncDOMSelection.tsx"],"sourcesContent":["import { Editor, Range as SlateRange } from 'slate'\nimport { useIsomorphicLayoutEffect } from '../../../../../components/hooks/useIsomorphicLayoutEffect'\nimport { MutableRefObject } from 'react'\nimport { ReactEditor } from 'slate-react'\n\n/**\n * Clicking outside of the host blurs our `<Editable />`.\n * `<Editable />` only updates the DOM's selection to match slate when it is focused.\n * In the case of a panel being clicked this hook updates the DOM selection to match slate.\n */\nexport function useSyncDOMSelection(editor: Editor, isEnabled: MutableRefObject<boolean>) {\n useIsomorphicLayoutEffect(() => {\n if (!isEnabled.current || editor.selection == null || ReactEditor.isFocused(editor)) return\n try {\n const root = ReactEditor.findDocumentOrShadowRoot(editor) as Document\n const domSelection = root.getSelection()\n const newDomRange: Range | null = ReactEditor.toDOMRange(editor, editor.selection)\n\n if (newDomRange) {\n if (SlateRange.isBackward(editor.selection!)) {\n domSelection?.setBaseAndExtent(\n newDomRange.endContainer,\n newDomRange.endOffset,\n newDomRange.startContainer,\n newDomRange.startOffset,\n )\n } else {\n domSelection?.setBaseAndExtent(\n newDomRange.startContainer,\n newDomRange.startOffset,\n newDomRange.endContainer,\n newDomRange.endOffset,\n )\n }\n } else {\n domSelection?.removeAllRanges()\n }\n } catch (e) {\n console.error(e)\n }\n })\n}\n"],"mappings":"AAAA,SAAiB,SAAS,kBAAkB;AAC5C,SAAS,iCAAiC;AAE1C,SAAS,mBAAmB;AAOrB,SAAS,oBAAoB,QAAgB,WAAsC;AACxF,4BAA0B,MAAM;AAC9B,QAAI,CAAC,UAAU,WAAW,OAAO,aAAa,QAAQ,YAAY,UAAU,MAAM;AAAG;AACrF,QAAI;AACF,YAAM,OAAO,YAAY,yBAAyB,MAAM;AACxD,YAAM,eAAe,KAAK,aAAa;AACvC,YAAM,cAA4B,YAAY,WAAW,QAAQ,OAAO,SAAS;AAEjF,UAAI,aAAa;AACf,YAAI,WAAW,WAAW,OAAO,SAAU,GAAG;AAC5C,wBAAc;AAAA,YACZ,YAAY;AAAA,YACZ,YAAY;AAAA,YACZ,YAAY;AAAA,YACZ,YAAY;AAAA,UACd;AAAA,QACF,OAAO;AACL,wBAAc;AAAA,YACZ,YAAY;AAAA,YACZ,YAAY;AAAA,YACZ,YAAY;AAAA,YACZ,YAAY;AAAA,UACd;AAAA,QACF;AAAA,MACF,OAAO;AACL,sBAAc,gBAAgB;AAAA,MAChC;AAAA,IACF,SAAS,GAAG;AACV,cAAQ,MAAM,CAAC;AAAA,IACjB;AAAA,EACF,CAAC;AACH;","names":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/slate/TypographyPlugin/normalizeTypographyUp.ts"],"sourcesContent":["import { Editor, Element, NodeEntry, Transforms, Node, Text } from 'slate'\nimport { RichTextTypography } from '@makeswift/controls'\n\nimport { MakeswiftEditor } from '../types'\nimport keys from '../../utils/keys'\nimport deepEqual from '../../utils/deepEqual'\nimport { shallowMergeTypographies } from './normalizeTypographyDown'\n\nfunction shallowAnd<A extends Record<string,
|
|
1
|
+
{"version":3,"sources":["../../../../src/slate/TypographyPlugin/normalizeTypographyUp.ts"],"sourcesContent":["import { Editor, Element, NodeEntry, Transforms, Node, Text } from 'slate'\nimport { type Data, RichTextTypography } from '@makeswift/controls'\n\nimport { MakeswiftEditor } from '../types'\nimport keys from '../../utils/keys'\nimport deepEqual from '../../utils/deepEqual'\nimport { shallowMergeTypographies } from './normalizeTypographyDown'\n\nfunction shallowAnd<A extends Record<string, Data>, B extends Record<string, Data>>(\n a: A,\n b: B,\n): A & B {\n const bKeys = keys(b)\n const aPrime = { ...a } as A & B\n const and = {} as A & B\n\n bKeys.forEach(key => {\n if (deepEqual(aPrime[key], b[key])) and[key] = aPrime[key]\n })\n\n return and\n}\n\nfunction shallowAndTypographies(...typographies: RichTextTypography[]): RichTextTypography {\n return {\n id: typographies.every(typography => typography?.id === typographies.at(0)?.id)\n ? typographies.at(0)?.id\n : undefined,\n style: [\n ...new Set(\n typographies.flatMap(typography => typography?.style.map(node => node.deviceId) ?? []),\n ),\n ].flatMap(deviceId => {\n const stylesForThisDevice = typographies\n .map(typography => typography.style.find(s => s.deviceId === deviceId)?.value)\n .filter((typography): typography is RichTextTypography['style'][number]['value'] =>\n Boolean(typography),\n )\n\n if (typographies.length !== stylesForThisDevice.length) return []\n\n const value = stylesForThisDevice.reduce(\n (acc, curr) => {\n return shallowAnd(acc, curr)\n },\n stylesForThisDevice.at(0) as RichTextTypography['style'][number]['value'],\n )\n\n if (value == null || Object.keys(value).length === 0) {\n return []\n }\n\n return [\n {\n deviceId,\n value,\n },\n ]\n }),\n }\n}\n\nfunction shallowInverseAnd<A extends Record<string, Data>, B extends Record<string, Data>>(\n a: A,\n b: B,\n): A & B {\n const bKeys = Array.from(new Set([...keys(b), ...keys(a)]))\n const aPrime = { ...a } as A & B\n const bPrime = { ...b } as A & B\n const xor = {} as A & B\n\n bKeys.forEach(key => {\n if (!deepEqual(aPrime[key], bPrime[key])) xor[key] = aPrime[key]\n })\n\n return xor\n}\n\nfunction shallowInverseAndTypographies(\n a: RichTextTypography,\n b: RichTextTypography,\n): RichTextTypography {\n const typography = { style: [] } as RichTextTypography\n if (a?.id !== b.id) {\n typography.id = a?.id\n }\n\n if (a && a.style.length > 0) {\n const styles: RichTextTypography['style'] = []\n for (const style of a.style) {\n const bDeviceTypography = b.style.find(s => s.deviceId === style.deviceId)\n if (bDeviceTypography == null) {\n styles.push(style)\n } else {\n const uniquePropertiesOfA = shallowInverseAnd(style.value, bDeviceTypography.value)\n\n if (Object.keys(uniquePropertiesOfA).length > 0) {\n styles.push({\n deviceId: style.deviceId,\n value: uniquePropertiesOfA,\n })\n }\n }\n }\n typography.style = styles\n }\n\n return typography\n}\n\n/**\n * If a text is empty then don't include it in our comparison.\n */\nfunction isException(node: Node): boolean {\n return Text.isText(node) && node.text === ''\n}\n\nexport function normalizeTypographyUp(editor: MakeswiftEditor, entry: NodeEntry): boolean {\n const [node, path] = entry\n if (Element.isElement(node) && node.children.length) {\n const typographiesOfChildren = node.children\n .filter(child => !isException(child))\n .map(child => child.typography)\n\n const definedTypographiesOfChildren = typographiesOfChildren.filter(\n (typography): typography is RichTextTypography => Boolean(typography),\n )\n if (typographiesOfChildren.length === definedTypographiesOfChildren.length) {\n let sharedTypography: RichTextTypography = shallowAndTypographies(\n ...definedTypographiesOfChildren,\n )\n\n if (sharedTypography.style.length > 0 || sharedTypography.id != null) {\n const rootTypography: RichTextTypography = shallowMergeTypographies(\n sharedTypography,\n node.typography,\n )\n Editor.withoutNormalizing(editor, () => {\n Transforms.setNodes(editor, { typography: rootTypography }, { at: path })\n for (let i = 0; i < node.children.length; i++) {\n const typography: RichTextTypography = shallowInverseAndTypographies(\n node.children.at(i)?.typography ?? { style: [] },\n sharedTypography,\n )\n\n Transforms.setNodes(editor, { typography }, { at: [...path, i] })\n }\n })\n return true\n }\n }\n }\n return false\n}\n"],"mappings":"AAAA,SAAS,QAAQ,SAAoB,YAAkB,YAAY;AAInE,OAAO,UAAU;AACjB,OAAO,eAAe;AACtB,SAAS,gCAAgC;AAEzC,SAAS,WACP,GACA,GACO;AACP,QAAM,QAAQ,KAAK,CAAC;AACpB,QAAM,SAAS,EAAE,GAAG,EAAE;AACtB,QAAM,MAAM,CAAC;AAEb,QAAM,QAAQ,SAAO;AACnB,QAAI,UAAU,OAAO,GAAG,GAAG,EAAE,GAAG,CAAC;AAAG,UAAI,GAAG,IAAI,OAAO,GAAG;AAAA,EAC3D,CAAC;AAED,SAAO;AACT;AAEA,SAAS,0BAA0B,cAAwD;AACzF,SAAO;AAAA,I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mBAAmB,QAAQ,MAAM;AACtC,qBAAW,SAAS,QAAQ,EAAE,YAAY,eAAe,GAAG,EAAE,IAAI,KAAK,CAAC;AACxE,mBAAS,IAAI,GAAG,IAAI,KAAK,SAAS,QAAQ,KAAK;AAC7C,kBAAM,aAAiC;AAAA,cACrC,KAAK,SAAS,GAAG,CAAC,GAAG,cAAc,EAAE,OAAO,CAAC,EAAE;AAAA,cAC/C;AAAA,YACF;AAEA,uBAAW,SAAS,QAAQ,EAAE,WAAW,GAAG,EAAE,IAAI,CAAC,GAAG,MAAM,CAAC,EAAE,CAAC;AAAA,UAClE;AAAA,QACF,CAAC;AACD,eAAO;AAAA,MACT;AAAA,IACF;AAAA,EACF;AACA,SAAO;AACT;","names":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/slate/selectors.ts"],"sourcesContent":["import { Editor, NodeEntry, Range, Text } from 'slate'\nimport {\n type Breakpoints,\n type BreakpointId,\n findBreakpointOverride,\n Slate,\n} from '@makeswift/controls'\n\nimport { EditableBlockKey } from './BlockPlugin/types'\n\nimport unhangRange from './utils/unhangRange'\nimport shallowEqual from '../utils/shallowEqual'\nimport { isNonNullable } from '../utils/isNonNullable'\n\nimport deepEqual from '../utils/deepEqual'\nimport keys from '../utils/keys'\n\nexport function getSelection(editor: Editor): Range {\n if (editor.selection) return unhangRange(editor, editor.selection)\n return {\n anchor: Editor.start(editor, []),\n focus: Editor.end(editor, []),\n }\n}\n\nexport function getBlocksInSelection(editor: Editor): NodeEntry<Slate.RootBlock>[] {\n return Array.from(\n Editor.nodes(editor, {\n at: getSelection(editor),\n match: node => Slate.isRootBlock(node),\n }),\n ).filter((entry): entry is NodeEntry<Slate.RootBlock> => Slate.isRootBlock(entry[0]))\n}\n\nexport function getInlinesInSelection(editor: Editor): NodeEntry<Slate.Inline>[] {\n return Array.from(\n Editor.nodes(editor, {\n at: getSelection(editor),\n match: node => Slate.isInline(node),\n }),\n ).filter((entry): entry is NodeEntry<Slate.Inline> => Slate.isInline(entry[0]))\n}\n\nexport function getActiveBlockType(editor: Editor): Slate.RootBlockType | null {\n const rootBlocks = getBlocksInSelection(editor).map(([node]) => node.type)\n\n return rootBlocks.reduce<Slate.RootBlockType | null>(\n (a, b) => (a === b ? b : null),\n rootBlocks.at(0) ?? null,\n )\n}\n\nexport function getActiveBlockValue(editor: Editor, key: EditableBlockKey) {\n const blocks = getBlocksInSelection(editor)\n\n const active = blocks.map(\n ([block]) => block[key] ?? null,\n ) as (Slate.ResponsiveBlockTextAlignment | null)[]\n\n return active.length === 0 ? null : active.reduce((a, b) => (shallowEqual(a, b) ? b : null))\n}\n\nexport function getActiveBlockDeviceOverrideValue(\n editor: Editor,\n key: EditableBlockKey,\n breakpoints: Breakpoints,\n deviceId: BreakpointId,\n) {\n const active: (Slate.BlockTextAlignment | null)[] = []\n const blocks = getBlocksInSelection(editor)\n\n blocks.forEach(([block]) => {\n const deviceOverride =\n findBreakpointOverride<Slate.BlockTextAlignment>(breakpoints, block[key], deviceId) || null\n active.push(deviceOverride?.value ?? null)\n })\n\n return active.length === 0 ? null : active.reduce((a, b) => (shallowEqual(a, b) ? b : null))\n}\n\n// Typography\n\nconst concat = (a: unknown[], b: unknown[]) => a.concat(b)\n\n// TODO: This is more cruft from trying to remove null from the typography type. This optimization is not worth it.\n/**\n * This is a c/p of the intersection of the utils from the root utils folder.\n * The only change is defaulting to undefined instead of to null.\n */\nexport default function intersection<A extends Record<string,
|
|
1
|
+
{"version":3,"sources":["../../../src/slate/selectors.ts"],"sourcesContent":["import { Editor, NodeEntry, Range, Text } from 'slate'\nimport {\n type Breakpoints,\n type BreakpointId,\n type Data,\n findBreakpointOverride,\n Slate,\n} from '@makeswift/controls'\n\nimport { EditableBlockKey } from './BlockPlugin/types'\n\nimport unhangRange from './utils/unhangRange'\nimport shallowEqual from '../utils/shallowEqual'\nimport { isNonNullable } from '../utils/isNonNullable'\n\nimport deepEqual from '../utils/deepEqual'\nimport keys from '../utils/keys'\n\nexport function getSelection(editor: Editor): Range {\n if (editor.selection) return unhangRange(editor, editor.selection)\n return {\n anchor: Editor.start(editor, []),\n focus: Editor.end(editor, []),\n }\n}\n\nexport function getBlocksInSelection(editor: Editor): NodeEntry<Slate.RootBlock>[] {\n return Array.from(\n Editor.nodes(editor, {\n at: getSelection(editor),\n match: node => Slate.isRootBlock(node),\n }),\n ).filter((entry): entry is NodeEntry<Slate.RootBlock> => Slate.isRootBlock(entry[0]))\n}\n\nexport function getInlinesInSelection(editor: Editor): NodeEntry<Slate.Inline>[] {\n return Array.from(\n Editor.nodes(editor, {\n at: getSelection(editor),\n match: node => Slate.isInline(node),\n }),\n ).filter((entry): entry is NodeEntry<Slate.Inline> => Slate.isInline(entry[0]))\n}\n\nexport function getActiveBlockType(editor: Editor): Slate.RootBlockType | null {\n const rootBlocks = getBlocksInSelection(editor).map(([node]) => node.type)\n\n return rootBlocks.reduce<Slate.RootBlockType | null>(\n (a, b) => (a === b ? b : null),\n rootBlocks.at(0) ?? null,\n )\n}\n\nexport function getActiveBlockValue(editor: Editor, key: EditableBlockKey) {\n const blocks = getBlocksInSelection(editor)\n\n const active = blocks.map(\n ([block]) => block[key] ?? null,\n ) as (Slate.ResponsiveBlockTextAlignment | null)[]\n\n return active.length === 0 ? null : active.reduce((a, b) => (shallowEqual(a, b) ? b : null))\n}\n\nexport function getActiveBlockDeviceOverrideValue(\n editor: Editor,\n key: EditableBlockKey,\n breakpoints: Breakpoints,\n deviceId: BreakpointId,\n) {\n const active: (Slate.BlockTextAlignment | null)[] = []\n const blocks = getBlocksInSelection(editor)\n\n blocks.forEach(([block]) => {\n const deviceOverride =\n findBreakpointOverride<Slate.BlockTextAlignment>(breakpoints, block[key], deviceId) || null\n active.push(deviceOverride?.value ?? null)\n })\n\n return active.length === 0 ? null : active.reduce((a, b) => (shallowEqual(a, b) ? b : null))\n}\n\n// Typography\n\nconst concat = (a: unknown[], b: unknown[]) => a.concat(b)\n\n// TODO: This is more cruft from trying to remove null from the typography type. This optimization is not worth it.\n/**\n * This is a c/p of the intersection of the utils from the root utils folder.\n * The only change is defaulting to undefined instead of to null.\n */\nexport default function intersection<A extends Record<string, Data>, B extends A>(\n a: A,\n b: B,\n isEqual: (a: Data, b: Data) => boolean = deepEqual,\n): { [K in keyof A]: A[K] | undefined } {\n const allKeys = [...new Set([...keys(a), ...keys(b)])] as (keyof A)[]\n\n return allKeys.reduce(\n (acc, k) => {\n if (isEqual(a[k], b[k])) acc[k] = a[k]\n else acc[k] = undefined\n\n return acc\n },\n {} as { [K in keyof A]: A[K] | undefined },\n )\n}\n\nconst fuseTypographyMarks = (\n values: Array<Slate.Typography | null | undefined>,\n breakpoints: Breakpoints,\n): Slate.Typography => {\n const devices = [\n ...new Set(\n values\n .filter(isNonNullable)\n .map(({ style }) => style.map(({ deviceId }) => deviceId))\n .reduce(concat, []),\n ),\n ] as BreakpointId[]\n\n return {\n id: values.map(v => v && v.id).reduce((a, b) => (a === b ? a : undefined)) ?? undefined,\n style: devices.map(deviceId =>\n values\n .map(\n v =>\n (v && findBreakpointOverride(breakpoints, v.style, deviceId)) || {\n deviceId,\n value: {},\n },\n )\n .reduce((acc, { value }) => {\n const a = intersection(acc.value, value)\n return {\n deviceId,\n value: a,\n }\n }),\n ),\n }\n}\n\nexport function getActiveTypographyMark(\n editor: Editor,\n breakpoints: Breakpoints,\n): Slate.Typography {\n const active: Slate.Typography[] = []\n\n const textNodes = Editor.nodes(editor, {\n at: getSelection(editor),\n match: node => Text.isText(node),\n })\n\n for (const [node] of textNodes) {\n if (Text.isText(node) && 'typography' in node && node.typography != undefined) {\n active.push(node.typography)\n }\n }\n return active.length === 0 ? { style: [] } : fuseTypographyMarks(active, breakpoints)\n}\n"],"mappings":"AAAA,SAAS,QAA0B,YAAY;AAC/C;AAAA,EAIE;AAAA,EACA;AAAA,OACK;AAIP,OAAO,iBAAiB;AACxB,OAAO,kBAAkB;AACzB,SAAS,qBAAqB;AAE9B,OAAO,eAAe;AACtB,OAAO,UA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AAE,OAAO,QAAQ,KAAM;AAAA,UAC/D;AAAA,UACA,OAAO,CAAC;AAAA,QACV;AAAA,MACJ,EACC,OAAO,CAAC,KAAK,EAAE,MAAM,MAAM;AAC1B,cAAM,IAAI,aAAa,IAAI,OAAO,KAAK;AACvC,eAAO;AAAA,UACL;AAAA,UACA,OAAO;AAAA,QACT;AAAA,MACF,CAAC;AAAA,IACL;AAAA,EACF;AACF;AAEO,SAAS,wBACd,QACA,aACkB;AAClB,QAAM,SAA6B,CAAC;AAEpC,QAAM,YAAY,OAAO,MAAM,QAAQ;AAAA,IACrC,IAAI,aAAa,MAAM;AAAA,IACvB,OAAO,UAAQ,KAAK,OAAO,IAAI;AAAA,EACjC,CAAC;AAED,aAAW,CAAC,IAAI,KAAK,WAAW;AAC9B,QAAI,KAAK,OAAO,IAAI,KAAK,gBAAgB,QAAQ,KAAK,cAAc,QAAW;AAC7E,aAAO,KAAK,KAAK,UAAU;AAAA,IAC7B;AAAA,EACF;AACA,SAAO,OAAO,WAAW,IAAI,EAAE,OAAO,CAAC,EAAE,IAAI,oBAAoB,QAAQ,WAAW;AACtF;","names":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/utils/intersection.ts"],"sourcesContent":["import deepEqual from './deepEqual'\nimport keys from './keys'\n\nexport default function intersection<A extends Record<string,
|
|
1
|
+
{"version":3,"sources":["../../../src/utils/intersection.ts"],"sourcesContent":["import { type Data } from '@makeswift/controls'\n\nimport deepEqual from './deepEqual'\nimport keys from './keys'\n\nexport default function intersection<A extends Record<string, Data>, B extends A>(\n a: A,\n b: B,\n isEqual: (a: Data, b: Data) => boolean = deepEqual,\n): { [K in keyof A]: A[K] | null } {\n const allKeys = [...new Set([...keys(a), ...keys(b)])] as (keyof A)[]\n\n return allKeys.reduce(\n (acc, k) => {\n if (isEqual(a[k], b[k])) acc[k] = a[k]\n else acc[k] = null\n\n return acc\n },\n {} as { [K in keyof A]: A[K] | null },\n )\n}\n"],"mappings":"AAEA,OAAO,eAAe;AACtB,OAAO,UAAU;AAEF,SAAR,aACL,GACA,GACA,UAAyC,WACR;AACjC,QAAM,UAAU,CAAC,GAAG,oBAAI,IAAI,CAAC,GAAG,KAAK,CAAC,GAAG,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC;AAErD,SAAO,QAAQ;AAAA,IACb,CAAC,KAAK,MAAM;AACV,UAAI,QAAQ,EAAE,CAAC,GAAG,EAAE,CAAC,CAAC;AAAG,YAAI,CAAC,IAAI,EAAE,CAAC;AAAA;AAChC,YAAI,CAAC,IAAI;AAEd,aAAO;AAAA,IACT;AAAA,IACA,CAAC;AAAA,EACH;AACF;","names":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Embed.d.ts","sourceRoot":"","sources":["../../../../../src/components/builtin/Embed/Embed.tsx"],"names":[],"mappings":"AAUA,KAAK,KAAK,GAAG;IACX,EAAE,CAAC,EAAE,MAAM,CAAA;IACX,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,MAAM,CAAC,EAAE,MAAM,CAAA;CAChB,CAAA;AA2BD,QAAA,MAAM,KAAK,
|
|
1
|
+
{"version":3,"file":"Embed.d.ts","sourceRoot":"","sources":["../../../../../src/components/builtin/Embed/Embed.tsx"],"names":[],"mappings":"AAUA,KAAK,KAAK,GAAG;IACX,EAAE,CAAC,EAAE,MAAM,CAAA;IACX,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,MAAM,CAAC,EAAE,MAAM,CAAA;CAChB,CAAA;AA2BD,QAAA,MAAM,KAAK,kGAoFT,CAAA;AAEF,eAAe,KAAK,CAAA"}
|
package/dist/types/runtimes/react/controls/rich-text/EditableText/useSyncWithBuilder.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useSyncWithBuilder.d.ts","sourceRoot":"","sources":["../../../../../../../src/runtimes/react/controls/rich-text/EditableText/useSyncWithBuilder.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"useSyncWithBuilder.d.ts","sourceRoot":"","sources":["../../../../../../../src/runtimes/react/controls/rich-text/EditableText/useSyncWithBuilder.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAS,MAAM,OAAO,CAAA;AACrC,OAAO,EAAE,KAAK,WAAW,EAA4C,MAAM,qBAAqB,CAAA;AAOhG;;;GAGG;AACH,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,WAAW,cAkCpE"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Editor, NodeEntry, Range } from 'slate';
|
|
2
|
-
import { type Breakpoints, type BreakpointId, Slate } from '@makeswift/controls';
|
|
2
|
+
import { type Breakpoints, type BreakpointId, type Data, Slate } from '@makeswift/controls';
|
|
3
3
|
import { EditableBlockKey } from './BlockPlugin/types';
|
|
4
4
|
export declare function getSelection(editor: Editor): Range;
|
|
5
5
|
export declare function getBlocksInSelection(editor: Editor): NodeEntry<Slate.RootBlock>[];
|
|
@@ -11,7 +11,7 @@ export declare function getActiveBlockDeviceOverrideValue(editor: Editor, key: E
|
|
|
11
11
|
* This is a c/p of the intersection of the utils from the root utils folder.
|
|
12
12
|
* The only change is defaulting to undefined instead of to null.
|
|
13
13
|
*/
|
|
14
|
-
export default function intersection<A extends Record<string,
|
|
14
|
+
export default function intersection<A extends Record<string, Data>, B extends A>(a: A, b: B, isEqual?: (a: Data, b: Data) => boolean): {
|
|
15
15
|
[K in keyof A]: A[K] | undefined;
|
|
16
16
|
};
|
|
17
17
|
export declare function getActiveTypographyMark(editor: Editor, breakpoints: Breakpoints): Slate.Typography;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"selectors.d.ts","sourceRoot":"","sources":["../../../src/slate/selectors.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE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AAmB,GACjD;KAAG,CAAC,IAAI,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,SAAS;CAAE,CAYtC;AAqCD,wBAAgB,uBAAuB,CACrC,MAAM,EAAE,MAAM,EACd,WAAW,EAAE,WAAW,GACvB,KAAK,CAAC,UAAU,CAclB"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
|
|
1
|
+
import { type Data } from '@makeswift/controls';
|
|
2
|
+
export default function intersection<A extends Record<string, Data>, B extends A>(a: A, b: B, isEqual?: (a: Data, b: Data) => boolean): {
|
|
2
3
|
[K in keyof A]: A[K] | null;
|
|
3
4
|
};
|
|
4
5
|
//# sourceMappingURL=intersection.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"intersection.d.ts","sourceRoot":"","sources":["../../../src/utils/intersection.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"intersection.d.ts","sourceRoot":"","sources":["../../../src/utils/intersection.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,IAAI,EAAE,MAAM,qBAAqB,CAAA;AAK/C,MAAM,CAAC,OAAO,UAAU,YAAY,CAAC,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,IAAI,CAAC,EAAE,CAAC,SAAS,CAAC,EAC9E,CAAC,EAAE,CAAC,EACJ,CAAC,EAAE,CAAC,EACJ,OAAO,GAAE,CAAC,CAAC,EAAE,IAAI,EAAE,CAAC,EAAE,IAAI,KAAK,OAAmB,GACjD;KAAG,CAAC,IAAI,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,IAAI;CAAE,CAYjC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@makeswift/runtime",
|
|
3
|
-
"version": "0.28.8-canary.
|
|
3
|
+
"version": "0.28.8-canary.8",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"repository": {
|
|
6
6
|
"url": "makeswift/makeswift",
|
|
@@ -238,9 +238,9 @@
|
|
|
238
238
|
"use-sync-external-store": "^1.5.0",
|
|
239
239
|
"uuid": "^9.0.0",
|
|
240
240
|
"zod": "^3.21.4",
|
|
241
|
-
"@makeswift/controls": "0.1.21-canary.
|
|
241
|
+
"@makeswift/controls": "0.1.21-canary.2",
|
|
242
242
|
"@makeswift/next-plugin": "0.6.1",
|
|
243
|
-
"@makeswift/prop-controllers": "0.4.15-canary.
|
|
243
|
+
"@makeswift/prop-controllers": "0.4.15-canary.2"
|
|
244
244
|
},
|
|
245
245
|
"devDependencies": {
|
|
246
246
|
"@emotion/jest": "^11.11.0",
|
package/dist/cjs/utils/is.js
DELETED
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __export = (target, all) => {
|
|
7
|
-
for (var name in all)
|
|
8
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
-
};
|
|
10
|
-
var __copyProps = (to, from, except, desc) => {
|
|
11
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
-
for (let key of __getOwnPropNames(from))
|
|
13
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
-
}
|
|
16
|
-
return to;
|
|
17
|
-
};
|
|
18
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
-
var is_exports = {};
|
|
20
|
-
__export(is_exports, {
|
|
21
|
-
default: () => is_default
|
|
22
|
-
});
|
|
23
|
-
module.exports = __toCommonJS(is_exports);
|
|
24
|
-
var import_controls = require("@makeswift/controls");
|
|
25
|
-
var is_default = import_controls.is;
|
|
26
|
-
//# sourceMappingURL=is.js.map
|
package/dist/cjs/utils/is.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/utils/is.ts"],"sourcesContent":["import { is } from '@makeswift/controls'\n\nexport default is\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,sBAAmB;AAEnB,IAAO,aAAQ;","names":[]}
|
package/dist/esm/utils/is.js
DELETED
package/dist/esm/utils/is.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/utils/is.ts"],"sourcesContent":["import { is } from '@makeswift/controls'\n\nexport default is\n"],"mappings":"AAAA,SAAS,UAAU;AAEnB,IAAO,aAAQ;","names":[]}
|
package/dist/types/utils/is.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"is.d.ts","sourceRoot":"","sources":["../../../src/utils/is.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,EAAE,EAAE,MAAM,qBAAqB,CAAA;AAExC,eAAe,EAAE,CAAA"}
|