@atlaskit/editor-plugin-block-menu 6.0.6 → 6.0.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/CHANGELOG.md +20 -0
- package/dist/cjs/editor-commands/transform-node-utils/flattenStep.js +0 -10
- package/dist/cjs/editor-commands/transform-node-utils/steps/applyTargetTextTypeStep.js +22 -18
- package/dist/cjs/editor-commands/transform-node-utils/steps/decisionListToListStep.js +1 -5
- package/dist/cjs/editor-commands/transform-node-utils/steps/flattenListStep.js +1 -3
- package/dist/cjs/editor-commands/transform-node-utils/steps/listToDecisionListStep.js +1 -1
- package/dist/cjs/editor-commands/transform-node-utils/steps/listToListStep.js +1 -1
- package/dist/cjs/editor-commands/transform-node-utils/steps/wrapMixedContentStep.js +79 -45
- package/dist/cjs/editor-commands/transform-node-utils/transform.js +13 -15
- package/dist/cjs/editor-commands/transformNode.js +8 -2
- package/dist/es2019/editor-commands/transform-node-utils/flattenStep.js +0 -8
- package/dist/es2019/editor-commands/transform-node-utils/steps/applyTargetTextTypeStep.js +22 -18
- package/dist/es2019/editor-commands/transform-node-utils/steps/decisionListToListStep.js +1 -5
- package/dist/es2019/editor-commands/transform-node-utils/steps/flattenListStep.js +1 -3
- package/dist/es2019/editor-commands/transform-node-utils/steps/listToDecisionListStep.js +1 -1
- package/dist/es2019/editor-commands/transform-node-utils/steps/listToListStep.js +1 -1
- package/dist/es2019/editor-commands/transform-node-utils/steps/wrapMixedContentStep.js +79 -45
- package/dist/es2019/editor-commands/transform-node-utils/transform.js +13 -15
- package/dist/es2019/editor-commands/transformNode.js +8 -2
- package/dist/esm/editor-commands/transform-node-utils/flattenStep.js +0 -10
- package/dist/esm/editor-commands/transform-node-utils/steps/applyTargetTextTypeStep.js +22 -18
- package/dist/esm/editor-commands/transform-node-utils/steps/decisionListToListStep.js +1 -5
- package/dist/esm/editor-commands/transform-node-utils/steps/flattenListStep.js +1 -3
- package/dist/esm/editor-commands/transform-node-utils/steps/listToDecisionListStep.js +1 -1
- package/dist/esm/editor-commands/transform-node-utils/steps/listToListStep.js +1 -1
- package/dist/esm/editor-commands/transform-node-utils/steps/wrapMixedContentStep.js +80 -46
- package/dist/esm/editor-commands/transform-node-utils/transform.js +13 -15
- package/dist/esm/editor-commands/transformNode.js +8 -2
- package/dist/types/editor-commands/transform-node-utils/steps/applyTargetTextTypeStep.d.ts +10 -7
- package/dist/types/editor-commands/transform-node-utils/steps/flattenListStep.d.ts +0 -2
- package/dist/types/editor-commands/transform-node-utils/steps/wrapMixedContentStep.d.ts +3 -0
- package/dist/types-ts4.5/editor-commands/transform-node-utils/steps/applyTargetTextTypeStep.d.ts +10 -7
- package/dist/types-ts4.5/editor-commands/transform-node-utils/steps/flattenListStep.d.ts +0 -2
- package/dist/types-ts4.5/editor-commands/transform-node-utils/steps/wrapMixedContentStep.d.ts +3 -0
- package/package.json +2 -2
- package/dist/cjs/editor-commands/transform-node-utils/steps/wrapTextToCodeblock.js +0 -21
- package/dist/es2019/editor-commands/transform-node-utils/steps/wrapTextToCodeblock.js +0 -18
- package/dist/esm/editor-commands/transform-node-utils/steps/wrapTextToCodeblock.js +0 -16
- package/dist/types/editor-commands/transform-node-utils/steps/wrapTextToCodeblock.d.ts +0 -9
- package/dist/types-ts4.5/editor-commands/transform-node-utils/steps/wrapTextToCodeblock.d.ts +0 -9
|
@@ -44,8 +44,14 @@ export var transformNode = function transformNode(api) {
|
|
|
44
44
|
});
|
|
45
45
|
var content = resultNodes.length > 0 ? resultNodes : slice.content;
|
|
46
46
|
if (preservedSelection instanceof NodeSelection && preservedSelection.node.type === nodes.mediaSingle) {
|
|
47
|
-
tr.
|
|
48
|
-
|
|
47
|
+
// when node is media single, use tr.replaceWith freeze editor, if modify position, tr.replaceWith creates duplicats
|
|
48
|
+
var deleteFrom = $from.pos;
|
|
49
|
+
var deleteTo = $to.pos;
|
|
50
|
+
tr.delete(deleteFrom, deleteTo);
|
|
51
|
+
// After deletion, recalculate the insertion position to ensure it's valid
|
|
52
|
+
// especially when mediaSingle with caption is at the bottom of the document
|
|
53
|
+
var insertPos = Math.min(deleteFrom, tr.doc.content.size);
|
|
54
|
+
tr.insert(insertPos, content);
|
|
49
55
|
} else {
|
|
50
56
|
tr.replaceWith(sliceStart, $to.pos, content);
|
|
51
57
|
}
|
|
@@ -1,17 +1,20 @@
|
|
|
1
1
|
import type { TransformStep } from '../types';
|
|
2
2
|
/**
|
|
3
|
-
* Applies target text type conversion.
|
|
4
|
-
* (
|
|
5
|
-
* Non-textblock nodes are always left unchanged.
|
|
3
|
+
* Applies target text type conversion. Converts textblock nodes to the target text type
|
|
4
|
+
* (paragraph or heading). Non-textblock nodes are left unchanged.
|
|
6
5
|
*
|
|
7
6
|
* @example
|
|
8
7
|
* Input:
|
|
9
|
-
* - paragraph "
|
|
10
|
-
* - paragraph "
|
|
8
|
+
* - paragraph "Text 1"
|
|
9
|
+
* - paragraph "Text 2"
|
|
11
10
|
*
|
|
12
11
|
* Output (with target: heading, level: 2):
|
|
13
|
-
* - heading (level: 2) "
|
|
14
|
-
* - heading (level: 2) "
|
|
12
|
+
* - heading (level: 2) "Text 1"
|
|
13
|
+
* - heading (level: 2) "Text 2"
|
|
14
|
+
*
|
|
15
|
+
* Output (with target: paragraph):
|
|
16
|
+
* - paragraph "Text 1"
|
|
17
|
+
* - paragraph "Text 2"
|
|
15
18
|
*
|
|
16
19
|
* @param nodes
|
|
17
20
|
* @param context
|
|
@@ -14,6 +14,9 @@ import type { TransformStep } from '../types';
|
|
|
14
14
|
* - Layouts always require layoutColumns as children (never paragraphs directly)
|
|
15
15
|
* - Layout columns can contain most block content including headings, paragraphs, lists, etc.
|
|
16
16
|
*
|
|
17
|
+
* Special handling for codeblocks:
|
|
18
|
+
* - Text nodes are converted to plain text and added to the codeblock
|
|
19
|
+
*
|
|
17
20
|
* Edge case handling:
|
|
18
21
|
* - For regular containers: If all content breaks out (container → container transform with no
|
|
19
22
|
* valid children), an empty container with a paragraph is created to ensure the target type exists
|
package/dist/types-ts4.5/editor-commands/transform-node-utils/steps/applyTargetTextTypeStep.d.ts
CHANGED
|
@@ -1,17 +1,20 @@
|
|
|
1
1
|
import type { TransformStep } from '../types';
|
|
2
2
|
/**
|
|
3
|
-
* Applies target text type conversion.
|
|
4
|
-
* (
|
|
5
|
-
* Non-textblock nodes are always left unchanged.
|
|
3
|
+
* Applies target text type conversion. Converts textblock nodes to the target text type
|
|
4
|
+
* (paragraph or heading). Non-textblock nodes are left unchanged.
|
|
6
5
|
*
|
|
7
6
|
* @example
|
|
8
7
|
* Input:
|
|
9
|
-
* - paragraph "
|
|
10
|
-
* - paragraph "
|
|
8
|
+
* - paragraph "Text 1"
|
|
9
|
+
* - paragraph "Text 2"
|
|
11
10
|
*
|
|
12
11
|
* Output (with target: heading, level: 2):
|
|
13
|
-
* - heading (level: 2) "
|
|
14
|
-
* - heading (level: 2) "
|
|
12
|
+
* - heading (level: 2) "Text 1"
|
|
13
|
+
* - heading (level: 2) "Text 2"
|
|
14
|
+
*
|
|
15
|
+
* Output (with target: paragraph):
|
|
16
|
+
* - paragraph "Text 1"
|
|
17
|
+
* - paragraph "Text 2"
|
|
15
18
|
*
|
|
16
19
|
* @param nodes
|
|
17
20
|
* @param context
|
package/dist/types-ts4.5/editor-commands/transform-node-utils/steps/wrapMixedContentStep.d.ts
CHANGED
|
@@ -14,6 +14,9 @@ import type { TransformStep } from '../types';
|
|
|
14
14
|
* - Layouts always require layoutColumns as children (never paragraphs directly)
|
|
15
15
|
* - Layout columns can contain most block content including headings, paragraphs, lists, etc.
|
|
16
16
|
*
|
|
17
|
+
* Special handling for codeblocks:
|
|
18
|
+
* - Text nodes are converted to plain text and added to the codeblock
|
|
19
|
+
*
|
|
17
20
|
* Edge case handling:
|
|
18
21
|
* - For regular containers: If all content breaks out (container → container transform with no
|
|
19
22
|
* valid children), an empty container with a paragraph is created to ensure the target type exists
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/editor-plugin-block-menu",
|
|
3
|
-
"version": "6.0.
|
|
3
|
+
"version": "6.0.8",
|
|
4
4
|
"description": "BlockMenu plugin for @atlaskit/editor-core",
|
|
5
5
|
"author": "Atlassian Pty Ltd",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -45,7 +45,7 @@
|
|
|
45
45
|
"@atlaskit/platform-feature-flags-react": "^0.4.0",
|
|
46
46
|
"@atlaskit/primitives": "^17.0.0",
|
|
47
47
|
"@atlaskit/tmp-editor-statsig": "^16.4.0",
|
|
48
|
-
"@atlaskit/tokens": "^9.
|
|
48
|
+
"@atlaskit/tokens": "^9.1.0",
|
|
49
49
|
"@babel/runtime": "^7.0.0"
|
|
50
50
|
},
|
|
51
51
|
"peerDependencies": {
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.wrapTextToCodeblockStep = void 0;
|
|
7
|
-
var _utils = require("../utils");
|
|
8
|
-
/**
|
|
9
|
-
* Transforms a paragraph (or heading) into a codeBlock by extracting its text content.
|
|
10
|
-
* This step handles the conversion of inline content (including marks) to plain text,
|
|
11
|
-
* which is required because codeBlocks can only contain plain text nodes.
|
|
12
|
-
*
|
|
13
|
-
* Example: paragraph with bold/italic/status → codeBlock with plain text
|
|
14
|
-
*/
|
|
15
|
-
var wrapTextToCodeblockStep = exports.wrapTextToCodeblockStep = function wrapTextToCodeblockStep(nodes, context) {
|
|
16
|
-
var schema = context.schema;
|
|
17
|
-
return nodes.map(function (node) {
|
|
18
|
-
var codeBlockNode = schema.nodes.codeBlock.createAndFill({}, schema.text((0, _utils.createTextContent)(node)));
|
|
19
|
-
return codeBlockNode !== null && codeBlockNode !== void 0 ? codeBlockNode : node;
|
|
20
|
-
});
|
|
21
|
-
};
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import { createTextContent } from '../utils';
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Transforms a paragraph (or heading) into a codeBlock by extracting its text content.
|
|
5
|
-
* This step handles the conversion of inline content (including marks) to plain text,
|
|
6
|
-
* which is required because codeBlocks can only contain plain text nodes.
|
|
7
|
-
*
|
|
8
|
-
* Example: paragraph with bold/italic/status → codeBlock with plain text
|
|
9
|
-
*/
|
|
10
|
-
export const wrapTextToCodeblockStep = (nodes, context) => {
|
|
11
|
-
const {
|
|
12
|
-
schema
|
|
13
|
-
} = context;
|
|
14
|
-
return nodes.map(node => {
|
|
15
|
-
const codeBlockNode = schema.nodes.codeBlock.createAndFill({}, schema.text(createTextContent(node)));
|
|
16
|
-
return codeBlockNode !== null && codeBlockNode !== void 0 ? codeBlockNode : node;
|
|
17
|
-
});
|
|
18
|
-
};
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { createTextContent } from '../utils';
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Transforms a paragraph (or heading) into a codeBlock by extracting its text content.
|
|
5
|
-
* This step handles the conversion of inline content (including marks) to plain text,
|
|
6
|
-
* which is required because codeBlocks can only contain plain text nodes.
|
|
7
|
-
*
|
|
8
|
-
* Example: paragraph with bold/italic/status → codeBlock with plain text
|
|
9
|
-
*/
|
|
10
|
-
export var wrapTextToCodeblockStep = function wrapTextToCodeblockStep(nodes, context) {
|
|
11
|
-
var schema = context.schema;
|
|
12
|
-
return nodes.map(function (node) {
|
|
13
|
-
var codeBlockNode = schema.nodes.codeBlock.createAndFill({}, schema.text(createTextContent(node)));
|
|
14
|
-
return codeBlockNode !== null && codeBlockNode !== void 0 ? codeBlockNode : node;
|
|
15
|
-
});
|
|
16
|
-
};
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import type { TransformStep } from '../types';
|
|
2
|
-
/**
|
|
3
|
-
* Transforms a paragraph (or heading) into a codeBlock by extracting its text content.
|
|
4
|
-
* This step handles the conversion of inline content (including marks) to plain text,
|
|
5
|
-
* which is required because codeBlocks can only contain plain text nodes.
|
|
6
|
-
*
|
|
7
|
-
* Example: paragraph with bold/italic/status → codeBlock with plain text
|
|
8
|
-
*/
|
|
9
|
-
export declare const wrapTextToCodeblockStep: TransformStep;
|
package/dist/types-ts4.5/editor-commands/transform-node-utils/steps/wrapTextToCodeblock.d.ts
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import type { TransformStep } from '../types';
|
|
2
|
-
/**
|
|
3
|
-
* Transforms a paragraph (or heading) into a codeBlock by extracting its text content.
|
|
4
|
-
* This step handles the conversion of inline content (including marks) to plain text,
|
|
5
|
-
* which is required because codeBlocks can only contain plain text nodes.
|
|
6
|
-
*
|
|
7
|
-
* Example: paragraph with bold/italic/status → codeBlock with plain text
|
|
8
|
-
*/
|
|
9
|
-
export declare const wrapTextToCodeblockStep: TransformStep;
|