@bendyline/squisq-editor-react 2.12.1 → 2.12.2
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.
|
@@ -412,9 +412,13 @@ function resolveFileKind(fileName, language) {
|
|
|
412
412
|
// src/useBlockNavigator.ts
|
|
413
413
|
import { useCallback, useMemo as useMemo2, useState } from "react";
|
|
414
414
|
var NEW_BLOCK_MARKDOWN = "## New section\n\n";
|
|
415
|
+
var NO_SLICES = [];
|
|
415
416
|
function useBlockNavigator(source, setSource, opts) {
|
|
416
417
|
const enabled = opts?.enabled ?? false;
|
|
417
|
-
const slices = useMemo2(
|
|
418
|
+
const slices = useMemo2(
|
|
419
|
+
() => enabled ? getBlockSlices(source) : NO_SLICES,
|
|
420
|
+
[enabled, source]
|
|
421
|
+
);
|
|
418
422
|
const blockCount = slices.length;
|
|
419
423
|
const [rawKey, setRawKey] = useState(0);
|
|
420
424
|
const activeBlockKey = blockCount === 0 ? 0 : Math.min(Math.max(rawKey, 0), blockCount - 1);
|
|
@@ -19,7 +19,7 @@ import {
|
|
|
19
19
|
useDictationState,
|
|
20
20
|
useEditorContext,
|
|
21
21
|
useEditorContextOptional
|
|
22
|
-
} from "./chunk-
|
|
22
|
+
} from "./chunk-SKKA3YFF.js";
|
|
23
23
|
import {
|
|
24
24
|
monacoLanguageRequestKey,
|
|
25
25
|
monacoLanguagesForDocument,
|
|
@@ -12436,8 +12436,7 @@ function slicePastHeading(doc, headingNode) {
|
|
|
12436
12436
|
}
|
|
12437
12437
|
return out;
|
|
12438
12438
|
}
|
|
12439
|
-
function
|
|
12440
|
-
const doc = parseMarkdown3(source);
|
|
12439
|
+
function findBlockSliceAtLineInDoc(doc, lineNumber) {
|
|
12441
12440
|
for (const node2 of doc.children) {
|
|
12442
12441
|
if (node2.type !== "heading") continue;
|
|
12443
12442
|
const pos = node2.position;
|
|
@@ -12449,7 +12448,9 @@ function findBlockSliceAtLine(source, lineNumber) {
|
|
|
12449
12448
|
return null;
|
|
12450
12449
|
}
|
|
12451
12450
|
function findBlockSliceByHeadingIndex(source, headingIndex) {
|
|
12452
|
-
|
|
12451
|
+
return findBlockSliceByHeadingIndexInDoc(parseMarkdown3(source), headingIndex);
|
|
12452
|
+
}
|
|
12453
|
+
function findBlockSliceByHeadingIndexInDoc(doc, headingIndex) {
|
|
12453
12454
|
let seen = 0;
|
|
12454
12455
|
for (const node2 of doc.children) {
|
|
12455
12456
|
if (node2.type !== "heading") continue;
|
|
@@ -19568,6 +19569,7 @@ function Toolbar({
|
|
|
19568
19569
|
const {
|
|
19569
19570
|
activeView,
|
|
19570
19571
|
markdownSource,
|
|
19572
|
+
markdownDoc,
|
|
19571
19573
|
doc,
|
|
19572
19574
|
setMarkdownSource,
|
|
19573
19575
|
tiptapEditor,
|
|
@@ -20779,17 +20781,17 @@ ${TASK_LIST_MARKDOWN}
|
|
|
20779
20781
|
}, [isWysiwyg, tiptapEditor]);
|
|
20780
20782
|
const currentTemplate = isWysiwyg ? wysiwygTemplate : isRawView ? rawTemplate : null;
|
|
20781
20783
|
const recommendedTemplates = useMemo24(() => {
|
|
20782
|
-
if (currentTemplate === null) return void 0;
|
|
20784
|
+
if (currentTemplate === null || !markdownDoc) return void 0;
|
|
20783
20785
|
let slice = null;
|
|
20784
20786
|
if (isRawView && rawHeadingLine !== null) {
|
|
20785
|
-
slice =
|
|
20787
|
+
slice = findBlockSliceAtLineInDoc(markdownDoc, rawHeadingLine);
|
|
20786
20788
|
} else if (isWysiwyg && wysiwygHeadingIndex !== null) {
|
|
20787
|
-
slice =
|
|
20789
|
+
slice = findBlockSliceByHeadingIndexInDoc(markdownDoc, wysiwygHeadingIndex);
|
|
20788
20790
|
}
|
|
20789
20791
|
if (slice === null) return void 0;
|
|
20790
20792
|
const profile = profileBlockContents(slice);
|
|
20791
20793
|
return recommendTemplatesForBlock(profile, TEMPLATE_NAMES).recommended;
|
|
20792
|
-
}, [currentTemplate, isRawView, isWysiwyg, rawHeadingLine, wysiwygHeadingIndex,
|
|
20794
|
+
}, [currentTemplate, isRawView, isWysiwyg, rawHeadingLine, wysiwygHeadingIndex, markdownDoc]);
|
|
20793
20795
|
const templatePreviewBlock = useMemo24(() => {
|
|
20794
20796
|
if (!doc || currentTemplate === null) return null;
|
|
20795
20797
|
const flat = flattenBlocks(doc.blocks);
|
|
@@ -34625,6 +34627,10 @@ function WysiwygEditor({
|
|
|
34625
34627
|
initialDisplayBodyRef.current = body;
|
|
34626
34628
|
}
|
|
34627
34629
|
}
|
|
34630
|
+
const initialContentRef = useRef48(void 0);
|
|
34631
|
+
if (initialContentRef.current === void 0) {
|
|
34632
|
+
initialContentRef.current = markdownToTiptap(initialDisplayBodyRef.current);
|
|
34633
|
+
}
|
|
34628
34634
|
const submitOnEnterRef = useRef48(submitOnEnter);
|
|
34629
34635
|
useEffect50(() => {
|
|
34630
34636
|
submitOnEnterRef.current = submitOnEnter;
|
|
@@ -34698,7 +34704,7 @@ function WysiwygEditor({
|
|
|
34698
34704
|
ReviewExtension,
|
|
34699
34705
|
DictationExtension
|
|
34700
34706
|
],
|
|
34701
|
-
content:
|
|
34707
|
+
content: initialContentRef.current,
|
|
34702
34708
|
onUpdate: ({ editor: ed }) => {
|
|
34703
34709
|
if (isExternalUpdate.current || externalApplyPendingRef.current) return;
|
|
34704
34710
|
const bodyMd = persistFromWrite(tiptapToMarkdown(ed.getHTML()), wrapStateRef.current);
|
|
@@ -35226,6 +35232,7 @@ import { VIEWPORT_PRESETS as VIEWPORT_PRESETS5 } from "@bendyline/squisq/schemas
|
|
|
35226
35232
|
import {
|
|
35227
35233
|
flattenBlocks as flattenBlocks4,
|
|
35228
35234
|
materializeBlockLayers as materializeBlockLayers2,
|
|
35235
|
+
coerceTemplateParams as coerceTemplateParams2,
|
|
35229
35236
|
DEFAULT_THEME as DEFAULT_THEME5,
|
|
35230
35237
|
deriveTemplateInputs as deriveTemplateInputs2
|
|
35231
35238
|
} from "@bendyline/squisq/doc";
|
|
@@ -35724,8 +35731,11 @@ function InlinePreviewGutter({
|
|
|
35724
35731
|
// Forward it before authored params/overrides so document-mode cards
|
|
35725
35732
|
// render the same CSV/XLSX data as block and full-preview modes.
|
|
35726
35733
|
...block.templateData,
|
|
35727
|
-
|
|
35728
|
-
|
|
35734
|
+
// Authored `{[…]}` params are raw strings. Coerce them per the
|
|
35735
|
+
// template's input descriptors, as the full preview does, or a
|
|
35736
|
+
// template with structured inputs renders nothing — twoColumn needs
|
|
35737
|
+
// `left="Web|Start in a browser"` as `{ label, sublabel }`.
|
|
35738
|
+
...coerceTemplateParams2(template, { ...annotation.params, ...block.templateOverrides }).input
|
|
35729
35739
|
};
|
|
35730
35740
|
const ctx = {
|
|
35731
35741
|
blockIndex: index2,
|
package/dist/index.d.ts
CHANGED
|
@@ -125,7 +125,7 @@ interface BlockNavigator {
|
|
|
125
125
|
editorSource: string;
|
|
126
126
|
/** What the bound editor writes through: splices back into the full source (block mode). */
|
|
127
127
|
setEditorSource: (s: string) => void;
|
|
128
|
-
/** Number of navigable blocks in the current source. */
|
|
128
|
+
/** Number of navigable blocks in the current source; 0 while disabled. */
|
|
129
129
|
blockCount: number;
|
|
130
130
|
/** Index of the active block (clamped into range). */
|
|
131
131
|
activeBlockKey: number;
|
|
@@ -150,7 +150,9 @@ interface BlockNavigator {
|
|
|
150
150
|
interface UseBlockNavigatorOptions {
|
|
151
151
|
/**
|
|
152
152
|
* When false (the default), the channel passes through to the full source
|
|
153
|
-
* and navigation is inert
|
|
153
|
+
* and navigation is inert: the source is not sliced, so `blockCount` is 0
|
|
154
|
+
* and `activeBlockStartLine` is null. Hosts flip this on to enter
|
|
155
|
+
* block-at-a-time mode.
|
|
154
156
|
*/
|
|
155
157
|
enabled?: boolean;
|
|
156
158
|
}
|
package/dist/index.js
CHANGED
|
@@ -233,7 +233,7 @@ import {
|
|
|
233
233
|
videoEmbedParagraphJson,
|
|
234
234
|
viewStateFromBinding,
|
|
235
235
|
writeHeadingViewState
|
|
236
|
-
} from "./chunk-
|
|
236
|
+
} from "./chunk-WA7KBG3D.js";
|
|
237
237
|
import {
|
|
238
238
|
EditorProvider,
|
|
239
239
|
applySourceEditsToText,
|
|
@@ -254,7 +254,7 @@ import {
|
|
|
254
254
|
useBlockNavigator,
|
|
255
255
|
useEditorContext,
|
|
256
256
|
useEditorInsertMenuItems
|
|
257
|
-
} from "./chunk-
|
|
257
|
+
} from "./chunk-SKKA3YFF.js";
|
|
258
258
|
import {
|
|
259
259
|
SPEECH_INPUT_SAMPLE_RATE,
|
|
260
260
|
isSpeechInputProviderFactory,
|
package/dist/review/index.js
CHANGED
package/dist/shell/index.js
CHANGED
|
@@ -5,12 +5,12 @@ import {
|
|
|
5
5
|
RawEditor,
|
|
6
6
|
WysiwygEditor,
|
|
7
7
|
useEditorContextMenuItems
|
|
8
|
-
} from "../chunk-
|
|
8
|
+
} from "../chunk-WA7KBG3D.js";
|
|
9
9
|
import {
|
|
10
10
|
EditorProvider,
|
|
11
11
|
useEditorContext,
|
|
12
12
|
useEditorInsertMenuItems
|
|
13
|
-
} from "../chunk-
|
|
13
|
+
} from "../chunk-SKKA3YFF.js";
|
|
14
14
|
import "../chunk-DNEVUOBZ.js";
|
|
15
15
|
import "../chunk-V4NBQF5C.js";
|
|
16
16
|
import "../chunk-KI5XQWRU.js";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bendyline/squisq-editor-react",
|
|
3
|
-
"version": "2.12.
|
|
3
|
+
"version": "2.12.2",
|
|
4
4
|
"description": "React editor shell with raw/WYSIWYG/preview modes for Squisq documents",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "Bendyline",
|
|
@@ -102,12 +102,12 @@
|
|
|
102
102
|
}
|
|
103
103
|
},
|
|
104
104
|
"dependencies": {
|
|
105
|
-
"@bendyline/squisq": "2.12.
|
|
105
|
+
"@bendyline/squisq": "2.12.1",
|
|
106
106
|
"@bendyline/squisq-calc": "2.11.2",
|
|
107
107
|
"@bendyline/squisq-formats": "2.7.1",
|
|
108
|
-
"@bendyline/squisq-grid-react": "2.11.
|
|
109
|
-
"@bendyline/squisq-react": "2.12.
|
|
110
|
-
"@bendyline/squisq-video-react": "2.5.
|
|
108
|
+
"@bendyline/squisq-grid-react": "2.11.24",
|
|
109
|
+
"@bendyline/squisq-react": "2.12.2",
|
|
110
|
+
"@bendyline/squisq-video-react": "2.5.2",
|
|
111
111
|
"@fortawesome/fontawesome-free": "7.3.1",
|
|
112
112
|
"@tiptap/core": "2.27.3",
|
|
113
113
|
"@tiptap/extension-heading": "2.27.3",
|