From 4f24f3ec68804f6f686906d623bed7b3e431e4b9 Mon Sep 17 00:00:00 2001 From: Aavishkar Mishra Date: Mon, 19 Aug 2024 01:05:57 +0530 Subject: [PATCH 1/4] AM|Dispatch change on update alignment --- src/index.ts | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/index.ts b/src/index.ts index 0b4943b..0c0e212 100644 --- a/src/index.ts +++ b/src/index.ts @@ -141,6 +141,11 @@ export default class Quote implements BlockTool { * Placeholder for Quote Tool */ private _quotePlaceholder: string; + + /** + * Current quote element + */ + private _quoteElement: HTMLElement | null; /** * Caption placeholder for Quote Tool */ @@ -190,6 +195,7 @@ export default class Quote implements BlockTool { input: this.api.styles.input, caption: "cdx-quote__caption", }; + this._quoteElement = null; } /** @@ -346,7 +352,7 @@ export default class Quote implements BlockTool { container.appendChild(quote); container.appendChild(caption); - + this._quoteElement = container; return container; } @@ -410,5 +416,10 @@ export default class Quote implements BlockTool { */ _toggleTune(tune: Alignment) { this._data.alignment = tune; + + // Dispatch change if quoteElement already exists + if (this._quoteElement) { + this.api.blocks.getBlockByElement(this._quoteElement)?.dispatchChange(); + } } } From f1dfc6ce1e2584c7ffe338c8aecc821c2c41b79c Mon Sep 17 00:00:00 2001 From: Aavishkar Mishra Date: Tue, 20 Aug 2024 21:17:19 +0530 Subject: [PATCH 2/4] Get block from contructor --- src/index.ts | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/src/index.ts b/src/index.ts index 0c0e212..977fab7 100644 --- a/src/index.ts +++ b/src/index.ts @@ -5,7 +5,7 @@ import "./index.css"; import { IconAlignLeft, IconAlignCenter, IconQuote } from "@codexteam/icons"; import { make } from "@editorjs/dom"; -import type { API, BlockTool, ToolConfig } from "@editorjs/editorjs"; +import type { API, BlockAPI, BlockTool, ToolConfig } from "@editorjs/editorjs"; import { MenuConfig } from "@editorjs/editorjs/types/tools"; /** @@ -63,6 +63,7 @@ export interface QuoteData { * @property {QuoteConfig} config - The configuration for the quote. * @property {API} api - The Editor.js API. * @property {boolean} readOnly - Is quote is read-only. + * @property {BlockAPI} block - BlockAPI object of Quote. */ interface QuoteParams { /** @@ -81,6 +82,10 @@ interface QuoteParams { * Is quote read-only. */ readOnly: boolean; + /** + * BlockAPI object of Quote. + */ + block: BlockAPI; } /** @@ -145,7 +150,7 @@ export default class Quote implements BlockTool { /** * Current quote element */ - private _quoteElement: HTMLElement | null; + private _block: BlockAPI; /** * Caption placeholder for Quote Tool */ @@ -168,7 +173,7 @@ export default class Quote implements BlockTool { * @param {API} params.api - editor.js api * @param {boolean} params.readOnly - read only mode flag */ - constructor({ data, config, api, readOnly }: QuoteParams) { + constructor({ data, config, api, readOnly, block }: QuoteParams) { const { DEFAULT_ALIGNMENT } = Quote; this.api = api; @@ -195,7 +200,7 @@ export default class Quote implements BlockTool { input: this.api.styles.input, caption: "cdx-quote__caption", }; - this._quoteElement = null; + this._block = block; } /** @@ -352,7 +357,6 @@ export default class Quote implements BlockTool { container.appendChild(quote); container.appendChild(caption); - this._quoteElement = container; return container; } @@ -418,8 +422,6 @@ export default class Quote implements BlockTool { this._data.alignment = tune; // Dispatch change if quoteElement already exists - if (this._quoteElement) { - this.api.blocks.getBlockByElement(this._quoteElement)?.dispatchChange(); - } + this._block.dispatchChange(); } } From 4f0980bab56d17892d7f0c5927d25e142c76b90c Mon Sep 17 00:00:00 2001 From: Aavishkar Mishra Date: Wed, 21 Aug 2024 10:38:43 +0530 Subject: [PATCH 3/4] Update patch version and bump @editorjs/dom to 0.0.5 --- package.json | 4 ++-- yarn.lock | 56 ++++++++++++++++++++++++++-------------------------- 2 files changed, 30 insertions(+), 30 deletions(-) diff --git a/package.json b/package.json index 110c293..4682d15 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@editorjs/quote", - "version": "2.7.0", + "version": "2.8.0", "keywords": [ "codex editor", "quote", @@ -41,6 +41,6 @@ }, "dependencies": { "@codexteam/icons": "^0.3.2", - "@editorjs/dom": "^0.0.1" + "@editorjs/dom": "^0.0.5" } } diff --git a/yarn.lock b/yarn.lock index e8e3017..602a3f3 100644 --- a/yarn.lock +++ b/yarn.lock @@ -33,22 +33,22 @@ resolved "https://registry.yarnpkg.com/@codexteam/icons/-/icons-0.3.2.tgz#b7aed0ba7b344e07953101f5476cded570d4f150" integrity sha512-P1ep2fHoy0tv4wx85eic+uee5plDnZQ1Qa6gDfv7eHPkCXorMtVqJhzMb75o1izogh6G7380PqmFDXV3bW3Pig== -"@editorjs/dom@^0.0.1": - version "0.0.1" - resolved "https://registry.yarnpkg.com/@editorjs/dom/-/dom-0.0.1.tgz#62297e0b597509598d4829aeaeb4b6a8a59a5d03" - integrity sha512-cFTVjsCKUFZHDjG9jFeooqkMchlWjkNbIJjWUYEA4DeK8VOc6VYiW3GJCjw4J2BXSkzwm3T4O7r6ra2dZxTx2w== +"@editorjs/dom@^0.0.5": + version "0.0.5" + resolved "https://registry.yarnpkg.com/@editorjs/dom/-/dom-0.0.5.tgz#768db5aa3c7413b5e55e831c350831271e8b1391" + integrity sha512-SZ78Gwpkp3EUhjBIp0lSojeQ35V9acF8SubJsMeOH/vlOUE40GOnvvwWZnF05lO7bIB0dOHhhJy4N7IIAWxP2w== dependencies: - "@editorjs/helpers" "workspace:*" + "@editorjs/helpers" "^0.0.4" "@editorjs/editorjs@^2.29.1": version "2.30.5" resolved "https://registry.yarnpkg.com/@editorjs/editorjs/-/editorjs-2.30.5.tgz#c1a6fc2b99f567a0271408c0edd51d3da21b4534" integrity sha512-sE7m/UPbuf+nSGjv9cmWggFsfvtYlgEX7PCby2lZWvOsOLbRxuLT+ZYlwbWshD+8BFJwiAmBj9e+ScZcOjCzeg== -"@editorjs/helpers@workspace:*": - version "0.0.1" - resolved "https://registry.yarnpkg.com/@editorjs/helpers/-/helpers-0.0.1.tgz#580eadca9b3a646d7466434579cee90ebebdc0a8" - integrity sha512-oEp8pqqvvx1Yut4KyvEoYKroAe5TFRNdXOPGIerleIB/6HA/n5hvARa8HRNQtOlMJH40vcRTT3Z+74J3NjlQlQ== +"@editorjs/helpers@^0.0.4": + version "0.0.4" + resolved "https://registry.yarnpkg.com/@editorjs/helpers/-/helpers-0.0.4.tgz#9351373f609e9f8333e0421f7b396c7c7fd41bfa" + integrity sha512-ieg3dzo2m1/ELze/RMNADiAiC5amXxIlVXoJ5vvXITOu/p/dPsrF+Oi3h5gBYvtGk9vg5LJUSG5YWU0tBUO1tw== "@esbuild/android-arm64@0.18.20": version "0.18.20" @@ -287,24 +287,24 @@ "@volar/language-core" "1.11.1" path-browserify "^1.0.1" -"@vue/compiler-core@3.4.37": - version "3.4.37" - resolved "https://registry.yarnpkg.com/@vue/compiler-core/-/compiler-core-3.4.37.tgz#55db3900e09424c65c39111a05a3c6e698f371e3" - integrity sha512-ZDDT/KiLKuCRXyzWecNzC5vTcubGz4LECAtfGPENpo0nrmqJHwuWtRLxk/Sb9RAKtR9iFflFycbkjkY+W/PZUQ== +"@vue/compiler-core@3.4.38": + version "3.4.38" + resolved "https://registry.yarnpkg.com/@vue/compiler-core/-/compiler-core-3.4.38.tgz#326dfe3c92fa2b0f1dc9b39a948a231980253496" + integrity sha512-8IQOTCWnLFqfHzOGm9+P8OPSEDukgg3Huc92qSG49if/xI2SAwLHQO2qaPQbjCWPBcQoO1WYfXfTACUrWV3c5A== dependencies: "@babel/parser" "^7.24.7" - "@vue/shared" "3.4.37" - entities "^5.0.0" + "@vue/shared" "3.4.38" + entities "^4.5.0" estree-walker "^2.0.2" source-map-js "^1.2.0" "@vue/compiler-dom@^3.3.0": - version "3.4.37" - resolved "https://registry.yarnpkg.com/@vue/compiler-dom/-/compiler-dom-3.4.37.tgz#a1fcf79e287cb828545082ff1afa8630480a3044" - integrity sha512-rIiSmL3YrntvgYV84rekAtU/xfogMUJIclUMeIKEtVBFngOL3IeZHhsH3UaFEgB5iFGpj6IW+8YuM/2Up+vVag== + version "3.4.38" + resolved "https://registry.yarnpkg.com/@vue/compiler-dom/-/compiler-dom-3.4.38.tgz#90348fac1130e0bbd408b650635cb626b3b9df06" + integrity sha512-Osc/c7ABsHXTsETLgykcOwIxFktHfGSUDkb05V61rocEfsFDcjDLH/IHJSNJP+/Sv9KeN2Lx1V6McZzlSb9EhQ== dependencies: - "@vue/compiler-core" "3.4.37" - "@vue/shared" "3.4.37" + "@vue/compiler-core" "3.4.38" + "@vue/shared" "3.4.38" "@vue/language-core@1.8.27", "@vue/language-core@^1.8.27": version "1.8.27" @@ -321,10 +321,10 @@ path-browserify "^1.0.1" vue-template-compiler "^2.7.14" -"@vue/shared@3.4.37", "@vue/shared@^3.3.0": - version "3.4.37" - resolved "https://registry.yarnpkg.com/@vue/shared/-/shared-3.4.37.tgz#4f4c08a2e73da512a77b47165cf59ffbc1b5ade8" - integrity sha512-nIh8P2fc3DflG8+5Uw8PT/1i17ccFn0xxN/5oE9RfV5SVnd7G0XEFRwakrnNFE/jlS95fpGXDVG5zDETS26nmg== +"@vue/shared@3.4.38", "@vue/shared@^3.3.0": + version "3.4.38" + resolved "https://registry.yarnpkg.com/@vue/shared/-/shared-3.4.38.tgz#552a6770098bfd556fa3e2c686c9d3b4f4cd94c2" + integrity sha512-q0xCiLkuWWQLzVrecPb0RMsNWyxICOjPrcrwxTUEHb1fsnvni4dcuyG7RT/Ie7VPTvnjzIaWzRMUBsrqNj/hhw== ajv@~6.12.6: version "6.12.6" @@ -390,10 +390,10 @@ debug@^4.3.4: dependencies: ms "2.1.2" -entities@^5.0.0: - version "5.0.0" - resolved "https://registry.yarnpkg.com/entities/-/entities-5.0.0.tgz#b2ab51fe40d995817979ec79dd621154c3c0f62b" - integrity sha512-BeJFvFRJddxobhvEdm5GqHzRV/X+ACeuw0/BuuxsCh1EUZcAIz8+kYmBp/LrQuloy6K1f3a0M7+IhmZ7QnkISA== +entities@^4.5.0: + version "4.5.0" + resolved "https://registry.yarnpkg.com/entities/-/entities-4.5.0.tgz#5d268ea5e7113ec74c4d033b79ea5a35a488fb48" + integrity sha512-V0hjH4dGPh9Ao5p0MoRY6BVqtwCjhz6vI5LT8AJ55H+4g9/4vbHx1I54fS0XuclLhDHArPQCiMjDxjaL8fPxhw== esbuild@^0.18.10: version "0.18.20" From 2b047afe38f03eec89e45d10ee9b838ebc665542 Mon Sep 17 00:00:00 2001 From: Aavishkar Mishra Date: Thu, 22 Aug 2024 18:40:15 +0530 Subject: [PATCH 4/4] Update package.json Co-authored-by: Peter --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 4682d15..4cf5657 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@editorjs/quote", - "version": "2.8.0", + "version": "2.7.2", "keywords": [ "codex editor", "quote",