From d9559e015dfaffaee3590a5002cd6f540c6c850a Mon Sep 17 00:00:00 2001 From: Krzysztof Branecki Date: Wed, 6 Mar 2024 10:03:55 +0100 Subject: [PATCH 1/9] chore(DEVOPS-506): fix build package action config --- .github/workflows/build-and-publish.yaml | 54 ------------------------ .github/workflows/semantic-release.yaml | 18 +++----- .releaserc.json | 4 +- package/package.json | 2 +- 4 files changed, 9 insertions(+), 69 deletions(-) delete mode 100644 .github/workflows/build-and-publish.yaml diff --git a/.github/workflows/build-and-publish.yaml b/.github/workflows/build-and-publish.yaml deleted file mode 100644 index 1a1deb9..0000000 --- a/.github/workflows/build-and-publish.yaml +++ /dev/null @@ -1,54 +0,0 @@ ---- -name: Build and publish package to npm registry - -on: - workflow_dispatch: - inputs: - release_tag: - description: | - 'Version to manually release' - required: true - type: string - dry_run: - description: | - 'Dry run mode build but do not publish' - type: boolean - default: true - workflow_call: - inputs: - release_tag: - description: | - 'Version to manually release' - required: true - type: string - dry_run: - description: | - 'Dry run mode build but do not publish' - type: boolean - default: true - -permissions: - id-token: write # required to use OIDC authentication - contents: write # required to checkout the code from the repo and to perform release - packages: write # required to publish to packages - pull-requests: write - -jobs: - publish: - runs-on: ubuntu-latest - name: Package Build & Publish - permissions: - contents: read - packages: write # allow GITHUB_TOKEN to publish packages - steps: - - uses: actions/checkout@v4 - - uses: actions/setup-node@v3 - with: - node-version: "20" - - run: cd ./package && npm install - - run: cd ./package && npm run build - - uses: JS-DevTools/npm-publish@v3 - with: - package: './package/package.json' - token: ${{ secrets.NPM_TOKEN }} - tag: ${{ needs.tag_version.outputs.new_version }} diff --git a/.github/workflows/semantic-release.yaml b/.github/workflows/semantic-release.yaml index 5bcc5db..c4c3a2a 100644 --- a/.github/workflows/semantic-release.yaml +++ b/.github/workflows/semantic-release.yaml @@ -53,6 +53,12 @@ jobs: steps: - name: Checkout uses: actions/checkout@v3 + - name: Build + uses: actions/setup-node@v3 + with: + node-version: "16" + - run: cd ./package && npm install + - run: cd ./package && npm run build - name: Get semantic release version uses: cycjimmy/semantic-release-action@v3 id: semantic_dry @@ -128,15 +134,3 @@ jobs: outputs: new_release: ${{ steps.semantic.outputs.new_release_published }} new_version: ${{ steps.semantic.outputs.new_release_version }} - - github-publish: - name: GitHub Build & Publish - ${{ needs.tag_version.outputs.new_version }} - needs: [tag_version] - if: | - needs.check.outputs.has_npm_secrets - && needs.tag_version.outputs.new_release - uses: ./.github/workflows/build-and-publish.yaml - with: - release_tag: ${{ needs.tag_version.outputs.new_version }} - dry_run: false - secrets: inherit diff --git a/.releaserc.json b/.releaserc.json index 81de49b..36abb05 100644 --- a/.releaserc.json +++ b/.releaserc.json @@ -1,6 +1,6 @@ { "tagFormat": "v${version}", - "initialVersion": "0.1.0", + "initialVersion": "1.0.0", "branches": [ "release", { @@ -130,7 +130,7 @@ [ "@semantic-release/npm", { - "npmPublish": false, + "npmPublish": true, "pkgRoot": "./package" } ], diff --git a/package/package.json b/package/package.json index cfa0ed3..57437c8 100644 --- a/package/package.json +++ b/package/package.json @@ -17,7 +17,7 @@ "author": "Roberto Ornelas ", "contributors": [ { - "name": "Krzysztof Branecki ", + "name": "Krzysztof Branecki", "email": "krzysztof.branecki@frontkom.com" } ], From e4755228758e91590431add3406743eff619a2bf Mon Sep 17 00:00:00 2001 From: semantic-release-bot Date: Wed, 6 Mar 2024 09:05:08 +0000 Subject: [PATCH 2/9] chore(release): 1.0.0-beta.5 [skip ci] --- package/changelogs/CHANGELOG-1.0.0-beta.5.md | 6 ++++++ package/package.json | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) create mode 100644 package/changelogs/CHANGELOG-1.0.0-beta.5.md diff --git a/package/changelogs/CHANGELOG-1.0.0-beta.5.md b/package/changelogs/CHANGELOG-1.0.0-beta.5.md new file mode 100644 index 0000000..fbfa20b --- /dev/null +++ b/package/changelogs/CHANGELOG-1.0.0-beta.5.md @@ -0,0 +1,6 @@ +## [1.0.0-beta.5](https://github.com/frontkom/block-react-parser/compare/v1.0.0-beta.4...v1.0.0-beta.5) (2024-03-06) + + +### Miscellaneous Chores + +* **DEVOPS-506:** fix build package action config ([d9559e0](https://github.com/frontkom/block-react-parser/commit/d9559e015dfaffaee3590a5002cd6f540c6c850a)) diff --git a/package/package.json b/package/package.json index 57437c8..4e98913 100644 --- a/package/package.json +++ b/package/package.json @@ -1,7 +1,7 @@ { "$schema": "https://json-schema.org/package.json", "name": "@frontkom/block-react-parser", - "version": "1.0.0-beta.4", + "version": "1.0.0-beta.5", "description": "Gutenberg-generated HTML to React parser.", "main": "dist/index.js", "module": "dist/index.js", From 0a99ae08358445e3e6f48e6621ed58f2f8d2e6a5 Mon Sep 17 00:00:00 2001 From: Krzysztof Branecki Date: Wed, 6 Mar 2024 11:10:49 +0100 Subject: [PATCH 3/9] chore(DEVOPS-506): fix build package action config --- .github/workflows/semantic-release.yaml | 6 ------ .releaserc.json | 2 +- package/package.json | 2 +- 3 files changed, 2 insertions(+), 8 deletions(-) diff --git a/.github/workflows/semantic-release.yaml b/.github/workflows/semantic-release.yaml index c4c3a2a..e09d281 100644 --- a/.github/workflows/semantic-release.yaml +++ b/.github/workflows/semantic-release.yaml @@ -53,12 +53,6 @@ jobs: steps: - name: Checkout uses: actions/checkout@v3 - - name: Build - uses: actions/setup-node@v3 - with: - node-version: "16" - - run: cd ./package && npm install - - run: cd ./package && npm run build - name: Get semantic release version uses: cycjimmy/semantic-release-action@v3 id: semantic_dry diff --git a/.releaserc.json b/.releaserc.json index 36abb05..39d2563 100644 --- a/.releaserc.json +++ b/.releaserc.json @@ -144,7 +144,7 @@ [ "@semantic-release/exec", { - "prepareCmd": "mv package/changelogs/CHANGELOG.md package/changelogs/CHANGELOG-${nextRelease.version}.md;" + "prepareCmd": "mv package/changelogs/CHANGELOG.md package/changelogs/CHANGELOG-${nextRelease.version}.md && cd ./package && npm install && npm run build;" } ], [ diff --git a/package/package.json b/package/package.json index 4e98913..aed612d 100644 --- a/package/package.json +++ b/package/package.json @@ -2,7 +2,7 @@ "$schema": "https://json-schema.org/package.json", "name": "@frontkom/block-react-parser", "version": "1.0.0-beta.5", - "description": "Gutenberg-generated HTML to React parser.", + "description": "Gutenberg-generated HTML to React parser. ", "main": "dist/index.js", "module": "dist/index.js", "scripts": { From be22f32c5082071d91a919f1e2149857c7a27c67 Mon Sep 17 00:00:00 2001 From: semantic-release-bot Date: Wed, 6 Mar 2024 10:12:04 +0000 Subject: [PATCH 4/9] chore(release): 1.0.0-beta.6 [skip ci] --- package/changelogs/CHANGELOG-1.0.0-beta.6.md | 6 + package/dist/components/Block.js | 56 ++++++ package/dist/components/Context.js | 31 ++++ package/dist/components/Tree.js | 58 ++++++ package/dist/elements/index.js | 181 +++++++++++++++++++ package/dist/elements/tags/img.js | 25 +++ package/dist/elements/tags/selfClosing.js | 17 ++ package/dist/index.js | 61 +++++++ package/dist/utils/attribsProps.js | 22 +++ package/dist/utils/htmlAttribs.js | 26 +++ package/dist/utils/innerNode.js | 20 ++ package/dist/utils/parseBlocks.js | 20 ++ package/package.json | 2 +- 13 files changed, 524 insertions(+), 1 deletion(-) create mode 100644 package/changelogs/CHANGELOG-1.0.0-beta.6.md create mode 100644 package/dist/components/Block.js create mode 100644 package/dist/components/Context.js create mode 100644 package/dist/components/Tree.js create mode 100644 package/dist/elements/index.js create mode 100644 package/dist/elements/tags/img.js create mode 100644 package/dist/elements/tags/selfClosing.js create mode 100644 package/dist/index.js create mode 100644 package/dist/utils/attribsProps.js create mode 100644 package/dist/utils/htmlAttribs.js create mode 100644 package/dist/utils/innerNode.js create mode 100644 package/dist/utils/parseBlocks.js diff --git a/package/changelogs/CHANGELOG-1.0.0-beta.6.md b/package/changelogs/CHANGELOG-1.0.0-beta.6.md new file mode 100644 index 0000000..31b41ee --- /dev/null +++ b/package/changelogs/CHANGELOG-1.0.0-beta.6.md @@ -0,0 +1,6 @@ +## [1.0.0-beta.6](https://github.com/frontkom/block-react-parser/compare/v1.0.0-beta.5...v1.0.0-beta.6) (2024-03-06) + + +### Miscellaneous Chores + +* **DEVOPS-506:** fix build package action config ([0a99ae0](https://github.com/frontkom/block-react-parser/commit/0a99ae08358445e3e6f48e6621ed58f2f8d2e6a5)) diff --git a/package/dist/components/Block.js b/package/dist/components/Block.js new file mode 100644 index 0000000..fe7691d --- /dev/null +++ b/package/dist/components/Block.js @@ -0,0 +1,56 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = Block; +var _react = _interopRequireDefault(require("react")); +var _Tree = _interopRequireDefault(require("./Tree")); +var _innerNode = _interopRequireDefault(require("../utils/innerNode")); +var _Context = require("./Context"); +var _htmlAttribs = _interopRequireDefault(require("../utils/htmlAttribs")); +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } +/** + * Block element. + * + * @param {object} componentProps - properties that includes the block object. + * @returns {JSX.Element | null | undefined} + */ +function Block(_ref) { + let { + block + } = _ref; + const { + blockName = null, + innerContent, + innerBlocks + } = block; + const CustomBlock = (0, _Context.useBlockComponent)(blockName); + const htmlAttrs = (0, _htmlAttribs.default)(innerContent[0]); + const blockExtended = { + ...block, + htmlAttrs + }; + if (CustomBlock) { + return /*#__PURE__*/_react.default.createElement(CustomBlock, { + block: blockExtended + }); + } + + // Filter out empty blocks. + if (!blockName && innerContent.length === 0) { + return null; + } + // Filter out empty lines and orphaned closing tags. + if (innerContent.length === 1 && (innerContent[0] === '\n' || innerContent[0].substring(0, 2) === ' /*#__PURE__*/_react.default.createElement(_Block.default, { + block: inner, + key: index + })); + } + return node.data; + } + + // Handle selfclosed elements (???) + if (CustomTag) { + var _node$children; + const tagChildren = (_node$children = node.children) === null || _node$children === void 0 ? void 0 : _node$children.map((child, index) => + /*#__PURE__*/ + // eslint-disable-next-line react/no-array-index-key + _react.default.createElement(Tree, { + node: child, + block: block, + key: index + })); + return /*#__PURE__*/_react.default.createElement(CustomTag, { + node: tagChildren, + attribs: node.attribs + }); + } + const Component = node.name; + const attrs = (0, _attribsProps.default)(node.attribs); + return /*#__PURE__*/_react.default.createElement(Component, attrs, (_node$children2 = node.children) === null || _node$children2 === void 0 ? void 0 : _node$children2.map((child, index) => + /*#__PURE__*/ + // eslint-disable-next-line react/no-array-index-key + _react.default.createElement(Tree, { + node: child, + block: block, + key: index + }))); +} \ No newline at end of file diff --git a/package/dist/elements/index.js b/package/dist/elements/index.js new file mode 100644 index 0000000..c432153 --- /dev/null +++ b/package/dist/elements/index.js @@ -0,0 +1,181 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.customTags = exports.customBlocks = exports.coreTags = exports.coreBlocks = void 0; +var _react = _interopRequireDefault(require("react")); +var _img = _interopRequireDefault(require("./tags/img")); +var _selfClosing = _interopRequireDefault(require("./tags/selfClosing")); +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } +const coreTags = exports.coreTags = { + img: _ref => { + let { + attribs + } = _ref; + return /*#__PURE__*/_react.default.createElement(_img.default, { + attribs: attribs + }); + }, + br: _ref2 => { + let { + attribs + } = _ref2; + return /*#__PURE__*/_react.default.createElement(_selfClosing.default, { + attribs: attribs, + tag: "br" + }); + }, + hr: _ref3 => { + let { + attribs + } = _ref3; + return /*#__PURE__*/_react.default.createElement(_selfClosing.default, { + attribs: attribs, + tag: "hr" + }); + }, + meta: _ref4 => { + let { + attribs + } = _ref4; + return null; + } + // area: ({attribs}) => , + // base: ({attribs}) => , + // col: ({attribs}) => , + // embed: ({attribs}) => , + // input: ({attribs}) => , + // link: ({attribs}) => , + // meta: ({attribs}) => , + // param: ({attribs}) => , + // source: ({attribs}) => , + // track: ({attribs}) => , + // wbr: ({attribs}) => , +}; +const coreBlocks = exports.coreBlocks = { + // 'core/archives': ({ block }) => doSomething(), + // 'core/audio': ({ block }) => doSomething(), + // 'core/avatar': ({ block }) => doSomething(), + // 'core/block': ({ block }) => doSomething(), + // 'core/button': ({ block }) => doSomething(), + // 'core/buttons': ({ block }) => doSomething(), + // 'core/calendar': ({ block }) => doSomething(), + // 'core/categories': ({ block }) => doSomething(), + // 'core/code': ({ block }) => doSomething(), + // 'core/column': ({ block }) =>

Column

, + // 'core/columns': ({ block }) => doSomething(), + // 'core/comment-author-avatar': ({ block }) => doSomething(), + // 'core/comment-author-name': ({ block }) => doSomething(), + // 'core/comment-content': ({ block }) => doSomething(), + // 'core/comment-date': ({ block }) => doSomething(), + // 'core/comment-edit-link': ({ block }) => doSomething(), + // 'core/comment-reply-link': ({ block }) => doSomething(), + // 'core/comment-template': ({ block }) => doSomething(), + // 'core/comments': ({ block }) => doSomething(), + // 'core/comments-pagination': ({ block }) => doSomething(), + // 'core/comments-pagination-next': ({ block }) => doSomething(), + // 'core/comments-pagination-numbers': ({ block }) => doSomething(), + // 'core/comments-pagination-previous': ({ block }) => doSomething(), + // 'core/comments-title': ({ block }) => doSomething(), + // 'core/cover': ({ block }) => doSomething(), + // 'core/embed': ({ block }) => doSomething(), + // 'core/file': ({ block }) => doSomething(), + // 'core/freeform': ({ block }) => doSomething(), + // 'core/gallery': ({ block }) => doSomething(), + // 'core/group': ({ block }) => doSomething(), + // 'core/heading': ({ block }) => doSomething(), + // 'core/home-link': ({ block }) => doSomething(), + // 'core/html': ({ block }) => doSomething(), + // 'core/image': ({ block }) => doSomething(), + // 'core/latest-comments': ({ block }) => doSomething(), + // 'core/latest-posts': ({ block }) => doSomething(), + // 'core/list': ({ block }) => doSomething(), + // 'core/list-item': ({ block }) => doSomething(), + // 'core/loginout': ({ block }) => doSomething(), + // 'core/media-text': ({ block }) => doSomething(), + // 'core/missing': ({ block }) => doSomething(), + // 'core/more': ({ block }) => doSomething(), + // 'core/navigation': ({ block }) => doSomething(), + // 'core/navigation-link': ({ block }) => doSomething(), + // 'core/navigation-submenu': ({ block }) => doSomething(), + // 'core/nextpage': ({ block }) => doSomething(), + // 'core/page-list': ({ block }) => doSomething(), + // 'core/paragraph': ({ block }) => doSomething(), + // 'core/pattern': ({ block }) => doSomething(), + // 'core/post-author': ({ block }) => doSomething(), + // 'core/post-author-biography': ({ block }) => doSomething(), + // 'core/post-author-name': ({ block }) => doSomething(), + // 'core/post-comment': ({ block }) => doSomething(), + // 'core/post-comments-count': ({ block }) => doSomething(), + // 'core/post-comments-form': ({ block }) => doSomething(), + // 'core/post-comments-link': ({ block }) => doSomething(), + // 'core/post-content': ({ block }) => doSomething(), + // 'core/post-date': ({ block }) => doSomething(), + // 'core/post-excerpt': ({ block }) => doSomething(), + // 'core/post-featured-image': ({ block }) => doSomething(), + // 'core/post-navigation-link': ({ block }) => doSomething(), + // 'core/post-template': ({ block }) => doSomething(), + // 'core/post-terms': ({ block }) => doSomething(), + // 'core/post-title': ({ block }) => doSomething(), + // 'core/preformatted': ({ block }) => doSomething(), + // 'core/pullquote': ({ block }) => doSomething(), + // 'core/query': ({ block }) => doSomething(), + // 'core/query-no-results': ({ block }) => doSomething(), + // 'core/query-pagination': ({ block }) => doSomething(), + // 'core/query-pagination-next': ({ block }) => doSomething(), + // 'core/query-pagination-numbers': ({ block }) => doSomething(), + // 'core/query-pagination-previous': ({ block }) => doSomething(), + // 'core/query-title': ({ block }) => doSomething(), + // 'core/quote': ({ block }) => doSomething(), + // 'core/read-more': ({ block }) => doSomething(), + // 'core/rss': ({ block }) => doSomething(), + // 'core/search': ({ block }) => doSomething(), + // 'core/separator': ({ block }) => doSomething(), + // 'core/shortcode': ({ block }) => doSomething(), + // 'core/site-logo': ({ block }) => doSomething(), + // 'core/site-tagline': ({ block }) => doSomething(), + // 'core/site-title': ({ block }) => doSomething(), + // 'core/social-link': ({ block }) => doSomething(), + // 'core/social-links': ({ block }) => doSomething(), + // 'core/spacer': ({ block }) => doSomething(), + // 'core/table': ({ block }) => doSomething(), + // 'core/table-of-contents': ({ block }) => doSomething(), + // 'core/tag-cloud': ({ block }) => doSomething(), + // 'core/template-part': ({ block }) => doSomething(), + // 'core/term-description': ({ block }) => doSomething(), + // 'core/text-columns': ({ block }) => doSomething(), + // 'core/verse': ({ block }) => doSomething(), + // 'core/video': ({ block }) => doSomething(), +}; + +/** + * Helper function to setup custom tags definitions. + * + * @param {object} tags - Optional object with custom blocks definitions. Empty by default. + * @returns {object} Object with blocks definitions + */ +const customTags = function () { + let tags = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; + return { + ...coreTags, + ...tags + }; +}; + +/** + * Helper function to setup custom blocks definitions. + * + * @param {object} blocks - Optional object with custom blocks definitions. Empty by default. + * @param {boolean} useDefaultBlocks - Optional boolean to use core blocks defaults. True by default. + * @returns {object} Object with blocks definitions + */ +exports.customTags = customTags; +const customBlocks = function () { + let blocks = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; + return { + ...coreBlocks, + ...blocks + }; +}; +exports.customBlocks = customBlocks; \ No newline at end of file diff --git a/package/dist/elements/tags/img.js b/package/dist/elements/tags/img.js new file mode 100644 index 0000000..a30d2b9 --- /dev/null +++ b/package/dist/elements/tags/img.js @@ -0,0 +1,25 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = Image; +function Image(_ref) { + let { + attribs + } = _ref; + const { + alt = '', + class: className = '', + src, + height, + width + } = attribs; + return /*#__PURE__*/React.createElement("img", { + alt: alt, + className: className, + src: src, + width: width, + height: height + }); +} \ No newline at end of file diff --git a/package/dist/elements/tags/selfClosing.js b/package/dist/elements/tags/selfClosing.js new file mode 100644 index 0000000..0002a37 --- /dev/null +++ b/package/dist/elements/tags/selfClosing.js @@ -0,0 +1,17 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = SelfClosing; +var _attribsProps = _interopRequireDefault(require("../../utils/attribsProps")); +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } +function SelfClosing(_ref) { + let { + attribs, + tag + } = _ref; + const Component = tag; + const attributes = (0, _attribsProps.default)(attribs); + return /*#__PURE__*/React.createElement(Component, attributes); +} \ No newline at end of file diff --git a/package/dist/index.js b/package/dist/index.js new file mode 100644 index 0000000..451b5c2 --- /dev/null +++ b/package/dist/index.js @@ -0,0 +1,61 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +Object.defineProperty(exports, "Block", { + enumerable: true, + get: function () { + return _Block.default; + } +}); +Object.defineProperty(exports, "Provider", { + enumerable: true, + get: function () { + return _Context.Provider; + } +}); +Object.defineProperty(exports, "Tree", { + enumerable: true, + get: function () { + return _Tree.default; + } +}); +Object.defineProperty(exports, "attribsProps", { + enumerable: true, + get: function () { + return _attribsProps.default; + } +}); +Object.defineProperty(exports, "customBlocks", { + enumerable: true, + get: function () { + return _elements.customBlocks; + } +}); +Object.defineProperty(exports, "customTags", { + enumerable: true, + get: function () { + return _elements.customTags; + } +}); +Object.defineProperty(exports, "innerNode", { + enumerable: true, + get: function () { + return _innerNode.default; + } +}); +Object.defineProperty(exports, "parseBlocks", { + enumerable: true, + get: function () { + return _parseBlocks.default; + } +}); +var _Block = _interopRequireDefault(require("./components/Block")); +var _Tree = _interopRequireDefault(require("./components/Tree")); +var _Context = require("./components/Context"); +var _elements = require("./elements"); +var _attribsProps = _interopRequireDefault(require("./utils/attribsProps")); +var _innerNode = _interopRequireDefault(require("./utils/innerNode")); +var _parseBlocks = _interopRequireDefault(require("./utils/parseBlocks")); +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } \ No newline at end of file diff --git a/package/dist/utils/attribsProps.js b/package/dist/utils/attribsProps.js new file mode 100644 index 0000000..3ffa92c --- /dev/null +++ b/package/dist/utils/attribsProps.js @@ -0,0 +1,22 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; +var _reactAttrConverter = _interopRequireDefault(require("react-attr-converter")); +var _styleToJs = _interopRequireDefault(require("style-to-js")); +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } +const attribsProps = attribs => { + if (attribs === undefined) { + return {}; + } + const props = Object.fromEntries(Object.entries(attribs).map(attribute => { + if (attribute[0] === 'style') { + return [(0, _reactAttrConverter.default)(attribute[0]), (0, _styleToJs.default)(attribute[1])]; + } + return [(0, _reactAttrConverter.default)(attribute[0]), attribute[1]]; + })); + return props; +}; +var _default = exports.default = attribsProps; \ No newline at end of file diff --git a/package/dist/utils/htmlAttribs.js b/package/dist/utils/htmlAttribs.js new file mode 100644 index 0000000..b975890 --- /dev/null +++ b/package/dist/utils/htmlAttribs.js @@ -0,0 +1,26 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; +var _htmlparser = require("htmlparser2"); +var _attribsProps2 = _interopRequireDefault(require("./attribsProps")); +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } +const htmlAttribs = html => { + const htmlFragment = html === null || html === void 0 ? void 0 : html.trim(); + if (htmlFragment && htmlFragment.length > 1) { + var _parsedFragment$child; + const parsedFragment = (0, _htmlparser.parseDocument)(htmlFragment, { + lowerCaseTags: true, + recognizeSelfClosing: true + }); + const attribs = parsedFragment === null || parsedFragment === void 0 || (_parsedFragment$child = parsedFragment.children[0]) === null || _parsedFragment$child === void 0 ? void 0 : _parsedFragment$child.attribs; + if (Object.keys(attribs).length !== 0) { + var _attribsProps; + return (_attribsProps = (0, _attribsProps2.default)(attribs)) !== null && _attribsProps !== void 0 ? _attribsProps : {}; + } + } + return {}; +}; +var _default = exports.default = htmlAttribs; \ No newline at end of file diff --git a/package/dist/utils/innerNode.js b/package/dist/utils/innerNode.js new file mode 100644 index 0000000..1c46f49 --- /dev/null +++ b/package/dist/utils/innerNode.js @@ -0,0 +1,20 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; +var _htmlparser = require("htmlparser2"); +const innerNode = (innerBlocks, innerContent) => { + var _tree$children$; + // If no inner blocks, return the block markup. + // If inner blocks, return the wrapping markup. + const innerHtml = !innerBlocks.length ? innerContent[0] : "".concat(innerContent[0], "[innerBlocks]").concat(innerContent[innerContent.length - 1]); + const html = innerHtml ? innerHtml.trim() : ''; + const tree = (0, _htmlparser.parseDocument)(html, { + lowerCaseTags: true, + recognizeSelfClosing: true + }); + return (_tree$children$ = tree.children[0]) !== null && _tree$children$ !== void 0 ? _tree$children$ : null; +}; +var _default = exports.default = innerNode; \ No newline at end of file diff --git a/package/dist/utils/parseBlocks.js b/package/dist/utils/parseBlocks.js new file mode 100644 index 0000000..148171a --- /dev/null +++ b/package/dist/utils/parseBlocks.js @@ -0,0 +1,20 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; +var _blockSerializationDefaultParser = require("@wordpress/block-serialization-default-parser"); +var _Block = _interopRequireDefault(require("../components/Block")); +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } +/** + * Parse Gutenberg blocks from HTML markup. + * + * @param {string} html - markup rendered by Gutenberg editor. + * @returns {JSX.Element[]} + */ +const parseBlocks = html => (0, _blockSerializationDefaultParser.parse)(html.trim()).map((block, key) => /*#__PURE__*/React.createElement(_Block.default, { + block: block, + key: key +})); +var _default = exports.default = parseBlocks; \ No newline at end of file diff --git a/package/package.json b/package/package.json index aed612d..b551ebc 100644 --- a/package/package.json +++ b/package/package.json @@ -1,7 +1,7 @@ { "$schema": "https://json-schema.org/package.json", "name": "@frontkom/block-react-parser", - "version": "1.0.0-beta.5", + "version": "1.0.0-beta.6", "description": "Gutenberg-generated HTML to React parser. ", "main": "dist/index.js", "module": "dist/index.js", From dcd4a9b9722a45174e2abd2e10df58860305819a Mon Sep 17 00:00:00 2001 From: semantic-release-bot Date: Wed, 6 Mar 2024 10:19:31 +0000 Subject: [PATCH 5/9] chore(release): 1.0.0-beta.7 [skip ci] --- package/changelogs/CHANGELOG-1.0.0-beta.7.md | 6 ++++++ package/package.json | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) create mode 100644 package/changelogs/CHANGELOG-1.0.0-beta.7.md diff --git a/package/changelogs/CHANGELOG-1.0.0-beta.7.md b/package/changelogs/CHANGELOG-1.0.0-beta.7.md new file mode 100644 index 0000000..56f3ae5 --- /dev/null +++ b/package/changelogs/CHANGELOG-1.0.0-beta.7.md @@ -0,0 +1,6 @@ +## [1.0.0-beta.7](https://github.com/frontkom/block-react-parser/compare/v1.0.0-beta.6...v1.0.0-beta.7) (2024-03-06) + + +### Miscellaneous Chores + +* **release:** 0.1.1 [skip ci] ([011f395](https://github.com/frontkom/block-react-parser/commit/011f39599ca5b94a5c3448aada36bd6d76d3f7ab)) diff --git a/package/package.json b/package/package.json index b551ebc..ab3e010 100644 --- a/package/package.json +++ b/package/package.json @@ -1,7 +1,7 @@ { "$schema": "https://json-schema.org/package.json", "name": "@frontkom/block-react-parser", - "version": "1.0.0-beta.6", + "version": "1.0.0-beta.7", "description": "Gutenberg-generated HTML to React parser. ", "main": "dist/index.js", "module": "dist/index.js", From ab67ce113828e7b4f471ef399740b4e64dd171c9 Mon Sep 17 00:00:00 2001 From: Krzysztof Branecki Date: Wed, 6 Mar 2024 11:24:15 +0100 Subject: [PATCH 6/9] chore(DEVOPS-506): remove dist folder from assets in @semantic-release/git --- .releaserc.json | 3 +-- package/package.json | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/.releaserc.json b/.releaserc.json index 39d2563..162df3a 100644 --- a/.releaserc.json +++ b/.releaserc.json @@ -152,8 +152,7 @@ { "assets": [ "package/package.json", - "package/changelogs/**", - "package/dist/**" + "package/changelogs/**" ], "message": "chore(release): ${nextRelease.version} [skip ci]" } diff --git a/package/package.json b/package/package.json index ab3e010..6cecfab 100644 --- a/package/package.json +++ b/package/package.json @@ -2,7 +2,7 @@ "$schema": "https://json-schema.org/package.json", "name": "@frontkom/block-react-parser", "version": "1.0.0-beta.7", - "description": "Gutenberg-generated HTML to React parser. ", + "description": "Gutenberg-generated HTML to React parser.", "main": "dist/index.js", "module": "dist/index.js", "scripts": { From 8f5d9e187b11e8fc90ed58ac38ebd12282f3c952 Mon Sep 17 00:00:00 2001 From: semantic-release-bot Date: Wed, 6 Mar 2024 10:25:29 +0000 Subject: [PATCH 7/9] chore(release): 1.0.0-beta.8 [skip ci] --- package/changelogs/CHANGELOG-1.0.0-beta.8.md | 6 ++++++ package/package.json | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) create mode 100644 package/changelogs/CHANGELOG-1.0.0-beta.8.md diff --git a/package/changelogs/CHANGELOG-1.0.0-beta.8.md b/package/changelogs/CHANGELOG-1.0.0-beta.8.md new file mode 100644 index 0000000..1f0b68a --- /dev/null +++ b/package/changelogs/CHANGELOG-1.0.0-beta.8.md @@ -0,0 +1,6 @@ +## [1.0.0-beta.8](https://github.com/frontkom/block-react-parser/compare/v1.0.0-beta.7...v1.0.0-beta.8) (2024-03-06) + + +### Miscellaneous Chores + +* **DEVOPS-506:** remove dist folder from assets in @semantic-release/git ([ab67ce1](https://github.com/frontkom/block-react-parser/commit/ab67ce113828e7b4f471ef399740b4e64dd171c9)) diff --git a/package/package.json b/package/package.json index 6cecfab..8d480ec 100644 --- a/package/package.json +++ b/package/package.json @@ -1,7 +1,7 @@ { "$schema": "https://json-schema.org/package.json", "name": "@frontkom/block-react-parser", - "version": "1.0.0-beta.7", + "version": "1.0.0-beta.8", "description": "Gutenberg-generated HTML to React parser.", "main": "dist/index.js", "module": "dist/index.js", From 390ece75eb8bb66e789fa841e71ad6a309b7f5d7 Mon Sep 17 00:00:00 2001 From: Krzysztof Branecki Date: Wed, 6 Mar 2024 11:28:02 +0100 Subject: [PATCH 8/9] chore(DEVOPS-506): remove dist folder --- package/dist/components/Block.js | 56 ------- package/dist/components/Context.js | 31 ---- package/dist/components/Tree.js | 58 ------- package/dist/elements/index.js | 181 ---------------------- package/dist/elements/tags/img.js | 25 --- package/dist/elements/tags/selfClosing.js | 17 -- package/dist/index.js | 61 -------- package/dist/utils/attribsProps.js | 22 --- package/dist/utils/htmlAttribs.js | 26 ---- package/dist/utils/innerNode.js | 20 --- package/dist/utils/parseBlocks.js | 20 --- 11 files changed, 517 deletions(-) delete mode 100644 package/dist/components/Block.js delete mode 100644 package/dist/components/Context.js delete mode 100644 package/dist/components/Tree.js delete mode 100644 package/dist/elements/index.js delete mode 100644 package/dist/elements/tags/img.js delete mode 100644 package/dist/elements/tags/selfClosing.js delete mode 100644 package/dist/index.js delete mode 100644 package/dist/utils/attribsProps.js delete mode 100644 package/dist/utils/htmlAttribs.js delete mode 100644 package/dist/utils/innerNode.js delete mode 100644 package/dist/utils/parseBlocks.js diff --git a/package/dist/components/Block.js b/package/dist/components/Block.js deleted file mode 100644 index fe7691d..0000000 --- a/package/dist/components/Block.js +++ /dev/null @@ -1,56 +0,0 @@ -"use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.default = Block; -var _react = _interopRequireDefault(require("react")); -var _Tree = _interopRequireDefault(require("./Tree")); -var _innerNode = _interopRequireDefault(require("../utils/innerNode")); -var _Context = require("./Context"); -var _htmlAttribs = _interopRequireDefault(require("../utils/htmlAttribs")); -function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } -/** - * Block element. - * - * @param {object} componentProps - properties that includes the block object. - * @returns {JSX.Element | null | undefined} - */ -function Block(_ref) { - let { - block - } = _ref; - const { - blockName = null, - innerContent, - innerBlocks - } = block; - const CustomBlock = (0, _Context.useBlockComponent)(blockName); - const htmlAttrs = (0, _htmlAttribs.default)(innerContent[0]); - const blockExtended = { - ...block, - htmlAttrs - }; - if (CustomBlock) { - return /*#__PURE__*/_react.default.createElement(CustomBlock, { - block: blockExtended - }); - } - - // Filter out empty blocks. - if (!blockName && innerContent.length === 0) { - return null; - } - // Filter out empty lines and orphaned closing tags. - if (innerContent.length === 1 && (innerContent[0] === '\n' || innerContent[0].substring(0, 2) === ' /*#__PURE__*/_react.default.createElement(_Block.default, { - block: inner, - key: index - })); - } - return node.data; - } - - // Handle selfclosed elements (???) - if (CustomTag) { - var _node$children; - const tagChildren = (_node$children = node.children) === null || _node$children === void 0 ? void 0 : _node$children.map((child, index) => - /*#__PURE__*/ - // eslint-disable-next-line react/no-array-index-key - _react.default.createElement(Tree, { - node: child, - block: block, - key: index - })); - return /*#__PURE__*/_react.default.createElement(CustomTag, { - node: tagChildren, - attribs: node.attribs - }); - } - const Component = node.name; - const attrs = (0, _attribsProps.default)(node.attribs); - return /*#__PURE__*/_react.default.createElement(Component, attrs, (_node$children2 = node.children) === null || _node$children2 === void 0 ? void 0 : _node$children2.map((child, index) => - /*#__PURE__*/ - // eslint-disable-next-line react/no-array-index-key - _react.default.createElement(Tree, { - node: child, - block: block, - key: index - }))); -} \ No newline at end of file diff --git a/package/dist/elements/index.js b/package/dist/elements/index.js deleted file mode 100644 index c432153..0000000 --- a/package/dist/elements/index.js +++ /dev/null @@ -1,181 +0,0 @@ -"use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.customTags = exports.customBlocks = exports.coreTags = exports.coreBlocks = void 0; -var _react = _interopRequireDefault(require("react")); -var _img = _interopRequireDefault(require("./tags/img")); -var _selfClosing = _interopRequireDefault(require("./tags/selfClosing")); -function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } -const coreTags = exports.coreTags = { - img: _ref => { - let { - attribs - } = _ref; - return /*#__PURE__*/_react.default.createElement(_img.default, { - attribs: attribs - }); - }, - br: _ref2 => { - let { - attribs - } = _ref2; - return /*#__PURE__*/_react.default.createElement(_selfClosing.default, { - attribs: attribs, - tag: "br" - }); - }, - hr: _ref3 => { - let { - attribs - } = _ref3; - return /*#__PURE__*/_react.default.createElement(_selfClosing.default, { - attribs: attribs, - tag: "hr" - }); - }, - meta: _ref4 => { - let { - attribs - } = _ref4; - return null; - } - // area: ({attribs}) => , - // base: ({attribs}) => , - // col: ({attribs}) => , - // embed: ({attribs}) => , - // input: ({attribs}) => , - // link: ({attribs}) => , - // meta: ({attribs}) => , - // param: ({attribs}) => , - // source: ({attribs}) => , - // track: ({attribs}) => , - // wbr: ({attribs}) => , -}; -const coreBlocks = exports.coreBlocks = { - // 'core/archives': ({ block }) => doSomething(), - // 'core/audio': ({ block }) => doSomething(), - // 'core/avatar': ({ block }) => doSomething(), - // 'core/block': ({ block }) => doSomething(), - // 'core/button': ({ block }) => doSomething(), - // 'core/buttons': ({ block }) => doSomething(), - // 'core/calendar': ({ block }) => doSomething(), - // 'core/categories': ({ block }) => doSomething(), - // 'core/code': ({ block }) => doSomething(), - // 'core/column': ({ block }) =>

Column

, - // 'core/columns': ({ block }) => doSomething(), - // 'core/comment-author-avatar': ({ block }) => doSomething(), - // 'core/comment-author-name': ({ block }) => doSomething(), - // 'core/comment-content': ({ block }) => doSomething(), - // 'core/comment-date': ({ block }) => doSomething(), - // 'core/comment-edit-link': ({ block }) => doSomething(), - // 'core/comment-reply-link': ({ block }) => doSomething(), - // 'core/comment-template': ({ block }) => doSomething(), - // 'core/comments': ({ block }) => doSomething(), - // 'core/comments-pagination': ({ block }) => doSomething(), - // 'core/comments-pagination-next': ({ block }) => doSomething(), - // 'core/comments-pagination-numbers': ({ block }) => doSomething(), - // 'core/comments-pagination-previous': ({ block }) => doSomething(), - // 'core/comments-title': ({ block }) => doSomething(), - // 'core/cover': ({ block }) => doSomething(), - // 'core/embed': ({ block }) => doSomething(), - // 'core/file': ({ block }) => doSomething(), - // 'core/freeform': ({ block }) => doSomething(), - // 'core/gallery': ({ block }) => doSomething(), - // 'core/group': ({ block }) => doSomething(), - // 'core/heading': ({ block }) => doSomething(), - // 'core/home-link': ({ block }) => doSomething(), - // 'core/html': ({ block }) => doSomething(), - // 'core/image': ({ block }) => doSomething(), - // 'core/latest-comments': ({ block }) => doSomething(), - // 'core/latest-posts': ({ block }) => doSomething(), - // 'core/list': ({ block }) => doSomething(), - // 'core/list-item': ({ block }) => doSomething(), - // 'core/loginout': ({ block }) => doSomething(), - // 'core/media-text': ({ block }) => doSomething(), - // 'core/missing': ({ block }) => doSomething(), - // 'core/more': ({ block }) => doSomething(), - // 'core/navigation': ({ block }) => doSomething(), - // 'core/navigation-link': ({ block }) => doSomething(), - // 'core/navigation-submenu': ({ block }) => doSomething(), - // 'core/nextpage': ({ block }) => doSomething(), - // 'core/page-list': ({ block }) => doSomething(), - // 'core/paragraph': ({ block }) => doSomething(), - // 'core/pattern': ({ block }) => doSomething(), - // 'core/post-author': ({ block }) => doSomething(), - // 'core/post-author-biography': ({ block }) => doSomething(), - // 'core/post-author-name': ({ block }) => doSomething(), - // 'core/post-comment': ({ block }) => doSomething(), - // 'core/post-comments-count': ({ block }) => doSomething(), - // 'core/post-comments-form': ({ block }) => doSomething(), - // 'core/post-comments-link': ({ block }) => doSomething(), - // 'core/post-content': ({ block }) => doSomething(), - // 'core/post-date': ({ block }) => doSomething(), - // 'core/post-excerpt': ({ block }) => doSomething(), - // 'core/post-featured-image': ({ block }) => doSomething(), - // 'core/post-navigation-link': ({ block }) => doSomething(), - // 'core/post-template': ({ block }) => doSomething(), - // 'core/post-terms': ({ block }) => doSomething(), - // 'core/post-title': ({ block }) => doSomething(), - // 'core/preformatted': ({ block }) => doSomething(), - // 'core/pullquote': ({ block }) => doSomething(), - // 'core/query': ({ block }) => doSomething(), - // 'core/query-no-results': ({ block }) => doSomething(), - // 'core/query-pagination': ({ block }) => doSomething(), - // 'core/query-pagination-next': ({ block }) => doSomething(), - // 'core/query-pagination-numbers': ({ block }) => doSomething(), - // 'core/query-pagination-previous': ({ block }) => doSomething(), - // 'core/query-title': ({ block }) => doSomething(), - // 'core/quote': ({ block }) => doSomething(), - // 'core/read-more': ({ block }) => doSomething(), - // 'core/rss': ({ block }) => doSomething(), - // 'core/search': ({ block }) => doSomething(), - // 'core/separator': ({ block }) => doSomething(), - // 'core/shortcode': ({ block }) => doSomething(), - // 'core/site-logo': ({ block }) => doSomething(), - // 'core/site-tagline': ({ block }) => doSomething(), - // 'core/site-title': ({ block }) => doSomething(), - // 'core/social-link': ({ block }) => doSomething(), - // 'core/social-links': ({ block }) => doSomething(), - // 'core/spacer': ({ block }) => doSomething(), - // 'core/table': ({ block }) => doSomething(), - // 'core/table-of-contents': ({ block }) => doSomething(), - // 'core/tag-cloud': ({ block }) => doSomething(), - // 'core/template-part': ({ block }) => doSomething(), - // 'core/term-description': ({ block }) => doSomething(), - // 'core/text-columns': ({ block }) => doSomething(), - // 'core/verse': ({ block }) => doSomething(), - // 'core/video': ({ block }) => doSomething(), -}; - -/** - * Helper function to setup custom tags definitions. - * - * @param {object} tags - Optional object with custom blocks definitions. Empty by default. - * @returns {object} Object with blocks definitions - */ -const customTags = function () { - let tags = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; - return { - ...coreTags, - ...tags - }; -}; - -/** - * Helper function to setup custom blocks definitions. - * - * @param {object} blocks - Optional object with custom blocks definitions. Empty by default. - * @param {boolean} useDefaultBlocks - Optional boolean to use core blocks defaults. True by default. - * @returns {object} Object with blocks definitions - */ -exports.customTags = customTags; -const customBlocks = function () { - let blocks = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; - return { - ...coreBlocks, - ...blocks - }; -}; -exports.customBlocks = customBlocks; \ No newline at end of file diff --git a/package/dist/elements/tags/img.js b/package/dist/elements/tags/img.js deleted file mode 100644 index a30d2b9..0000000 --- a/package/dist/elements/tags/img.js +++ /dev/null @@ -1,25 +0,0 @@ -"use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.default = Image; -function Image(_ref) { - let { - attribs - } = _ref; - const { - alt = '', - class: className = '', - src, - height, - width - } = attribs; - return /*#__PURE__*/React.createElement("img", { - alt: alt, - className: className, - src: src, - width: width, - height: height - }); -} \ No newline at end of file diff --git a/package/dist/elements/tags/selfClosing.js b/package/dist/elements/tags/selfClosing.js deleted file mode 100644 index 0002a37..0000000 --- a/package/dist/elements/tags/selfClosing.js +++ /dev/null @@ -1,17 +0,0 @@ -"use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.default = SelfClosing; -var _attribsProps = _interopRequireDefault(require("../../utils/attribsProps")); -function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } -function SelfClosing(_ref) { - let { - attribs, - tag - } = _ref; - const Component = tag; - const attributes = (0, _attribsProps.default)(attribs); - return /*#__PURE__*/React.createElement(Component, attributes); -} \ No newline at end of file diff --git a/package/dist/index.js b/package/dist/index.js deleted file mode 100644 index 451b5c2..0000000 --- a/package/dist/index.js +++ /dev/null @@ -1,61 +0,0 @@ -"use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -Object.defineProperty(exports, "Block", { - enumerable: true, - get: function () { - return _Block.default; - } -}); -Object.defineProperty(exports, "Provider", { - enumerable: true, - get: function () { - return _Context.Provider; - } -}); -Object.defineProperty(exports, "Tree", { - enumerable: true, - get: function () { - return _Tree.default; - } -}); -Object.defineProperty(exports, "attribsProps", { - enumerable: true, - get: function () { - return _attribsProps.default; - } -}); -Object.defineProperty(exports, "customBlocks", { - enumerable: true, - get: function () { - return _elements.customBlocks; - } -}); -Object.defineProperty(exports, "customTags", { - enumerable: true, - get: function () { - return _elements.customTags; - } -}); -Object.defineProperty(exports, "innerNode", { - enumerable: true, - get: function () { - return _innerNode.default; - } -}); -Object.defineProperty(exports, "parseBlocks", { - enumerable: true, - get: function () { - return _parseBlocks.default; - } -}); -var _Block = _interopRequireDefault(require("./components/Block")); -var _Tree = _interopRequireDefault(require("./components/Tree")); -var _Context = require("./components/Context"); -var _elements = require("./elements"); -var _attribsProps = _interopRequireDefault(require("./utils/attribsProps")); -var _innerNode = _interopRequireDefault(require("./utils/innerNode")); -var _parseBlocks = _interopRequireDefault(require("./utils/parseBlocks")); -function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } \ No newline at end of file diff --git a/package/dist/utils/attribsProps.js b/package/dist/utils/attribsProps.js deleted file mode 100644 index 3ffa92c..0000000 --- a/package/dist/utils/attribsProps.js +++ /dev/null @@ -1,22 +0,0 @@ -"use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.default = void 0; -var _reactAttrConverter = _interopRequireDefault(require("react-attr-converter")); -var _styleToJs = _interopRequireDefault(require("style-to-js")); -function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } -const attribsProps = attribs => { - if (attribs === undefined) { - return {}; - } - const props = Object.fromEntries(Object.entries(attribs).map(attribute => { - if (attribute[0] === 'style') { - return [(0, _reactAttrConverter.default)(attribute[0]), (0, _styleToJs.default)(attribute[1])]; - } - return [(0, _reactAttrConverter.default)(attribute[0]), attribute[1]]; - })); - return props; -}; -var _default = exports.default = attribsProps; \ No newline at end of file diff --git a/package/dist/utils/htmlAttribs.js b/package/dist/utils/htmlAttribs.js deleted file mode 100644 index b975890..0000000 --- a/package/dist/utils/htmlAttribs.js +++ /dev/null @@ -1,26 +0,0 @@ -"use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.default = void 0; -var _htmlparser = require("htmlparser2"); -var _attribsProps2 = _interopRequireDefault(require("./attribsProps")); -function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } -const htmlAttribs = html => { - const htmlFragment = html === null || html === void 0 ? void 0 : html.trim(); - if (htmlFragment && htmlFragment.length > 1) { - var _parsedFragment$child; - const parsedFragment = (0, _htmlparser.parseDocument)(htmlFragment, { - lowerCaseTags: true, - recognizeSelfClosing: true - }); - const attribs = parsedFragment === null || parsedFragment === void 0 || (_parsedFragment$child = parsedFragment.children[0]) === null || _parsedFragment$child === void 0 ? void 0 : _parsedFragment$child.attribs; - if (Object.keys(attribs).length !== 0) { - var _attribsProps; - return (_attribsProps = (0, _attribsProps2.default)(attribs)) !== null && _attribsProps !== void 0 ? _attribsProps : {}; - } - } - return {}; -}; -var _default = exports.default = htmlAttribs; \ No newline at end of file diff --git a/package/dist/utils/innerNode.js b/package/dist/utils/innerNode.js deleted file mode 100644 index 1c46f49..0000000 --- a/package/dist/utils/innerNode.js +++ /dev/null @@ -1,20 +0,0 @@ -"use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.default = void 0; -var _htmlparser = require("htmlparser2"); -const innerNode = (innerBlocks, innerContent) => { - var _tree$children$; - // If no inner blocks, return the block markup. - // If inner blocks, return the wrapping markup. - const innerHtml = !innerBlocks.length ? innerContent[0] : "".concat(innerContent[0], "[innerBlocks]").concat(innerContent[innerContent.length - 1]); - const html = innerHtml ? innerHtml.trim() : ''; - const tree = (0, _htmlparser.parseDocument)(html, { - lowerCaseTags: true, - recognizeSelfClosing: true - }); - return (_tree$children$ = tree.children[0]) !== null && _tree$children$ !== void 0 ? _tree$children$ : null; -}; -var _default = exports.default = innerNode; \ No newline at end of file diff --git a/package/dist/utils/parseBlocks.js b/package/dist/utils/parseBlocks.js deleted file mode 100644 index 148171a..0000000 --- a/package/dist/utils/parseBlocks.js +++ /dev/null @@ -1,20 +0,0 @@ -"use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.default = void 0; -var _blockSerializationDefaultParser = require("@wordpress/block-serialization-default-parser"); -var _Block = _interopRequireDefault(require("../components/Block")); -function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } -/** - * Parse Gutenberg blocks from HTML markup. - * - * @param {string} html - markup rendered by Gutenberg editor. - * @returns {JSX.Element[]} - */ -const parseBlocks = html => (0, _blockSerializationDefaultParser.parse)(html.trim()).map((block, key) => /*#__PURE__*/React.createElement(_Block.default, { - block: block, - key: key -})); -var _default = exports.default = parseBlocks; \ No newline at end of file From 63b7c616db3145a15c4d80d871df3ed8dff7b5ba Mon Sep 17 00:00:00 2001 From: semantic-release-bot Date: Wed, 6 Mar 2024 10:29:13 +0000 Subject: [PATCH 9/9] chore(release): 1.0.0-beta.9 [skip ci] --- package/changelogs/CHANGELOG-1.0.0-beta.9.md | 6 ++++++ package/package.json | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) create mode 100644 package/changelogs/CHANGELOG-1.0.0-beta.9.md diff --git a/package/changelogs/CHANGELOG-1.0.0-beta.9.md b/package/changelogs/CHANGELOG-1.0.0-beta.9.md new file mode 100644 index 0000000..81a6ded --- /dev/null +++ b/package/changelogs/CHANGELOG-1.0.0-beta.9.md @@ -0,0 +1,6 @@ +## [1.0.0-beta.9](https://github.com/frontkom/block-react-parser/compare/v1.0.0-beta.8...v1.0.0-beta.9) (2024-03-06) + + +### Miscellaneous Chores + +* **DEVOPS-506:** remove dist folder ([390ece7](https://github.com/frontkom/block-react-parser/commit/390ece75eb8bb66e789fa841e71ad6a309b7f5d7)) diff --git a/package/package.json b/package/package.json index 8d480ec..a2afb8e 100644 --- a/package/package.json +++ b/package/package.json @@ -1,7 +1,7 @@ { "$schema": "https://json-schema.org/package.json", "name": "@frontkom/block-react-parser", - "version": "1.0.0-beta.8", + "version": "1.0.0-beta.9", "description": "Gutenberg-generated HTML to React parser.", "main": "dist/index.js", "module": "dist/index.js",