diff --git a/package.json b/package.json index 0c490cd..4cf5657 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@editorjs/quote", - "version": "2.7.1", + "version": "2.7.2", "keywords": [ "codex editor", "quote", diff --git a/src/index.ts b/src/index.ts index 0b4943b..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; } /** @@ -141,6 +146,11 @@ export default class Quote implements BlockTool { * Placeholder for Quote Tool */ private _quotePlaceholder: string; + + /** + * Current quote element + */ + private _block: BlockAPI; /** * Caption placeholder for Quote Tool */ @@ -163,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; @@ -190,6 +200,7 @@ export default class Quote implements BlockTool { input: this.api.styles.input, caption: "cdx-quote__caption", }; + this._block = block; } /** @@ -346,7 +357,6 @@ export default class Quote implements BlockTool { container.appendChild(quote); container.appendChild(caption); - return container; } @@ -410,5 +420,8 @@ export default class Quote implements BlockTool { */ _toggleTune(tune: Alignment) { this._data.alignment = tune; + + // Dispatch change if quoteElement already exists + this._block.dispatchChange(); } } diff --git a/yarn.lock b/yarn.lock index 1e0d096..602a3f3 100644 --- a/yarn.lock +++ b/yarn.lock @@ -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"