Skip to content

Commit

Permalink
Merge pull request #69 from aavishkarmishra/master
Browse files Browse the repository at this point in the history
Trigger block-changed event on update text alignment
  • Loading branch information
neSpecc authored Aug 23, 2024
2 parents 1069a86 + 2b047af commit 5740e1c
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 23 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@editorjs/quote",
"version": "2.7.1",
"version": "2.7.2",
"keywords": [
"codex editor",
"quote",
Expand Down
19 changes: 16 additions & 3 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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";

/**
Expand Down Expand Up @@ -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 {
/**
Expand All @@ -81,6 +82,10 @@ interface QuoteParams {
* Is quote read-only.
*/
readOnly: boolean;
/**
* BlockAPI object of Quote.
*/
block: BlockAPI;
}

/**
Expand Down Expand Up @@ -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
*/
Expand All @@ -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;
Expand All @@ -190,6 +200,7 @@ export default class Quote implements BlockTool {
input: this.api.styles.input,
caption: "cdx-quote__caption",
};
this._block = block;
}

/**
Expand Down Expand Up @@ -346,7 +357,6 @@ export default class Quote implements BlockTool {

container.appendChild(quote);
container.appendChild(caption);

return container;
}

Expand Down Expand Up @@ -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();
}
}
38 changes: 19 additions & 19 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -287,24 +287,24 @@
"@volar/language-core" "1.11.1"
path-browserify "^1.0.1"

"@vue/[email protected].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/[email protected].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/[email protected]", "@vue/language-core@^1.8.27":
version "1.8.27"
Expand All @@ -321,10 +321,10 @@
path-browserify "^1.0.1"
vue-template-compiler "^2.7.14"

"@vue/[email protected].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/[email protected].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"
Expand Down Expand Up @@ -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"
Expand Down

0 comments on commit 5740e1c

Please sign in to comment.